SVN_SILENT made messages (.desktop file)
[kdeaccessibility.git] / kmouth / phrasebook / phrasebookparser.cpp
blob91dc856f1a96915517e5717143d2d081438a1a1e
1 /***************************************************************************
2 phrasebookparser.cpp - description
3 -------------------
4 begin : Don Sep 12 2002
5 copyright : (C) 2002 by Gunnar Schmi Dt
6 email : kmouth@schmi-dt.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include "phrasebookparser.h"
20 PhraseBookParser::PhraseBookParser() {
23 PhraseBookParser::~PhraseBookParser() {
26 bool PhraseBookParser::warning (const QXmlParseException &) {
27 return false;
30 bool PhraseBookParser::error (const QXmlParseException &) {
31 return false;
34 bool PhraseBookParser::fatalError (const QXmlParseException &) {
35 return false;
38 QString PhraseBookParser::errorString() const {
39 return "";
42 bool PhraseBookParser::startDocument() {
43 list.clear ();
44 isInPhrase = false;
45 level = 0;
46 offset = 0;
47 starting = true;
48 return true;
51 bool PhraseBookParser::startElement (const QString &, const QString &,
52 const QString &name,
53 const QXmlAttributes &attributes)
55 if (name == "phrase") {
56 if (isInPhrase)
57 return false;
59 phrase.phrase = "";
60 phrase.shortcut = attributes.value("shortcut");
61 isInPhrase = true;
63 else if (name == "phrasebook") {
64 if (isInPhrase)
65 return false;
67 phrase.phrase = attributes.value("name");
68 phrase.shortcut = "";
69 if ((phrase.phrase.isNull() || phrase.phrase.isEmpty()) && starting)
70 offset = -1;
71 else {
72 list += PhraseBookEntry (phrase, level, false);
73 level++;
75 starting = false;
77 return true;
80 bool PhraseBookParser::characters (const QString &ch) {
81 phrase.phrase += ch;
82 return true;
85 bool PhraseBookParser::ignorableWhitespace (const QString &ch) {
86 phrase.phrase += ch;
87 return true;
90 bool PhraseBookParser::endElement (const QString &, const QString &,
91 const QString &name)
93 if (name == "phrase") {
94 list += PhraseBookEntry (phrase, level, true);
95 isInPhrase = false;
97 else if (name == "phrasebook") {
98 if (level == offset)
99 return false;
101 level--;
103 return true;
106 bool PhraseBookParser::endDocument() {
107 return (level == offset);
110 PhraseBookEntryList PhraseBookParser::getPhraseList() {
111 return list;