Refactorings.
This commit is contained in:
parent
b7d390da0e
commit
247c547630
|
@ -130,8 +130,7 @@ bool FeedsModelCategory::removeItself() {
|
|||
}
|
||||
|
||||
// Children are removed, remove this standard category too.
|
||||
QSqlDatabase database = qApp->database()->connection("FeedsModelCategory",
|
||||
DatabaseFactory::FromSettings);
|
||||
QSqlDatabase database = qApp->database()->connection("FeedsModelCategory", DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_remove(database);
|
||||
|
||||
query_remove.setForwardOnly(true);
|
||||
|
|
|
@ -392,9 +392,7 @@ QVariant FeedsModelFeed::data(int column, int role) const {
|
|||
void FeedsModelFeed::update() {
|
||||
QByteArray feed_contents;
|
||||
int download_timeout = qApp->settings()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt();
|
||||
m_networkError = NetworkFactory::downloadFile(url(), download_timeout,
|
||||
feed_contents, passwordProtected(),
|
||||
username(), password());
|
||||
m_networkError = NetworkFactory::downloadFile(url(), download_timeout, feed_contents, passwordProtected(), username(), password());
|
||||
|
||||
if (m_networkError != QNetworkReply::NoError) {
|
||||
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();
|
||||
|
||||
if (datetime_stamps.size() == 0 ||
|
||||
(message.m_createdFromFeed &&
|
||||
!datetime_stamps.contains(message.m_created.toMSecsSinceEpoch()))) {
|
||||
if (datetime_stamps.isEmpty() ||(message.m_createdFromFeed && !datetime_stamps.contains(message.m_created.toMSecsSinceEpoch()))) {
|
||||
// Message is not fetched in this feed yet
|
||||
// or it is. If it is, then go
|
||||
// through datetime stamps of stored messages
|
||||
|
|
|
@ -351,8 +351,8 @@ void FeedsView::deleteSelectedItem() {
|
|||
selection_model->clearSelection();
|
||||
selection_model->select(current_index, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
||||
|
||||
qApp->showGuiMessage(tr("Cannot delete item"),
|
||||
tr("Selected item cannot be deleted because feed update is ongoing."),
|
||||
qApp->showGuiMessage(tr("You selected multiplet items for deletion."),
|
||||
tr("You can delete feeds/categories only one by one."),
|
||||
QSystemTrayIcon::Warning, qApp->mainForm());
|
||||
}
|
||||
|
||||
|
@ -365,6 +365,9 @@ void FeedsView::deleteSelectedItem() {
|
|||
else {
|
||||
// Item WAS NOT removed, either database-related error occurred
|
||||
// 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.
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "gui/systemtrayicon.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QDesktopServices>
|
||||
#include <QProcess>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
|
@ -94,7 +93,7 @@ void FormUpdate::checkForUpdates() {
|
|||
|
||||
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,
|
||||
tr("New release available."),
|
||||
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) {
|
||||
QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;;
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
QString temp_directory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
#else
|
||||
QString temp_directory = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
|
||||
#endif
|
||||
QString temp_directory = qApp->getTempDirectory();
|
||||
|
||||
if (!temp_directory.isEmpty()) {
|
||||
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::setWindowIcon(QIcon(APP_ICON_PATH));
|
||||
|
||||
qDebug().nospace() << "Creating main application form in thread: \'" <<
|
||||
QThread::currentThreadId() << "\'.";
|
||||
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
|
||||
|
||||
// Instantiate main application window.
|
||||
FormMain main_window;
|
||||
|
@ -100,9 +99,7 @@ int main(int argc, char *argv[]) {
|
|||
DynamicShortcuts::load(main_window.allActions());
|
||||
|
||||
// Display main window.
|
||||
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden",
|
||||
false).toBool() &&
|
||||
SystemTrayIcon::isSystemTrayActivated()) {
|
||||
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
|
||||
qDebug("Hiding the main window when the application is starting.");
|
||||
main_window.switchVisibility(true);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
#include <QMutex>
|
||||
#include <QList>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
|
@ -113,6 +119,16 @@ class Application : public QtSingleApplication {
|
|||
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
|
||||
// SystemTrayIcon::isSystemTrayActivated().
|
||||
SystemTrayIcon *trayIcon();
|
||||
|
|
|
@ -50,15 +50,12 @@ DatabaseFactory::MySQLError DatabaseFactory::mysqlTestConnection(const QString &
|
|||
if (database.open()) {
|
||||
// Connection succeeded, clean up the mess and return OK status.
|
||||
database.close();
|
||||
removeConnection(APP_DB_MYSQL_TEST);
|
||||
return MySQLOk;
|
||||
}
|
||||
else {
|
||||
// Connection failed, do cleanup and return specific
|
||||
// error code.
|
||||
MySQLError error_code = static_cast<MySQLError>(database.lastError().number());
|
||||
|
||||
removeConnection(APP_DB_MYSQL_TEST);
|
||||
return error_code;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue