diff --git a/CMakeLists.txt b/CMakeLists.txt index ccf63113f..2778f9960 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -419,6 +419,7 @@ set(APP_SOURCES src/services/abstract/feed.cpp src/services/abstract/category.cpp src/services/abstract/serviceroot.cpp + src/services/abstract/recyclebin.cpp # STANDARD feed service sources. src/services/standard/gui/formstandardcategorydetails.cpp @@ -535,6 +536,7 @@ set(APP_HEADERS src/services/abstract/feed.h src/services/abstract/category.h src/services/abstract/serviceroot.h + src/services/abstract/recyclebin.h # STANDARD service headers. src/services/standard/standardfeedsimportexportmodel.h diff --git a/src/core/rootitem.h b/src/core/rootitem.h index 0f36a8d6e..ef47662f5 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -32,7 +32,7 @@ namespace RootItemKind { // Describes the kind of the item. enum Kind { Root = 1, - Bin = 2, + Bin = 2, Feed = 4, Category = 8, ServiceRoot = 16 diff --git a/src/services/abstract/recyclebin.cpp b/src/services/abstract/recyclebin.cpp new file mode 100644 index 000000000..042c5c989 --- /dev/null +++ b/src/services/abstract/recyclebin.cpp @@ -0,0 +1,43 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 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/abstract/recyclebin.h" + +#include "miscellaneous/application.h" +#include "miscellaneous/iconfactory.h" + + +RecycleBin::RecycleBin(RootItem *parent_item) : RootItem(parent_item) { + setKind(RootItemKind::Bin); + setIcon(qApp->icons()->fromTheme(QSL("folder-recycle-bin"))); + setTitle(tr("Recycle bin")); + setDescription(tr("Recycle bin contains all deleted messages from all feeds.")); + setCreationDate(QDateTime::currentDateTime()); +} + +RecycleBin::~RecycleBin() { +} + +QVariant RecycleBin::data(int column, int role) const { + switch (role) { + case Qt::ToolTipRole: + return tr("Recycle bin\n%1").arg(tr("%n deleted message(s).", 0, countOfAllMessages())); + + default: + return RootItem::data(column, role); + } +} diff --git a/src/services/abstract/recyclebin.h b/src/services/abstract/recyclebin.h new file mode 100644 index 000000000..ef347b010 --- /dev/null +++ b/src/services/abstract/recyclebin.h @@ -0,0 +1,37 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 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 . + +#ifndef RECYCLEBIN_H +#define RECYCLEBIN_H + +#include "core/rootitem.h" + + +class RecycleBin : public RootItem { + Q_OBJECT + + public: + explicit RecycleBin(RootItem *parent_item = NULL); + virtual ~RecycleBin(); + + QVariant data(int column, int role) const; + + virtual bool empty() = 0; + virtual bool restore() = 0; +}; + +#endif // RECYCLEBIN_H diff --git a/src/services/standard/standardrecyclebin.cpp b/src/services/standard/standardrecyclebin.cpp index 61a8a8c52..c82b90e8a 100755 --- a/src/services/standard/standardrecyclebin.cpp +++ b/src/services/standard/standardrecyclebin.cpp @@ -25,13 +25,8 @@ StandardRecycleBin::StandardRecycleBin(RootItem *parent) - : RootItem(parent) { - setKind(RootItemKind::Bin); - setIcon(qApp->icons()->fromTheme(QSL("folder-recycle-bin"))); + : RecycleBin(parent) { setId(ID_RECYCLE_BIN); - setTitle(tr("Recycle bin")); - setDescription(tr("Recycle bin contains all deleted messages from all feeds.")); - setCreationDate(QDateTime::currentDateTime()); updateCounts(true); } @@ -43,14 +38,6 @@ StandardServiceRoot *StandardRecycleBin::serviceRoot() { return static_cast(getParentServiceRoot()); } -int StandardRecycleBin::childCount() const { - return 0; -} - -void StandardRecycleBin::appendChild(RootItem *child) { - Q_UNUSED(child) -} - int StandardRecycleBin::countOfUnreadMessages() const { return m_unreadCount; } @@ -59,16 +46,6 @@ int StandardRecycleBin::countOfAllMessages() const { return m_totalCount; } -QVariant StandardRecycleBin::data(int column, int role) const { - switch (role) { - case Qt::ToolTipRole: - return tr("Recycle bin\n%1").arg(tr("%n deleted message(s).", 0, countOfAllMessages())); - - default: - return RootItem::data(column, role); - } -} - bool StandardRecycleBin::markAsReadUnread(RootItem::ReadStatus status) { return serviceRoot()->markRecycleBinReadUnread(status); } diff --git a/src/services/standard/standardrecyclebin.h b/src/services/standard/standardrecyclebin.h index 24ec68591..fb3794e4b 100755 --- a/src/services/standard/standardrecyclebin.h +++ b/src/services/standard/standardrecyclebin.h @@ -15,17 +15,17 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#ifndef RECYCLEBIN_H -#define RECYCLEBIN_H +#ifndef STANDARDRECYCLEBIN_H +#define STANDARDRECYCLEBIN_H -#include "core/rootitem.h" +#include "services/abstract/recyclebin.h" #include class StandardServiceRoot; -class StandardRecycleBin : public RootItem { +class StandardRecycleBin : public RecycleBin { Q_OBJECT public: @@ -34,12 +34,9 @@ class StandardRecycleBin : public RootItem { StandardServiceRoot *serviceRoot(); - int childCount() const; - void appendChild(RootItem *child); int countOfUnreadMessages() const; int countOfAllMessages() const; - QVariant data(int column, int role) const; - bool markAsReadUnread(ReadStatus status); + bool markAsReadUnread(RootItem::ReadStatus status); bool empty(); bool restore(); @@ -52,4 +49,4 @@ class StandardRecycleBin : public RootItem { int m_unreadCount; }; -#endif // RECYCLEBIN_H +#endif // STANDARDRECYCLEBIN_H