[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfliblegacyengine.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfliblegacyengine.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: klfliblegacyengine.h 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 #ifndef KLFLIBLEGACYENGINE_H
25 #define KLFLIBLEGACYENGINE_H
26 
27 
28 #include <QDateTime>
29 #include <QList>
30 #include <QDataStream>
31 #include <QPixmap>
32 #include <QMap>
33 #include <QMetaType>
34 #include <QFile>
35 #include <QTimer>
36 
37 #include <klflib.h>
38 #include <klflibview.h> // scheme guesser
39 
40 
46 class KLF_EXPORT KLFLegacyData {
47 public:
48 
49  struct KLFStyle {
50  KLFStyle(QString nm = QString(), unsigned long fgcol = qRgba(0,0,0,255),
51  unsigned long bgcol = qRgba(255,255,255,0),
52  const QString& mmode = QString(),
53  const QString& pre = QString(),
54  int dotsperinch = -1)
55  : name(nm), fg_color(fgcol), bg_color(bgcol), mathmode(mmode), preamble(pre),
56  dpi(dotsperinch) { }
57  QString name; // this may not always be set, it's only important in saved style list.
58  unsigned long fg_color;
59  unsigned long bg_color;
62  int dpi;
63  };
64 
65  // THESE VALUES MUST NOT CHANGE FROM ONE VERSION TO ANOTHER OF KLATEXFORMULA :
66  enum {
67  LibResource_History = 0,
68  LibResource_Archive = 1,
69  // user resources must be in the following range:
70  LibResourceUSERMIN = 100,
71  LibResourceUSERMAX = 99999
72  };
73 
75  quint32 id;
77  };
78 
79  struct KLFLibraryItem {
80  quint32 id;
81  static quint32 MaxId;
82 
88 
91 
93  };
94 
98 
99 private:
100 
101  KLFLegacyData();
102 };
103 
104 KLF_EXPORT QDataStream& operator<<(QDataStream& stream, const KLFLegacyData::KLFStyle& style);
105 KLF_EXPORT QDataStream& operator>>(QDataStream& stream, KLFLegacyData::KLFStyle& style);
106 KLF_EXPORT bool operator==(const KLFLegacyData::KLFStyle& a, const KLFLegacyData::KLFStyle& b);
107 
108 // it is important to note that the >> operator imports in a compatible way to KLF 2.0
109 KLF_EXPORT QDataStream& operator<<(QDataStream& stream, const KLFLegacyData::KLFLibraryItem& item);
111 
112 KLF_EXPORT QDataStream& operator<<(QDataStream& stream, const KLFLegacyData::KLFLibraryResource& item);
114 
115 // exact matches, style included, but excluding ID and datetime
117 
118 // is needed for QMap : these operators compare ID only.
121 // name comparision
124 
125 
126 
128 
130 
136 {
137  Q_OBJECT
138 public:
146  static KLFLibLegacyEngine * openUrl(const QUrl& url, QObject *parent = NULL);
147 
158  static KLFLibLegacyEngine * createDotKLF(const QString& fileName, QString legacyResourceName,
159  QObject *parent = NULL);
160 
161  virtual ~KLFLibLegacyEngine();
162 
163  virtual uint compareUrlTo(const QUrl& other, uint interestFlags = 0xfffffff) const;
164 
165  virtual bool canModifyData(const QString& subRes, ModifyType modifytype) const;
166  virtual bool canModifyProp(int propid) const;
167  virtual bool canRegisterProperty(const QString& propName) const;
168 
169  virtual KLFLibEntry entry(const QString& resource, entryId id);
170  virtual QList<KLFLibEntryWithId> allEntries(const QString& resource,
171  const QList<int>& wantedEntryProperties = QList<int>());
172 
173  virtual QStringList subResourceList() const;
174 
175  virtual bool canCreateSubResource() const;
176  virtual bool canRenameSubResource(const QString& subResource) const;
177  virtual bool canDeleteSubResource(const QString& subResource) const;
178 
179 public slots:
180 
181  virtual bool createSubResource(const QString& subResource, const QString& subResourceTitle);
182  virtual bool renameSubResource(const QString& subResource, const QString& subResourceName);
183  virtual bool deleteSubResource(const QString& subResource);
184 
185  virtual bool save();
186  virtual void setAutoSaveInterval(int intervalms);
187 
188  virtual QList<entryId> insertEntries(const QString& subResource, const KLFLibEntryList& entries);
189  virtual bool changeEntries(const QString& subResource, const QList<entryId>& idlist,
190  const QList<int>& properties, const QList<QVariant>& values);
191  virtual bool deleteEntries(const QString& subResource, const QList<entryId>& idlist);
192 
193  virtual bool saveTo(const QUrl& newPath);
194 
195 protected:
196  virtual bool saveResourceProperty(int propId, const QVariant& value);
197 
198 protected slots:
199  void updateResourceProperty(int propId);
200 
201 private:
202  KLFLibLegacyEngine(const QString& fileName, const QString& resname, const QUrl& url, QObject *parent);
203 
205 };
206 
207 
208 
209 
210 
212 {
213 public:
215 
216  QString guessScheme(const QString& fileName) const;
217 };
218 
219 
222 {
223  Q_OBJECT
224 public:
225  KLFLibLegacyEngineFactory(QObject *parent = NULL);
227 
228  virtual QStringList supportedTypes() const;
229  virtual QString schemeTitle(const QString& scheme) const ;
230 
231  virtual uint schemeFunctions(const QString& scheme) const;
232 
233  virtual QString correspondingWidgetType(const QString& scheme) const;
234 
236  virtual KLFLibResourceEngine *openResource(const QUrl& location, QObject *parent = NULL);
237 
238  virtual KLFLibResourceEngine *createResource(const QString& scheme, const Parameters& parameters,
239  QObject *parent = NULL);
240 };
241 
242 
243 
244 
245 
246 #endif
QDataStream & operator<<(QDataStream &stream, const KLFLatexSymbol &s)
virtual bool saveTo(const QUrl &newPath)
Definition: klflib.cpp:704
virtual uint schemeFunctions(const QString &scheme) const
What this factory is capable of doing.
Definition: klflib.cpp:1158
QList< KLFLibraryResource > KLFLibraryResourceList
virtual bool canRenameSubResource(const QString &subResource) const
Definition: klflib.cpp:519
QDataStream & operator>>(QDataStream &stream, KLFLatexSymbol &s)
virtual bool createSubResource(const QString &subResource, const QString &subResourceTitle)
Create a new sub-resource.
Definition: klflib.cpp:599
virtual uint compareUrlTo(const QUrl &other, uint interestFlags=0xfffffff) const =0
Compare this resource&#39;s URL with another&#39;s.
KLFLib::entryId entryId
Definition: klflib.h:444
virtual bool canRegisterProperty(const QString &propName) const
Definition: klflib.cpp:491
virtual KLFLibResourceEngine * openResource(const QUrl &location, QObject *parent=NULL)=0
virtual KLFLibEntry entry(const QString &subResource, entryId id)=0
query an entry in this resource
KLFLegacyData::KLFStyle style
virtual bool deleteSubResource(const QString &subResource)
Definition: klflib.cpp:612
KLFStyle(QString nm=QString(), unsigned long fgcol=qRgba(0, 0, 0, 255), unsigned long bgcol=qRgba(255, 255, 255, 0), const QString &mmode=QString(), const QString &pre=QString(), int dotsperinch=-1)
virtual QStringList supportedTypes() const =0
A list of supported URL schemes this factory can open.
virtual bool renameSubResource(const QString &oldSubResourceName, const QString &newSubResourceName)
Definition: klflib.cpp:608
The Legacy Library support for the KLFLib framework.
virtual bool saveResourceProperty(int propId, const QVariant &value)=0
Save a resource property to the backend resource data.
virtual KLFLibResourceEngine * createResource(const QString &scheme, const Parameters &parameters, QObject *parent=NULL)
Create a new resource of given type and parameters.
Definition: klflib.cpp:1178
virtual bool canCreateSubResource() const
Definition: klflib.cpp:514
virtual bool deleteEntries(const QString &subResource, const QList< entryId > &idlist)=0
Delete some entries in this resource.
virtual bool canModifyData(const QString &subResource, ModifyType modifytype) const
Definition: klflib.cpp:472
virtual QList< entryId > insertEntries(const QString &subResource, const KLFLibEntryList &entrylist)=0
Insert new entries in this resource.
virtual QStringList subResourceList() const
Definition: klflib.h:722
Provides a simple API for reading library resources.
Definition: klflib.h:1588
QMap< KLFLibraryResource, KLFLibraryList > KLFLibrary
Interface for guessing file schemes.
Definition: klflibview.h:1096
virtual QString correspondingWidgetType(const QString &scheme) const =0
KLF_EXPORT bool operator<(const KLFLatexSymbol &a, const KLFLatexSymbol &b)
An entry (single formula) in the library.
Definition: klflib.h:55
KLF_EXPORT bool operator==(const KLFLatexSymbol &a, const KLFLatexSymbol &b)
virtual bool changeEntries(const QString &subResource, const QList< entryId > &idlist, const QList< int > &properties, const QList< QVariant > &values)=0
Change some entries in this resource.
virtual QList< KLFLibEntryWithId > allEntries(const QString &subResource, const QList< int > &wantedEntryProperties=QList< int >())=0
query all entries in this resource
An abstract resource engine.
Definition: klflib.h:440
virtual bool canDeleteSubResource(const QString &subResource) const
Definition: klflib.cpp:523
QList< KLFLibraryItem > KLFLibraryList
virtual bool canModifyProp(int propId) const
Definition: klflib.cpp:485
virtual QString guessScheme(const QString &fileName) const =0
Guess the appropriate scheme for handling the given file.
KLFLibLegacyLocalFileSchemeGuesser(QObject *parent)
virtual QString schemeTitle(const QString &scheme) const =0
KLF_EXPORT bool resources_equal_for_import(const KLFLegacyData::KLFLibraryResource a, const KLFLegacyData::KLFLibraryResource b)

Generated by doxygen 1.8.5