From 738929e280fa8dcf821db1bee7df04f18b46edbc Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 20 Sep 2017 07:30:11 +0200 Subject: [PATCH] Removed some redundant code. --- rssguard.pro | 11 ++-- src/definitions/definitions.h | 7 +- src/gui/dialogs/formaddaccount.ui | 2 +- src/miscellaneous/feedreader.cpp | 5 +- src/services/abstract/feed.cpp | 28 +++++++- src/services/abstract/recyclebin.cpp | 6 ++ .../definitions.h} | 22 ++----- .../inoreader/inoreaderentrypoint.cpp | 65 +++++++++++++++++++ .../inoreaderentrypoint.h} | 29 +++++---- src/services/owncloud/owncloudrecyclebin.cpp | 38 ----------- .../owncloud/owncloudserviceentrypoint.cpp | 9 +-- src/services/tt-rss/ttrssfeed.cpp | 46 ------------- src/services/tt-rss/ttrssfeed.h | 1 - src/services/tt-rss/ttrssrecyclebin.cpp | 36 ---------- 14 files changed, 137 insertions(+), 168 deletions(-) rename src/services/{tt-rss/ttrssrecyclebin.h => inoreader/definitions.h} (65%) create mode 100755 src/services/inoreader/inoreaderentrypoint.cpp rename src/services/{owncloud/owncloudrecyclebin.h => inoreader/inoreaderentrypoint.h} (57%) delete mode 100755 src/services/owncloud/owncloudrecyclebin.cpp delete mode 100755 src/services/tt-rss/ttrssrecyclebin.cpp diff --git a/rssguard.pro b/rssguard.pro index 3c6e6b6a4..9d609dab8 100755 --- a/rssguard.pro +++ b/rssguard.pro @@ -298,7 +298,6 @@ HEADERS += src/core/feeddownloader.h \ src/services/owncloud/network/owncloudnetworkfactory.h \ src/services/owncloud/owncloudcategory.h \ src/services/owncloud/owncloudfeed.h \ - src/services/owncloud/owncloudrecyclebin.h \ src/services/owncloud/owncloudserviceentrypoint.h \ src/services/owncloud/owncloudserviceroot.h \ src/services/standard/gui/formstandardcategorydetails.h \ @@ -314,7 +313,6 @@ HEADERS += src/core/feeddownloader.h \ src/services/tt-rss/network/ttrssnetworkfactory.h \ src/services/tt-rss/ttrsscategory.h \ src/services/tt-rss/ttrssfeed.h \ - src/services/tt-rss/ttrssrecyclebin.h \ src/services/tt-rss/ttrssserviceentrypoint.h \ src/services/tt-rss/ttrssserviceroot.h \ src/gui/settings/settingspanel.h \ @@ -339,7 +337,9 @@ HEADERS += src/core/feeddownloader.h \ src/gui/treeviewcolumnsmenu.h \ src/services/abstract/labelsrootitem.h \ src/services/abstract/label.h \ - src/miscellaneous/externaltool.h + src/miscellaneous/externaltool.h \ + src/services/inoreader/definitions.h \ + src/services/inoreader/inoreaderentrypoint.h SOURCES += src/core/feeddownloader.cpp \ src/core/feedsmodel.cpp \ @@ -425,7 +425,6 @@ SOURCES += src/core/feeddownloader.cpp \ src/services/owncloud/network/owncloudnetworkfactory.cpp \ src/services/owncloud/owncloudcategory.cpp \ src/services/owncloud/owncloudfeed.cpp \ - src/services/owncloud/owncloudrecyclebin.cpp \ src/services/owncloud/owncloudserviceentrypoint.cpp \ src/services/owncloud/owncloudserviceroot.cpp \ src/services/standard/gui/formstandardcategorydetails.cpp \ @@ -440,7 +439,6 @@ SOURCES += src/core/feeddownloader.cpp \ src/services/tt-rss/network/ttrssnetworkfactory.cpp \ src/services/tt-rss/ttrsscategory.cpp \ src/services/tt-rss/ttrssfeed.cpp \ - src/services/tt-rss/ttrssrecyclebin.cpp \ src/services/tt-rss/ttrssserviceentrypoint.cpp \ src/services/tt-rss/ttrssserviceroot.cpp \ src/gui/settings/settingspanel.cpp \ @@ -465,7 +463,8 @@ SOURCES += src/core/feeddownloader.cpp \ src/gui/treeviewcolumnsmenu.cpp \ src/services/abstract/labelsrootitem.cpp \ src/services/abstract/label.cpp \ - src/miscellaneous/externaltool.cpp + src/miscellaneous/externaltool.cpp \ + src/services/inoreader/inoreaderentrypoint.cpp OBJECTIVE_SOURCES += src/miscellaneous/disablewindowtabbing.mm diff --git a/src/definitions/definitions.h b/src/definitions/definitions.h index 84296fb44..f44f0a896 100755 --- a/src/definitions/definitions.h +++ b/src/definitions/definitions.h @@ -21,9 +21,10 @@ #include -#define SERVICE_CODE_STD_RSS "std-rss" -#define SERVICE_CODE_TT_RSS "tt-rss" -#define SERVICE_CODE_OWNCLOUD "owncloud" +#define SERVICE_CODE_STD_RSS "std-rss" +#define SERVICE_CODE_TT_RSS "tt-rss" +#define SERVICE_CODE_OWNCLOUD "owncloud" +#define SERVICE_CODE_INOREADER "inoreader" #define ARGUMENTS_LIST_SEPARATOR "\n" diff --git a/src/gui/dialogs/formaddaccount.ui b/src/gui/dialogs/formaddaccount.ui index cdb35edbe..03ae852dc 100755 --- a/src/gui/dialogs/formaddaccount.ui +++ b/src/gui/dialogs/formaddaccount.ui @@ -7,7 +7,7 @@ 0 0 685 - 271 + 300 diff --git a/src/miscellaneous/feedreader.cpp b/src/miscellaneous/feedreader.cpp index af75f98cf..ab7fb812a 100755 --- a/src/miscellaneous/feedreader.cpp +++ b/src/miscellaneous/feedreader.cpp @@ -19,6 +19,7 @@ #include "miscellaneous/feedreader.h" #include "services/abstract/serviceroot.h" +#include "services/inoreader/inoreaderentrypoint.h" #include "services/owncloud/owncloudserviceentrypoint.h" #include "services/standard/standardserviceentrypoint.h" #include "services/tt-rss/ttrssserviceentrypoint.h" @@ -45,6 +46,7 @@ FeedReader::FeedReader(QObject* parent) m_feedsProxyModel = new FeedsProxyModel(m_feedsModel, this); m_messagesModel = new MessagesModel(this); m_messagesProxyModel = new MessagesProxyModel(m_messagesModel, this); + connect(m_autoUpdateTimer, &QTimer::timeout, this, &FeedReader::executeNextAutoUpdate); updateAutoUpdateStatus(); asyncCacheSaveFinished(); @@ -63,9 +65,10 @@ FeedReader::~FeedReader() { QList FeedReader::feedServices() { if (m_feedServices.isEmpty()) { // NOTE: All installed services create their entry points here. + m_feedServices.append(new InoreaderEntryPoint()); + m_feedServices.append(new OwnCloudServiceEntryPoint()); m_feedServices.append(new StandardServiceEntryPoint()); m_feedServices.append(new TtRssServiceEntryPoint()); - m_feedServices.append(new OwnCloudServiceEntryPoint()); } return m_feedServices; diff --git a/src/services/abstract/feed.cpp b/src/services/abstract/feed.cpp index e20bd16a1..7eede996d 100755 --- a/src/services/abstract/feed.cpp +++ b/src/services/abstract/feed.cpp @@ -48,12 +48,38 @@ QVariant Feed::data(int column, int role) const { switch (role) { case Qt::ToolTipRole: if (column == FDS_MODEL_TITLE_INDEX) { + QString auto_update_string; + + switch (autoUpdateType()) { + case DontAutoUpdate: + + //: Describes feed auto-update status. + auto_update_string = tr("does not use auto-update"); + break; + + case DefaultAutoUpdate: + + //: Describes feed auto-update status. + auto_update_string = tr("uses global settings"); + break; + + case SpecificAutoUpdate: + default: + + //: Describes feed auto-update status. + auto_update_string = tr("uses specific settings " + "(%n minute(s) to next auto-update)", + 0, + autoUpdateRemainingInterval()); + break; + } + //: Tooltip for feed. return tr("%1" "%2\n\n" "Auto-update status: %3").arg(title(), description().isEmpty() ? QString() : QString('\n') + description(), - getAutoUpdateStatusDescription()); + auto_update_string); } else { return RootItem::data(column, role); diff --git a/src/services/abstract/recyclebin.cpp b/src/services/abstract/recyclebin.cpp index 93fa2635a..387874e86 100755 --- a/src/services/abstract/recyclebin.cpp +++ b/src/services/abstract/recyclebin.cpp @@ -22,6 +22,7 @@ #include "miscellaneous/databasequeries.h" #include "miscellaneous/iconfactory.h" #include "miscellaneous/textfactory.h" +#include "services/abstract/cacheforserviceroot.h" #include "services/abstract/serviceroot.h" #include @@ -97,6 +98,11 @@ QList RecycleBin::undeletedMessages() const { bool RecycleBin::markAsReadUnread(RootItem::ReadStatus status) { QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings); ServiceRoot* parent_root = getParentServiceRoot(); + CacheForServiceRoot* cache = dynamic_cast(parent_root); + + if (cache != nullptr) { + cache->addMessageStatesToCache(parent_root->customIDSOfMessagesForItem(this), status); + } if (DatabaseQueries::markBinReadUnread(database, parent_root->accountId(), status)) { updateCounts(false); diff --git a/src/services/tt-rss/ttrssrecyclebin.h b/src/services/inoreader/definitions.h similarity index 65% rename from src/services/tt-rss/ttrssrecyclebin.h rename to src/services/inoreader/definitions.h index e6d4ae0e1..8b0e4ee35 100755 --- a/src/services/tt-rss/ttrssrecyclebin.h +++ b/src/services/inoreader/definitions.h @@ -16,23 +16,9 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#ifndef TTRSSRECYCLEBIN_H -#define TTRSSRECYCLEBIN_H +#ifndef INOREADER_DEFINITIONS_H +#define INOREADER_DEFINITIONS_H -#include "services/abstract/recyclebin.h" +#define INOREADER_API_VERSION "0" -class TtRssServiceRoot; - -class TtRssRecycleBin : public RecycleBin { - Q_OBJECT - - public: - explicit TtRssRecycleBin(RootItem* parent = nullptr); - virtual ~TtRssRecycleBin(); - - TtRssServiceRoot* serviceRoot(); - - bool markAsReadUnread(ReadStatus status); -}; - -#endif // TTRSSRECYCLEBIN_H +#endif // INOREADER_DEFINITIONS_H diff --git a/src/services/inoreader/inoreaderentrypoint.cpp b/src/services/inoreader/inoreaderentrypoint.cpp new file mode 100755 index 000000000..65c5eb55f --- /dev/null +++ b/src/services/inoreader/inoreaderentrypoint.cpp @@ -0,0 +1,65 @@ +// This file is part of RSS Guard. + +// +// Copyright (C) 2011-2017 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + +#include "services/inoreader/inoreaderentrypoint.h" + +#include "definitions/definitions.h" +#include "miscellaneous/application.h" +#include "miscellaneous/databasequeries.h" +#include "miscellaneous/iconfactory.h" +#include "services/inoreader/definitions.h" + +InoreaderEntryPoint::InoreaderEntryPoint() {} + +InoreaderEntryPoint::~InoreaderEntryPoint() {} + +ServiceRoot* InoreaderEntryPoint::createNewRoot() const { + return nullptr; +} + +QList InoreaderEntryPoint::initializeSubtree() const { + return QList(); +} + +bool InoreaderEntryPoint::isSingleInstanceService() const { + return false; +} + +QString InoreaderEntryPoint::name() const { + return QSL("Inoreader"); +} + +QString InoreaderEntryPoint::code() const { + return SERVICE_CODE_INOREADER; +} + +QString InoreaderEntryPoint::description() const { + return QObject::tr("This is integration of Inoreader. This plugin implements API, version %1.").arg(INOREADER_API_VERSION); +} + +QString InoreaderEntryPoint::version() const { + return APP_VERSION; +} + +QString InoreaderEntryPoint::author() const { + return APP_AUTHOR; +} + +QIcon InoreaderEntryPoint::icon() const { + return qApp->icons()->miscIcon(QSL("inoreader")); +} diff --git a/src/services/owncloud/owncloudrecyclebin.h b/src/services/inoreader/inoreaderentrypoint.h similarity index 57% rename from src/services/owncloud/owncloudrecyclebin.h rename to src/services/inoreader/inoreaderentrypoint.h index 5da6b1995..e0ab2738e 100755 --- a/src/services/owncloud/owncloudrecyclebin.h +++ b/src/services/inoreader/inoreaderentrypoint.h @@ -16,23 +16,26 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#ifndef OWNCLOUDRECYCLEBIN_H -#define OWNCLOUDRECYCLEBIN_H +#ifndef INOREADERENTRYPOINT_H +#define INOREADERENTRYPOINT_H -#include "services/abstract/recyclebin.h" - -class OwnCloudServiceRoot; - -class OwnCloudRecycleBin : public RecycleBin { - Q_OBJECT +#include "services/abstract/serviceentrypoint.h" +class InoreaderEntryPoint : public ServiceEntryPoint { public: - explicit OwnCloudRecycleBin(RootItem* parent = nullptr); - virtual ~OwnCloudRecycleBin(); + explicit InoreaderEntryPoint(); + virtual ~InoreaderEntryPoint(); - OwnCloudServiceRoot* serviceRoot(); + ServiceRoot* createNewRoot() const; - bool markAsReadUnread(ReadStatus status); + QList initializeSubtree() const; + bool isSingleInstanceService() const; + QString name() const; + QString code() const; + QString description() const; + QString version() const; + QString author() const; + QIcon icon() const; }; -#endif // OWNCLOUDRECYCLEBIN_H +#endif // INOREADERENTRYPOINT_H diff --git a/src/services/owncloud/owncloudrecyclebin.cpp b/src/services/owncloud/owncloudrecyclebin.cpp deleted file mode 100755 index cc276ec40..000000000 --- a/src/services/owncloud/owncloudrecyclebin.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// This file is part of RSS Guard. - -// -// Copyright (C) 2011-2017 by Martin Rotter -// -// RSS Guard is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#include "services/owncloud/owncloudrecyclebin.h" - -#include "services/abstract/cacheforserviceroot.h" -#include "services/owncloud/network/owncloudnetworkfactory.h" -#include "services/owncloud/owncloudserviceroot.h" - -#include - -OwnCloudRecycleBin::OwnCloudRecycleBin(RootItem* parent) : RecycleBin(parent) {} - -OwnCloudRecycleBin::~OwnCloudRecycleBin() {} - -OwnCloudServiceRoot* OwnCloudRecycleBin::serviceRoot() { - return qobject_cast(getParentServiceRoot()); -} - -bool OwnCloudRecycleBin::markAsReadUnread(RootItem::ReadStatus status) { - serviceRoot()->addMessageStatesToCache(getParentServiceRoot()->customIDSOfMessagesForItem(this), status); - return RecycleBin::markAsReadUnread(status); -} diff --git a/src/services/owncloud/owncloudserviceentrypoint.cpp b/src/services/owncloud/owncloudserviceentrypoint.cpp index 32c385b44..cc5b6b734 100755 --- a/src/services/owncloud/owncloudserviceentrypoint.cpp +++ b/src/services/owncloud/owncloudserviceentrypoint.cpp @@ -31,8 +31,9 @@ OwnCloudServiceEntryPoint::OwnCloudServiceEntryPoint() {} OwnCloudServiceEntryPoint::~OwnCloudServiceEntryPoint() {} ServiceRoot* OwnCloudServiceEntryPoint::createNewRoot() const { - QScopedPointer form_acc(new FormEditOwnCloudAccount(qApp->mainFormWidget())); - return form_acc->execForCreate(); + FormEditOwnCloudAccount form_acc(qApp->mainFormWidget()); + + return form_acc.execForCreate(); } QList OwnCloudServiceEntryPoint::initializeSubtree() const { @@ -54,8 +55,8 @@ QString OwnCloudServiceEntryPoint::code() const { } QString OwnCloudServiceEntryPoint::description() const { - return QObject::tr("The News app is an RSS/Atom feed aggregator. It is part of Nextcloud suite. This plugin implements %1 API.").arg( - API_VERSION); + return QObject::tr("The News app is an RSS/Atom feed aggregator. It is part of Nextcloud suite. This plugin implements %1 API.") + .arg(API_VERSION); } QString OwnCloudServiceEntryPoint::version() const { diff --git a/src/services/tt-rss/ttrssfeed.cpp b/src/services/tt-rss/ttrssfeed.cpp index 145df54d5..f397e24c5 100755 --- a/src/services/tt-rss/ttrssfeed.cpp +++ b/src/services/tt-rss/ttrssfeed.cpp @@ -50,52 +50,6 @@ TtRssServiceRoot* TtRssFeed::serviceRoot() const { return qobject_cast(getParentServiceRoot()); } -QVariant TtRssFeed::data(int column, int role) const { - switch (role) { - case Qt::ToolTipRole: - if (column == FDS_MODEL_TITLE_INDEX) { - QString auto_update_string; - - switch (autoUpdateType()) { - case DontAutoUpdate: - - //: Describes feed auto-update status. - auto_update_string = tr("does not use auto-update"); - break; - - case DefaultAutoUpdate: - - //: Describes feed auto-update status. - auto_update_string = tr("uses global settings"); - break; - - case SpecificAutoUpdate: - default: - - //: Describes feed auto-update status. - auto_update_string = tr("uses specific settings " - "(%n minute(s) to next auto-update)", - 0, - autoUpdateRemainingInterval()); - break; - } - - //: Tooltip for feed. - return tr("%1" - "%2\n\n" - "Auto-update status: %3").arg(title(), - description().isEmpty() ? QString() : QString('\n') + description(), - auto_update_string); - } - else { - return Feed::data(column, role); - } - - default: - return Feed::data(column, role); - } -} - bool TtRssFeed::canBeEdited() const { return true; } diff --git a/src/services/tt-rss/ttrssfeed.h b/src/services/tt-rss/ttrssfeed.h index cb477e066..025a54499 100755 --- a/src/services/tt-rss/ttrssfeed.h +++ b/src/services/tt-rss/ttrssfeed.h @@ -35,7 +35,6 @@ class TtRssFeed : public Feed { TtRssServiceRoot* serviceRoot() const; - QVariant data(int column, int role) const; bool canBeEdited() const; bool editViaGui(); bool canBeDeleted() const; diff --git a/src/services/tt-rss/ttrssrecyclebin.cpp b/src/services/tt-rss/ttrssrecyclebin.cpp deleted file mode 100755 index ed56bf12f..000000000 --- a/src/services/tt-rss/ttrssrecyclebin.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// This file is part of RSS Guard. - -// -// Copyright (C) 2011-2017 by Martin Rotter -// -// RSS Guard is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// RSS Guard is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with RSS Guard. If not, see . - -#include "services/tt-rss/ttrssrecyclebin.h" - -#include "services/tt-rss/definitions.h" -#include "services/tt-rss/network/ttrssnetworkfactory.h" -#include "services/tt-rss/ttrssserviceroot.h" - -TtRssRecycleBin::TtRssRecycleBin(RootItem* parent) : RecycleBin(parent) {} - -TtRssRecycleBin::~TtRssRecycleBin() {} - -TtRssServiceRoot* TtRssRecycleBin::serviceRoot() { - return qobject_cast(getParentServiceRoot()); -} - -bool TtRssRecycleBin::markAsReadUnread(RootItem::ReadStatus status) { - serviceRoot()->addMessageStatesToCache(getParentServiceRoot()->customIDSOfMessagesForItem(this), status); - return RecycleBin::markAsReadUnread(status); -}