aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/colorscheme.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-07-10 12:45:31 +0200
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-07-13 14:22:27 +0200
commit6684c8f15c54abf266f6e3e101c56bd5b3d06d58 (patch)
tree8d5f6fe44579991ea3359e81e44f1ba95f6d4529 /src/plugins/texteditor/colorscheme.cpp
parentc6d4663ddbc7ab4f9e718105703f4dc127cd2233 (diff)
Simplified the ColorSchemeReader
Diffstat (limited to 'src/plugins/texteditor/colorscheme.cpp')
-rw-r--r--src/plugins/texteditor/colorscheme.cpp58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/plugins/texteditor/colorscheme.cpp b/src/plugins/texteditor/colorscheme.cpp
index 9e7e01281fa..b131337c2fa 100644
--- a/src/plugins/texteditor/colorscheme.cpp
+++ b/src/plugins/texteditor/colorscheme.cpp
@@ -202,7 +202,8 @@ public:
QString readName(const QString &fileName);
private:
- void readUnknownElement();
+ bool readNextStartElement();
+ void skipCurrentElement();
void readStyleScheme();
void readStyle();
@@ -223,14 +224,10 @@ bool ColorSchemeReader::read(const QString &fileName, ColorScheme *scheme)
setDevice(&file);
- while (readNext() != Invalid) {
- if (isStartElement()) {
- if (name() == QLatin1String("style-scheme"))
- readStyleScheme();
- else
- raiseError(QObject::tr("Not a color scheme file."));
- }
- }
+ if (readNextStartElement() && name() == QLatin1String("style-scheme"))
+ readStyleScheme();
+ else
+ raiseError(QObject::tr("Not a color scheme file."));
return true;
}
@@ -241,17 +238,21 @@ QString ColorSchemeReader::readName(const QString &fileName)
return m_name;
}
-void ColorSchemeReader::readUnknownElement()
+bool ColorSchemeReader::readNextStartElement()
{
- Q_ASSERT(isStartElement());
-
- while (!atEnd()) {
- readNext();
- if (isEndElement())
- break;
- else if (isStartElement())
- readUnknownElement();
+ while (readNext() != Invalid) {
+ if (isStartElement())
+ return true;
+ else if (isEndElement())
+ return false;
}
+ return false;
+}
+
+void ColorSchemeReader::skipCurrentElement()
+{
+ while (readNextStartElement())
+ skipCurrentElement();
}
void ColorSchemeReader::readStyleScheme()
@@ -266,15 +267,11 @@ void ColorSchemeReader::readStyleScheme()
else
m_scheme->setName(m_name);
- while (readNext() != Invalid) {
- if (isEndElement()) {
- break;
- } else if (isStartElement()) {
- if (name() == QLatin1String("style"))
- readStyle();
- else
- readUnknownElement();
- }
+ while (readNextStartElement()) {
+ if (name() == QLatin1String("style"))
+ readStyle();
+ else
+ skipCurrentElement();
}
}
@@ -297,12 +294,7 @@ void ColorSchemeReader::readStyle()
m_scheme->setFormatFor(name, format);
- while (readNext() != Invalid) {
- if (isEndElement())
- break;
- else if (isStartElement())
- readUnknownElement();
- }
+ skipCurrentElement();
}
} // anonymous namespace