[KLF Application]
[KLF Tools]
[KLF Backend]
[KLF Home]
KLatexFormula Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
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
;
60
QString
mathmode
;
61
QString
preamble
;
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
74
struct
KLFLibraryResource
{
75
quint32
id
;
76
QString
name
;
77
};
78
79
struct
KLFLibraryItem
{
80
quint32
id
;
81
static
quint32
MaxId
;
82
83
QDateTime
datetime
;
86
QString
latex
;
87
QPixmap
preview
;
88
89
QString
category
;
90
QString
tags
;
91
92
KLFLegacyData::KLFStyle
style
;
93
};
94
95
typedef
QList<KLFLibraryItem>
KLFLibraryList
;
96
typedef
QList<KLFLibraryResource>
KLFLibraryResourceList
;
97
typedef
QMap<KLFLibraryResource, KLFLibraryList>
KLFLibrary
;
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);
110
KLF_EXPORT
QDataStream
&
operator>>
(
QDataStream
& stream,
KLFLegacyData::KLFLibraryItem
& item);
111
112
KLF_EXPORT
QDataStream
&
operator<<
(
QDataStream
& stream,
const
KLFLegacyData::KLFLibraryResource
& item);
113
KLF_EXPORT
QDataStream
&
operator>>
(
QDataStream
& stream,
KLFLegacyData::KLFLibraryResource
& item);
114
115
// exact matches, style included, but excluding ID and datetime
116
KLF_EXPORT
bool
operator==
(
const
KLFLegacyData::KLFLibraryItem
& a,
const
KLFLegacyData::KLFLibraryItem
& b);
117
118
// is needed for QMap : these operators compare ID only.
119
KLF_EXPORT
bool
operator<
(
const
KLFLegacyData::KLFLibraryResource
a,
const
KLFLegacyData::KLFLibraryResource
b);
120
KLF_EXPORT
bool
operator==
(
const
KLFLegacyData::KLFLibraryResource
a,
const
KLFLegacyData::KLFLibraryResource
b);
121
// name comparision
122
KLF_EXPORT
bool
resources_equal_for_import
(
const
KLFLegacyData::KLFLibraryResource
a,
123
const
KLFLegacyData::KLFLibraryResource
b);
124
125
126
127
class
KLFLibLegacyFileDataPrivate
;
128
130
135
class
KLF_EXPORT
KLFLibLegacyEngine
:
public
KLFLibResourceSimpleEngine
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
204
KLFLibLegacyFileDataPrivate
*d;
205
};
206
207
208
209
210
211
class
KLF_EXPORT
KLFLibLegacyLocalFileSchemeGuesser
:
public
QObject
,
public
KLFLibLocalFileSchemeGuesser
212
{
213
public
:
214
KLFLibLegacyLocalFileSchemeGuesser
(
QObject
*parent) :
QObject
(parent) { }
215
216
QString
guessScheme
(
const
QString
& fileName)
const
;
217
};
218
219
221
class
KLF_EXPORT
KLFLibLegacyEngineFactory
:
public
KLFLibEngineFactory
222
{
223
Q_OBJECT
224
public
:
225
KLFLibLegacyEngineFactory
(
QObject
*parent = NULL);
226
virtual
~KLFLibLegacyEngineFactory
() { }
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
Generated by
doxygen
1.8.2