|
|
@ -43,13 +43,17 @@ |
|
|
|
#include "../rss_article.h" |
|
|
|
#include "../rss_article.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
namespace |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
class XmlStreamEntityResolver : public QXmlStreamEntityResolver |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
QString resolveUndeclaredEntity(const QString &name) override |
|
|
|
{ |
|
|
|
{ |
|
|
|
// (X)HTML entities declared in:
|
|
|
|
// (X)HTML entities declared in:
|
|
|
|
// http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
|
|
|
|
// http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent
|
|
|
|
// http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent
|
|
|
|
// http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent
|
|
|
|
// http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
|
|
|
|
// http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent
|
|
|
|
using StringHash = QHash<QString, QString>; |
|
|
|
static const QHash<QString, QString> HTMLEntities { |
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(StringHash, HTML_ENTITIES, ({ |
|
|
|
|
|
|
|
{"nbsp", " "}, // no-break space = non-breaking space, U+00A0 ISOnum
|
|
|
|
{"nbsp", " "}, // no-break space = non-breaking space, U+00A0 ISOnum
|
|
|
|
{"iexcl", "¡"}, // inverted exclamation mark, U+00A1 ISOnum
|
|
|
|
{"iexcl", "¡"}, // inverted exclamation mark, U+00A1 ISOnum
|
|
|
|
{"cent", "¢"}, // cent sign, U+00A2 ISOnum
|
|
|
|
{"cent", "¢"}, // cent sign, U+00A2 ISOnum
|
|
|
@ -347,38 +351,30 @@ namespace |
|
|
|
{"clubs", "♣"}, // black club suit = shamrock, U+2663 ISOpub
|
|
|
|
{"clubs", "♣"}, // black club suit = shamrock, U+2663 ISOpub
|
|
|
|
{"hearts", "♥"}, // black heart suit = valentine, U+2665 ISOpub
|
|
|
|
{"hearts", "♥"}, // black heart suit = valentine, U+2665 ISOpub
|
|
|
|
{"diams", "♦"} // black diamond suit, U+2666 ISOpub
|
|
|
|
{"diams", "♦"} // black diamond suit, U+2666 ISOpub
|
|
|
|
})) |
|
|
|
}; |
|
|
|
|
|
|
|
return HTMLEntities.value(name); |
|
|
|
class XmlStreamEntityResolver : public QXmlStreamEntityResolver |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
QString resolveUndeclaredEntity(const QString &name) override |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return HTML_ENTITIES->value(name); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ported to Qt from KDElibs4
|
|
|
|
|
|
|
|
QDateTime parseDate(const QString &string) |
|
|
|
|
|
|
|
{ |
|
|
|
const char shortDay[][4] = { |
|
|
|
const char shortDay[][4] = { |
|
|
|
"Mon", "Tue", "Wed", |
|
|
|
"Mon", "Tue", "Wed", |
|
|
|
"Thu", "Fri", "Sat", |
|
|
|
"Thu", "Fri", "Sat", |
|
|
|
"Sun" |
|
|
|
"Sun" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const char longDay[][10] = { |
|
|
|
const char longDay[][10] = { |
|
|
|
"Monday", "Tuesday", "Wednesday", |
|
|
|
"Monday", "Tuesday", "Wednesday", |
|
|
|
"Thursday", "Friday", "Saturday", |
|
|
|
"Thursday", "Friday", "Saturday", |
|
|
|
"Sunday" |
|
|
|
"Sunday" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const char shortMonth[][4] = { |
|
|
|
const char shortMonth[][4] = { |
|
|
|
"Jan", "Feb", "Mar", "Apr", |
|
|
|
"Jan", "Feb", "Mar", "Apr", |
|
|
|
"May", "Jun", "Jul", "Aug", |
|
|
|
"May", "Jun", "Jul", "Aug", |
|
|
|
"Sep", "Oct", "Nov", "Dec" |
|
|
|
"Sep", "Oct", "Nov", "Dec" |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Ported to Qt from KDElibs4
|
|
|
|
|
|
|
|
QDateTime parseDate(const QString &string) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const QString str = string.trimmed(); |
|
|
|
const QString str = string.trimmed(); |
|
|
|
if (str.isEmpty()) |
|
|
|
if (str.isEmpty()) |
|
|
|
return QDateTime::currentDateTime(); |
|
|
|
return QDateTime::currentDateTime(); |
|
|
|