From 04028ef6bb8bc41fb7796dc938f3ccceea6326fa Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 8 Dec 2015 09:58:05 +0100 Subject: [PATCH] Fixed expanding when importing, newer readme. --- README.md | 2 + src/gui/dialogs/formmain.cpp | 2 + .../standard/gui/formstandardimportexport.cpp | 1 + src/services/standard/standardserviceroot.cpp | 5 +- src/services/tt-rss/ttrssfeed.cpp | 46 ++++++++++++++++++- src/services/tt-rss/ttrssfeed.h | 11 +++++ src/services/tt-rss/ttrssserviceroot.cpp | 5 +- 7 files changed, 68 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/services/tt-rss/ttrssfeed.cpp mode change 100644 => 100755 src/services/tt-rss/ttrssfeed.h diff --git a/README.md b/README.md index 716888781..b3cfb76d5 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ RSS Guard is simple (yet powerful) feed reader. It is able to fetch the most kno RSS Guard is written in C++. It is pretty fast even with tons of messages loaded. The core features are: +* support for online feed synchronization via plugins, + * Tiny Tiny RSS (from RSS Guard 3.0.0). * multiplatformity, * support for all feed formats, * simplicity, diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 278a791c8..ce207f599 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -80,6 +80,8 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f) setupIcons(); loadSize(); + statusBar()->setVisible(false); + // Initialize the web factory. WebFactory::instance()->loadState(); } diff --git a/src/services/standard/gui/formstandardimportexport.cpp b/src/services/standard/gui/formstandardimportexport.cpp index 9c10ac444..6e7f869cd 100755 --- a/src/services/standard/gui/formstandardimportexport.cpp +++ b/src/services/standard/gui/formstandardimportexport.cpp @@ -233,6 +233,7 @@ void FormStandardImportExport::importFeeds() { QString output_message; if (m_serviceRoot->mergeImportExportModel(m_model, output_message)) { + m_serviceRoot->requestItemExpand(m_serviceRoot->getSubTree(), true); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, output_message, output_message); } else { diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index c261155f0..e86be599b 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -85,7 +85,10 @@ void StandardServiceRoot::start() { try { model.importAsOPML20(IOFactory::readTextFile(file_to_load)); model.checkAllItems(); - mergeImportExportModel(&model, output_msg); + + if (mergeImportExportModel(&model, output_msg)) { + requestItemExpand(getSubTree(), true); + } } catch (ApplicationException &ex) { MessageBox::show(qApp->mainForm(), QMessageBox::Critical, tr("Error when loading initial feeds"), ex.message()); diff --git a/src/services/tt-rss/ttrssfeed.cpp b/src/services/tt-rss/ttrssfeed.cpp old mode 100644 new mode 100755 index 45d90dc31..5c8dc0810 --- a/src/services/tt-rss/ttrssfeed.cpp +++ b/src/services/tt-rss/ttrssfeed.cpp @@ -18,14 +18,58 @@ #include "services/tt-rss/ttrssfeed.h" #include "definitions/definitions.h" +#include "miscellaneous/application.h" +#include "miscellaneous/databasefactory.h" +#include "services/tt-rss/ttrssserviceroot.h" + +#include -TtRssFeed::TtRssFeed(RootItem *parent) : Feed(parent), m_customId(NO_PARENT_CATEGORY) { +TtRssFeed::TtRssFeed(RootItem *parent) + : Feed(parent), m_customId(NO_PARENT_CATEGORY), m_totalCount(0), m_unreadCount(0) { } TtRssFeed::~TtRssFeed() { } +TtRssServiceRoot *TtRssFeed::serviceRoot() { + return qobject_cast(getParentServiceRoot()); +} + +void TtRssFeed::updateCounts(bool including_total_count) { + QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); + QSqlQuery query_all(database); + + query_all.setForwardOnly(true); + + if (including_total_count) { + if (query_all.exec(QString("SELECT count(*) FROM Messages WHERE feed = '%1' AND is_deleted = 0 AND account_id = %2;").arg(QString::number(customId()), + QString::number(serviceRoot()->accountId()))) && query_all.next()) { + m_totalCount = query_all.value(0).toInt(); + } + } + + // Obtain count of unread messages. + if (query_all.exec(QString("SELECT count(*) FROM Messages WHERE feed = '%1' AND is_deleted = 0 AND is_read = 0 AND account_id = %2;").arg(QString::number(customId()), + QString::number(serviceRoot()->accountId()))) && query_all.next()) { + int new_unread_count = query_all.value(0).toInt(); + + if (status() == NewMessages && new_unread_count < m_unreadCount) { + setStatus(Normal); + } + + m_unreadCount = new_unread_count; + } +} + +int TtRssFeed::countOfAllMessages() { + return m_totalCount; +} + +int TtRssFeed::countOfUnreadMessages() { + return m_unreadCount; +} + int TtRssFeed::update() { return 0; } diff --git a/src/services/tt-rss/ttrssfeed.h b/src/services/tt-rss/ttrssfeed.h old mode 100644 new mode 100755 index 314ad880d..a66335781 --- a/src/services/tt-rss/ttrssfeed.h +++ b/src/services/tt-rss/ttrssfeed.h @@ -21,11 +21,20 @@ #include "services/abstract/feed.h" +class TtRssServiceRoot; + class TtRssFeed : public Feed { public: explicit TtRssFeed(RootItem *parent = NULL); virtual ~TtRssFeed(); + TtRssServiceRoot *serviceRoot(); + + void updateCounts(bool including_total_count); + + int countOfAllMessages(); + int countOfUnreadMessages(); + int update(); QList undeletedMessages() const; @@ -34,6 +43,8 @@ class TtRssFeed : public Feed { private: int m_customId; + int m_totalCount; + int m_unreadCount; }; #endif // TTRSSFEED_H diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index 0f6680779..50eeb2bd3 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -254,8 +254,11 @@ void TtRssServiceRoot::syncIn() { appendChild(top_level_item); } + updateCounts(true); + new_tree->clearChildren(); new_tree->deleteLater(); + itemChanged(QList() << this); requestFeedReadFilterReload(); requestReloadMessageList(true); @@ -322,8 +325,6 @@ void TtRssServiceRoot::storeNewFeedTree(RootItem *root) { if (query_feed.exec()) { feed->setId(query_feed.lastInsertId().toInt()); - - // TODO: updatecounts; } else { // TODO: logovat.