Work on messages/recycle bin handling.
This commit is contained in:
parent
8eb34100a4
commit
b7f6666e62
@ -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
|
||||
|
43
src/services/abstract/recyclebin.cpp
Normal file
43
src/services/abstract/recyclebin.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
37
src/services/abstract/recyclebin.h
Normal file
37
src/services/abstract/recyclebin.h
Normal file
@ -0,0 +1,37 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
@ -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<StandardServiceRoot*>(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);
|
||||
}
|
||||
|
@ -15,17 +15,17 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef RECYCLEBIN_H
|
||||
#define RECYCLEBIN_H
|
||||
#ifndef STANDARDRECYCLEBIN_H
|
||||
#define STANDARDRECYCLEBIN_H
|
||||
|
||||
#include "core/rootitem.h"
|
||||
#include "services/abstract/recyclebin.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user