[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:18:21 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=408567d
The following commit has been merged in the master branch:
commit 408567d60ba2d34dddbb524afb1afc34290c4cb9
Author: Dominik Schmidt <ich at dominik-schmidt.de>
Date: Mon Oct 4 00:57:49 2010 +0000
PlistFileReader: Use d pointer. Sanitize API.
svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1182264
---
lib/chatstyleplistfilereader.cpp | 59 ++++++++++++++++++++++++----------------
lib/chatstyleplistfilereader.h | 9 ++++--
2 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/lib/chatstyleplistfilereader.cpp b/lib/chatstyleplistfilereader.cpp
index f95f123..6864097 100644
--- a/lib/chatstyleplistfilereader.cpp
+++ b/lib/chatstyleplistfilereader.cpp
@@ -25,11 +25,23 @@
#include <QVariant>
#include <QDebug>
+class ChatStylePlistFileReader::Private
+{
+public:
+ Private() {}
+
+ ~Private() {}
+
+ QMap<QString, QVariant> data;
+ Status m_status;
+};
+
ChatStylePlistFileReader::ChatStylePlistFileReader(const QString &fileName)
{
- QFile bla(fileName);
+ QFile file(fileName);
- readAndParseFile(bla);
+ d = new Private();
+ d->m_status = readAndParseFile(file);
}
ChatStylePlistFileReader::ChatStylePlistFileReader(const QByteArray& fileContent)
@@ -37,31 +49,26 @@ ChatStylePlistFileReader::ChatStylePlistFileReader(const QByteArray& fileContent
QDomDocument document;
document.setContent(fileContent);
- parse(document);
+ d = new Private();
+ d->m_status = parse(document);
}
-int ChatStylePlistFileReader::readAndParseFile(QFile& file)
+ChatStylePlistFileReader::Status ChatStylePlistFileReader::readAndParseFile(QFile& file)
{
QDomDocument document;
if (!file.open(QIODevice::ReadOnly)) {
- return 1;
+ return CannotOpenFileError;
} if (!document.setContent(&file)) {
file.close();
- return 2;
+ return UnknownError;
}
file.close();
- if(!parse(document)) {
- // everything ok
- return 0;
- } else {
- // parse failed
- return 3;
- }
+ return parse(document);
}
-int ChatStylePlistFileReader::parse(const QDomDocument &document)
+ChatStylePlistFileReader::Status ChatStylePlistFileReader::parse(const QDomDocument& document)
{
QString key, value;
QDomNodeList keyElements = document.elementsByTagName("key");
@@ -69,48 +76,54 @@ int ChatStylePlistFileReader::parse(const QDomDocument &document)
if (keyElements.at(i).nextSibling().toElement().tagName() != "key") {
key = keyElements.at(i).toElement().text();
value = keyElements.at(i).nextSibling().toElement().text();
- data.insert(key, value);
+ d->data.insert(key, value);
}
}
- return 0;
+ return Ok;
}
ChatStylePlistFileReader::~ChatStylePlistFileReader()
{
+ delete d;
}
QString ChatStylePlistFileReader::CFBundleGetInfoString()
{
- return data.value("CFBundleGetInfoString").toString();
+ return d->data.value("CFBundleGetInfoString").toString();
}
QString ChatStylePlistFileReader::CFBundleName()
{
- return data.value("CFBundleName").toString();
+ return d->data.value("CFBundleName").toString();
}
QString ChatStylePlistFileReader::CFBundleIdentifier()
{
- return data.value("CFBundleIdentifier").toString();
+ return d->data.value("CFBundleIdentifier").toString();
}
QString ChatStylePlistFileReader::defaultFontFamily()
{
- return data.value("DefaultFontFamily").toString();
+ return d->data.value("DefaultFontFamily").toString();
}
int ChatStylePlistFileReader::defaultFontSize()
{
- return data.value("DefaultFontSize").toInt();
+ return d->data.value("DefaultFontSize").toInt();
}
QString ChatStylePlistFileReader::defaultVariant()
{
- return data.value("DefaultVariant").toString();
+ return d->data.value("DefaultVariant").toString();
}
int ChatStylePlistFileReader::messageViewVersion()
{
- return data.value("MessageViewVersion").toInt();
+ return d->data.value("MessageViewVersion").toInt();
}
+
+ChatStylePlistFileReader::Status ChatStylePlistFileReader::status()
+{
+ return d->m_status;
+}
\ No newline at end of file
diff --git a/lib/chatstyleplistfilereader.h b/lib/chatstyleplistfilereader.h
index 488a940..a206cdc 100644
--- a/lib/chatstyleplistfilereader.h
+++ b/lib/chatstyleplistfilereader.h
@@ -32,6 +32,7 @@ class ChatStylePlistFileReader
{
public:
+ enum Status { Ok = 0, CannotOpenFileError, ParseError, UnknownError };
ChatStylePlistFileReader(const QString &fileName);
ChatStylePlistFileReader(const QByteArray &file);
virtual ~ChatStylePlistFileReader();
@@ -43,12 +44,14 @@ public:
int defaultFontSize();
QString defaultVariant();
int messageViewVersion();
+ Status status();
private:
- QMap<QString, QVariant> data;
- int readAndParseFile(QFile &file);
- int parse(const QDomDocument &document);
+ class Private;
+ Private *d;
+ ChatStylePlistFileReader::Status readAndParseFile(QFile &file);
+ ChatStylePlistFileReader::Status parse(const QDomDocument &document);
};
#endif // CHATSTYLEPLISTFILEREADER_H
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list