From 005e6c18a4b078673ea9b6b25923327c12d709a3 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 7 Feb 2014 11:49:24 +0100 Subject: [PATCH] Very initial preparations for MySQL support. --- src/core/defs.h.in | 1 + src/core/settings.cpp | 2 +- src/gui/formsettings.cpp | 35 ++++- src/gui/formsettings.ui | 308 ++++++++++++++++++++++++++++----------- 4 files changed, 255 insertions(+), 91 deletions(-) diff --git a/src/core/defs.h.in b/src/core/defs.h.in index dd96a41ab..bcdbc06aa 100755 --- a/src/core/defs.h.in +++ b/src/core/defs.h.in @@ -30,6 +30,7 @@ #define MAX_ZOOM_FACTOR 10.0 #define ICON_SIZE_SETTINGS 16 #define DATABASE_DRIVER "QSQLITE" +#define DATABASE_DRIVER_MYSQL "QMYSQL" #define NO_PARENT_CATEGORY -1 #define TRAY_ICON_BUBBLE_TIMEOUT 15000 #define KEY_MESSAGES_VIEW "messages_view_column_" diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 392dc43ef..de0727385 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -62,7 +62,7 @@ QSettings::Status Settings::setupSettings() { QWebSettings::setIconDatabasePath(web_path); qDebug("Initializing settings in '%s' (portable way).", - qPrintable(QDir::toNativeSeparators(app_path))); + qPrintable(QDir::toNativeSeparators(app_path_file))); } else { // Portable settings are NOT available, store them in diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index cb6aa9f1e..3dc75d9b9 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -438,8 +438,23 @@ void FormSettings::loadGeneral() { break; } + // Load SQLITE. + m_ui->m_cmbDatabaseDriver->addItem("SQLite", DATABASE_DRIVER); + // Load in-memory database status. - m_ui->m_cmbUseInMemoryDatabase->setChecked(Settings::instance()->value(APP_CFG_GEN, "use_in_memory_db", false).toBool()); + m_ui->m_cmbSqliteUseInMemoryDatabase->setChecked(Settings::instance()->value(APP_CFG_GEN, "use_in_memory_db", false).toBool()); + + if (QSqlDatabase::isDriverAvailable(DATABASE_DRIVER_MYSQL)) { + // Load MySQL. + m_ui->m_cmbDatabaseDriver->addItem("MySQL", DATABASE_DRIVER_MYSQL); + + // TODO: nacist username, password atp. + } + + // TODO: nacist podle nastaveni + m_ui->m_cmbDatabaseDriver->setCurrentIndex(m_ui->m_cmbDatabaseDriver->findData(Settings::instance()->value(APP_CFG_GEN, + "database_driver", + DATABASE_DRIVER).toString())); } void FormSettings::saveGeneral() { @@ -454,13 +469,29 @@ void FormSettings::saveGeneral() { // Setup in-memory database status. bool original_inmemory = Settings::instance()->value(APP_CFG_GEN, "use_in_memory_db", false).toBool(); - bool new_inmemory = m_ui->m_cmbUseInMemoryDatabase->isChecked(); + bool new_inmemory = m_ui->m_cmbSqliteUseInMemoryDatabase->isChecked(); if (original_inmemory != new_inmemory) { m_changedDataTexts.append(tr("in-memory database switched")); } + // Save data storage settings. + QString original_db_driver = Settings::instance()->value(APP_CFG_GEN, "database_driver", DATABASE_DRIVER).toString(); + QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString(); + + // Save SQLite. Settings::instance()->setValue(APP_CFG_GEN, "use_in_memory_db", new_inmemory); + + if (QSqlDatabase::isDriverAvailable(DATABASE_DRIVER_MYSQL)) { + // Save MySQL. + // TODO: ulozit username, password atp. + } + + Settings::instance()->setValue(APP_CFG_GEN, "database_driver", selected_db_driver); + + if (original_db_driver != selected_db_driver) { + m_changedDataTexts.append(tr("data storage backend changed")); + } } void FormSettings::loadInterface() { diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui index 1a4506f15..2a7225255 100644 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -14,13 +14,74 @@ Settings + + + + + 220 + 0 + + + + + 220 + 16777215 + + + + false + + + false + + + QListView::Static + + + false + + + 0 + + + + General + + + + + Keyboard shortcuts + + + + + User interface + + + + + Language + + + + + Web browser & proxy + + + + + Feeds & messages + + + + - 5 + 0 - + 0 @@ -33,24 +94,59 @@ 0 - + Launch RSS Guard on operating system startup - - - - Use in-memory database as the working database + + + + + 0 + 0 + - - - - - - Usage of in-memory working database has several advantages and pitfalls. Make sure that you are familiar with these before you turn this feature on. Advantages: + + Data storage + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Database driver + + + + + + + + + + 0 + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Use in-memory database as the working database + + + + + + + Usage of in-memory working database has several advantages and pitfalls. Make sure that you are familiar with these before you turn this feature on. Advantages: <ul> <li>higher speed for feed/message manipulations (especially with thousands of messages displayed),</li> <li>whole database stored in RAM, thus your hard drive can rest more.</li> @@ -61,16 +157,91 @@ Disadvantages: <li>application startup and shutdown can take little longer (max. 2 seconds).</li> </ul> Authors of this application are NOT responsible for lost data. - - - Qt::RichText - - - true - - - 20 - + + + Qt::RichText + + + true + + + 20 + + + + + + + + + + + Hostname + + + + + + + + + + + + Port + + + + + + + + 100 + 0 + + + + + + + + + + Username + + + + + + + + + + Password + + + + + + + + + + + + + + WARNING: Note that switching to another data storage type will NOT preserve your data from currently active data storage. + + + Qt::AlignCenter + + + true + + + + @@ -102,8 +273,8 @@ Authors of this application are NOT responsible for lost data. 0 0 - 100 - 30 + 564 + 363 @@ -180,8 +351,8 @@ Authors of this application are NOT responsible for lost data. 0 0 - 167 - 219 + 558 + 337 @@ -839,67 +1010,6 @@ Authors of this application are NOT responsible for lost data. - - - - - 220 - 0 - - - - - 220 - 16777215 - - - - false - - - false - - - QListView::Static - - - false - - - 0 - - - - General - - - - - Keyboard shortcuts - - - - - User interface - - - - - Language - - - - - Web browser & proxy - - - - - Feeds & messages - - - - @@ -919,6 +1029,12 @@ Authors of this application are NOT responsible for lost data.
dynamicshortcutswidget.h
1 + + LineEditWithStatus + QWidget +
lineeditwithstatus.h
+ 1 +
@@ -1002,5 +1118,21 @@ Authors of this application are NOT responsible for lost data. + + m_cmbDatabaseDriver + currentIndexChanged(int) + m_stackedDatabaseDriver + setCurrentIndex(int) + + + 558 + 96 + + + 516 + 215 + + +