Commit 9001e42e authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Codepaster: Fix listing of pastebin.com

Once again.

Task-number: QTCREATORBUG-5356
Change-Id: I1278afee9f32955ba27f7b92300c3936426bdd6a
Reviewed-on: http://codereview.qt.nokia.com/1353

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarJarek Kobus <jaroslaw.kobus@nokia.com>
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@nokia.com>
parent 9499c18a
...@@ -271,11 +271,22 @@ enum ParseState ...@@ -271,11 +271,22 @@ enum ParseState
WithinTableElement, WithinTableElementAnchor, ParseError WithinTableElement, WithinTableElementAnchor, ParseError
}; };
static inline ParseState nextOpeningState(ParseState current, const QStringRef &element) QDebug operator<<(QDebug d, const QXmlStreamAttributes &al)
{ {
QDebug nospace = d.nospace();
foreach (const QXmlStreamAttribute &a, al)
nospace << a.name().toString() << '=' << a.value().toString() << ' ';
return d;
}
static inline ParseState nextOpeningState(ParseState current, const QXmlStreamReader &reader)
{
const QStringRef element = reader.name();
switch (current) { switch (current) {
case OutSideTable: case OutSideTable:
if (element == QLatin1String("table")) // Trigger on main table only.
if (element == QLatin1String("table")
&& reader.attributes().value(QLatin1String("class")) == QLatin1String("maintable"))
return WithinTable; return WithinTable;
return OutSideTable; return OutSideTable;
case WithinTable: case WithinTable:
...@@ -342,7 +353,8 @@ static inline QStringList parseLists(QIODevice *io) ...@@ -342,7 +353,8 @@ static inline QStringList parseLists(QIODevice *io)
int tableColumn = 0; int tableColumn = 0;
const QString hrefAttribute = QLatin1String("href"); const QString hrefAttribute = QLatin1String("href");
//: Unknown user of paste.
const QString unknownUser = PasteBinDotComProtocol::tr("<Unknown>");
QString link; QString link;
QString user; QString user;
QString description; QString description;
...@@ -350,7 +362,7 @@ static inline QStringList parseLists(QIODevice *io) ...@@ -350,7 +362,7 @@ static inline QStringList parseLists(QIODevice *io)
while (!reader.atEnd()) { while (!reader.atEnd()) {
switch(reader.readNext()) { switch(reader.readNext()) {
case QXmlStreamReader::StartElement: case QXmlStreamReader::StartElement:
state = nextOpeningState(state, reader.name()); state = nextOpeningState(state, reader);
switch (state) { switch (state) {
case WithinTableRow: case WithinTableRow:
tableColumn = 0; tableColumn = 0;
...@@ -379,10 +391,11 @@ static inline QStringList parseLists(QIODevice *io) ...@@ -379,10 +391,11 @@ static inline QStringList parseLists(QIODevice *io)
return rc; return rc;
break; break;
case WithinTable: case WithinTable:
if (tableRow && !user.isEmpty() && !link.isEmpty() && !description.isEmpty()) { // User can occasionally be empty.
if (tableRow && !link.isEmpty() && !description.isEmpty()) {
QString entry = link; QString entry = link;
entry += QLatin1Char(' '); entry += QLatin1Char(' ');
entry += user; entry += user.isEmpty() ? unknownUser : user;
entry += QLatin1Char(' '); entry += QLatin1Char(' ');
entry += description; entry += description;
rc.push_back(entry); rc.push_back(entry);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment