rssguard/src/core/feedsmodelrootitem.h

72 lines
2.0 KiB
C
Raw Normal View History

2013-12-23 10:43:45 +01:00
#ifndef FEEDSMODELROOTITEM_H
#define FEEDSMODELROOTITEM_H
2013-12-11 14:07:18 +01:00
2013-12-12 08:27:05 +01:00
#include <QIcon>
2013-12-11 14:07:18 +01:00
// Represents ROOT item of FeedsModel.
// NOTE: This class is derived to add functionality for
2013-12-12 08:27:05 +01:00
// all other non-root items of FeedsModel.
class FeedsModelRootItem {
2013-12-11 14:07:18 +01:00
public:
2013-12-16 10:22:23 +01:00
// Describes the kind of the item.
2013-12-16 09:11:14 +01:00
enum Kind {
2013-12-16 12:53:48 +01:00
RootItem = 1001,
Feed = 1002,
Category = 1003
2013-12-16 09:11:14 +01:00
};
2013-12-11 14:07:18 +01:00
// Constructors and destructors.
2013-12-12 15:07:17 +01:00
explicit FeedsModelRootItem(FeedsModelRootItem *parent_item = NULL);
2013-12-11 14:07:18 +01:00
virtual ~FeedsModelRootItem();
2013-12-14 18:54:35 +01:00
// Basic operations.
2013-12-28 17:40:22 +01:00
virtual FeedsModelRootItem *parent() const;
2013-12-16 10:22:23 +01:00
virtual void setParent(FeedsModelRootItem *parent_item);
2013-12-12 08:27:05 +01:00
virtual FeedsModelRootItem *child(int row);
2013-12-12 10:10:17 +01:00
virtual void appendChild(FeedsModelRootItem *child);
2013-12-12 08:27:05 +01:00
virtual int childCount() const;
virtual int columnCount() const;
virtual int row() const;
virtual QVariant data(int column, int role) const;
2013-12-11 14:07:18 +01:00
2013-12-14 18:54:35 +01:00
// Each item offers "counts" of messages.
2013-12-12 22:28:51 +01:00
virtual int countOfUnreadMessages() const;
virtual int countOfAllMessages() const;
2013-12-16 09:11:14 +01:00
virtual Kind kind() const;
2013-12-14 18:54:35 +01:00
// Each item has icon.
2013-12-28 16:44:21 +01:00
QIcon icon() const;
2013-12-13 16:35:52 +01:00
void setIcon(const QIcon &icon);
2013-12-14 18:54:35 +01:00
// Each item has some kind of id.
2013-12-13 20:48:45 +01:00
int id() const;
void setId(int id);
2013-12-16 10:22:23 +01:00
// Each item has its title.
// NOTE: This is note entirely true for the root item.
2013-12-16 09:11:14 +01:00
QString title() const;
void setTitle(const QString &title);
2013-12-23 10:43:45 +01:00
// Access to children.
2013-12-16 10:22:23 +01:00
QList<FeedsModelRootItem *> childItems() const;
// Removes all childs from this item.
void clearChilds();
// Compares two model items.
static bool isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs);
static bool lessThan(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs);
2013-12-11 14:07:18 +01:00
protected:
2013-12-16 09:11:14 +01:00
Kind m_kind;
QString m_title;
2013-12-13 20:48:45 +01:00
int m_id;
2013-12-12 08:27:05 +01:00
QIcon m_icon;
QList<FeedsModelRootItem*> m_childItems;
2013-12-12 10:10:17 +01:00
FeedsModelRootItem *m_parentItem;
2013-12-11 14:07:18 +01:00
};
#endif // FEEDMODELROOTITEM_H