Account initial starting is now delayed after main form construction, better now. Also some more stuff.

This commit is contained in:
Martin Rotter 2015-12-08 09:34:14 +01:00
parent 683517948d
commit 11dfe67b4a
6 changed files with 21 additions and 11 deletions

View file

@ -70,7 +70,7 @@ FeedsModel::FeedsModel(QObject *parent)
connect(m_autoUpdateTimer, SIGNAL(timeout()), this, SLOT(executeNextAutoUpdate()));
loadActivatedServiceAccounts();
//loadActivatedServiceAccounts();
updateAutoUpdateStatus();
if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()) {
@ -82,6 +82,10 @@ FeedsModel::FeedsModel(QObject *parent)
FeedsModel::~FeedsModel() {
qDebug("Destroying FeedsModel instance.");
foreach (ServiceRoot *account, serviceRoots()) {
account->stop();
}
// Delete all model items.
delete m_rootItem;
}

View file

@ -151,6 +151,9 @@ class FeedsModel : public QAbstractItemModel {
// Adds given service root account.
bool addServiceAccount(ServiceRoot *root);
// Loads feed/categories from the database.
void loadActivatedServiceAccounts();
public slots:
// Checks if new parent node is different from one used by original node.
// If it is, then it reassigns original_node to new parent.
@ -221,9 +224,6 @@ class FeedsModel : public QAbstractItemModel {
// which are suitable as IN clause for SQL queries.
QStringList textualFeedIds(const QList<Feed*> &feeds);
// Loads feed/categories from the database.
void loadActivatedServiceAccounts();
RootItem *m_rootItem;
QList<QString> m_headerData;
QList<QString> m_tooltipData;

View file

@ -103,8 +103,6 @@ void FeedMessageViewer::loadSize() {
Settings *settings = qApp->settings();
int default_msg_section_size = m_messagesView->header()->defaultSectionSize();
m_feedsView->loadExpandedStates();
// Restore offsets of splitters.
m_feedSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI), SETTING(GUI::SplitterFeeds)).toString().toLocal8Bit()));
m_messageSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI), SETTING(GUI::SplitterMessages)).toString().toLocal8Bit()));

View file

@ -121,6 +121,10 @@ int main(int argc, char *argv[]) {
QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesOnStartup()));
}
// Load activated accounts.
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->loadActivatedServiceAccounts();
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadExpandedStates();
// Setup single-instance behavior.
QObject::connect(&application, SIGNAL(messageReceived(QString)), &application, SLOT(processExecutionMessage(QString)));

View file

@ -64,6 +64,8 @@ class ServiceRoot : public RootItem {
// Start/stop services.
// Start method is called when feed model gets initialized OR after user adds new service.
// Account should synchronously initialize its children (load them from DB is recommended
// here).
//
// Stop method is called just before application exits OR when
// user explicitly deletes existing service instance.
@ -79,8 +81,6 @@ class ServiceRoot : public RootItem {
// and then use method QSqlTableModel::setFilter(....).
// NOTE: It would be more preferable if all messages are downloaded
// right when feeds are updated.
// TODO: toto možná udělat asynchronně, zobrazit
// "loading" dialog přes view a toto zavolat, nasledně signalovat
virtual bool loadMessagesForItem(RootItem *item, QSqlTableModel *model) = 0;
// Called BEFORE this read status update (triggered by user in message list) is stored in DB,

View file

@ -20,6 +20,7 @@
#include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
#include "gui/dialogs/formmain.h"
#include "network-web/networkfactory.h"
#include "services/tt-rss/ttrssserviceentrypoint.h"
#include "services/tt-rss/ttrssfeed.h"
#include "services/tt-rss/ttrsscategory.h"
@ -44,16 +45,19 @@ TtRssServiceRoot::~TtRssServiceRoot() {
}
void TtRssServiceRoot::start() {
// TODO: posunout starty rootů až je okno uděláno
loadFromDatabase();
// TODO: pokud tady není nic načteno, tak
// syncIn
if (childCount() == 0) {
// TODO: pokud tady není nic načteno, tak
// syncIn
}
}
void TtRssServiceRoot::stop() {
QNetworkReply::NetworkError error;
m_network->logout(error);
qDebug("Stopping Tiny Tiny RSS account, logging out with result '%d'.", (int) error);
}
QString TtRssServiceRoot::code() {