Recycle bin moved to superclass.
This commit is contained in:
parent
e9748c1d2a
commit
e758511cc2
@ -27,8 +27,7 @@
|
||||
|
||||
#include <QThread>
|
||||
|
||||
RecycleBin::RecycleBin(RootItem* parent_item) : RootItem(parent_item), m_totalCount(0),
|
||||
m_unreadCount(0), m_contextMenu(QList<QAction*>()) {
|
||||
RecycleBin::RecycleBin(RootItem* parent_item) : RootItem(parent_item), m_totalCount(0), m_unreadCount(0), m_contextMenu(QList<QAction*>()) {
|
||||
setKind(RootItemKind::Bin);
|
||||
setId(ID_RECYCLE_BIN);
|
||||
setIcon(qApp->icons()->fromTheme(QSL("user-trash")));
|
||||
|
@ -42,23 +42,9 @@ class RecycleBin : public RootItem {
|
||||
void updateCounts(bool update_total_count);
|
||||
|
||||
public slots:
|
||||
|
||||
/////////////////////////////////////////
|
||||
// /* Members to override.
|
||||
/////////////////////////////////////////
|
||||
|
||||
// Empties the bin - removes all messages from it (does not remove
|
||||
// them from DB, just permanently hide them, so that they are not
|
||||
// re-downloaded).
|
||||
virtual bool empty();
|
||||
|
||||
// Performs complete restoration of all messages contained in the bin
|
||||
virtual bool restore();
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Members to override. */
|
||||
/////////////////////////////////////////
|
||||
|
||||
private:
|
||||
int m_totalCount;
|
||||
int m_unreadCount;
|
||||
|
@ -137,8 +137,10 @@ class RootItem : public QObject {
|
||||
}
|
||||
|
||||
inline void appendChild(RootItem* child) {
|
||||
m_childItems.append(child);
|
||||
child->setParent(this);
|
||||
if (child != nullptr) {
|
||||
m_childItems.append(child);
|
||||
child->setParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Access to children.
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
|
||||
ServiceRoot::ServiceRoot(RootItem* parent) : RootItem(parent), m_accountId(NO_PARENT_CATEGORY) {
|
||||
ServiceRoot::ServiceRoot(RootItem* parent) : RootItem(parent), m_recycleBin(new RecycleBin(this)), m_accountId(NO_PARENT_CATEGORY) {
|
||||
setKind(RootItemKind::ServiceRoot);
|
||||
setCreationDate(QDateTime::currentDateTime());
|
||||
}
|
||||
@ -66,6 +66,10 @@ QList<QAction*> ServiceRoot::addItemMenu() {
|
||||
return QList<QAction*>();
|
||||
}
|
||||
|
||||
RecycleBin* ServiceRoot::recycleBin() const {
|
||||
return m_recycleBin;
|
||||
}
|
||||
|
||||
QList<QAction*> ServiceRoot::contextMenu() {
|
||||
return serviceMenu();
|
||||
}
|
||||
|
@ -45,9 +45,12 @@ class ServiceRoot : public RootItem {
|
||||
explicit ServiceRoot(RootItem* parent = nullptr);
|
||||
virtual ~ServiceRoot();
|
||||
|
||||
void updateCounts(bool including_total_count);
|
||||
bool deleteViaGui();
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
virtual RecycleBin* recycleBin() const;
|
||||
|
||||
QList<Message> undeletedMessages() const;
|
||||
virtual bool supportsFeedAdding() const = 0;
|
||||
virtual bool supportsCategoryAdding() const = 0;
|
||||
|
||||
@ -67,13 +70,6 @@ class ServiceRoot : public RootItem {
|
||||
// NOTE: Caller does NOT take ownership of created menu!
|
||||
virtual QList<QAction*> serviceMenu();
|
||||
|
||||
// Access to recycle bin of this account if there is any.
|
||||
virtual RecycleBin* recycleBin() const = 0;
|
||||
|
||||
void updateCounts(bool including_total_count);
|
||||
|
||||
QList<Message> undeletedMessages() const;
|
||||
|
||||
// Start/stop services.
|
||||
// Start method is called when feed model gets initialized OR after user adds new service.
|
||||
// Account should synchronously initialize its children (load them from DB is recommended
|
||||
@ -198,8 +194,6 @@ class ServiceRoot : public RootItem {
|
||||
void assembleFeeds(Assignment feeds);
|
||||
|
||||
signals:
|
||||
|
||||
// Emitted if data in any item belonging to this root are changed.
|
||||
void dataChanged(QList<RootItem*> items);
|
||||
void reloadMessageListRequested(bool mark_selected_messages_read);
|
||||
void itemExpandRequested(QList<RootItem*> items, bool expand);
|
||||
@ -211,6 +205,9 @@ class ServiceRoot : public RootItem {
|
||||
private:
|
||||
virtual QMap<int, QVariant> storeCustomFeedsData() = 0;
|
||||
virtual void restoreCustomFeedsData(const QMap<int, QVariant>& data, const QHash<int, Feed*>& feeds) = 0;
|
||||
|
||||
private:
|
||||
RecycleBin* m_recycleBin;
|
||||
int m_accountId;
|
||||
};
|
||||
|
||||
|
@ -24,16 +24,16 @@
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
#include "services/owncloud/gui/formeditowncloudaccount.h"
|
||||
#include "services/owncloud/gui/formowncloudfeeddetails.h"
|
||||
#include "services/owncloud/network/owncloudnetworkfactory.h"
|
||||
#include "services/owncloud/owncloudcategory.h"
|
||||
#include "services/owncloud/owncloudfeed.h"
|
||||
#include "services/owncloud/owncloudrecyclebin.h"
|
||||
#include "services/owncloud/owncloudserviceentrypoint.h"
|
||||
|
||||
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent), CacheForServiceRoot(), m_recycleBin(new OwnCloudRecycleBin(this)),
|
||||
: ServiceRoot(parent), CacheForServiceRoot(),
|
||||
m_actionSyncIn(nullptr), m_serviceMenu(QList<QAction*>()), m_network(new OwnCloudNetworkFactory()) {
|
||||
setIcon(OwnCloudServiceEntryPoint().icon());
|
||||
}
|
||||
@ -85,10 +85,6 @@ QList<QAction*> OwnCloudServiceRoot::serviceMenu() {
|
||||
return m_serviceMenu;
|
||||
}
|
||||
|
||||
RecycleBin* OwnCloudServiceRoot::recycleBin() const {
|
||||
return m_recycleBin;
|
||||
}
|
||||
|
||||
void OwnCloudServiceRoot::start(bool freshly_activated) {
|
||||
Q_UNUSED(freshly_activated)
|
||||
loadFromDatabase();
|
||||
@ -298,6 +294,6 @@ void OwnCloudServiceRoot::loadFromDatabase() {
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(m_recycleBin);
|
||||
appendChild(recycleBin());
|
||||
updateCounts(true);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QMap>
|
||||
|
||||
class OwnCloudNetworkFactory;
|
||||
class OwnCloudRecycleBin;
|
||||
class Mutex;
|
||||
|
||||
class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||
@ -42,7 +41,6 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||
bool supportsFeedAdding() const;
|
||||
bool supportsCategoryAdding() const;
|
||||
QList<QAction*> serviceMenu();
|
||||
RecycleBin* recycleBin() const;
|
||||
|
||||
void start(bool freshly_activated);
|
||||
void stop();
|
||||
@ -70,7 +68,6 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||
|
||||
void loadFromDatabase();
|
||||
|
||||
OwnCloudRecycleBin* m_recycleBin;
|
||||
QAction* m_actionSyncIn;
|
||||
|
||||
QList<QAction*> m_serviceMenu;
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <QStack>
|
||||
|
||||
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent), m_recycleBin(new RecycleBin(this)),
|
||||
: ServiceRoot(parent),
|
||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_serviceMenu(QList<QAction*>()),
|
||||
m_feedContextMenu(QList<QAction*>()), m_actionFeedFetchMetadata(nullptr) {
|
||||
setTitle(qApp->system()->loggedInUser() + QL1S("@") + QL1S(APP_LOW_NAME));
|
||||
@ -161,10 +161,6 @@ Qt::ItemFlags StandardServiceRoot::additionalFlags() const {
|
||||
return Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
RecycleBin* StandardServiceRoot::recycleBin() const {
|
||||
return m_recycleBin;
|
||||
}
|
||||
|
||||
void StandardServiceRoot::loadFromDatabase() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
Assignment categories = DatabaseQueries::getCategories(database, accountId());
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QPair>
|
||||
|
||||
class RecycleBin;
|
||||
class StandardCategory;
|
||||
class StandardFeed;
|
||||
class FeedsImportExportModel;
|
||||
@ -52,9 +51,6 @@ class StandardServiceRoot : public ServiceRoot {
|
||||
QVariant data(int column, int role) const;
|
||||
Qt::ItemFlags additionalFlags() const;
|
||||
|
||||
// Access to recycle bin.
|
||||
RecycleBin* recycleBin() const;
|
||||
|
||||
// Returns menu to be shown in "Services -> service" menu.
|
||||
QList<QAction*> serviceMenu();
|
||||
|
||||
@ -79,7 +75,6 @@ class StandardServiceRoot : public ServiceRoot {
|
||||
QString processFeedUrl(const QString& feed_url);
|
||||
void checkArgumentsForFeedAdding();
|
||||
|
||||
RecycleBin* m_recycleBin;
|
||||
QAction* m_actionExportFeeds;
|
||||
QAction* m_actionImportFeeds;
|
||||
|
||||
|
@ -25,13 +25,13 @@
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
#include "services/tt-rss/definitions.h"
|
||||
#include "services/tt-rss/gui/formeditttrssaccount.h"
|
||||
#include "services/tt-rss/gui/formttrssfeeddetails.h"
|
||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||
#include "services/tt-rss/ttrsscategory.h"
|
||||
#include "services/tt-rss/ttrssfeed.h"
|
||||
#include "services/tt-rss/ttrssrecyclebin.h"
|
||||
#include "services/tt-rss/ttrssserviceentrypoint.h"
|
||||
|
||||
#include <QClipboard>
|
||||
@ -39,7 +39,7 @@
|
||||
#include <QSqlTableModel>
|
||||
|
||||
TtRssServiceRoot::TtRssServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent), CacheForServiceRoot(), m_recycleBin(new TtRssRecycleBin(this)),
|
||||
: ServiceRoot(parent), CacheForServiceRoot(),
|
||||
m_actionSyncIn(nullptr), m_serviceMenu(QList<QAction*>()), m_network(new TtRssNetworkFactory()) {
|
||||
setIcon(TtRssServiceEntryPoint().icon());
|
||||
}
|
||||
@ -153,10 +153,6 @@ QVariant TtRssServiceRoot::data(int column, int role) const {
|
||||
}
|
||||
}
|
||||
|
||||
RecycleBin* TtRssServiceRoot::recycleBin() const {
|
||||
return m_recycleBin;
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::saveAllCachedData() {
|
||||
QPair<QMap<RootItem::ReadStatus, QStringList>, QMap<RootItem::Importance, QList<Message>>> msgCache = takeMessageCache();
|
||||
QMapIterator<RootItem::ReadStatus, QStringList> i(msgCache.first);
|
||||
@ -280,7 +276,7 @@ void TtRssServiceRoot::loadFromDatabase() {
|
||||
assembleFeeds(feeds);
|
||||
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(m_recycleBin);
|
||||
appendChild(recycleBin());
|
||||
updateCounts(true);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
class TtRssCategory;
|
||||
class TtRssFeed;
|
||||
class TtRssNetworkFactory;
|
||||
class TtRssRecycleBin;
|
||||
|
||||
class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||
Q_OBJECT
|
||||
@ -48,7 +47,6 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||
bool supportsCategoryAdding() const;
|
||||
QVariant data(int column, int role) const;
|
||||
QList<QAction*> serviceMenu();
|
||||
RecycleBin* recycleBin() const;
|
||||
|
||||
void saveAllCachedData();
|
||||
|
||||
@ -73,7 +71,6 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||
|
||||
void loadFromDatabase();
|
||||
|
||||
TtRssRecycleBin* m_recycleBin;
|
||||
QAction* m_actionSyncIn;
|
||||
|
||||
QList<QAction*> m_serviceMenu;
|
||||
|
Loading…
x
Reference in New Issue
Block a user