[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfmain.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfmain.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfmain.h 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 #ifndef KLFMAIN_H
25 #define KLFMAIN_H
26 
27 #include <QCoreApplication>
28 #include <QString>
29 #include <QList>
30 #include <QMap>
31 #include <QStringList>
32 #include <QDataStream>
33 #include <QTranslator>
34 #include <QDir>
35 
36 #include <klfdefs.h>
37 
38 
39 
40 
41 // SOME DEFINITIONS
42 
43 #if defined(Q_WS_WIN)
44 #define KLF_DLL_EXT_LIST (QStringList()<<"*.dll")
45 #elif defined(Q_WS_MAC)
46 #define KLF_DLL_EXT_LIST (QStringList()<<"*.so"<<"*.dylib")
47 #else
48 #define KLF_DLL_EXT_LIST (QStringList()<<"*.so")
49 #endif
50 
51 
52 
53 // SOME DECLARATIONS FOR ADD-ONS
54 
55 class KLF_EXPORT KLFAddOnInfo
56 {
57 public:
60  KLFAddOnInfo(QString rccfpath, bool isFresh = false);
61 
63  KLFAddOnInfo(const KLFAddOnInfo& o);
64 
65  struct KLF_EXPORT PluginSysInfo {
78 
79  bool isCompatibleWithCurrentSystem() const;
80  };
81 
82  ~KLFAddOnInfo();
83 
85  QString dir() { return d->dir; }
87  QString fname() { return d->fname; };
89  QString fpath() { return d->fpath; }
91  bool islocal() { return d->islocal; }
92 
94  QString title() { return d->title; }
96  QString author() { return d->author; }
98  QString description() { return d->description; }
100  QString klfminversion() { return d->klfminversion; }
101 
103  QString rccmountroot() { return d->rccmountroot; }
104 
113  QStringList pluginList() const { return d->pluginList; }
114 
115  PluginSysInfo pluginSysInfo(const QString& plugin) const { return d->plugins[plugin]; }
116 
117  QString pluginLocalSubDirName(const QString& plugin) const
118  {
119  if ( ! d->plugins[plugin].klfminversion.isEmpty() )
120  return QString("klf%1").arg(d->plugins[plugin].klfminversion);
121  return QString(".");
122  }
123 
130  QStringList localPluginList() const;
131 
132 
135  QStringList translations() { return d->translations; }
136 
140  bool isfresh() { return d->isfresh; }
141 
142 private:
143 
145  struct Private {
146  int ref; // number of times this data structure is referenced
147 
148  QString dir;
149  QString fname;
150  QString fpath;
151  bool islocal;
152 
153  QString title;
154  QString author;
155  QString description;
156  QString klfminversion;
157 
158  QString rccmountroot;
159 
160  QStringList pluginList;
162 
163  QStringList translations;
164 
165  bool isfresh;
166  };
167 
168  Private *d;
169 
170  void initPlugins();
171 };
172 
173 KLF_EXPORT extern QList<KLFAddOnInfo> klf_addons;
174 KLF_EXPORT extern bool klf_addons_canimport;
175 
176 KLF_EXPORT QDebug& operator<<(QDebug& str, const KLFAddOnInfo::PluginSysInfo& i);
177 
178 
179 
180 // SOME DEFINITIONS FOR PLUGINS
181 
183 
185 {
190 
193 
195 };
196 
197 
198 KLF_EXPORT extern QList<KLFPluginInfo> klf_plugins;
199 
200 
201 
202 
203 
204 
212 struct KLF_EXPORT KLFTranslationInfo
213 {
214  KLFTranslationInfo() : hasnicetranslatedname(false) { }
215 
222 };
223 
226 
228 KLF_EXPORT extern QList<QTranslator*> klf_translators;
229 
230 
239 class KLF_EXPORT KLFI18nFile
240 {
241 public:
249 
251  KLFI18nFile(QString filepath);
252 };
253 
254 
255 
256 KLF_EXPORT void klf_add_avail_translation(KLFI18nFile i18nfile);
257 
258 
260 KLF_EXPORT void klf_reload_translations(QCoreApplication *app, const QString& currentlocale);
261 
262 
263 
264 // eg. baseFileName="cmdl-help" extension=".txt" will look for
265 // "cmdl-help_fr_CH.txt", "cmdl-help_fr.txt", "cmdl-help.txt" assuming current locale is "fr_CH"
266 KLF_EXPORT QString klfFindTranslatedDataFile(const QString& baseFileName, const QString& extension);
267 
268 
269 
270 
280 #define KLF_DATA_STREAM_APP_VERSION "3.2"
281 // --- don't forget to update below too! ---
282 
284 #define KLF_DATA_STREAM_APP_VERSION_MAJ 3
285 
286 #define KLF_DATA_STREAM_APP_VERSION_MIN 2
287 
288 
294 { return d.device()->property("klfDataStreamAppVersion").toString(); }
295 
296 
304 KLF_EXPORT void klfDataStreamWriteHeader(QDataStream& stream, const QString headermagic);
305 
308 KLF_EXPORT bool klfDataStreamReadHeader(QDataStream& stream, const QStringList possibleHeaders,
309  QString * readHeader = NULL, QString * readCompatKLFVersion = NULL) ;
310 
311 
312 
313 #endif
QString description()
Definition: klfmain.h:98
QStringList translations()
Definition: klfmain.h:135
QString dir()
Definition: klfmain.h:85
KLF_EXPORT bool klfDataStreamReadHeader(QDataStream &stream, const QStringList possibleHeaders, QString *readHeader=NULL, QString *readCompatKLFVersion=NULL)
Definition: klfmain.cpp:546
QString pluginLocalSubDirName(const QString &plugin) const
Definition: klfmain.h:117
QString locale
Locale Name (e.g. "fr" or "fr_CH")
Definition: klfmain.h:246
QString klfminversion()
Definition: klfmain.h:100
QString translatedname
Definition: klfmain.h:217
KLF_EXPORT QList< KLFPluginInfo > klf_plugins
Definition: klfmain.cpp:50
QString fpath
Definition: klfmain.h:191
KLF_EXPORT void klf_add_avail_translation(KLFI18nFile i18nfile)
Definition: klfmain.cpp:324
QString fname()
Definition: klfmain.h:87
KLFPluginGenericInterface * instance
Definition: klfmain.h:194
QString title
Definition: klfmain.h:188
QStringList pluginList() const
Definition: klfmain.h:113
KLF_EXPORT void klf_reload_translations(QCoreApplication *app, const QString &currentlocale)
Definition: klfmain.cpp:396
QString localename
Definition: klfmain.h:216
QString name
Definition: klfmain.h:186
QString fpath()
Definition: klfmain.h:89
KLF_EXPORT QString klfFindTranslatedDataFile(const QString &baseFileName, const QString &extension)
Definition: klfmain.cpp:504
bool isfresh()
Definition: klfmain.h:140
KLF_EXPORT bool klf_addons_canimport
Definition: klfmain.cpp:55
QString klfDataStreamAppVersion(const QDataStream &d)
Obtain the KLF version stream operations on d have to be compatible with.
Definition: klfmain.h:293
KLF_EXPORT void klfDataStreamWriteHeader(QDataStream &stream, const QString headermagic)
Definition: klfmain.cpp:529
QString fpath
Definition: klfmain.h:242
PluginSysInfo pluginSysInfo(const QString &plugin) const
Definition: klfmain.h:115
bool islocal()
Definition: klfmain.h:91
QString author
Definition: klfmain.h:187
Small minimalist structure to store basic information about available translations.
Definition: klfmain.h:212
KLF_EXPORT QList< QTranslator * > klf_translators
Definition: klfmain.cpp:44
Small structure to store information for a translation file (.qm)
Definition: klfmain.h:239
KLF_EXPORT QList< KLFAddOnInfo > klf_addons
Definition: klfmain.cpp:54
int locale_specificity
how specific the locale is (e.g. ""->0 , "fr"->1, "fr_CH"->2 )
Definition: klfmain.h:248
QString author()
Definition: klfmain.h:96
QString title()
Definition: klfmain.h:94
KLF_EXPORT QDebug & operator<<(QDebug &str, const KLFAddOnInfo::PluginSysInfo &i)
Definition: klfmain.cpp:143
bool hasnicetranslatedname
TRUE if the translatedname was provided by translator itself.
Definition: klfmain.h:221
QString description
Definition: klfmain.h:189
KLF_EXPORT QList< KLFTranslationInfo > klf_avail_translations
Definition: klfmain.cpp:42
QString fname
Definition: klfmain.h:192
QString rccmountroot()
where in the resource tree this rcc resource data is mounted
Definition: klfmain.h:103
QString name
Translation file base name (e.g. &#39;klf&#39; for klf_fr.qm)
Definition: klfmain.h:244

Generated by doxygen 1.8.11