From 7e077072961e6b36b32c2ee0b6ccc774736a0036 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 17 Dec 2013 16:50:05 +0100 Subject: [PATCH] Reloaded languages, some work on database consistency. --- localization/rssguard_cs.ts | 41 +++++++++++++++++-------- localization/rssguard_en.ts | 40 ++++++++++++++++-------- localization/rssguard_nl.ts | 40 ++++++++++++++++-------- src/core/databasefactory.cpp | 30 +++++++++++------- src/core/databasefactory.h | 3 +- src/core/feedsmodel.h | 2 +- src/core/feedsmodelfeed.cpp | 12 ++++++++ src/core/feedsmodelfeed.h | 7 +++++ src/core/feedsmodelstandardcategory.cpp | 2 +- src/gui/feedsview.cpp | 3 ++ 10 files changed, 127 insertions(+), 53 deletions(-) diff --git a/localization/rssguard_cs.ts b/localization/rssguard_cs.ts index b6511cdf1..5f18bfde3 100644 --- a/localization/rssguard_cs.ts +++ b/localization/rssguard_cs.ts @@ -374,22 +374,10 @@ Mark selected feed(s)/category(ies) as read. - - Mark all messages read. - - - - Mark all messages unread. - - Delete selected messages. - - Delete all messages. - - Add new &feed @@ -426,6 +414,18 @@ Add new &category + + Mark all messages from selected feeds read. This does NOT take message filters into account. + + + + Mark all messages from selected feeds unread. This does NOT take message filters into account. + + + + Delete all messages from selected feeds. This does NOT take message filters into account. + + FormSettings @@ -935,7 +935,7 @@ LANG_ABBREV - Abbreviation of language, e.g. en. Use ISO 639-1 code here! + Abbreviation of language, e.g. en. Use ISO 639-1 code here. They may be combined with ISO 3166-1 (alpha-2) codes. Examples: "cs", "nl", "en", "cs_CZ", "en_GB", "en_US". cs @@ -953,6 +953,21 @@ Email of translator - optional. rotter.martinos@gmail.com + + %1 + +Category type: standard +Creation date: %2 + + + + %n unread message(s). + + %n nepřečtená zpráva. + %n nepřečtené zprávy. + %n nepřečtených zpráv. + + ShortcutCatcher diff --git a/localization/rssguard_en.ts b/localization/rssguard_en.ts index 08790543b..dd07b4c59 100644 --- a/localization/rssguard_en.ts +++ b/localization/rssguard_en.ts @@ -374,22 +374,10 @@ Mark selected feed(s)/category(ies) as read. - - Mark all messages read. - - - - Mark all messages unread. - - Delete selected messages. - - Delete all messages. - - Add new &feed @@ -426,6 +414,18 @@ Add new &category + + Mark all messages from selected feeds read. This does NOT take message filters into account. + + + + Mark all messages from selected feeds unread. This does NOT take message filters into account. + + + + Delete all messages from selected feeds. This does NOT take message filters into account. + + FormSettings @@ -927,7 +927,7 @@ LANG_ABBREV - Abbreviation of language, e.g. en. Use ISO 639-1 code here! + Abbreviation of language, e.g. en. Use ISO 639-1 code here. They may be combined with ISO 3166-1 (alpha-2) codes. Examples: "cs", "nl", "en", "cs_CZ", "en_GB", "en_US". en @@ -945,6 +945,20 @@ Email of translator - optional. rotter.martinos@gmail.com + + %1 + +Category type: standard +Creation date: %2 + + + + %n unread message(s). + + + + + ShortcutCatcher diff --git a/localization/rssguard_nl.ts b/localization/rssguard_nl.ts index 91e9a43a7..2fc4bfd6d 100644 --- a/localization/rssguard_nl.ts +++ b/localization/rssguard_nl.ts @@ -374,22 +374,10 @@ Mark selected feed(s)/category(ies) as read. Markeer geselecteerde feed(s)/categorie(ën) als gelezen. - - Mark all messages read. - Markeer alle berichten als gelezen. - - - Mark all messages unread. - Markeer alle berichten als ongelezen. - Delete selected messages. Verwijder geselecteerde berichten. - - Delete all messages. - Verwijder alle berichten. - Add new &feed Voeg nieuwe &feed toe @@ -426,6 +414,18 @@ Add new &category Voeg nieuwe &categorie toe + + Mark all messages from selected feeds read. This does NOT take message filters into account. + + + + Mark all messages from selected feeds unread. This does NOT take message filters into account. + + + + Delete all messages from selected feeds. This does NOT take message filters into account. + + FormSettings @@ -935,7 +935,7 @@ LANG_ABBREV - Abbreviation of language, e.g. en. Use ISO 639-1 code here! + Abbreviation of language, e.g. en. Use ISO 639-1 code here. They may be combined with ISO 3166-1 (alpha-2) codes. Examples: "cs", "nl", "en", "cs_CZ", "en_GB", "en_US". nl @@ -953,6 +953,20 @@ Email of translator - optional. elbert.pol@gmail.com + + %1 + +Category type: standard +Creation date: %2 + + + + %n unread message(s). + + + + + ShortcutCatcher diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp index aa87c5d85..e7289fdb3 100644 --- a/src/core/databasefactory.cpp +++ b/src/core/databasefactory.cpp @@ -130,15 +130,27 @@ QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) { return initialize(connection_name); } else { - QSqlDatabase database = QSqlDatabase::addDatabase(DATABASE_DRIVER, - connection_name); - QDir db_path(getDatabasePath()); - QFile db_file(db_path.absoluteFilePath(APP_DB_FILE)); + QSqlDatabase database; - // Setup database file path. - database.setDatabaseName(db_file.fileName()); + if (QSqlDatabase::contains(connection_name)) { + qDebug("Connection '%s' is already active.", + qPrintable(connection_name)); - if (!database.open()) { + // This database connection was added previously, no need to + // setup its properties. + database = QSqlDatabase::database(connection_name); + } + else { + database = QSqlDatabase::addDatabase(DATABASE_DRIVER, connection_name); + + QDir db_path(getDatabasePath()); + QFile db_file(db_path.absoluteFilePath(APP_DB_FILE)); + + // Setup database file path. + database.setDatabaseName(db_file.fileName()); + } + + if (!database.isOpen() && !database.open()) { qFatal("Database was NOT opened. Delivered error message: '%s'", qPrintable(database.lastError().text())); } @@ -147,10 +159,6 @@ QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) { } } -QSqlDatabase DatabaseFactory::getConnection(const QString &connection_name) { - return QSqlDatabase::database(connection_name); -} - void DatabaseFactory::removeConnection(const QString &connection_name) { qDebug("Removing database connection '%s'.", qPrintable(connection_name)); QSqlDatabase::removeDatabase(connection_name); diff --git a/src/core/databasefactory.h b/src/core/databasefactory.h index 3e8dfb33d..aef9a6333 100644 --- a/src/core/databasefactory.h +++ b/src/core/databasefactory.h @@ -40,7 +40,8 @@ class DatabaseFactory : public QObject { // NOTE: This returns OPENED database. QSqlDatabase addConnection(const QString &connection_name); - QSqlDatabase getConnection(const QString &connection_name); + + // Removes connection. void removeConnection(const QString &connection_name); // Singleton getter. diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 8620ad379..6a303f198 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -49,7 +49,7 @@ class FeedsModel : public QAbstractItemModel { // null if index is invalid. FeedsModelRootItem *itemForIndex(const QModelIndex &index); - protected: + protected: // Loads feed/categories from the database. void loadFromDatabase(); diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp index 6c7e3dfcf..87246d04f 100755 --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feedsmodelfeed.cpp @@ -23,10 +23,18 @@ int FeedsModelFeed::countOfAllMessages() const { return m_totalCount; } +void FeedsModelFeed::setCountOfAllMessages(int count) { + m_totalCount = count; +} + int FeedsModelFeed::countOfUnreadMessages() const { return m_unreadCount; } +void FeedsModelFeed::setCountOfUnreadMessages(int count) { + m_unreadCount = count; +} + FeedsModelFeed::Type FeedsModelFeed::type() const { return m_type; } @@ -34,3 +42,7 @@ FeedsModelFeed::Type FeedsModelFeed::type() const { void FeedsModelFeed::setType(const Type &type) { m_type = type; } + +void FeedsModelFeed::updateCounts() { + //QSqlDatabase database = DatabaseFactory::getInstance()-> +} diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h index 1eabaa5ec..465510783 100755 --- a/src/core/feedsmodelfeed.h +++ b/src/core/feedsmodelfeed.h @@ -27,12 +27,19 @@ class FeedsModelFeed : public FeedsModelRootItem { // NOTE: For feeds, counts are stored internally // and can be updated from the database. int countOfAllMessages() const; + void setCountOfAllMessages(int count); + int countOfUnreadMessages() const; + void setCountOfUnreadMessages(int count); // Other getters/setters. Type type() const; void setType(const Type &type); + public slots: + // Updates counts of all/unread messages for this feed. + void updateCounts(); + protected: Type m_type; int m_totalCount; diff --git a/src/core/feedsmodelstandardcategory.cpp b/src/core/feedsmodelstandardcategory.cpp index 4ef2d50ba..b30382874 100755 --- a/src/core/feedsmodelstandardcategory.cpp +++ b/src/core/feedsmodelstandardcategory.cpp @@ -26,7 +26,7 @@ QVariant FeedsModelStandardCategory::data(int column, int role) const { } else if (column == FDS_MODEL_COUNTS_INDEX) { // TODO: tady dat plural a singular - return QObject::tr("%1 unread messages.").arg(countOfUnreadMessages()); + return QObject::tr("%n unread message(s).", "", countOfUnreadMessages()); } else { return QVariant(); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index b4da86a5e..92a3dccc9 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -49,6 +49,9 @@ void FeedsView::setupAppearance() { void FeedsView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { + Q_UNUSED(selected) + Q_UNUSED(deselected) + QModelIndexList selection = selectionModel()->selectedRows(); QModelIndexList mapped_selection = m_proxyModel->mapListToSource(selection); QList selected_feeds = m_sourceModel->feedsForIndexes(mapped_selection);