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