Some work on feeds core.

This commit is contained in:
Martin Rotter 2015-04-04 07:44:13 +02:00
parent 8a797ddf5b
commit 820b1b9a52
5 changed files with 23 additions and 17 deletions

View file

@ -264,7 +264,6 @@ bool FeedsModel::removeItem(const QModelIndex &index) {
endRemoveRows(); endRemoveRows();
delete deleting_item; delete deleting_item;
return true; return true;
} }
} }

0
src/core/feedsmodelrecyclebin.cpp Normal file → Executable file
View file

0
src/core/feedsmodelrecyclebin.h Normal file → Executable file
View file

10
src/gui/formsettings.ui Normal file → Executable file
View file

@ -88,7 +88,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings"> <widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex"> <property name="currentIndex">
<number>7</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="m_pageGeneral"> <widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5"> <layout class="QFormLayout" name="formLayout_5">
@ -346,7 +346,9 @@ Authors of this application are NOT responsible for lost data.</string>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QLabel" name="m_lblMysqlInfo"> <widget class="QLabel" name="m_lblMysqlInfo">
<property name="text"> <property name="text">
<string>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.</string> <string>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 &quot;rssguard&quot;. 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.</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -470,8 +472,8 @@ Authors of this application are NOT responsible for lost data.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>695</width> <width>167</width>
<height>425</height> <height>219</height>
</rect> </rect>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">

View file

@ -248,9 +248,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString &c
query_db.exec("PRAGMA temp_store = MEMORY"); query_db.exec("PRAGMA temp_store = MEMORY");
// Sample query which checks for existence of tables. // Sample query which checks for existence of tables.
query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'"); if (!query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'")) {
if (query_db.lastError().isValid()) {
qWarning("Error occurred. File-based SQLite database is not initialized. Initializing now."); qWarning("Error occurred. File-based SQLite database is not initialized. Initializing now.");
QFile file_init(APP_MISC_PATH + QDir::separator() + APP_DB_SQLITE_INIT); 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)); qPrintable(APP_MISC_PATH));
} }
QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, QStringList statements = QString(file_init.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
QString::SkipEmptyParts);
database.transaction(); database.transaction();
foreach(const QString &statement, statements) { foreach(const QString &statement, statements) {
@ -403,8 +400,7 @@ bool DatabaseFactory::mysqlUpdateDatabaseSchema(QSqlDatabase database, const QSt
return true; return true;
} }
QSqlDatabase DatabaseFactory::connection(const QString &connection_name, QSqlDatabase DatabaseFactory::connection(const QString &connection_name, DesiredType desired_type) {
DesiredType desired_type) {
switch (m_activeDatabaseDriver) { switch (m_activeDatabaseDriver) {
case MYSQL: case MYSQL:
return mysqlConnection(connection_name); return mysqlConnection(connection_name);
@ -534,12 +530,10 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_
} }
else { else {
QSqlQuery query_db(database); QSqlQuery query_db(database);
query_db.setForwardOnly(true); query_db.setForwardOnly(true);
if (!query_db.exec("USE rssguard") || !query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'")) { if (!query_db.exec("USE rssguard") || !query_db.exec("SELECT inf_value FROM Information WHERE inf_key = 'schema_version'")) {
// If no "rssguard" database exists // If no "rssguard" database exists or schema version is wrong, then initialize it.
// or schema version is wrong, then initialize it.
qWarning("Error occurred. MySQL database is not initialized. Initializing now."); qWarning("Error occurred. MySQL database is not initialized. Initializing now.");
QFile file_init(APP_MISC_PATH + QDir::separator() + APP_DB_MYSQL_INIT); 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."); qDebug("MySQL database backend should be ready now.");
} }
else { else {
// Database was previously initialized. Now just check the schema version.
query_db.next(); query_db.next();
qDebug("MySQL database connection '%s' seems to be established.", qPrintable(connection_name)); QString installed_db_schema = query_db.value(0).toString();
qDebug("MySQL database has version '%s'.", qPrintable(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(); query_db.finish();