Some more advancements, stored TT-RSS accounts are now correctly loaded w/o feeds/categories so far.

This commit is contained in:
Martin Rotter 2015-12-03 11:14:14 +01:00
parent 441e0e8632
commit 4f2a370901
4 changed files with 24 additions and 5 deletions

View File

@ -81,7 +81,7 @@ void MessagesModel::loadMessages(RootItem *item) {
if (!item->getParentServiceRoot()->loadMessagesForItem(item, this)) {
setFilter("true != true");
qWarning("Loading of messages from item '%s' failed.", qPrintable(item->title()));
qApp->showGuiMessage(tr("Loading of messages from item '%s' failed.").arg(item->title()),
qApp->showGuiMessage(tr("Loading of messages from item '%1' failed.").arg(item->title()),
tr("Loading of messages failed, maybe messages could not be downloaded."),
QSystemTrayIcon::Critical,
qApp->mainForm(),

View File

@ -23,8 +23,10 @@
#include "gui/dialogs/formmain.h"
#include "services/tt-rss/gui/formeditaccount.h"
#include "services/tt-rss/ttrssserviceroot.h"
#include "services/tt-rss/network/ttrssnetworkfactory.h"
#include <QPointer>
#include <QSqlQuery>
TtRssServiceEntryPoint::TtRssServiceEntryPoint(){
@ -72,5 +74,23 @@ ServiceRoot *TtRssServiceEntryPoint::createNewRoot() {
}
QList<ServiceRoot*> TtRssServiceEntryPoint::initializeSubtree() {
return QList<ServiceRoot*>();
// Check DB if standard account is enabled.
QSqlDatabase database = qApp->database()->connection(QSL("TtRssServiceEntryPoint"), DatabaseFactory::FromSettings);
QSqlQuery query(database);
QList<ServiceRoot*> roots;
if (query.exec("SELECT id, username, password, url FROM TtRssAccounts;")) {
while (query.next()) {
TtRssServiceRoot *root = new TtRssServiceRoot();
root->setAccountId(query.value(0).toInt());
root->network()->setUsername(query.value(1).toString());
root->network()->setPassword(query.value(2).toString());
root->network()->setUrl(query.value(3).toString());
root->updateTitle();
root->loadFromDatabase();
roots.append(root);
}
}
return roots;
}

View File

@ -184,7 +184,7 @@ void TtRssServiceRoot::saveToDatabase() {
}
void TtRssServiceRoot::loadFromDatabase() {
// Account ID is set, load connection data from DB.
// TODO: Load feeds/categories from DB.
}
void TtRssServiceRoot::updateTitle() {

View File

@ -67,10 +67,9 @@ class TtRssServiceRoot : public ServiceRoot {
void saveToDatabase();
void loadFromDatabase();
private:
void updateTitle();
private:
TtRssNetworkFactory *m_network;
};