diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp index 9cdba6e37..f64265058 100644 --- a/src/core/databasefactory.cpp +++ b/src/core/databasefactory.cpp @@ -298,6 +298,12 @@ QSqlDatabase DatabaseFactory::connection(const QString &connection_name, } } +void DatabaseFactory::removeConnection(const QString &connection_name) { + qDebug("Removing database connection '%s'.", qPrintable(connection_name)); + + QSqlDatabase::removeDatabase(connection_name); +} + void DatabaseFactory::saveMemoryDatabase() { QSqlDatabase database = connection(); QSqlDatabase file_database = connection(objectName(), false); diff --git a/src/core/databasefactory.h b/src/core/databasefactory.h index 971e39037..9d8cb05fe 100644 --- a/src/core/databasefactory.h +++ b/src/core/databasefactory.h @@ -25,11 +25,7 @@ class DatabaseFactory : public QObject { bool in_memory = true); // Removes connection. - inline void removeConnection(const QString &connection_name = QString()) { - qDebug("Removing database connection '%s'.", qPrintable(connection_name)); - - QSqlDatabase::removeDatabase(connection_name); - } + void removeConnection(const QString &connection_name = QString()); // Performs saving of items from in-memory database // to file-based database. diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 483f4ea86..399f410b9 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -317,7 +317,7 @@ void FeedsModel::reloadWholeLayout() { void FeedsModel::loadFromDatabase() { // Delete all childs of the root node and clear them from the memory. qDeleteAll(m_rootItem->childItems()); - m_rootItem->clearChilds(); + m_rootItem->clearChildren(); QSqlDatabase database = DatabaseFactory::instance()->connection(); CategoryAssignment categories; diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index 1e177063b..60b80b562 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -16,23 +16,7 @@ FeedsModelRootItem::~FeedsModelRootItem() { qDeleteAll(m_childItems); } -FeedsModelRootItem::Kind FeedsModelRootItem::kind() const { - return m_kind; -} -QIcon FeedsModelRootItem::icon() const { - return m_icon; -} - -void FeedsModelRootItem::appendChild(FeedsModelRootItem *child) { - m_childItems.append(child); - child->setParent(this); -} - -int FeedsModelRootItem::columnCount() const { - // FeedsModel offers exactly two columns. - return 2; -} int FeedsModelRootItem::row() const { if (m_parentItem) { @@ -44,10 +28,6 @@ int FeedsModelRootItem::row() const { } } -int FeedsModelRootItem::childCount() const { - return m_childItems.size(); -} - QVariant FeedsModelRootItem::data(int column, int role) const { Q_UNUSED(column) Q_UNUSED(role) @@ -76,34 +56,6 @@ int FeedsModelRootItem::countOfUnreadMessages() const { return total_count; } -void FeedsModelRootItem::setIcon(const QIcon &icon) { - m_icon = icon; -} - -int FeedsModelRootItem::id() const { - return m_id; -} - -void FeedsModelRootItem::setId(int id) { - m_id = id; -} - -QString FeedsModelRootItem::title() const { - return m_title; -} - -void FeedsModelRootItem::setTitle(const QString &title) { - m_title = title; -} - -QList FeedsModelRootItem::childItems() const { - return m_childItems; -} - -void FeedsModelRootItem::clearChilds() { - m_childItems.clear(); -} - bool FeedsModelRootItem::removeChild(int index) { if (index >= 0 && index < m_childItems.size()) { m_childItems.removeAt(index); @@ -114,25 +66,6 @@ bool FeedsModelRootItem::removeChild(int index) { } } - - -QDateTime FeedsModelRootItem::creationDate() const { - return m_creationDate; -} - -void FeedsModelRootItem::setCreationDate(const QDateTime &creation_date) { - m_creationDate = creation_date; -} - -QString FeedsModelRootItem::description() const { - return m_description; -} - -void FeedsModelRootItem::setDescription(const QString &description) { - m_description = description; -} - - bool FeedsModelRootItem::isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs) { return (lhs->kind() == rhs->kind()) && (lhs->id() == rhs->id()); diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index e6719be06..fed4d7402 100755 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -35,9 +35,20 @@ class FeedsModelRootItem { return m_childItems.value(row); } - virtual void appendChild(FeedsModelRootItem *child); - virtual int childCount() const; - virtual int columnCount() const; + inline virtual int childCount() const { + return m_childItems.size(); + } + + inline virtual int columnCount() const { + // FeedsModel offers exactly two columns. + return 2; + } + + inline virtual void appendChild(FeedsModelRootItem *child) { + m_childItems.append(child); + child->setParent(this); + } + virtual int row() const; virtual QVariant data(int column, int role) const; @@ -46,38 +57,69 @@ class FeedsModelRootItem { virtual int countOfUnreadMessages() const; virtual int countOfAllMessages() const; - virtual Kind kind() const; - - // Each item has icon. - QIcon icon() const; - void setIcon(const QIcon &icon); - - // Each item has some kind of id. - int id() const; - void setId(int id); - - // Each item has its title. - // NOTE: This is note entirely true for the root item. - QString title() const; - void setTitle(const QString &title); - - QDateTime creationDate() const; - void setCreationDate(const QDateTime &creation_date); - - QString description() const; - void setDescription(const QString &description); - // Access to children. - QList childItems() const; + inline QList childItems() const { + return m_childItems; + } // Removes all children from this item. // NOTE: Children are NOT freed from the memory. - void clearChilds(); + inline void clearChildren() { + m_childItems.clear(); + } // Removes particular child at given index. // NOTE: Child is NOT freed from the memory. bool removeChild(int index); + inline Kind kind() const { + return m_kind; + } + + // Each item has icon. + inline QIcon icon() const { + return m_icon; + } + + inline void setIcon(const QIcon &icon) { + m_icon = icon; + } + + // Each item has some kind of id. + inline int id() const { + return m_id; + } + + inline void setId(int id) { + m_id = id; + } + + // Each item has its title. + // NOTE: This is note entirely true for the root item. + inline QString title() const { + return m_title; + } + + inline void setTitle(const QString &title) { + m_title = title; + } + + inline QDateTime creationDate() const { + return m_creationDate; + } + + inline void setCreationDate(const QDateTime &creation_date) { + m_creationDate = creation_date; + } + + inline QString description() const { + return m_description; + } + + inline void setDescription(const QString &description) { + m_description = description; + } + // Compares two model items. static bool isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs); static bool lessThan(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs); diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp index 23e4cc994..644f471a1 100755 --- a/src/core/feedsmodelstandardfeed.cpp +++ b/src/core/feedsmodelstandardfeed.cpp @@ -38,30 +38,6 @@ FeedsModelStandardFeed *FeedsModelStandardFeed::loadFromRecord(const QSqlRecord return feed; } -QString FeedsModelStandardFeed::encoding() const { - return m_encoding; -} - -void FeedsModelStandardFeed::setEncoding(const QString &encoding) { - m_encoding = encoding; -} - -QString FeedsModelStandardFeed::url() const { - return m_url; -} - -void FeedsModelStandardFeed::setUrl(const QString &url) { - m_url = url; -} - -QString FeedsModelStandardFeed::language() const { - return m_language; -} - -void FeedsModelStandardFeed::setLanguage(const QString &language) { - m_language = language; -} - QVariant FeedsModelStandardFeed::data(int column, int role) const { switch (role) { case Qt::DisplayRole: @@ -131,8 +107,8 @@ QVariant FeedsModelStandardFeed::data(int column, int role) const { void FeedsModelStandardFeed::update() { QByteArray feed_contents; int download_timeout = Settings::instance()->value(APP_CFG_FEEDS, - "download_timeout", - DOWNLOAD_TIMEOUT).toInt(); + "download_timeout", + DOWNLOAD_TIMEOUT).toInt(); // TODO: Provide download time-measures debugging // outputs here. diff --git a/src/core/feedsmodelstandardfeed.h b/src/core/feedsmodelstandardfeed.h index 4dd4dcc8d..cc2ab0510 100644 --- a/src/core/feedsmodelstandardfeed.h +++ b/src/core/feedsmodelstandardfeed.h @@ -25,14 +25,29 @@ class FeedsModelStandardFeed : public FeedsModelFeed { void update(); // Various getters/setters. - QString encoding() const; - void setEncoding(const QString &encoding); + inline QString encoding() const { + return m_encoding; + } - QString url() const; - void setUrl(const QString &url); + inline void setEncoding(const QString &encoding) { + m_encoding = encoding; + } - QString language() const; - void setLanguage(const QString &language); + inline QString url() const { + return m_url; + } + + inline void setUrl(const QString &url) { + m_url = url; + } + + inline QString language() const { + return m_language; + } + + inline void setLanguage(const QString &language) { + m_language = language; + } // Loads standard feed object from given SQL record. static FeedsModelStandardFeed *loadFromRecord(const QSqlRecord &record); diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp index 5259cf69c..46cfba186 100755 --- a/src/core/feedsproxymodel.cpp +++ b/src/core/feedsproxymodel.cpp @@ -25,9 +25,7 @@ FeedsProxyModel::~FeedsProxyModel() { qDebug("Destroying FeedsProxyModel instance"); } -FeedsModel *FeedsProxyModel::sourceModel() { - return m_sourceModel; -} + bool FeedsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { diff --git a/src/core/feedsproxymodel.h b/src/core/feedsproxymodel.h index 42e1c5def..3e86045af 100755 --- a/src/core/feedsproxymodel.h +++ b/src/core/feedsproxymodel.h @@ -15,7 +15,9 @@ class FeedsProxyModel : public QSortFilterProxyModel { virtual ~FeedsProxyModel(); // Access to the source model. - FeedsModel *sourceModel(); + inline FeedsModel *sourceModel() { + return m_sourceModel; + } // Maps list of indexes. QModelIndexList mapListToSource(const QModelIndexList &indexes); diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index ade7690fd..14a50e6c5 100644 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -32,10 +32,7 @@ MessagesModel::~MessagesModel() { qDebug("Destroying MessagesModel instance."); } -bool MessagesModel::submitAll() { - qFatal("Submitting changes via model is not allowed."); - return false; -} + void MessagesModel::setupIcons() { m_favoriteIcon = IconThemeFactory::instance()->fromTheme("favorites"); @@ -55,9 +52,7 @@ void MessagesModel::setupFonts() { m_boldFont.setBold(true); } -QList MessagesModel::currentFeeds() const { - return m_currentFeeds; -} + void MessagesModel::loadMessages(const QList feed_ids) { m_currentFeeds = feed_ids; diff --git a/src/core/messagesmodel.h b/src/core/messagesmodel.h index 2c7e33166..88a354c3c 100644 --- a/src/core/messagesmodel.h +++ b/src/core/messagesmodel.h @@ -44,11 +44,17 @@ class MessagesModel : public QSqlTableModel { int messageId(int row_index) const; // Access to list of currently loaded feed IDs. - QList currentFeeds() const; + inline QList currentFeeds() const { + return m_currentFeeds; + } public slots: // To disable persistent changes submissions. - bool submitAll(); + inline bool submitAll() { + qFatal("Submitting changes via model is not allowed."); + + return false; + } // CORE messages manipulators. // NOTE: These are used to change properties of one message. diff --git a/src/core/messagesproxymodel.cpp b/src/core/messagesproxymodel.cpp index 46be6e5ed..a4071ece3 100644 --- a/src/core/messagesproxymodel.cpp +++ b/src/core/messagesproxymodel.cpp @@ -21,9 +21,7 @@ MessagesProxyModel::~MessagesProxyModel() { qDebug("Destroying MessagesProxyModel instance."); } -MessagesModel *MessagesProxyModel::sourceModel() { - return m_sourceModel; -} + bool MessagesProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { // TODO: Maybe use QString::localeAwareCompare() here for diff --git a/src/core/messagesproxymodel.h b/src/core/messagesproxymodel.h index cbdf27b19..be04ef67a 100644 --- a/src/core/messagesproxymodel.h +++ b/src/core/messagesproxymodel.h @@ -15,7 +15,9 @@ class MessagesProxyModel : public QSortFilterProxyModel { virtual ~MessagesProxyModel(); // Source model getter. - MessagesModel *sourceModel(); + inline MessagesModel *sourceModel() { + return m_sourceModel; + } // Maps list of indexes. QModelIndexList mapListToSource(const QModelIndexList &indexes); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 1980eb6a6..766a15920 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -21,13 +21,12 @@ Settings::~Settings() { qDebug("Deleting Settings instance."); } -Settings::Type Settings::type() const { - return m_initializationStatus; -} + QSettings::Status Settings::checkSettings() { qDebug("Syncing settings."); + sync(); return status(); } @@ -40,17 +39,9 @@ Settings *Settings::instance() { return s_instance; } -QVariant Settings::value(const QString §ion, - const QString &key, - const QVariant &default_value) { - return QSettings::value(QString("%1/%2").arg(section, key), default_value); -} -void Settings::setValue(const QString §ion, - const QString &key, - const QVariant &value) { - QSettings::setValue(QString("%1/%2").arg(section, key), value); -} + + QSettings::Status Settings::setupSettings() { // If settings file exists in executable file working directory diff --git a/src/core/settings.h b/src/core/settings.h index 29a9d5c98..aca50f34f 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -22,16 +22,22 @@ class Settings : public QSettings { virtual ~Settings(); // Type of used settings. - Type type() const; + inline Type type() const { + return m_initializationStatus; + } // Getter/setter for settings values. - QVariant value(const QString §ion, + inline QVariant value(const QString §ion, const QString &key, - const QVariant &default_value = QVariant()); + const QVariant &default_value = QVariant()) { + return QSettings::value(QString("%1/%2").arg(section, key), default_value); + } - void setValue(const QString §ion, + inline void setValue(const QString §ion, const QString &key, - const QVariant &value); + const QVariant &value) { + QSettings::setValue(QString("%1/%2").arg(section, key), value); + } // Synchronizes settings. QSettings::Status checkSettings(); diff --git a/src/core/systemfactory.cpp b/src/core/systemfactory.cpp index 2d4f97c4a..41d2f1902 100644 --- a/src/core/systemfactory.cpp +++ b/src/core/systemfactory.cpp @@ -102,9 +102,7 @@ SystemFactory *SystemFactory::getInstance() { return s_instance; } -QReadWriteLock *SystemFactory::applicationCloseLock() const { - return m_applicationCloseLock; -} + bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) { SystemFactory::AutoStartStatus current_status = SystemFactory::getAutoStartStatus(); diff --git a/src/core/systemfactory.h b/src/core/systemfactory.h index 70b7ef23e..9fb869576 100644 --- a/src/core/systemfactory.h +++ b/src/core/systemfactory.h @@ -40,11 +40,14 @@ class SystemFactory : public QObject { QString getAutostartDesktopFileLocation(); #endif - // Singleton getter. - static SystemFactory *getInstance(); // Access to application-wide close lock. - QReadWriteLock *applicationCloseLock() const; + inline QReadWriteLock *applicationCloseLock() const { + return m_applicationCloseLock; + } + + // Singleton getter. + static SystemFactory *getInstance(); private: // This read-write lock is used by application on its close. diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 442d395e0..a6c53782b 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -185,6 +185,8 @@ void FeedMessageViewer::createConnections() { m_feedDownloader, SLOT(updateFeeds(QList))); connect(m_feedDownloader, SIGNAL(finished()), this, SLOT(onFeedUpdatesFinished())); + connect(m_feedDownloader, SIGNAL(started()), + this, SLOT(onFeedUpdatesStarted())); connect(m_feedDownloader, SIGNAL(progress(FeedsModelFeed*,int,int)), this, SLOT(onFeedUpdatesProgress(FeedsModelFeed*,int,int))); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index a55fd8c43..d20482f1e 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -32,13 +32,9 @@ FeedsView::~FeedsView() { qDebug("Destroying FeedsView instance."); } -FeedsProxyModel *FeedsView::model() { - return m_proxyModel; -} -FeedsModel *FeedsView::sourceModel() { - return m_sourceModel; -} + + void FeedsView::setSortingEnabled(bool enable) { QTreeView::setSortingEnabled(enable); diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 6729b3c0a..8b15289bc 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -31,8 +31,13 @@ class FeedsView : public QTreeView { explicit FeedsView(QWidget *parent = 0); virtual ~FeedsView(); - FeedsProxyModel *model(); - FeedsModel *sourceModel(); + inline FeedsProxyModel *model() { + return m_proxyModel; + } + + inline FeedsModel *sourceModel() { + return m_sourceModel; + } // Enables or disables sorting. void setSortingEnabled(bool enable); @@ -77,9 +82,6 @@ class FeedsView : public QTreeView { // Reloads counts for particular feed. void updateCountsOfParticularFeed(FeedsModelFeed *feed, bool update_total_too = true); - // TODO: pouzit metodu dole pro uvodni zobrazeni - // poctu v trayi - // Notifies other components about messages // counts. inline void notifyWithCounts() { diff --git a/src/gui/formcategorydetails.h b/src/gui/formcategorydetails.h index bbd1ab715..785293d8d 100644 --- a/src/gui/formcategorydetails.h +++ b/src/gui/formcategorydetails.h @@ -38,7 +38,7 @@ class FormCategoryDetails : public QDialog { // and parent_item contains parent item of newly // created or edited category. // NOTE: Newly ADDED category is NOT added to the model NOR - // in the database. + // to the database. // NOTE: Newly EDITED category IS COPY of its original. // SO NO ORIGINAL MODEL DATA ARE EDITED OR CHANGED. FormCategoryDetailsAnswer exec(FeedsModelCategory *input_category, diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index 8dd7e83e9..679b70031 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -56,13 +56,9 @@ FormMain *FormMain::instance() { return s_instance; } -QMenu *FormMain::trayMenu() { - return m_trayMenu; -} -TabWidget *FormMain::tabWidget() { - return m_ui->m_tabWidget; -} + + QList FormMain::allActions() { QList actions; @@ -95,9 +91,7 @@ QList FormMain::allActions() { return actions; } -StatusBar *FormMain::statusBar() { - return m_statusBar; -} + void FormMain::prepareMenus() { // Setup menu for tray icon. diff --git a/src/gui/formmain.h b/src/gui/formmain.h index 1ac30a68d..4731a2160 100644 --- a/src/gui/formmain.h +++ b/src/gui/formmain.h @@ -23,19 +23,25 @@ class FormMain : public QMainWindow { virtual ~FormMain(); // Returns menu for the tray icon. - QMenu *trayMenu(); + inline QMenu *trayMenu() { + return m_trayMenu; + } // Returns global tab widget. - TabWidget *tabWidget(); + inline TabWidget *tabWidget() { + return m_ui->m_tabWidget; + } + + // Access to statusbar. + inline StatusBar *statusBar() { + return m_statusBar; + } // Returns list of all globally available actions. // NOTE: This is used for setting dynamic shortcuts // for given actions. QList allActions(); - // Access to statusbar. - StatusBar *statusBar(); - // Singleton accessor. static FormMain *instance();