diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 00bb99ac80741fc50ef8a289719373032f2391eb (patch) | |
tree | 3a5a9bf72f942784b38bf77dd66c534662fab5f2 /kmouth/phrasebook/phrasebookparser.cpp | |
download | tdeaccessibility-00bb99ac80741fc50ef8a289719373032f2391eb.tar.gz tdeaccessibility-00bb99ac80741fc50ef8a289719373032f2391eb.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaccessibility@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmouth/phrasebook/phrasebookparser.cpp')
-rw-r--r-- | kmouth/phrasebook/phrasebookparser.cpp | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/kmouth/phrasebook/phrasebookparser.cpp b/kmouth/phrasebook/phrasebookparser.cpp new file mode 100644 index 0000000..9883e49 --- /dev/null +++ b/kmouth/phrasebook/phrasebookparser.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + phrasebookparser.cpp - description + ------------------- + begin : Don Sep 12 2002 + copyright : (C) 2002 by Gunnar Schmi Dt + email : kmouth@schmi-dt.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "phrasebookparser.h" + +PhraseBookParser::PhraseBookParser() { +} + +PhraseBookParser::~PhraseBookParser() { +} + +bool PhraseBookParser::warning (const QXmlParseException &) { + return false; +} + +bool PhraseBookParser::error (const QXmlParseException &) { + return false; +} + +bool PhraseBookParser::fatalError (const QXmlParseException &) { + return false; +} + +QString PhraseBookParser::errorString() { + return ""; +} + +bool PhraseBookParser::startDocument() { + list.clear (); + isInPhrase = false; + level = 0; + offset = 0; + starting = true; + return true; +} + +bool PhraseBookParser::startElement (const QString &, const QString &, + const QString &name, + const QXmlAttributes &attributes) +{ + if (name == "phrase") { + if (isInPhrase) + return false; + + phrase.phrase = ""; + phrase.shortcut = attributes.value("shortcut"); + isInPhrase = true; + } + else if (name == "phrasebook") { + if (isInPhrase) + return false; + + phrase.phrase = attributes.value("name"); + phrase.shortcut = ""; + if ((phrase.phrase.isNull() || phrase.phrase.isEmpty()) && starting) + offset = -1; + else { + list += PhraseBookEntry (phrase, level, false); + level++; + } + starting = false; + } + return true; +} + +bool PhraseBookParser::characters (const QString &ch) { + phrase.phrase += ch; + return true; +} + +bool PhraseBookParser::ignorableWhitespace (const QString &ch) { + phrase.phrase += ch; + return true; +} + +bool PhraseBookParser::endElement (const QString &, const QString &, + const QString &name) +{ + if (name == "phrase") { + list += PhraseBookEntry (phrase, level, true); + isInPhrase = false; + } + else if (name == "phrasebook") { + if (level == offset) + return false; + + level--; + } + return true; +} + +bool PhraseBookParser::endDocument() { + return (level == offset); +} + +PhraseBookEntryList PhraseBookParser::getPhraseList() { + return list; +} |