Refactorings.
This commit is contained in:
parent
b7d390da0e
commit
247c547630
7 changed files with 28 additions and 26 deletions
|
@ -130,8 +130,7 @@ bool FeedsModelCategory::removeItself() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Children are removed, remove this standard category too.
|
// Children are removed, remove this standard category too.
|
||||||
QSqlDatabase database = qApp->database()->connection("FeedsModelCategory",
|
QSqlDatabase database = qApp->database()->connection("FeedsModelCategory", DatabaseFactory::FromSettings);
|
||||||
DatabaseFactory::FromSettings);
|
|
||||||
QSqlQuery query_remove(database);
|
QSqlQuery query_remove(database);
|
||||||
|
|
||||||
query_remove.setForwardOnly(true);
|
query_remove.setForwardOnly(true);
|
||||||
|
|
|
@ -392,9 +392,7 @@ QVariant FeedsModelFeed::data(int column, int role) const {
|
||||||
void FeedsModelFeed::update() {
|
void FeedsModelFeed::update() {
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
int download_timeout = qApp->settings()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt();
|
int download_timeout = qApp->settings()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt();
|
||||||
m_networkError = NetworkFactory::downloadFile(url(), download_timeout,
|
m_networkError = NetworkFactory::downloadFile(url(), download_timeout, feed_contents, passwordProtected(), username(), password());
|
||||||
feed_contents, passwordProtected(),
|
|
||||||
username(), password());
|
|
||||||
|
|
||||||
if (m_networkError != QNetworkReply::NoError) {
|
if (m_networkError != QNetworkReply::NoError) {
|
||||||
qWarning("Error during fetching of new messages for feed '%s' (id %d).", qPrintable(url()), id());
|
qWarning("Error during fetching of new messages for feed '%s' (id %d).", qPrintable(url()), id());
|
||||||
|
@ -524,9 +522,7 @@ void FeedsModelFeed::updateMessages(const QList<Message> &messages) {
|
||||||
|
|
||||||
query_select.finish();
|
query_select.finish();
|
||||||
|
|
||||||
if (datetime_stamps.size() == 0 ||
|
if (datetime_stamps.isEmpty() ||(message.m_createdFromFeed && !datetime_stamps.contains(message.m_created.toMSecsSinceEpoch()))) {
|
||||||
(message.m_createdFromFeed &&
|
|
||||||
!datetime_stamps.contains(message.m_created.toMSecsSinceEpoch()))) {
|
|
||||||
// Message is not fetched in this feed yet
|
// Message is not fetched in this feed yet
|
||||||
// or it is. If it is, then go
|
// or it is. If it is, then go
|
||||||
// through datetime stamps of stored messages
|
// through datetime stamps of stored messages
|
||||||
|
|
|
@ -351,8 +351,8 @@ void FeedsView::deleteSelectedItem() {
|
||||||
selection_model->clearSelection();
|
selection_model->clearSelection();
|
||||||
selection_model->select(current_index, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
selection_model->select(current_index, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
||||||
|
|
||||||
qApp->showGuiMessage(tr("Cannot delete item"),
|
qApp->showGuiMessage(tr("You selected multiplet items for deletion."),
|
||||||
tr("Selected item cannot be deleted because feed update is ongoing."),
|
tr("You can delete feeds/categories only one by one."),
|
||||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +365,9 @@ void FeedsView::deleteSelectedItem() {
|
||||||
else {
|
else {
|
||||||
// Item WAS NOT removed, either database-related error occurred
|
// Item WAS NOT removed, either database-related error occurred
|
||||||
// or update is undergoing.
|
// or update is undergoing.
|
||||||
|
qApp->showGuiMessage(tr("Deletion of item failed."),
|
||||||
|
tr("Selected item was not deleted due to error."),
|
||||||
|
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changes are done, unlock the update master lock.
|
// Changes are done, unlock the update master lock.
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -94,7 +93,7 @@ void FormUpdate::checkForUpdates() {
|
||||||
|
|
||||||
bool is_self_update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported();
|
bool is_self_update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported();
|
||||||
|
|
||||||
if (update.first.m_availableVersion > APP_VERSION) {
|
if (update.first.m_availableVersion != APP_VERSION) {
|
||||||
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok,
|
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok,
|
||||||
tr("New release available."),
|
tr("New release available."),
|
||||||
tr("This is new version which can be\ndownloaded and installed."));
|
tr("This is new version which can be\ndownloaded and installed."));
|
||||||
|
@ -130,12 +129,7 @@ void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) {
|
||||||
|
|
||||||
void FormUpdate::saveUpdateFile(const QByteArray &file_contents) {
|
void FormUpdate::saveUpdateFile(const QByteArray &file_contents) {
|
||||||
QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;;
|
QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;;
|
||||||
|
QString temp_directory = qApp->getTempDirectory();
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
QString temp_directory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
|
||||||
#else
|
|
||||||
QString temp_directory = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!temp_directory.isEmpty()) {
|
if (!temp_directory.isEmpty()) {
|
||||||
QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1);
|
QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1);
|
||||||
|
|
|
@ -87,8 +87,7 @@ int main(int argc, char *argv[]) {
|
||||||
Application::setOrganizationDomain(APP_URL);
|
Application::setOrganizationDomain(APP_URL);
|
||||||
Application::setWindowIcon(QIcon(APP_ICON_PATH));
|
Application::setWindowIcon(QIcon(APP_ICON_PATH));
|
||||||
|
|
||||||
qDebug().nospace() << "Creating main application form in thread: \'" <<
|
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
|
||||||
QThread::currentThreadId() << "\'.";
|
|
||||||
|
|
||||||
// Instantiate main application window.
|
// Instantiate main application window.
|
||||||
FormMain main_window;
|
FormMain main_window;
|
||||||
|
@ -100,9 +99,7 @@ int main(int argc, char *argv[]) {
|
||||||
DynamicShortcuts::load(main_window.allActions());
|
DynamicShortcuts::load(main_window.allActions());
|
||||||
|
|
||||||
// Display main window.
|
// Display main window.
|
||||||
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden",
|
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
|
||||||
false).toBool() &&
|
|
||||||
SystemTrayIcon::isSystemTrayActivated()) {
|
|
||||||
qDebug("Hiding the main window when the application is starting.");
|
qDebug("Hiding the main window when the application is starting.");
|
||||||
main_window.switchVisibility(true);
|
main_window.switchVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#else
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(qApp)
|
#if defined(qApp)
|
||||||
#undef qApp
|
#undef qApp
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,6 +119,16 @@ class Application : public QtSingleApplication {
|
||||||
m_mainForm = main_form;
|
m_mainForm = main_form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QString getTempDirectory() {
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
QString temp_directory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||||
|
#else
|
||||||
|
QString temp_directory = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return temp_directory;
|
||||||
|
}
|
||||||
|
|
||||||
// Access to application tray icon. Always use this in cooperation with
|
// Access to application tray icon. Always use this in cooperation with
|
||||||
// SystemTrayIcon::isSystemTrayActivated().
|
// SystemTrayIcon::isSystemTrayActivated().
|
||||||
SystemTrayIcon *trayIcon();
|
SystemTrayIcon *trayIcon();
|
||||||
|
|
|
@ -50,15 +50,12 @@ DatabaseFactory::MySQLError DatabaseFactory::mysqlTestConnection(const QString &
|
||||||
if (database.open()) {
|
if (database.open()) {
|
||||||
// Connection succeeded, clean up the mess and return OK status.
|
// Connection succeeded, clean up the mess and return OK status.
|
||||||
database.close();
|
database.close();
|
||||||
removeConnection(APP_DB_MYSQL_TEST);
|
|
||||||
return MySQLOk;
|
return MySQLOk;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Connection failed, do cleanup and return specific
|
// Connection failed, do cleanup and return specific
|
||||||
// error code.
|
// error code.
|
||||||
MySQLError error_code = static_cast<MySQLError>(database.lastError().number());
|
MySQLError error_code = static_cast<MySQLError>(database.lastError().number());
|
||||||
|
|
||||||
removeConnection(APP_DB_MYSQL_TEST);
|
|
||||||
return error_code;
|
return error_code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue