Refactoring.
This commit is contained in:
parent
a3c5bc0548
commit
c615a2b450
@ -76,14 +76,14 @@ int main(int argc, char *argv[]) {
|
|||||||
Application application(APP_LOW_NAME, run_minimal_without_gui, argc, argv);
|
Application application(APP_LOW_NAME, run_minimal_without_gui, argc, argv);
|
||||||
qDebug("Instantiated Application class.");
|
qDebug("Instantiated Application class.");
|
||||||
|
|
||||||
application.feedReader()->start();
|
|
||||||
|
|
||||||
// Check if another instance is running.
|
// Check if another instance is running.
|
||||||
if (application.sendMessage((QStringList() << APP_IS_RUNNING << application.arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR))) {
|
if (application.sendMessage((QStringList() << APP_IS_RUNNING << application.arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR))) {
|
||||||
qWarning("Another instance of the application is already running. Notifying it.");
|
qWarning("Another instance of the application is already running. Notifying it.");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
application.setFeedReader(new FeedReader(&application));
|
||||||
|
|
||||||
// Register needed metatypes.
|
// Register needed metatypes.
|
||||||
qRegisterMetaType<QList<Message> >("QList<Message>");
|
qRegisterMetaType<QList<Message> >("QList<Message>");
|
||||||
qRegisterMetaType<QList<RootItem*> >("QList<RootItem*>");
|
qRegisterMetaType<QList<RootItem*> >("QList<RootItem*>");
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
Application::Application(const QString &id, bool run_minimal_without_gui, int &argc, char **argv)
|
Application::Application(const QString &id, bool run_minimal_without_gui, int &argc, char **argv)
|
||||||
: QtSingleApplication(id, argc, argv),
|
: QtSingleApplication(id, argc, argv),
|
||||||
m_runMinimalWithoutGui(run_minimal_without_gui), m_feedReader(new FeedReader(this)),
|
m_runMinimalWithoutGui(run_minimal_without_gui), m_feedReader(nullptr),
|
||||||
m_updateFeedsLock(nullptr), m_userActions(QList<QAction*>()), m_mainForm(nullptr),
|
m_updateFeedsLock(nullptr), m_userActions(QList<QAction*>()), m_mainForm(nullptr),
|
||||||
m_trayIcon(nullptr), m_settings(nullptr), m_system(nullptr), m_skins(nullptr),
|
m_trayIcon(nullptr), m_settings(nullptr), m_system(nullptr), m_skins(nullptr),
|
||||||
m_localization(nullptr), m_icons(nullptr), m_database(nullptr), m_downloadManager(nullptr) {
|
m_localization(nullptr), m_icons(nullptr), m_database(nullptr), m_downloadManager(nullptr) {
|
||||||
@ -92,9 +92,13 @@ void Application::eliminateFirstRun(const QString &version) {
|
|||||||
settings()->setValue(GROUP(General), QString(General::FirstRun) + QL1C('_') + version, false);
|
settings()->setValue(GROUP(General), QString(General::FirstRun) + QL1C('_') + version, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setFeedReader(FeedReader *feed_reader) {
|
||||||
|
m_feedReader = feed_reader;
|
||||||
|
}
|
||||||
|
|
||||||
IconFactory *Application::icons() {
|
IconFactory *Application::icons() {
|
||||||
if (m_icons == nullptr) {
|
if (m_icons == nullptr) {
|
||||||
m_icons = new IconFactory(this);
|
m_icons = new IconFactory(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_icons;
|
return m_icons;
|
||||||
|
@ -57,6 +57,7 @@ class Application : public QtSingleApplication {
|
|||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
FeedReader *feedReader();
|
FeedReader *feedReader();
|
||||||
|
void setFeedReader(FeedReader *feed_reader);
|
||||||
|
|
||||||
// Globally accessible actions.
|
// Globally accessible actions.
|
||||||
QList<QAction*> userActions();
|
QList<QAction*> userActions();
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
|
|
||||||
|
|
||||||
FeedReader::FeedReader(QObject *parent) : QObject(parent), m_feedServices(QList<ServiceEntryPoint*>()) {
|
FeedReader::FeedReader(QObject *parent) : QObject(parent), m_feedServices(QList<ServiceEntryPoint*>()) {
|
||||||
|
m_feedDownloader = new FeedDownloader(this);
|
||||||
|
m_feedsModel = new FeedsModel(this);
|
||||||
|
m_feedProxyModel = new FeedsProxyModel(m_feedsModel, this);
|
||||||
|
m_messagesModel = new MessagesModel(this);
|
||||||
|
m_messagesProxyModel = new MessagesProxyModel(m_messagesModel, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedReader::~FeedReader() {
|
FeedReader::~FeedReader() {
|
||||||
@ -60,15 +65,9 @@ MessagesModel *FeedReader::messagesModel() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedReader::start() {
|
void FeedReader::start() {
|
||||||
m_feedDownloader = new FeedDownloader(this);
|
|
||||||
m_feedsModel = new FeedsModel(this);
|
|
||||||
m_feedProxyModel = new FeedsProxyModel(m_feedsModel, this);
|
|
||||||
m_messagesModel = new MessagesModel(this);
|
|
||||||
m_messagesProxyModel = new MessagesProxyModel(m_messagesModel, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedReader::stop() {
|
void FeedReader::stop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesProxyModel *FeedReader::messagesProxyModel() const {
|
MessagesProxyModel *FeedReader::messagesProxyModel() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user