1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
/***************************************************************************
quantacommon.h - description
-------------------
begin : Sat Jul 27 2002
copyright : (C) 2002, 2003 by Andras Mantia <amantia@kde.org>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2 of the License. *
* *
***************************************************************************/
#ifndef QUANTACOMMON_H
#define QUANTACOMMON_H
#include <tdeversion.h>
#include "qtag.h"
#include "node.h"
#include "parser.h"
/**Some common, mostly static functions.
*@author Andras Mantia
*/
#define DEFAULT_DTD TQString("-//W3C//DTD HTML 4.01 Transitional//EN")
class TQString;
class DCOPReply;
class KURL;
class KStandardDirs;
class TQWidget;
class Tag;
class KConfig;
class KPopupMenu;
/** Describes one abbreviation group */
class Abbreviation{
public:
/*A list with abbreviations in the for of: <template templatename, code> */
TQMap<TQString, TQString> abbreviations;
TQStringList dteps;
};
//Quanta main configuration structure
class TQConfig{
public:
//Tag style options
uint tagCase;
uint attrCase;
TQChar attrValueQuotation;
bool closeOptionalTags;
bool closeTags;
bool updateClosingTags;
//editor settings
bool useAutoCompletion;
bool enableDTDToolbar;
TQString defaultEncoding;
//parser options
bool instantUpdate;
bool showEmptyNodes;
bool showClosingTags;
uint refreshFrequency;
TQString defaultDocType;
uint expandLevel;
bool showDTDSelectDialog;
TQString showCloseButtons; ///< can be Disabled, ShowAlways or ShowDelayed
uint toolviewTabs; ///< how does the toolview tabs look like
//kafka sync options
bool quantaRefreshOnFocus;
int quantaRefreshDelay;
bool kafkaRefreshOnFocus;
int kafkaRefreshDelay;
//kafka indentation options
bool inlineNodeIndentation;
//environment options
TQString globalDataDir; //not stored, initialized on app startup
TQStringList pluginSearchPaths; //global but read from plugins.rc
TQString markupMimeTypes;
TQString scriptMimeTypes;
TQString imageMimeTypes;
TQString textMimeTypes;
TQString previewPosition;
TQString docPosition;
TQString windowLayout;
uint autosaveInterval;
TQString backupDirPath;
TQString quantaPID;
bool showHiddenFiles; ///< show hidden files in files treeview?
bool saveTrees; ///< save tree status for local trees?
TQMap<TQString, Abbreviation> abbreviations; ///< the abbreviation groups
bool replaceAccented; ///< replace or not the accented characters
bool replaceNotInEncoding; ///< replace characters with their entity number if they cannot be saved in the current encoding of the document.
bool smartTagInsertion; //enable/disable smartTagInsertion
};
struct DirInfo {
TQString mimeType;
TQString preText;
TQString postText;
bool usePrePostText;
};
/**Some common, mostly static functions.
*@author Andras Mantia
*/
class QuantaCommon {
public:
QuantaCommon();
~QuantaCommon();
/** convert tag to upper or lower case */
static TQString tagCase( const TQString& tag);
/** convert tag to upper or lower case */
static TQString attrCase( const TQString& attr);
/** returns the attribute value in quoted form, by taking care of the
quotation setting*/
static TQString quoteAttributeValue(const TQString& value);
/** Set's up the url correctly from urlString. */
static void setUrl(KURL &url, const TQString& urlString);
/** No descriptions */
static bool isSingleTag(const TQString& dtdName, const TQString& tag);
/** No descriptions */
static bool isOptionalTag(const TQString& dtdName, const TQString& tag);
/** No descriptions */
static bool isKnownTag(const TQString& dtdName, const TQString& tag);
/** No descriptions */
static AttributeList* tagAttributes(const TQString& dtdName, const TQString& tag);
/** Returns the TQTag object for the tag "tag" from the DTD named "dtdname". */
static TQTag* tagFromDTD(const TQString& dtdName, const TQString& tag);
/** Returns the TQTag object for the tag "tag" from the DTD. */
static TQTag* tagFromDTD(const DTDStruct* dtd, const TQString& tag);
/** Returns the TQTag object for the node "node" from node's DTD. */
static TQTag* tagFromDTD(Node *node);
/** Returns an XML style string containing the GUI for attributes. */
static TQString xmlFromAttributes(AttributeList* attributes);
/** Returns 0 if the (line,col) is inside the area specified by the other arguments,
-1 if it is before the area and 1 if it is after. */
static int isBetween(int line, int col, int bLine, int bCol, int eLine, int eCol);
/** Returns a pointer to a KStandardDirs object usable for plugin searchup. type is the plugin binary type (exe or lib). The returned
pointer must be deleted by the caller!! */
static KStandardDirs* pluginDirs(const char *type);
/** Return true, if the url has the mimetype starting with type. */
static bool checkMimeGroup(const KURL& url, const TQString& type);
/** Return true, if the url has the mimetype type. */
static bool checkMimeType(const KURL& url, const TQString& type);
/** Return true, if the url has exactly the mimetype type. */
static bool checkExactMimeType(const KURL& url, const TQString& type);
/** Returns the url without the filename. */
static KURL convertToPath(const KURL& url);
/** Return a string to be used when an url is saved to the project file.
Returns url.url() if it's an absolute url and
url.path() if the url is relative */
static TQString qUrl(const KURL& url);
/** No descriptions */
static void dirCreationError(TQWidget *widget, const KURL& url);
/**
Adds the backslash before the special chars (like ?, *, . ) so the returned string can be used in regular expressions.
*/
static TQString makeRxCompatible(const TQString& s);
/** Returns the translated a_str in English. A "back-translation" useful e.g in case of CSS elements selected from a listbox. */
static TQString i18n2normal(const TQString& a_str);
/** No descriptions */
static void normalizeStructure(TQString f,TQStringList& l);
/**Returns true if tag2 is the closing pair of tag1. It's namespace aware.*/
static bool closesTag(Tag *tag1, Tag *tag2);
static bool closesTag(TQString namespaceName, TQString tagName, bool caseSensitive,
TQString namespaceName2, TQString tagName2, bool caseSensitive2);
static int denyBinaryInsert(TQWidget *window);
static void removeCommentsAndQuotes(TQString& str, const DTDStruct* dtd);
static bool insideCommentsOrQuotes(int position, const TQString &string, const DTDStruct *dtd);
/** Calls a Quanta DCOP method.
* @param interface the DCOP interface the method belongs to
* @param method the DCOP method name (with the argument types)
* @param arguments comma separated list of argument
* @return the return value of the DCOP caller
*/
static DCOPReply callDCOPMethod(const TQString& interface, const TQString& method, const TQString& arguments);
/** Checks if url exists and shows a question about overwriting it.
* @param url the url to check
* @return true if the user answered yes, false otherwise.
*/
static bool checkOverwrite(const KURL& url, TQWidget *window);
/**
* Same as KConfigBase::readPathListEntry, but resolves symlinks
* @param config
* @param pKey
* @return
*/
static TQStringList readPathListEntry(KConfig *config, const TQString &pKey);
/**
* Same as KConfigBase::readPathEntry, but resolves symlinks
* @param config
* @param pKey
* @return
*/
static TQString readPathEntry(KConfig *config, const TQString &pKey);
/**
* Returns the HTML encoding string for character with the specified code.
* If no such literal encoding is known (like ä), the numeric encoding
* is returned: &#code;
* @param code the numeric code of the character
* @return the encoded string
*/
static TQString encodedChar(uint code);
};
#endif
|