Refactoring.

This commit is contained in:
Martin Rotter 2016-08-16 08:51:09 +02:00
parent 5f7f6d898f
commit ba60a3638b
5 changed files with 22 additions and 23 deletions

View File

@ -167,6 +167,10 @@ bool FeedDownloadResults::lessThan(const QPair<QString, int> &lhs, const QPair<Q
return lhs.second > rhs.second; return lhs.second > rhs.second;
} }
void FeedDownloadResults::clear() {
m_updatedFeeds.clear();
}
QList<QPair<QString,int> > FeedDownloadResults::updatedFeeds() const { QList<QPair<QString,int> > FeedDownloadResults::updatedFeeds() const {
return m_updatedFeeds; return m_updatedFeeds;
} }

View File

@ -37,13 +37,10 @@ class FeedDownloadResults {
void appendUpdatedFeed(const QPair<QString,int> &feed); void appendUpdatedFeed(const QPair<QString,int> &feed);
void sort(); void sort();
void clear();
static bool lessThan(const QPair<QString,int> &lhs, const QPair<QString,int> &rhs); static bool lessThan(const QPair<QString,int> &lhs, const QPair<QString,int> &rhs);
inline void clear() {
m_updatedFeeds.clear();
}
private: private:
// QString represents title if the feed, int represents count of newly downloaded messages. // QString represents title if the feed, int represents count of newly downloaded messages.
QList<QPair<QString,int> > m_updatedFeeds; QList<QPair<QString,int> > m_updatedFeeds;

View File

@ -33,6 +33,7 @@
#include "gui/statusbar.h" #include "gui/statusbar.h"
#include "gui/dialogs/formmain.h" #include "gui/dialogs/formmain.h"
#include "core/feeddownloader.h" #include "core/feeddownloader.h"
#include "services/abstract/serviceentrypoint.h"
#include <QThread> #include <QThread>
#include <QSqlError> #include <QSqlError>

View File

@ -181,6 +181,18 @@ void Application::setMainForm(FormMain *main_form) {
m_mainForm = main_form; m_mainForm = main_form;
} }
QString Application::tempFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::TempLocation);
}
QString Application::documentsFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::DocumentsLocation);
}
QString Application::homeFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::HomeLocation);
}
void Application::backupDatabaseSettings(bool backup_database, bool backup_settings, void Application::backupDatabaseSettings(bool backup_database, bool backup_settings,
const QString &target_path, const QString &backup_name) { const QString &target_path, const QString &backup_name) {
if (!QFileInfo(target_path).isWritable()) { if (!QFileInfo(target_path).isWritable()) {

View File

@ -29,7 +29,6 @@
#include "miscellaneous/iofactory.h" #include "miscellaneous/iofactory.h"
#include "gui/systemtrayicon.h" #include "gui/systemtrayicon.h"
#include "network-web/downloadmanager.h" #include "network-web/downloadmanager.h"
#include "services/abstract/serviceentrypoint.h"
#include "core/feeddownloader.h" #include "core/feeddownloader.h"
#include <QList> #include <QList>
@ -76,31 +75,17 @@ class Application : public QtSingleApplication {
IconFactory *icons(); IconFactory *icons();
DownloadManager *downloadManager(); DownloadManager *downloadManager();
Settings *settings(); Settings *settings();
// Access to application-wide close lock.
Mutex *feedUpdateLock(); Mutex *feedUpdateLock();
FormMain *mainForm(); FormMain *mainForm();
QWidget *mainFormWidget(); QWidget *mainFormWidget();
// Access to application tray icon. Always use this in cooperation with
// SystemTrayIcon::isSystemTrayActivated().
SystemTrayIcon *trayIcon(); SystemTrayIcon *trayIcon();
QString tempFolderPath();
QString documentsFolderPath();
QString homeFolderPath();
void setMainForm(FormMain *main_form); void setMainForm(FormMain *main_form);
inline QString tempFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::TempLocation);
}
inline QString documentsFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::DocumentsLocation);
}
inline QString homeFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::HomeLocation);
}
void backupDatabaseSettings(bool backup_database, bool backup_settings, void backupDatabaseSettings(bool backup_database, bool backup_settings,
const QString &target_path, const QString &backup_name); const QString &target_path, const QString &backup_name);
void restoreDatabaseSettings(bool restore_database, bool restore_settings, void restoreDatabaseSettings(bool restore_database, bool restore_settings,