From 256e7837ce8cb30b0c0a8c73306abdffa80365a6 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Thu, 4 Apr 2013 16:46:18 +0200 Subject: fix a few issues --- board.cpp | 9 ++++++--- fetchpostsaction.cpp | 11 +++-------- i18n/en.ts | 6 +++--- i18n/es.qm | Bin 423 -> 423 bytes i18n/es.ts | 14 +++++++------- main.cpp | 6 ++++-- tapasboard.pro | 10 +++------- 7 files changed, 26 insertions(+), 30 deletions(-) diff --git a/board.cpp b/board.cpp index 7766088..b3c5bcb 100644 --- a/board.cpp +++ b/board.cpp @@ -212,17 +212,20 @@ QString Board::renderHumanDate(const QDateTime &dateTime) QString Board::renderHumanTime(const QDateTime &dateTime) { + const QDateTime now = QDateTime::currentDateTime(); QDateTime localDateTime = dateTime.toLocalTime(); - const int secs = localDateTime.secsTo(QDateTime::currentDateTime()); + const int secs = localDateTime.secsTo(now); if (secs < 1) { return tr("Just now"); } else if (secs < 60) { return tr("%n second(s) ago", 0, secs); } else if (secs < 3600) { - int mins = (secs + 10) / 3600; // + 10 to round a bit + int mins = (secs + 10) / 60; // + 10 to round a bit return tr("%n minute(s) ago", 0, mins); - } else { + } else if (localDateTime.daysTo(now) < 1) { return localDateTime.time().toString(Qt::DefaultLocaleShortDate); + } else { + return localDateTime.toString(Qt::DefaultLocaleShortDate); } } diff --git a/fetchpostsaction.cpp b/fetchpostsaction.cpp index 714718c..e38e423 100644 --- a/fetchpostsaction.cpp +++ b/fetchpostsaction.cpp @@ -65,9 +65,7 @@ void FetchPostsAction::handleFinishedCall() // Not fatal, just assume it's the one we requested topic_id = _topicId; } - QString topic_title = map["topic_title"].toString(); - int unread_position = map["position"].toInt(); - qDebug() << "unread_position" << unread_position; + QString topic_title = unencodePostContent(map["topic_title"]); QSqlQuery query(db); query.prepare("INSERT OR REPLACE INTO posts (topic_id, post_id, post_title, post_content, post_author_id, post_author_name, can_edit, icon_url, post_time, last_update_time) " @@ -105,10 +103,6 @@ void FetchPostsAction::handleFinishedCall() _board->notifyTopicPostsChanged(_topicId, _start, _start + posts.size() - 1); } - if (unread_position > 0) { - // API says this is 1-indexed instead of 0-indexed. - _board->notifyTopicPostsUnread(_topicId, unread_position - 1); - } if (_end == FetchAllPosts && posts.size() == MAX_TOPIC_PAGE_SIZE) { // Ok, let's prepare to fetch the next block of posts because // there are probably more of them @@ -132,7 +126,8 @@ QString FetchPostsAction::unencodePostText(const QVariant &v) QString FetchPostsAction::unencodePostTitle(const QVariant &v, const QString &topicTitle) { QString title = unencodePostText(v); - if (QString::compare(title, "Re: " + topicTitle, Qt::CaseInsensitive)) { + if (QString::compare(title, "Re: " + topicTitle, Qt::CaseInsensitive) == 0) { + // Hack to disable the useless "Re: $TOPIC_TITLE" post titles everywhere return QString(); } return title; diff --git a/i18n/en.ts b/i18n/en.ts index b074b2f..104f908 100644 --- a/i18n/en.ts +++ b/i18n/en.ts @@ -14,12 +14,12 @@ Yesterday - + Just now Just now - + %n second(s) ago %n seconds ago @@ -27,7 +27,7 @@ - + %n minute(s) ago %n minute ago diff --git a/i18n/es.qm b/i18n/es.qm index 8a2f61f..a41c85c 100644 Binary files a/i18n/es.qm and b/i18n/es.qm differ diff --git a/i18n/es.ts b/i18n/es.ts index b408e68..47c3b9d 100644 --- a/i18n/es.ts +++ b/i18n/es.ts @@ -14,24 +14,24 @@ Ayer - + Just now Ahora mismo - + %n second(s) ago - Hace %n segundo - Hace %n segundos + hace %n segundo + hace %n segundos - + %n minute(s) ago - Hace %n minuto - Hace %n minutos + hace %n minuto + hace %n minutos diff --git a/main.cpp b/main.cpp index 2d23694..5d7a619 100644 --- a/main.cpp +++ b/main.cpp @@ -45,7 +45,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) if (!(translator.load(locale, locale_path))) { // Fallback to English qDebug() << "Translation not available for" << locale; - translator.load("en", locale_path); + if (!translator.load("en", locale_path)) { + qDebug() << "Translations not available in" << locale_path; + } } app->installTranslator(&translator); @@ -67,7 +69,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) viewer.engine()->setNetworkAccessManagerFactory(image_nam_factory.data()); viewer.rootContext()->setContextProperty("boardManager", board_manager); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - viewer.setMainQmlFile(QLatin1String("qml/tapasboard/main.qml")); + viewer.setMainQmlFile(QLatin1String("qml/main.qml")); viewer.showExpanded(); return app->exec(); diff --git a/tapasboard.pro b/tapasboard.pro index 4c16089..4189ff8 100644 --- a/tapasboard.pro +++ b/tapasboard.pro @@ -1,8 +1,8 @@ # Add more folders to ship with the application, here qml_folder.source = qml -qml_folder.target = qml -i18n_folder.source = i18n/*.qm -i18n_folder.target = i18n +qml_folder.target = . +i18n_folder.source = i18n +i18n_folder.target = . DEPLOYMENTFOLDERS = qml_folder i18n_folder # Additional import path used to resolve QML modules in Creator's code model @@ -74,10 +74,6 @@ HEADERS += \ TRANSLATIONS += i18n/en.ts i18n/es.ts -evil_hack_to_fool_lupdate { - SOURCES += qml/*.qml -} - OTHER_FILES += \ qtc_packaging/debian_harmattan/rules \ qtc_packaging/debian_harmattan/README \ -- cgit v1.2.3