Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp index 6059e9b..9fa4452 100644 --- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp | |||
@@ -7,48 +7,53 @@ | |||
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "katesyntaxdocument.h" | 18 | #include "katesyntaxdocument.h" |
19 | #include <kateconfig.h> | 19 | #include "kateconfig.h" |
20 | #include "kdebug.h" | ||
21 | #include "kstddirs.h" | ||
22 | #include "klocale.h" | ||
23 | #include "kmessagebox.h" | ||
24 | #include "kglobal.h" | ||
25 | |||
26 | /* OPIE */ | ||
27 | #include <opie2/odebug.h> | ||
28 | #include <qpe/qpeapplication.h> | ||
29 | |||
30 | /* QT */ | ||
20 | #include <qfile.h> | 31 | #include <qfile.h> |
21 | #include <kdebug.h> | ||
22 | #include <kstddirs.h> | ||
23 | #include <klocale.h> | ||
24 | #include <kmessagebox.h> | ||
25 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
26 | #include <kglobal.h> | ||
27 | #include <qpe/qpeapplication.h> | ||
28 | #include <qdir.h> | 33 | #include <qdir.h> |
29 | 34 | ||
30 | SyntaxDocument::SyntaxDocument() | 35 | SyntaxDocument::SyntaxDocument() |
31 | { | 36 | { |
32 | m_root=0; | 37 | m_root=0; |
33 | currentFile=""; | 38 | currentFile=""; |
34 | setupModeList(); | 39 | setupModeList(); |
35 | } | 40 | } |
36 | 41 | ||
37 | void SyntaxDocument::setIdentifier(const QString& identifier) | 42 | void SyntaxDocument::setIdentifier(const QString& identifier) |
38 | { | 43 | { |
39 | #warning FIXME delete m_root; | 44 | #warning FIXME delete m_root; |
40 | m_root=Opie::Core::XMLElement::load(identifier); | 45 | m_root=Opie::Core::XMLElement::load(identifier); |
41 | if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); | 46 | if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); |
42 | 47 | ||
43 | } | 48 | } |
44 | 49 | ||
45 | SyntaxDocument::~SyntaxDocument() | 50 | SyntaxDocument::~SyntaxDocument() |
46 | { | 51 | { |
47 | } | 52 | } |
48 | 53 | ||
49 | void SyntaxDocument::setupModeList(bool force) | 54 | void SyntaxDocument::setupModeList(bool force) |
50 | { | 55 | { |
51 | 56 | ||
52 | if (myModeList.count() > 0) return; | 57 | if (myModeList.count() > 0) return; |
53 | 58 | ||
54 | KateConfig *config=KGlobal::config(); | 59 | KateConfig *config=KGlobal::config(); |
@@ -67,39 +72,39 @@ void SyntaxDocument::setupModeList(bool force) | |||
67 | { | 72 | { |
68 | config->setGroup(Group); | 73 | config->setGroup(Group); |
69 | syntaxModeListItem *mli=new syntaxModeListItem; | 74 | syntaxModeListItem *mli=new syntaxModeListItem; |
70 | mli->name = config->readEntry("name",""); | 75 | mli->name = config->readEntry("name",""); |
71 | mli->section = config->readEntry("section",""); | 76 | mli->section = config->readEntry("section",""); |
72 | mli->mimetype = config->readEntry("mimetype",""); | 77 | mli->mimetype = config->readEntry("mimetype",""); |
73 | mli->extension = config->readEntry("extension",""); | 78 | mli->extension = config->readEntry("extension",""); |
74 | mli->identifier = path+*it; | 79 | mli->identifier = path+*it; |
75 | myModeList.append(mli); | 80 | myModeList.append(mli); |
76 | } | 81 | } |
77 | else | 82 | else |
78 | { | 83 | { |
79 | qDebug("Found a description file:"+path+(*it)); | 84 | odebug << "Found a description file:"+path+(*it) << oendl; |
80 | setIdentifier(path+(*it)); | 85 | setIdentifier(path+(*it)); |
81 | Opie::Core::XMLElement *e=m_root; | 86 | Opie::Core::XMLElement *e=m_root; |
82 | if (e) | 87 | if (e) |
83 | { | 88 | { |
84 | e=e->firstChild(); | 89 | e=e->firstChild(); |
85 | qDebug(e->tagName()); | 90 | odebug << e->tagName() << oendl; |
86 | if (e->tagName()=="language") | 91 | if (e->tagName()=="language") |
87 | { | 92 | { |
88 | syntaxModeListItem *mli=new syntaxModeListItem; | 93 | syntaxModeListItem *mli=new syntaxModeListItem; |
89 | mli->name = e->attribute("name"); | 94 | mli->name = e->attribute("name"); |
90 | mli->section = e->attribute("section"); | 95 | mli->section = e->attribute("section"); |
91 | mli->mimetype = e->attribute("mimetype"); | 96 | mli->mimetype = e->attribute("mimetype"); |
92 | mli->extension = e->attribute("extensions"); | 97 | mli->extension = e->attribute("extensions"); |
93 | qDebug(QString("valid description for: %1/%2").arg(mli->section).arg(mli->name)); | 98 | odebug << QString("valid description for: %1/%2").arg(mli->section).arg(mli->name) << oendl; |
94 | if (mli->section.isEmpty()) | 99 | if (mli->section.isEmpty()) |
95 | mli->section=i18n("Other"); | 100 | mli->section=i18n("Other"); |
96 | 101 | ||
97 | mli->identifier = path+(*it); | 102 | mli->identifier = path+(*it); |
98 | config->setGroup(Group); | 103 | config->setGroup(Group); |
99 | config->writeEntry("name",mli->name); | 104 | config->writeEntry("name",mli->name); |
100 | config->writeEntry("section",mli->section); | 105 | config->writeEntry("section",mli->section); |
101 | config->writeEntry("mimetype",mli->mimetype); | 106 | config->writeEntry("mimetype",mli->mimetype); |
102 | config->writeEntry("extension",mli->extension); | 107 | config->writeEntry("extension",mli->extension); |
103 | myModeList.append(mli); | 108 | myModeList.append(mli); |
104 | } | 109 | } |
105 | } | 110 | } |
@@ -171,27 +176,27 @@ QString SyntaxDocument::groupData( syntaxContextData* data,QString name) | |||
171 | return QString(); | 176 | return QString(); |
172 | } | 177 | } |
173 | 178 | ||
174 | void SyntaxDocument::freeGroupInfo( syntaxContextData* data) | 179 | void SyntaxDocument::freeGroupInfo( syntaxContextData* data) |
175 | { | 180 | { |
176 | if (data) | 181 | if (data) |
177 | delete data; | 182 | delete data; |
178 | } | 183 | } |
179 | 184 | ||
180 | syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) | 185 | syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) |
181 | { | 186 | { |
182 | syntaxContextData *retval=new syntaxContextData; | 187 | syntaxContextData *retval=new syntaxContextData; |
183 | retval->parent=0; | 188 | retval->parent=0; |
184 | retval->currentGroup=0; | 189 | retval->currentGroup=0; |
185 | retval->item=0; | 190 | retval->item=0; |
186 | if (data != 0) | 191 | if (data != 0) |
187 | { | 192 | { |
188 | retval->parent=data->currentGroup; | 193 | retval->parent=data->currentGroup; |
189 | retval->currentGroup=data->item; | 194 | retval->currentGroup=data->item; |
190 | retval->item=0; | 195 | retval->item=0; |
191 | } | 196 | } |
192 | 197 | ||
193 | return retval; | 198 | return retval; |
194 | } | 199 | } |
195 | 200 | ||
196 | syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) | 201 | syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) |
197 | { | 202 | { |
@@ -203,26 +208,26 @@ syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const | |||
203 | 208 | ||
204 | if (e->tagName().compare(mainGroupName)==0 ) | 209 | if (e->tagName().compare(mainGroupName)==0 ) |
205 | { | 210 | { |
206 | Opie::Core::XMLElement *e1=e->firstChild(); | 211 | Opie::Core::XMLElement *e1=e->firstChild(); |
207 | 212 | ||
208 | while (e1) | 213 | while (e1) |
209 | { | 214 | { |
210 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; | 215 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; |
211 | 216 | ||
212 | if (e1->tagName()==Config) | 217 | if (e1->tagName()==Config) |
213 | { | 218 | { |
214 | syntaxContextData *data=new ( syntaxContextData); | 219 | syntaxContextData *data=new ( syntaxContextData); |
215 | data->currentGroup=0; | 220 | data->currentGroup=0; |
216 | data->parent=0; | 221 | data->parent=0; |
217 | data->item=e1; | 222 | data->item=e1; |
218 | return data; | 223 | return data; |
219 | } | 224 | } |
220 | 225 | ||
221 | e1=e1->nextChild(); | 226 | e1=e1->nextChild(); |
222 | } | 227 | } |
223 | 228 | ||
224 | kdDebug(13010) << "WARNING :returning null 3"<< endl; | 229 | kdDebug(13010) << "WARNING :returning null 3"<< endl; |
225 | return 0; | 230 | return 0; |
226 | } | 231 | } |
227 | 232 | ||
228 | e=e->nextChild(); | 233 | e=e->nextChild(); |
@@ -245,26 +250,26 @@ syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, co | |||
245 | 250 | ||
246 | if (e->tagName().compare(mainGroupName)==0 ) | 251 | if (e->tagName().compare(mainGroupName)==0 ) |
247 | { | 252 | { |
248 | Opie::Core::XMLElement *e1=e->firstChild(); | 253 | Opie::Core::XMLElement *e1=e->firstChild(); |
249 | 254 | ||
250 | while (e1) | 255 | while (e1) |
251 | { | 256 | { |
252 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; | 257 | kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; |
253 | if (e1->tagName()==group+"s") | 258 | if (e1->tagName()==group+"s") |
254 | { | 259 | { |
255 | syntaxContextData *data=new ( syntaxContextData); | 260 | syntaxContextData *data=new ( syntaxContextData); |
256 | data->parent=e1; | 261 | data->parent=e1; |
257 | data->currentGroup=0; | 262 | data->currentGroup=0; |
258 | data->item=0; | 263 | data->item=0; |
259 | return data; | 264 | return data; |
260 | } | 265 | } |
261 | 266 | ||
262 | e1=e1->nextChild(); | 267 | e1=e1->nextChild(); |
263 | } | 268 | } |
264 | 269 | ||
265 | kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; | 270 | kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; |
266 | return 0; | 271 | return 0; |
267 | } | 272 | } |
268 | 273 | ||
269 | e=e->nextChild(); | 274 | e=e->nextChild(); |
270 | } | 275 | } |
@@ -275,32 +280,32 @@ syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, co | |||
275 | 280 | ||
276 | 281 | ||
277 | QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) | 282 | QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) |
278 | { | 283 | { |
279 | Opie::Core::XMLElement *e = m_root->firstChild(); | 284 | Opie::Core::XMLElement *e = m_root->firstChild(); |
280 | if (clearList) | 285 | if (clearList) |
281 | m_data.clear(); | 286 | m_data.clear(); |
282 | 287 | ||
283 | for(e=e->firstChild(); e; e=e->nextChild()) | 288 | for(e=e->firstChild(); e; e=e->nextChild()) |
284 | { | 289 | { |
285 | if (e->tagName()==mainGroup) | 290 | if (e->tagName()==mainGroup) |
286 | { | 291 | { |
287 | for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) | 292 | for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) |
288 | { | 293 | { |
289 | if (e1->tagName()!="list") continue; | 294 | if (e1->tagName()!="list") continue; |
290 | 295 | ||
291 | if (e1->attribute("name")==type) | 296 | if (e1->attribute("name")==type) |
292 | { | 297 | { |
293 | for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) | 298 | for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) |
294 | { | 299 | { |
295 | qDebug("FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value()); | 300 | odebug << "FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value() << oendl; |
296 | m_data+=e2->firstChild()->value().stripWhiteSpace(); | 301 | m_data+=e2->firstChild()->value().stripWhiteSpace(); |
297 | } | 302 | } |
298 | break; | 303 | break; |
299 | } | 304 | } |
300 | } | 305 | } |
301 | break; | 306 | break; |
302 | } | 307 | } |
303 | } | 308 | } |
304 | 309 | ||
305 | return m_data; | 310 | return m_data; |
306 | } | 311 | } |