summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-04-06 17:42:47 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-04-06 17:42:47 +0200
commitb04a2a981a91ed58e55a275402cb2f9f73bd85a2 (patch)
tree1fc1690f78fb40de214bc95361dff5fcbe516d0c
parenta4626f5306ed3c5e52c28bb49d61ec50c7c2f329 (diff)
downloadtapasboard-b04a2a981a91ed58e55a275402cb2f9f73bd85a2.tar.gz
tapasboard-b04a2a981a91ed58e55a275402cb2f9f73bd85a2.zip
timezone issue was tapatalk plugin bug, so remove workaround
-rw-r--r--fetchforumsaction.cpp6
-rw-r--r--fetchforumsaction.h2
-rw-r--r--fetchpostsaction.cpp27
-rw-r--r--fetchpostsaction.h7
-rw-r--r--fetchtopicsaction.cpp15
-rw-r--r--fetchtopicsaction.h3
-rw-r--r--i18n/en.qmbin419 -> 612 bytes
-rw-r--r--i18n/en.ts21
-rw-r--r--i18n/es.qmbin423 -> 640 bytes
-rw-r--r--i18n/es.ts21
-rw-r--r--tapasboard.pro3
-rw-r--r--xmlrpcpendingcall.cpp42
-rw-r--r--xmlrpcpendingcall.h1
13 files changed, 90 insertions, 58 deletions
diff --git a/fetchforumsaction.cpp b/fetchforumsaction.cpp
index 8bbe23b..814ae02 100644
--- a/fetchforumsaction.cpp
+++ b/fetchforumsaction.cpp
@@ -58,8 +58,8 @@ void FetchForumsAction::handleFinishedCall()
query.bindValue(":forum_id", forum_id);
query.bindValue(":parent_id", parent_id);
- query.bindValue(":forum_name", unencodeForumText(map["forum_name"]));
- query.bindValue(":description", unencodeForumText(map["description"]));
+ query.bindValue(":forum_name", decodeForumText(map["forum_name"]));
+ query.bindValue(":description", decodeForumText(map["description"]));
query.bindValue(":logo_url", map["logo_url"].toString());
query.bindValue(":new_post", map["new_post"].toBool() ? 1 : 0);
query.bindValue(":is_protected", map["is_protected"].toBool() ? 1 : 0);
@@ -109,7 +109,7 @@ QList<QVariantMap> FetchForumsAction::flattenForumList(const QVariantList &list,
return flattened;
}
-QString FetchForumsAction::unencodeForumText(const QVariant &v)
+QString FetchForumsAction::decodeForumText(const QVariant &v)
{
QByteArray ba = v.toByteArray();
return QString::fromUtf8(ba.constData(), ba.length());
diff --git a/fetchforumsaction.h b/fetchforumsaction.h
index b047bcb..3652492 100644
--- a/fetchforumsaction.h
+++ b/fetchforumsaction.h
@@ -21,7 +21,7 @@ private slots:
private:
static QList<QVariantMap> flattenForumList(const QVariantList& list, int *order);
- static QString unencodeForumText(const QVariant& v);
+ static QString decodeForumText(const QVariant& v);
private:
diff --git a/fetchpostsaction.cpp b/fetchpostsaction.cpp
index dbfaf41..d293129 100644
--- a/fetchpostsaction.cpp
+++ b/fetchpostsaction.cpp
@@ -83,7 +83,7 @@ void FetchPostsAction::handleFinishedCall()
// Not fatal, just assume it's the one we requested
topic_id = _topicId;
}
- const QString topic_title = unencodePostText(map["topic_title"]);
+ const QString topic_title = decodePostText(map["topic_title"]);
const int unread_position = map["position"].toInt() - 1;
const int total_post_num = map["total_post_num"].toInt();
@@ -126,13 +126,13 @@ void FetchPostsAction::handleFinishedCall()
query.bindValue(":topic_id", topic_id);
query.bindValue(":post_id", post_id);
- query.bindValue(":post_title", unencodePostTitle(post["post_title"], topic_title));
- query.bindValue(":post_content", unencodePostContent(post["post_content"]));
+ query.bindValue(":post_title", decodePostTitle(post["post_title"], topic_title));
+ query.bindValue(":post_content", decodePostContent(post["post_content"]));
query.bindValue(":post_author_id", post["post_author_id"].toInt());
- query.bindValue(":post_author_name", unencodePostText(post["post_author_name"]));
+ query.bindValue(":post_author_name", decodePostText(post["post_author_name"]));
query.bindValue(":can_edit", post["can_edit"].toBool() ? 1 : 0);
query.bindValue(":icon_url", post["icon_url"].toString());
- query.bindValue(":post_time", unencodeDateTime(post["post_time"]));
+ query.bindValue(":post_time", post["post_time"].toDateTime().toUTC());
query.bindValue(":position", position);
query.bindValue(":last_update_time", QDateTime::currentDateTimeUtc());
@@ -176,15 +176,15 @@ void FetchPostsAction::handleFinishedCall()
_call->deleteLater();
}
-QString FetchPostsAction::unencodePostText(const QVariant &v)
+QString FetchPostsAction::decodePostText(const QVariant &v)
{
QByteArray ba = v.toByteArray();
return QString::fromUtf8(ba.constData(), ba.length());
}
-QString FetchPostsAction::unencodePostTitle(const QVariant &v, const QString &topicTitle)
+QString FetchPostsAction::decodePostTitle(const QVariant &v, const QString &topicTitle)
{
- QString title = unencodePostText(v);
+ QString title = decodePostText(v);
if (QString::compare(title, "Re: " + topicTitle, Qt::CaseInsensitive) == 0) {
// Hack to disable the useless "Re: $TOPIC_TITLE" post titles everywhere
return QString();
@@ -192,15 +192,8 @@ QString FetchPostsAction::unencodePostTitle(const QVariant &v, const QString &to
return title;
}
-QString FetchPostsAction::unencodePostContent(const QVariant &v)
+QString FetchPostsAction::decodePostContent(const QVariant &v)
{
- QString richText = _board->bbcodeToRichText(unencodePostText(v));
+ QString richText = _board->bbcodeToRichText(decodePostText(v));
return _board->parseSmilies(richText);
}
-
-QDateTime FetchPostsAction::unencodeDateTime(const QVariant &v)
-{
- QDateTime dt = v.toDateTime();
- dt.setTimeSpec(Qt::UTC);
- return dt;
-}
diff --git a/fetchpostsaction.h b/fetchpostsaction.h
index f8ad03e..6586ae6 100644
--- a/fetchpostsaction.h
+++ b/fetchpostsaction.h
@@ -28,10 +28,9 @@ private slots:
void handleFinishedCall();
private:
- static QString unencodePostText(const QVariant& v);
- static QString unencodePostTitle(const QVariant& v, const QString& topicTitle);
- QString unencodePostContent(const QVariant& v);
- static QDateTime unencodeDateTime(const QVariant& v);
+ static QString decodePostText(const QVariant& v);
+ static QString decodePostTitle(const QVariant& v, const QString& topicTitle);
+ QString decodePostContent(const QVariant& v);
private:
XmlRpcPendingCall *_call;
diff --git a/fetchtopicsaction.cpp b/fetchtopicsaction.cpp
index d71bdca..9e42723 100644
--- a/fetchtopicsaction.cpp
+++ b/fetchtopicsaction.cpp
@@ -85,13 +85,13 @@ void FetchTopicsAction::handleFinishedCall()
query.bindValue(":forum_id", forum_id);
query.bindValue(":topic_id", topic_id);
- query.bindValue(":topic_title", unencodeTopicText(topic["topic_title"]));
+ query.bindValue(":topic_title", decodeTopicText(topic["topic_title"]));
query.bindValue(":topic_author_id", topic["topic_author_id"].toInt());
- query.bindValue(":topic_author_name", unencodeTopicText(topic["topic_author_name"]));
+ query.bindValue(":topic_author_name", decodeTopicText(topic["topic_author_name"]));
query.bindValue(":is_subscribed", topic["is_subscribed"].toBool() ? 1 : 0);
query.bindValue(":is_closed", topic["is_closed"].toBool() ? 1 : 0);
query.bindValue(":icon_url", topic["icon_url"].toString());
- query.bindValue(":last_reply_time", unencodeDateTime(topic["last_reply_time"]));
+ query.bindValue(":last_reply_time", topic["last_reply_time"].toDateTime().toUTC());
query.bindValue(":reply_number", topic["reply_number"].toInt());
query.bindValue(":new_post", topic["new_post"].toBool() ? 1 : 0);
query.bindValue(":position", position);
@@ -130,15 +130,8 @@ void FetchTopicsAction::handleFinishedCall()
_call->deleteLater();
}
-QString FetchTopicsAction::unencodeTopicText(const QVariant &v)
+QString FetchTopicsAction::decodeTopicText(const QVariant &v)
{
QByteArray ba = v.toByteArray();
return QString::fromUtf8(ba.constData(), ba.length());
}
-
-QDateTime FetchTopicsAction::unencodeDateTime(const QVariant &v)
-{
- QDateTime dt = v.toDateTime();
- dt.setTimeSpec(Qt::UTC);
- return dt;
-}
diff --git a/fetchtopicsaction.h b/fetchtopicsaction.h
index 0519e0c..87b756f 100644
--- a/fetchtopicsaction.h
+++ b/fetchtopicsaction.h
@@ -25,8 +25,7 @@ private slots:
void handleFinishedCall();
private:
- static QString unencodeTopicText(const QVariant& v);
- static QDateTime unencodeDateTime(const QVariant& v);
+ static QString decodeTopicText(const QVariant& v);
private:
XmlRpcPendingCall *_call;
diff --git a/i18n/en.qm b/i18n/en.qm
index c8f4d42..1304d18 100644
--- a/i18n/en.qm
+++ b/i18n/en.qm
Binary files differ
diff --git a/i18n/en.ts b/i18n/en.ts
index 104f908..2704bf2 100644
--- a/i18n/en.ts
+++ b/i18n/en.ts
@@ -4,22 +4,22 @@
<context>
<name>Board</name>
<message>
- <location filename="../board.cpp" line="203"/>
+ <location filename="../board.cpp" line="204"/>
<source>Today</source>
<translation>Today</translation>
</message>
<message>
- <location filename="../board.cpp" line="205"/>
+ <location filename="../board.cpp" line="206"/>
<source>Yesterday</source>
<translation>Yesterday</translation>
</message>
<message>
- <location filename="../board.cpp" line="219"/>
+ <location filename="../board.cpp" line="220"/>
<source>Just now</source>
<translation>Just now</translation>
</message>
<message numerus="yes">
- <location filename="../board.cpp" line="221"/>
+ <location filename="../board.cpp" line="222"/>
<source>%n second(s) ago</source>
<translation>
<numerusform>%n seconds ago</numerusform>
@@ -35,4 +35,17 @@
</translation>
</message>
</context>
+<context>
+ <name>BoardPage</name>
+ <message>
+ <location filename="../qml/BoardPage.qml" line="40"/>
+ <source>Mark all forums read</source>
+ <translation>Mark all forums read</translation>
+ </message>
+ <message>
+ <location filename="../qml/BoardPage.qml" line="40"/>
+ <source>Mark subforums read</source>
+ <translation>Mark subforums read</translation>
+ </message>
+</context>
</TS>
diff --git a/i18n/es.qm b/i18n/es.qm
index a41c85c..238d330 100644
--- a/i18n/es.qm
+++ b/i18n/es.qm
Binary files differ
diff --git a/i18n/es.ts b/i18n/es.ts
index 47c3b9d..acb10ce 100644
--- a/i18n/es.ts
+++ b/i18n/es.ts
@@ -4,22 +4,22 @@
<context>
<name>Board</name>
<message>
- <location filename="../board.cpp" line="203"/>
+ <location filename="../board.cpp" line="204"/>
<source>Today</source>
<translation>Hoy</translation>
</message>
<message>
- <location filename="../board.cpp" line="205"/>
+ <location filename="../board.cpp" line="206"/>
<source>Yesterday</source>
<translation>Ayer</translation>
</message>
<message>
- <location filename="../board.cpp" line="219"/>
+ <location filename="../board.cpp" line="220"/>
<source>Just now</source>
<translation>Ahora mismo</translation>
</message>
<message numerus="yes">
- <location filename="../board.cpp" line="221"/>
+ <location filename="../board.cpp" line="222"/>
<source>%n second(s) ago</source>
<translation>
<numerusform>hace %n segundo</numerusform>
@@ -35,4 +35,17 @@
</translation>
</message>
</context>
+<context>
+ <name>BoardPage</name>
+ <message>
+ <location filename="../qml/BoardPage.qml" line="40"/>
+ <source>Mark all forums read</source>
+ <translation>Marcar foros como leídos</translation>
+ </message>
+ <message>
+ <location filename="../qml/BoardPage.qml" line="40"/>
+ <source>Mark subforums read</source>
+ <translation>Marcar subforos como leídos</translation>
+ </message>
+</context>
</TS>
diff --git a/tapasboard.pro b/tapasboard.pro
index 33c2306..5d9bd08 100644
--- a/tapasboard.pro
+++ b/tapasboard.pro
@@ -76,6 +76,9 @@ HEADERS += \
TRANSLATIONS += i18n/en.ts i18n/es.ts
+# Uncomment this while working on the translations
+# lupdate_hack { SOURCES += qml/*.qml }
+
OTHER_FILES += \
qtc_packaging/debian_harmattan/rules \
qtc_packaging/debian_harmattan/README \
diff --git a/xmlrpcpendingcall.cpp b/xmlrpcpendingcall.cpp
index 8f318bd..f6e4e60 100644
--- a/xmlrpcpendingcall.cpp
+++ b/xmlrpcpendingcall.cpp
@@ -73,18 +73,7 @@ QVariant XmlRpcPendingCall::decodeValue(QXmlStreamReader *r)
if (!ok) value.clear();
} else if (r->name() == "dateTime.iso8601") {
QString text = r->readElementText();
- QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
- if (!dateTime.isValid()) {
- // Qt seems not be happy without dashes
- text.insert(4, '-');
- text.insert(7, '-');
- dateTime = QDateTime::fromString(text, Qt::ISODate);
- if (!dateTime.isValid()) {
- qWarning() << "Invalid dateTime format" << text;
- return QVariant();
- }
- }
- value = QVariant::fromValue(dateTime);
+ value = QVariant::fromValue(decodeISODate(text));
} else if (r->name() == "base64") {
QByteArray data = r->readElementText().toAscii();
value = QVariant::fromValue(QByteArray::fromBase64(data));
@@ -150,6 +139,35 @@ QVariant XmlRpcPendingCall::decodeValue(QXmlStreamReader *r)
}
}
+QDateTime XmlRpcPendingCall::decodeISODate(QString text)
+{
+ if (text.length() < 8) {
+ // Too short!
+ return QDateTime();
+ }
+ if (text[4].isNumber() && text[7].isNumber()) {
+ // Qt seems not be happy without dashes (YYYYMMDD vs YYYY-MM-DD)
+ text.insert(4, '-');
+ text.insert(7, '-');
+ }
+ // Qt will consider UTC offset "+00:00" invalid, so we replace it by "Z".
+ if (text.endsWith("+00:00") || text.endsWith("-00:00")) {
+ const int len = 6; // "+00:00"
+ const int pos = text.length() - len;
+ text.replace(pos, len, "Z");
+ } else if (text.endsWith("+0000") || text.endsWith("-0000")) {
+ const int len = 5; // "+0000"
+ const int pos = text.length() - len;
+ text.replace(pos, len, "Z");
+ } else if (text.endsWith("+00") || text.endsWith("-00")) {
+ const int len = 3; // "+00"
+ const int pos = text.length() - len;
+ text.replace(pos, len, "Z");
+ }
+ QDateTime dt = QDateTime::fromString(text, Qt::ISODate);
+ return dt;
+}
+
void XmlRpcPendingCall::handleRequestFinished()
{
Q_ASSERT(_state == StateWaitingReply);
diff --git a/xmlrpcpendingcall.h b/xmlrpcpendingcall.h
index 620ddc4..8c72bc6 100644
--- a/xmlrpcpendingcall.h
+++ b/xmlrpcpendingcall.h
@@ -30,6 +30,7 @@ signals:
private:
bool decodeMethodResponse(QXmlStreamReader* r);
static QVariant decodeValue(QXmlStreamReader* r);
+ static QDateTime decodeISODate(QString text);
private slots:
void handleRequestFinished();