Added ability to load messages.
This commit is contained in:
parent
523adcf4b7
commit
eb1eef3a50
2 changed files with 23 additions and 1 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||
#include "services/tt-rss/gui/formeditaccount.h"
|
||||
|
||||
#include <QSqlTableModel>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include <QPointer>
|
||||
|
@ -118,7 +119,13 @@ RecycleBin *TtRssServiceRoot::recycleBin() {
|
|||
}
|
||||
|
||||
bool TtRssServiceRoot::loadMessagesForItem(RootItem *item, QSqlTableModel *model) {
|
||||
return false;
|
||||
QList<Feed*> 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<QAction*> TtRssServiceRoot::serviceMenu() {
|
||||
|
@ -305,6 +312,17 @@ void TtRssServiceRoot::syncIn() {
|
|||
}
|
||||
}
|
||||
|
||||
QStringList TtRssServiceRoot::textualFeedIds(const QList<Feed*> &feeds) {
|
||||
QStringList stringy_ids;
|
||||
stringy_ids.reserve(feeds.size());
|
||||
|
||||
foreach (Feed *feed, feeds) {
|
||||
stringy_ids.append(QString("'%1'").arg(QString::number(static_cast<TtRssFeed*>(feed)->customId())));
|
||||
}
|
||||
|
||||
return stringy_ids;
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::removeOldFeedTree() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query(database);
|
||||
|
|
|
@ -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<Feed*> &feeds);
|
||||
|
||||
void removeOldFeedTree();
|
||||
void cleanAllItems();
|
||||
void storeNewFeedTree(RootItem *root);
|
||||
|
|
Loading…
Add table
Reference in a new issue