diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index 532610aa7..5ac50a600 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -27,6 +27,7 @@ #include "services/tt-rss/network/ttrssnetworkfactory.h" #include "services/tt-rss/gui/formeditaccount.h" +#include #include #include #include @@ -118,7 +119,13 @@ RecycleBin *TtRssServiceRoot::recycleBin() { } bool TtRssServiceRoot::loadMessagesForItem(RootItem *item, QSqlTableModel *model) { - return false; + QList children = item->getSubTreeFeeds(); + QString filter_clause = textualFeedIds(children).join(QSL(", ")); + + model->setFilter(QString(QSL("feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0")).arg(filter_clause)); + qDebug("Loading messages from feeds: %s.", qPrintable(filter_clause)); + + return true; } QList TtRssServiceRoot::serviceMenu() { @@ -305,6 +312,17 @@ void TtRssServiceRoot::syncIn() { } } +QStringList TtRssServiceRoot::textualFeedIds(const QList &feeds) { + QStringList stringy_ids; + stringy_ids.reserve(feeds.size()); + + foreach (Feed *feed, feeds) { + stringy_ids.append(QString("'%1'").arg(QString::number(static_cast(feed)->customId()))); + } + + return stringy_ids; +} + void TtRssServiceRoot::removeOldFeedTree() { QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); QSqlQuery query(database); diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index 5ff7cffb6..56519886f 100755 --- a/src/services/tt-rss/ttrssserviceroot.h +++ b/src/services/tt-rss/ttrssserviceroot.h @@ -75,6 +75,10 @@ class TtRssServiceRoot : public ServiceRoot { void syncIn(); private: + // Returns converted ids of given feeds + // which are suitable as IN clause for SQL queries. + QStringList textualFeedIds(const QList &feeds); + void removeOldFeedTree(); void cleanAllItems(); void storeNewFeedTree(RootItem *root);