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