Remove xmlpatterns.
This commit is contained in:
parent
81ec000e48
commit
2fdd613805
5 changed files with 40 additions and 28 deletions
|
@ -422,7 +422,7 @@ if(${USE_QT_5})
|
||||||
Sql
|
Sql
|
||||||
Network
|
Network
|
||||||
Xml
|
Xml
|
||||||
XmlPatterns
|
#XmlPatterns
|
||||||
WebKit
|
WebKit
|
||||||
WebKitWidgets
|
WebKitWidgets
|
||||||
)
|
)
|
||||||
|
@ -443,7 +443,7 @@ else(${USE_QT_5})
|
||||||
${QT_QTNETWORK_LIBRARY}
|
${QT_QTNETWORK_LIBRARY}
|
||||||
${QT_QTSQL_LIBRARY}
|
${QT_QTSQL_LIBRARY}
|
||||||
${QT_QTXML_LIBRARY}
|
${QT_QTXML_LIBRARY}
|
||||||
${QT_QTXMLPATTERNS_LIBRARY}
|
#${QT_QTXMLPATTERNS_LIBRARY}
|
||||||
${QT_QTMAIN_LIBRARY}
|
${QT_QTMAIN_LIBRARY}
|
||||||
${QT_QTWEBKIT_LIBRARY}
|
${QT_QTWEBKIT_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,10 @@ class Message {
|
||||||
QString m_author;
|
QString m_author;
|
||||||
QString m_contents;
|
QString m_contents;
|
||||||
QDateTime m_created;
|
QDateTime m_created;
|
||||||
|
|
||||||
|
// Is true if "created" date was obtained directly
|
||||||
|
// from the feed, otherwise is false
|
||||||
|
bool m_createdFromFeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MessagesModel : public QSqlTableModel {
|
class MessagesModel : public QSqlTableModel {
|
||||||
|
|
|
@ -9,9 +9,15 @@
|
||||||
ParsingFactory::ParsingFactory() {
|
ParsingFactory::ParsingFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Message> ParsingFactory::parseAsATOM10(const QString &data) {
|
||||||
|
// TODO: Implement this.
|
||||||
|
return QList<Message>();
|
||||||
|
}
|
||||||
|
|
||||||
QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
|
QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
|
||||||
QList<Message> messages;
|
QList<Message> messages;
|
||||||
QDomDocument xml_file;
|
QDomDocument xml_file;
|
||||||
|
QDateTime current_time = QDateTime::currentDateTime();
|
||||||
xml_file.setContent(data, true);
|
xml_file.setContent(data, true);
|
||||||
QDomNodeList messages_in_xml = xml_file.elementsByTagName("item");
|
QDomNodeList messages_in_xml = xml_file.elementsByTagName("item");
|
||||||
|
|
||||||
|
@ -49,6 +55,13 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
new_message.m_created = TextFactory::parseDateTime(elem_updated.text());
|
new_message.m_created = TextFactory::parseDateTime(elem_updated.text());
|
||||||
|
new_message.m_createdFromFeed = !new_message.m_created.isNull();
|
||||||
|
|
||||||
|
if (!new_message.m_createdFromFeed) {
|
||||||
|
// Date was NOT obtained from the feed,
|
||||||
|
// set current date as creation date for the message.
|
||||||
|
new_message.m_created = current_time;
|
||||||
|
}
|
||||||
|
|
||||||
messages.append(new_message);
|
messages.append(new_message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
// parse input Unicode textual data into
|
// parse input Unicode textual data into
|
||||||
// another objects.
|
// another objects.
|
||||||
//
|
//
|
||||||
// NOTE: Each parsed message MUST CONTAINT THESE FIELDS.
|
// NOTE: Each parsed message MUST CONTAINT THESE FIELDS (fields
|
||||||
|
// of Message class:
|
||||||
|
// a) m_created,
|
||||||
|
// b) m_title.
|
||||||
class ParsingFactory {
|
class ParsingFactory {
|
||||||
private:
|
private:
|
||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
|
@ -20,6 +22,7 @@ class ParsingFactory {
|
||||||
public:
|
public:
|
||||||
// Parses input textual data into Message objects.
|
// Parses input textual data into Message objects.
|
||||||
// NOTE: Input is correctly encoded in Unicode.
|
// NOTE: Input is correctly encoded in Unicode.
|
||||||
|
static QList<Message> parseAsATOM10(const QString &data);
|
||||||
static QList<Message> parseAsRSS20(const QString &data);
|
static QList<Message> parseAsRSS20(const QString &data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QXmlQuery>
|
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QDomElement>
|
||||||
|
|
||||||
|
|
||||||
QPointer<SkinFactory> SkinFactory::s_instance;
|
QPointer<SkinFactory> SkinFactory::s_instance;
|
||||||
|
@ -105,11 +106,11 @@ QString SkinFactory::getCurrentMarkup() {
|
||||||
|
|
||||||
Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) {
|
Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) {
|
||||||
Skin skin;
|
Skin skin;
|
||||||
QXmlQuery query;
|
|
||||||
QString styles;
|
QString styles;
|
||||||
QFile skin_file(APP_SKIN_PATH + QDir::separator() + skin_name);
|
QFile skin_file(APP_SKIN_PATH + QDir::separator() + skin_name);
|
||||||
|
QDomDocument dokument;
|
||||||
|
|
||||||
if (!skin_file.open(QIODevice::Text | QIODevice::ReadOnly) || !query.setFocus(&skin_file)) {
|
if (!skin_file.open(QIODevice::Text | QIODevice::ReadOnly) || !dokument.setContent(&skin_file, true)) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
*ok = false;
|
*ok = false;
|
||||||
}
|
}
|
||||||
|
@ -117,39 +118,30 @@ Skin SkinFactory::getSkinInfo(const QString &skin_name, bool *ok) {
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDomNode skin_node = dokument.namedItem("skin");
|
||||||
|
|
||||||
// Obtain visible skin name.
|
// Obtain visible skin name.
|
||||||
query.setQuery("string(skin/name)");
|
skin.m_visibleName = skin_node.namedItem("name").toElement().text();
|
||||||
query.evaluateTo(&skin.m_visibleName);
|
|
||||||
skin.m_visibleName = skin.m_visibleName.remove('\n');
|
|
||||||
|
|
||||||
// Obtain skin raw data.
|
// Obtain skin raw data.
|
||||||
query.setQuery("string(skin/data)");
|
skin.m_rawData = skin_node.namedItem("data").toElement().text();
|
||||||
query.evaluateTo(&skin.m_rawData);
|
|
||||||
skin.m_rawData = QByteArray::fromBase64(skin.m_rawData.toLocal8Bit());
|
skin.m_rawData = QByteArray::fromBase64(skin.m_rawData.toLocal8Bit());
|
||||||
|
|
||||||
// Obtain style name.
|
// Obtain style name.
|
||||||
query.setQuery("string(/skin/style)");
|
styles = skin_node.namedItem("style").toElement().text();
|
||||||
query.evaluateTo(&styles);
|
skin.m_stylesNames = styles.split(',', QString::SkipEmptyParts);
|
||||||
skin.m_stylesNames = styles.remove('\n').split(',', QString::SkipEmptyParts);
|
|
||||||
|
|
||||||
// Obtain author.
|
// Obtain author.
|
||||||
query.setQuery("string(/skin/author/name)");
|
skin.m_author = skin_node.namedItem("author").namedItem("name").toElement().text();
|
||||||
query.evaluateTo(&skin.m_author);
|
|
||||||
skin.m_author = skin.m_author.remove('\n');
|
|
||||||
|
|
||||||
// Obtain email.
|
// Obtain email.
|
||||||
query.setQuery("string(/skin/author/email)");
|
skin.m_email = skin_node.namedItem("author").namedItem("email").toElement().text();
|
||||||
query.evaluateTo(&skin.m_email);
|
|
||||||
skin.m_email = skin.m_email.remove('\n');
|
|
||||||
|
|
||||||
// Obtain version.
|
// Obtain version.
|
||||||
query.setQuery("string(/skin/@version)");
|
skin.m_version = skin_node.attributes().namedItem("version").toAttr().value();
|
||||||
query.evaluateTo(&skin.m_version);
|
|
||||||
skin.m_version = skin.m_version.remove('\n');
|
|
||||||
|
|
||||||
// Obtain layout markup.
|
// Obtain layout markup.
|
||||||
query.setQuery("string(/skin/markup)");
|
skin.m_layoutMarkup = skin_node.namedItem("markup").toElement().text();
|
||||||
query.evaluateTo(&skin.m_layoutMarkup);
|
|
||||||
skin.m_layoutMarkup = QByteArray::fromBase64(skin.m_layoutMarkup.toLocal8Bit());
|
skin.m_layoutMarkup = QByteArray::fromBase64(skin.m_layoutMarkup.toLocal8Bit());
|
||||||
|
|
||||||
// Obtain other information.
|
// Obtain other information.
|
||||||
|
|
Loading…
Add table
Reference in a new issue