From 8f7cf6ab97a64b07723e5d2a6e3738c2a316f4b2 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 2 Apr 2015 07:31:18 +0200 Subject: [PATCH 1/4] Hmmm. --- src/gui/feedsview.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index bb20054fd..2923a1d7f 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -171,7 +171,7 @@ void FeedsView::updateAllFeeds() { } else { qApp->showGuiMessage(tr("Cannot update all items"), - tr("You cannot update all items because another feed update is ongoing."), + tr("You cannot update all items because another another critical operation is ongoing."), QSystemTrayIcon::Warning, qApp->mainForm()); } } @@ -189,7 +189,7 @@ void FeedsView::updateSelectedFeeds() { } else { qApp->showGuiMessage(tr("Cannot update selected items"), - tr("You cannot update selected items because another feed update is ongoing."), + tr("You cannot update selected items because another critical operation is ongoing."), QSystemTrayIcon::Warning, qApp->mainForm()); } } @@ -258,7 +258,7 @@ void FeedsView::addNewCategory() { // it is used probably by feed updater or application // is quitting. qApp->showGuiMessage(tr("Cannot add standard category"), - tr("You cannot add new standard category now because feed update is ongoing."), + tr("You cannot add new standard category now because another critical operation is ongoing."), QSystemTrayIcon::Warning, qApp->mainForm()); return; } @@ -287,7 +287,7 @@ void FeedsView::addNewFeed() { // it is used probably by feed updater or application // is quitting. qApp->showGuiMessage(tr("Cannot add standard feed"), - tr("You cannot add new standard feed now because feed update is ongoing."), + tr("You cannot add new standard feed now because another critical operation is ongoing."), QSystemTrayIcon::Warning, qApp->mainForm()); return; } @@ -328,7 +328,6 @@ void FeedsView::receiveMessageCountsChange(MessagesModel::MessageMode mode, // total counts. // b) total count of message was not changed - some messages switched state --> we need to update // counts of just selected feeds. - if (mode == MessagesModel::MessagesFromRecycleBin) { if (total_msg_count_changed) { if (any_msg_restored) { @@ -353,7 +352,7 @@ void FeedsView::editSelectedItem() { // it is used probably by feed updater or application // is quitting. qApp->showGuiMessage(tr("Cannot edit item"), - tr("Selected item cannot be edited because feed update is ongoing."), + tr("Selected item cannot be edited because another critical operation is ongoing."), QSystemTrayIcon::Warning, qApp->mainForm()); // Thus, cannot delete and quit the method. @@ -380,7 +379,7 @@ void FeedsView::deleteSelectedItem() { // it is used probably by feed updater or application // is quitting. qApp->showGuiMessage(tr("Cannot delete item"), - tr("Selected item cannot be deleted because feed update is ongoing."), + tr("Selected item cannot be deleted because another critical operation is ongoing."), QSystemTrayIcon::Warning, qApp->mainForm()); // Thus, cannot delete and quit the method. @@ -462,15 +461,12 @@ void FeedsView::emptyRecycleBin() { if (MessageBox::show(qApp->mainForm(), QMessageBox::Question, tr("Permanently delete messages"), tr("You are about to permanenty delete all messages from your recycle bin."), tr("Do you really want to empty your recycle bin?"), - QString(), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) { - // User changed his mind. - return; + QString(), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) { + m_sourceModel->recycleBin()->empty(); + updateCountsOfSelectedFeeds(true); + + emit feedsNeedToBeReloaded(1); } - - m_sourceModel->recycleBin()->empty(); - updateCountsOfSelectedFeeds(true); - - emit feedsNeedToBeReloaded(1); } void FeedsView::restoreRecycleBin() { @@ -637,7 +633,6 @@ void FeedsView::selectionChanged(const QItemSelection &selected, const QItemSele foreach (FeedsModelFeed *feed, selected_feeds) { #if defined(DEBUG) QModelIndex index_for_feed = m_sourceModel->indexForItem(feed); - qDebug("Selecting feed '%s' (source index [%d, %d]).", qPrintable(feed->title()), index_for_feed.row(), index_for_feed.column()); #endif From 8a797ddf5ba61b6d0395864034a2e83622604042 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 4 Apr 2015 06:28:56 +0200 Subject: [PATCH 2/4] Compilation fix? --- src/gui/formabout.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/formabout.cpp b/src/gui/formabout.cpp index 826eff536..a0fdc1344 100755 --- a/src/gui/formabout.cpp +++ b/src/gui/formabout.cpp @@ -19,6 +19,7 @@ #include "miscellaneous/iconfactory.h" #include "miscellaneous/textfactory.h" +#include "miscellaneous/settingsproperties.h" #if !defined(Q_OS_WIN) #include "gui/messagebox.h" From 820b1b9a52c5aae6c833f42413c45f8c10099090 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 4 Apr 2015 07:44:13 +0200 Subject: [PATCH 3/4] Some work on feeds core. --- src/core/feedsmodel.cpp | 1 - src/core/feedsmodelrecyclebin.cpp | 0 src/core/feedsmodelrecyclebin.h | 0 src/gui/formsettings.ui | 10 +++++---- src/miscellaneous/databasefactory.cpp | 29 ++++++++++++++++----------- 5 files changed, 23 insertions(+), 17 deletions(-) mode change 100644 => 100755 src/core/feedsmodelrecyclebin.cpp mode change 100644 => 100755 src/core/feedsmodelrecyclebin.h mode change 100644 => 100755 src/gui/formsettings.ui diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index eeda8bdd5..f926e4d05 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -264,7 +264,6 @@ bool FeedsModel::removeItem(const QModelIndex &index) { endRemoveRows(); delete deleting_item; - return true; } } diff --git a/src/core/feedsmodelrecyclebin.cpp b/src/core/feedsmodelrecyclebin.cpp old mode 100644 new mode 100755 diff --git a/src/core/feedsmodelrecyclebin.h b/src/core/feedsmodelrecyclebin.h old mode 100644 new mode 100755 diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui old mode 100644 new mode 100755 index 3f8bfa391..3f10b5ee8 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -88,7 +88,7 @@ - 7 + 1 @@ -346,7 +346,9 @@ Authors of this application are NOT responsible for lost data. - Note that speed of used MySQL server and latency of used connection medium HEAVILY influences the final performance of this application. Using slow database connections leads to bad performance when browsing feeds or messages. + Note that speed of used MySQL server and latency of used connection medium HEAVILY influences the final performance of this application. Using slow database connections leads to bad performance when browsing feeds or messages. + +MySQL backend will automatically use database with name "rssguard". Do not create this database manually, let this application to handle it by itself. Therefore, given user must have rights to created and deleted databases. Qt::AlignCenter @@ -470,8 +472,8 @@ Authors of this application are NOT responsible for lost data. 0 0 - 695 - 425 + 167 + 219 diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index a2d5cac6a..2a76189c4 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -248,9 +248,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString &c query_db.exec("PRAGMA temp_store = MEMORY"); // Sample query which checks for existence of tables. - query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'"); - - if (query_db.lastError().isValid()) { + if (!query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'")) { qWarning("Error occurred. File-based SQLite database is not initialized. Initializing now."); QFile file_init(APP_MISC_PATH + QDir::separator() + APP_DB_SQLITE_INIT); @@ -262,8 +260,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString &c qPrintable(APP_MISC_PATH)); } - QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, - QString::SkipEmptyParts); + QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts); database.transaction(); foreach(const QString &statement, statements) { @@ -403,8 +400,7 @@ bool DatabaseFactory::mysqlUpdateDatabaseSchema(QSqlDatabase database, const QSt return true; } -QSqlDatabase DatabaseFactory::connection(const QString &connection_name, - DesiredType desired_type) { +QSqlDatabase DatabaseFactory::connection(const QString &connection_name, DesiredType desired_type) { switch (m_activeDatabaseDriver) { case MYSQL: return mysqlConnection(connection_name); @@ -534,12 +530,10 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_ } else { QSqlQuery query_db(database); - query_db.setForwardOnly(true); if (!query_db.exec("USE rssguard") || !query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'")) { - // If no "rssguard" database exists - // or schema version is wrong, then initialize it. + // If no "rssguard" database exists or schema version is wrong, then initialize it. qWarning("Error occurred. MySQL database is not initialized. Initializing now."); QFile file_init(APP_MISC_PATH + QDir::separator() + APP_DB_MYSQL_INIT); @@ -567,10 +561,21 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_ qDebug("MySQL database backend should be ready now."); } else { + // Database was previously initialized. Now just check the schema version. query_db.next(); - qDebug("MySQL database connection '%s' seems to be established.", qPrintable(connection_name)); - qDebug("MySQL database has version '%s'.", qPrintable(query_db.value(0).toString())); + QString installed_db_schema = query_db.value(0).toString(); + + if (!mysqlUpdateDatabaseSchema(database, installed_db_schema)) { + qFatal("Database schema was not updated from '%s' to '%s' successully.", + qPrintable(installed_db_schema), + APP_DB_SCHEMA_VERSION); + } + else { + qDebug("Database schema was updated from '%s' to '%s' successully or it is already up to date.", + qPrintable(installed_db_schema), + APP_DB_SCHEMA_VERSION); + } } query_db.finish(); From 7747dc49a30beb0c7f165fab0685bfc563d14386 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 4 Apr 2015 11:15:47 +0200 Subject: [PATCH 4/4] Settings type fix. --- src/gui/formabout.cpp | 2 +- src/miscellaneous/databasefactory.cpp | 2 +- src/miscellaneous/settings.cpp | 8 ++++---- src/miscellaneous/settings.h | 6 +++--- src/miscellaneous/settingsproperties.h | 9 +++++---- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/gui/formabout.cpp b/src/gui/formabout.cpp index a0fdc1344..8c60ec459 100755 --- a/src/gui/formabout.cpp +++ b/src/gui/formabout.cpp @@ -105,7 +105,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) APP_NAME)); // Load additional paths information. - if (qApp->settings()->type() == SettingsType::Portable) { + if (qApp->settings()->type() == SettingsProperties::Portable) { m_ui->m_txtPathsSettingsType->setText(tr("FULLY portable")); m_ui->m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(qApp->applicationDirPath() + QDir::separator() + QString(APP_DB_SQLITE_PATH))); } diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index 2a76189c4..2ebe6b9ab 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -114,7 +114,7 @@ void DatabaseFactory::finishRestoration() { } void DatabaseFactory::sqliteAssemblyDatabaseFilePath() { - if (qApp->settings()->type() == SettingsType::Portable) { + if (qApp->settings()->type() == SettingsProperties::Portable) { m_sqliteDatabaseFilePath = qApp->applicationDirPath() + QDir::separator() + QString(APP_DB_SQLITE_PATH); } else { diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 1cf8eab5f..983e0b959 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -238,7 +238,7 @@ DVALUE(bool) Browser::QueueTabsDef = true; // Categories. DKEY Categories::ID = "categories_expand_states"; -Settings::Settings(const QString &file_name, Format format, const SettingsType &status, QObject *parent) +Settings::Settings(const QString &file_name, Format format, const SettingsProperties::SettingsType &status, QObject *parent) : QSettings(file_name, format, parent), m_initializationStatus(status) { } @@ -298,7 +298,7 @@ Settings *Settings::setupSettings(QObject *parent) { QWebSettings::setIconDatabasePath(web_path); // Check if portable settings are available. - if (properties.m_type == SettingsType::Portable) { + if (properties.m_type == SettingsProperties::Portable) { qDebug("Initializing settings in '%s' (portable way).", qPrintable(QDir::toNativeSeparators(properties.m_absoluteSettingsFileName))); } else { @@ -325,11 +325,11 @@ SettingsProperties Settings::determineProperties() { bool will_we_use_portable_settings = portable_settings_available && !non_portable_settings_exist; if (will_we_use_portable_settings) { - properties.m_type = SettingsType::Portable; + properties.m_type = SettingsProperties::Portable; properties.m_baseDirectory = app_path; } else { - properties.m_type = SettingsType::NonPortable; + properties.m_type = SettingsProperties::NonPortable; properties.m_baseDirectory = home_path; } diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h index ab0cef82f..234129fa4 100755 --- a/src/miscellaneous/settings.h +++ b/src/miscellaneous/settings.h @@ -272,7 +272,7 @@ class Settings : public QSettings { virtual ~Settings(); // Type of used settings. - inline SettingsType type() const { + inline SettingsProperties::SettingsType type() const { return m_initializationStatus; } @@ -313,9 +313,9 @@ class Settings : public QSettings { private: // Constructor. - explicit Settings(const QString &file_name, Format format, const SettingsType &type, QObject *parent = 0); + explicit Settings(const QString &file_name, Format format, const SettingsProperties::SettingsType &type, QObject *parent = 0); - SettingsType m_initializationStatus; + SettingsProperties::SettingsType m_initializationStatus; }; #endif // SETTINGS_H diff --git a/src/miscellaneous/settingsproperties.h b/src/miscellaneous/settingsproperties.h index 258c91a7f..2c7384299 100755 --- a/src/miscellaneous/settingsproperties.h +++ b/src/miscellaneous/settingsproperties.h @@ -5,13 +5,14 @@ // Describes possible types of loaded settings. -enum SettingsType { - Portable, - NonPortable -}; // Describes characteristics of settings. struct SettingsProperties { + enum SettingsType { + Portable, + NonPortable + }; + SettingsType m_type; QString m_baseDirectory; QString m_settingsSuffix;