diff --git a/CMakeLists.txt b/CMakeLists.txt index d3bcc1361..869c59416 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,11 +366,6 @@ set(APP_FORMS src/gui/formcategorydetails.ui ) -# Add resources. -set(APP_RESOURCES - resources/rssguard_resources.qrc -) - # Add translations. set(APP_TRANSLATIONS localization/rssguard_en.ts @@ -397,7 +392,6 @@ set(APP_TEXT # Wrap files, create moc files. if(${USE_QT_5}) qt5_wrap_ui(APP_UI ${APP_FORMS}) - qt5_add_resources(APP_RCC ${APP_RESOURCES}) # Load translations. if(Qt5LinguistTools_FOUND) @@ -409,7 +403,6 @@ if(${USE_QT_5}) else(${USE_QT_5}) qt4_wrap_cpp(APP_MOC ${APP_HEADERS}) qt4_wrap_ui(APP_UI ${APP_FORMS}) - qt4_add_resources(APP_RCC ${APP_RESOURCES}) # Load translations. qt4_add_translation(APP_QM ${APP_TRANSLATIONS}) diff --git a/resources/rssguard_resources.qrc b/resources/rssguard_resources.qrc deleted file mode 100644 index 7646d2b36..000000000 --- a/resources/rssguard_resources.qrc +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp index 4bebf6fd6..9cdba6e37 100644 --- a/src/core/databasefactory.cpp +++ b/src/core/databasefactory.cpp @@ -34,12 +34,12 @@ DatabaseFactory *DatabaseFactory::instance() { void DatabaseFactory::assemblyDatabaseFilePath() { if (Settings::instance()->type() == Settings::Portable) { - m_databasePath = qApp->applicationDirPath() + + m_databaseFilePath = qApp->applicationDirPath() + QDir::separator() + QString(APP_DB_PATH); } else { - m_databasePath = QDir::homePath() + QDir::separator() + + m_databaseFilePath = QDir::homePath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QString(APP_DB_PATH); } @@ -298,11 +298,6 @@ 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 bddf071d1..971e39037 100644 --- a/src/core/databasefactory.h +++ b/src/core/databasefactory.h @@ -15,7 +15,7 @@ class DatabaseFactory : public QObject { // Returns absolute file path to database file. inline QString getDatabasePath() { - return m_databasePath; + return m_databaseFilePath; } // If in-memory is true, then :memory: database is returned @@ -25,7 +25,11 @@ class DatabaseFactory : public QObject { bool in_memory = true); // Removes connection. - void removeConnection(const QString &connection_name = QString()); + inline void removeConnection(const QString &connection_name = QString()) { + qDebug("Removing database connection '%s'.", qPrintable(connection_name)); + + QSqlDatabase::removeDatabase(connection_name); + } // Performs saving of items from in-memory database // to file-based database. @@ -47,7 +51,7 @@ class DatabaseFactory : public QObject { QSqlDatabase initializeFileBasedDatabase(const QString &connection_name); // Path to database file. - QString m_databasePath; + QString m_databaseFilePath; // Is database file initialized? bool m_fileBasedinitialized; diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 785948b0b..483f4ea86 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -38,10 +38,6 @@ FeedsModel::~FeedsModel() { delete m_rootItem; } -QVariant FeedsModel::data(const QModelIndex &index, int role) const { - return itemForIndex(index)->data(index.column(), role); -} - QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -137,14 +133,6 @@ int FeedsModel::rowCount(const QModelIndex &parent) const { return parent_item->childCount(); } -int FeedsModel::countOfAllMessages() const { - return m_rootItem->countOfAllMessages(); -} - -int FeedsModel::countOfUnreadMessages() const { - return m_rootItem->countOfUnreadMessages(); -} - // TODO: přepsat tudle metodu, // vim ze to zhruba funguje ale je potreba pridat taky // vymazani feedu/kategorie z SQL (pridat metodu do FeedsModelRootItem @@ -600,10 +588,6 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) { } } -FeedsModelRootItem *FeedsModel::rootItem() const { - return m_rootItem; -} - void FeedsModel::assembleCategories(CategoryAssignment categories) { QHash assignments; assignments.insert(NO_PARENT_CATEGORY, m_rootItem); diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index e32640415..e6c6cca2f 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -4,11 +4,11 @@ #include #include "core/messagesmodel.h" +#include "core/feedsmodelrootitem.h" #include -class FeedsModelRootItem; class FeedsModelCategory; class FeedsModelFeed; @@ -26,7 +26,10 @@ class FeedsModel : public QAbstractItemModel { virtual ~FeedsModel(); // Model implementation. - QVariant data(const QModelIndex &index, int role) const; + inline QVariant data(const QModelIndex &index, int role) const { + return itemForIndex(index)->data(index.column(), role); + } + QVariant headerData(int section, Qt::Orientation orientation, int role) const; QModelIndex index(int row, int column, const QModelIndex &parent) const; QModelIndex parent(const QModelIndex &child) const; @@ -34,8 +37,13 @@ class FeedsModel : public QAbstractItemModel { int rowCount(const QModelIndex &parent) const; // Returns couns of ALL/UNREAD (non-deleted) messages for the model. - int countOfAllMessages() const; - int countOfUnreadMessages() const; + inline int countOfAllMessages() const { + return m_rootItem->countOfAllMessages(); + } + + inline int countOfUnreadMessages() const { + return m_rootItem->countOfUnreadMessages(); + } // Feed/category manipulators. bool removeItems(const QModelIndexList &indexes); @@ -84,7 +92,9 @@ class FeedsModel : public QAbstractItemModel { QModelIndex indexForItem(FeedsModelRootItem *item) const; // Access to root item. - FeedsModelRootItem *rootItem() const; + inline FeedsModelRootItem *rootItem() const { + return m_rootItem; + } public slots: // Feeds operations. diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp index b3db8fbe6..8a61df140 100755 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -24,11 +24,3 @@ FeedsModelCategory::FeedsModelCategory(const FeedsModelCategory &other) FeedsModelCategory::~FeedsModelCategory() { } - -FeedsModelCategory:: Type FeedsModelCategory::type() const { - return m_type; -} - -void FeedsModelCategory::setType(const Type &type) { - m_type = type; -} diff --git a/src/core/feedsmodelcategory.h b/src/core/feedsmodelcategory.h index f62afc207..74f145d81 100755 --- a/src/core/feedsmodelcategory.h +++ b/src/core/feedsmodelcategory.h @@ -25,8 +25,13 @@ class FeedsModelCategory : public FeedsModelRootItem { virtual ~FeedsModelCategory(); // All types of categories offer these getters/setters. - Type type() const; - void setType(const Type &type); + inline Type type() const { + return m_type; + } + + inline void setType(const Type &type) { + m_type = type; + } protected: Type m_type; diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp index 844b522fc..0a07c6c74 100755 --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feedsmodelfeed.cpp @@ -29,17 +29,6 @@ int FeedsModelFeed::countOfUnreadMessages() const { return m_unreadCount; } -void FeedsModelFeed::update() { -} - -FeedsModelFeed::Type FeedsModelFeed::type() const { - return m_type; -} - -void FeedsModelFeed::setType(const Type &type) { - m_type = type; -} - QString FeedsModelFeed::typeToString(FeedsModelFeed::Type type) { switch (type) { case StandardAtom10: diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h index 2ed88d341..57d5d1174 100755 --- a/src/core/feedsmodelfeed.h +++ b/src/core/feedsmodelfeed.h @@ -34,11 +34,17 @@ class FeedsModelFeed : public FeedsModelRootItem { // NOTE: This method is used in the "update worker". // For example, it can fetch new messages from a remote destination // and store them in a local database and so on. - virtual void update(); + virtual void update() { + } // Other getters/setters. - Type type() const; - void setType(const Type &type); + inline Type type() const { + return m_type; + } + + inline void setType(const Type &type) { + m_type = type; + } // Converts particular feed type to string. static QString typeToString(Type type); diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index f979c8207..1e177063b 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -12,17 +12,10 @@ FeedsModelRootItem::FeedsModelRootItem(FeedsModelRootItem *parent_item) FeedsModelRootItem::~FeedsModelRootItem() { qDebug("Destroying FeedsModelRootItem instance."); + qDeleteAll(m_childItems); } -FeedsModelRootItem *FeedsModelRootItem::parent() const { - return m_parentItem; -} - -void FeedsModelRootItem::setParent(FeedsModelRootItem *parent_item) { - m_parentItem = parent_item; -} - FeedsModelRootItem::Kind FeedsModelRootItem::kind() const { return m_kind; } @@ -31,10 +24,6 @@ QIcon FeedsModelRootItem::icon() const { return m_icon; } -FeedsModelRootItem *FeedsModelRootItem::child(int row) { - return m_childItems.value(row); -} - void FeedsModelRootItem::appendChild(FeedsModelRootItem *child) { m_childItems.append(child); child->setParent(this); diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index bd308d125..e6719be06 100755 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -23,9 +23,18 @@ class FeedsModelRootItem { virtual ~FeedsModelRootItem(); // Basic operations. - virtual FeedsModelRootItem *parent() const; - virtual void setParent(FeedsModelRootItem *parent_item); - virtual FeedsModelRootItem *child(int row); + inline virtual FeedsModelRootItem *parent() const { + return m_parentItem; + } + + inline virtual void setParent(FeedsModelRootItem *parent_item) { + m_parentItem = parent_item; + } + + inline virtual FeedsModelRootItem *child(int row) { + return m_childItems.value(row); + } + virtual void appendChild(FeedsModelRootItem *child); virtual int childCount() const; virtual int columnCount() const; diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index e664c3689..86352b8b5 100644 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -28,6 +28,11 @@ class FeedMessageViewer : public TabContent { return m_messagesBrowser; } + // FeedsView getter. + inline FeedsView *feedsView() { + return m_feedsView; + } + // Loads/saves sizes and states of ALL // underlying widgets, this contains primarily // splitters, toolbar and views. diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index b788abee1..6729b3c0a 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -82,7 +82,7 @@ class FeedsView : public QTreeView { // Notifies other components about messages // counts. - void notifyWithCounts() { + inline void notifyWithCounts() { emit feedCountsChanged(m_sourceModel->countOfUnreadMessages(), m_sourceModel->countOfAllMessages()); } diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index 8651ce48a..8dd7e83e9 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -56,15 +56,15 @@ FormMain *FormMain::instance() { return s_instance; } -QMenu *FormMain::getTrayMenu() { +QMenu *FormMain::trayMenu() { return m_trayMenu; } -TabWidget *FormMain::getTabWidget() { +TabWidget *FormMain::tabWidget() { return m_ui->m_tabWidget; } -QList FormMain::getActions() { +QList FormMain::allActions() { QList actions; // Add basic actions. @@ -358,10 +358,7 @@ void FormMain::showAbout() { void FormMain::showSettings() { QPointer form_pointer = new FormSettings(this); - if (form_pointer.data()->exec() == QDialog::Accepted) { - // User applied new settings, reload neede components. - m_ui->m_tabWidget->checkTabBarVisibility(); - } + form_pointer.data()->exec(); delete form_pointer.data(); } diff --git a/src/gui/formmain.h b/src/gui/formmain.h index fccdaa374..1ac30a68d 100644 --- a/src/gui/formmain.h +++ b/src/gui/formmain.h @@ -23,14 +23,15 @@ class FormMain : public QMainWindow { virtual ~FormMain(); // Returns menu for the tray icon. - QMenu *getTrayMenu(); + QMenu *trayMenu(); // Returns global tab widget. - TabWidget *getTabWidget(); + TabWidget *tabWidget(); // Returns list of all globally available actions. - // NOTE: This is used for setting dynamic shortcuts for given actions. - QList getActions(); + // NOTE: This is used for setting dynamic shortcuts + // for given actions. + QList allActions(); // Access to statusbar. StatusBar *statusBar(); @@ -73,6 +74,7 @@ class FormMain : public QMainWindow { void switchFullscreenMode(bool turn_fullscreen_on); protected slots: + // Last-minute reactors. void onCommitData(QSessionManager &manager); void onSaveState(QSessionManager &manager); @@ -87,7 +89,6 @@ class FormMain : public QMainWindow { void showAbout(); private: - bool m_quitting; Ui::FormMain *m_ui; QMenu *m_trayMenu; StatusBar *m_statusBar; diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 62b0648e2..129baef31 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -11,6 +11,8 @@ #include "gui/iconthemefactory.h" #include "gui/skinfactory.h" #include "gui/systemtrayicon.h" +#include "gui/feedmessageviewer.h" +#include "gui/feedsview.h" #include "gui/formmain.h" #include "gui/webbrowser.h" @@ -408,7 +410,7 @@ void FormSettings::saveLanguage() { } void FormSettings::loadShortcuts() { - m_ui->m_shortcuts->populate(FormMain::instance()->getActions()); + m_ui->m_shortcuts->populate(FormMain::instance()->allActions()); } void FormSettings::saveShortcuts() { @@ -416,7 +418,7 @@ void FormSettings::saveShortcuts() { m_ui->m_shortcuts->updateShortcuts(); // Save new shortcuts to the settings. - DynamicShortcuts::save(FormMain::instance()->getActions()); + DynamicShortcuts::save(FormMain::instance()->allActions()); } void FormSettings::loadGeneral() { @@ -551,6 +553,7 @@ void FormSettings::saveInterface() { m_ui->m_checkHidden->isChecked()); if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) { SystemTrayIcon::instance()->show(); + FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts(); } else { FormMain::instance()->display(); @@ -587,4 +590,6 @@ void FormSettings::saveInterface() { m_ui->m_checkNewTabDoubleClick->isChecked()); settings->setValue(APP_CFG_GUI, "hide_tabbar_one_tab", m_ui->m_hideTabBarIfOneTabVisible->isChecked()); + + FormMain::instance()->tabWidget()->checkTabBarVisibility(); } diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index fac63fa72..3a1b9e1bd 100644 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -46,7 +46,7 @@ SystemTrayIcon::SystemTrayIcon(const QString &normal_icon, // Initialize icon. setNumber(); - setContextMenu(parent->getTrayMenu()); + setContextMenu(parent->trayMenu()); // Create necessary connections. connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index beea31459..624069442 100644 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -122,7 +122,7 @@ void WebBrowser::createConnections() { connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl))); // Connect this WebBrowser to global TabWidget. - TabWidget *tab_widget = FormMain::instance()->getTabWidget(); + TabWidget *tab_widget = FormMain::instance()->tabWidget(); connect(m_webView, SIGNAL(newTabRequested()), tab_widget, SLOT(addEmptyBrowser())); connect(m_webView, SIGNAL(linkMiddleClicked(QUrl)), tab_widget, SLOT(addLinkedBrowser(QUrl))); diff --git a/src/main.cpp b/src/main.cpp index c2b08744c..d1ca9da62 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,8 @@ #include "gui/formmain.h" #include "gui/formwelcome.h" #include "gui/systemtrayicon.h" +#include "gui/feedmessageviewer.h" +#include "gui/feedsview.h" #include "qtsingleapplication/qtsingleapplication.h" // Needed for setting ini file format on Mac OS. @@ -83,18 +85,18 @@ int main(int argc, char *argv[]) { QThread::currentThreadId() << "\'."; // Instantiate main application window. - FormMain window; + FormMain main_window; // Set correct information for main window. - window.setWindowTitle(APP_LONG_NAME); + main_window.setWindowTitle(APP_LONG_NAME); // Now is a good time to initialize dynamic keyboard shortcuts. - DynamicShortcuts::load(window.getActions()); + DynamicShortcuts::load(main_window.allActions()); // Display welcome dialog if application is launched for the first time. if (Settings::instance()->value(APP_CFG_GEN, "first_start", true).toBool()) { Settings::instance()->setValue(APP_CFG_GEN, "first_start", false); - FormWelcome(&window).exec(); + FormWelcome(&main_window).exec(); } // Display main window. @@ -102,21 +104,22 @@ int main(int argc, char *argv[]) { false).toBool() && SystemTrayIcon::isSystemTrayActivated()) { qDebug("Hiding the main window when the application is starting."); - window.hide(); + main_window.hide(); } else { qDebug("Showing the main window when the application is starting."); - window.show(); + main_window.show(); } // Display tray icon if it is enabled and available. if (SystemTrayIcon::isSystemTrayActivated()) { SystemTrayIcon::instance()->show(); + main_window.tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts(); } // Setup single-instance behavior. QObject::connect(&application, SIGNAL(messageReceived(QString)), - &window, SLOT(processExecutionMessage(QString))); + &main_window, SLOT(processExecutionMessage(QString))); // Enter global event loop. return QtSingleApplication::exec();