sHIt.¨
This commit is contained in:
parent
86095778a3
commit
6aaec164f1
@ -440,13 +440,9 @@ Feed *FeedsModel::feedForIndex(const QModelIndex &index) {
|
||||
}
|
||||
|
||||
bool FeedsModel::markItemRead(RootItem *item, RootItem::ReadStatus read) {
|
||||
if (item->canBeMarkedAsReadUnread(read)) {
|
||||
return item->markAsReadUnread(read);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FeedsModel::markItemCleared(RootItem *item, bool clean_read_only) {
|
||||
return item->cleanMessages(clean_read_only);
|
||||
}
|
||||
|
@ -100,22 +100,6 @@ void RootItem::setupFonts() {
|
||||
m_boldFont.setBold(true);
|
||||
}
|
||||
|
||||
QFont RootItem::boldFont() const {
|
||||
return m_boldFont;
|
||||
}
|
||||
|
||||
void RootItem::setBoldFont(const QFont &bold_font) {
|
||||
m_boldFont = bold_font;
|
||||
}
|
||||
|
||||
QFont RootItem::normalFont() const {
|
||||
return m_normalFont;
|
||||
}
|
||||
|
||||
void RootItem::setNormalFont(const QFont &normal_font) {
|
||||
m_normalFont = normal_font;
|
||||
}
|
||||
|
||||
int RootItem::row() const {
|
||||
if (m_parentItem) {
|
||||
return m_parentItem->m_childItems.indexOf(const_cast<RootItem*>(this));
|
||||
@ -133,7 +117,7 @@ QVariant RootItem::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::EditRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return title();
|
||||
return m_title;
|
||||
}
|
||||
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||
return countOfUnreadMessages();
|
||||
@ -143,11 +127,11 @@ QVariant RootItem::data(int column, int role) const {
|
||||
}
|
||||
|
||||
case Qt::FontRole:
|
||||
return countOfUnreadMessages() > 0 ? boldFont() : normalFont();
|
||||
return countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
|
||||
|
||||
case Qt::DisplayRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return title();
|
||||
return m_title;
|
||||
}
|
||||
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||
int count_all = countOfAllMessages();
|
||||
@ -192,6 +176,34 @@ int RootItem::countOfAllMessages() const {
|
||||
return total_count;
|
||||
}
|
||||
|
||||
bool RootItem::isChildOf(RootItem *root) {
|
||||
if (root == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootItem *this_item = this;
|
||||
|
||||
while (this_item->kind() != RootItemKind::Root) {
|
||||
if (root->childItems().contains(this_item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
this_item = this_item->parent();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RootItem::isParentOf(RootItem *child) {
|
||||
if (child == NULL) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return child->isChildOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
QList<RootItem*> RootItem::getSubTree() {
|
||||
QList<RootItem*> children;
|
||||
QList<RootItem*> traversable_items;
|
||||
|
@ -74,19 +74,33 @@ class RootItem : public QObject {
|
||||
// NOTE: Ownership of returned actions is not switched to caller, free them when needed.
|
||||
virtual QList<QAction*> contextMenuActions();
|
||||
|
||||
// Can properties of this item be edited?
|
||||
virtual bool canBeEdited();
|
||||
|
||||
// Performs editing of properties of this item (probably via dialog)
|
||||
// and returns result status.
|
||||
virtual bool editViaGui();
|
||||
|
||||
// Can the item be deleted?
|
||||
virtual bool canBeDeleted();
|
||||
|
||||
// Performs deletion of the item, this
|
||||
// method should NOT display any additional dialogs.
|
||||
// Returns result status.
|
||||
virtual bool deleteViaGui();
|
||||
|
||||
// Can this item be marked read/unread?
|
||||
virtual bool canBeMarkedAsReadUnread(ReadStatus status);
|
||||
|
||||
// Performs all needed steps (DB update, remote server update)
|
||||
// to mark this item as read/unread.
|
||||
virtual bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
// This method should "clean" all messages it contains.
|
||||
// What "clean" means? It means delete message -> move them to recycle bin
|
||||
// What "clean" means? It means delete messages -> move them to recycle bin
|
||||
// or eventually remove them completely if there is no recycle bin functionality.
|
||||
// If this method is called on "recycle bin" instance of your
|
||||
// service account, it should not do anything.
|
||||
// service account, it should NOT do anything.
|
||||
virtual bool cleanMessages(bool clear_only_read);
|
||||
|
||||
// Updates counts of all/unread messages for this feed.
|
||||
@ -104,7 +118,6 @@ class RootItem : public QObject {
|
||||
// Members to override. */
|
||||
/////////////////////////////////////////
|
||||
|
||||
// Basic operations.
|
||||
inline RootItem *parent() const {
|
||||
return m_parentItem;
|
||||
}
|
||||
@ -131,47 +144,28 @@ class RootItem : public QObject {
|
||||
return m_childItems;
|
||||
}
|
||||
|
||||
inline void setChildItems(QList<RootItem*> child_items) {
|
||||
m_childItems = child_items;
|
||||
}
|
||||
|
||||
// Checks whether THIS object is child (direct or indirect)
|
||||
// of the given root.
|
||||
bool isChildOf(RootItem *root) {
|
||||
if (root == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootItem *this_item = this;
|
||||
|
||||
while (this_item->kind() != RootItemKind::Root) {
|
||||
if (root->childItems().contains(this_item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
this_item = this_item->parent();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is "this" item parent if given child?
|
||||
bool isParentOf(RootItem *child) {
|
||||
if (child == NULL) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return child->isChildOf(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Removes all children from this item.
|
||||
// NOTE: Children are NOT freed from the memory.
|
||||
inline void clearChildren() {
|
||||
m_childItems.clear();
|
||||
}
|
||||
|
||||
inline void setChildItems(QList<RootItem*> child_items) {
|
||||
m_childItems = child_items;
|
||||
}
|
||||
|
||||
// Removes particular child at given index.
|
||||
// NOTE: Child is NOT freed from the memory.
|
||||
bool removeChild(int index);
|
||||
bool removeChild(RootItem *child);
|
||||
|
||||
// Checks whether "this" object is child (direct or indirect)
|
||||
// of the given root.
|
||||
bool isChildOf(RootItem *root);
|
||||
|
||||
// Is "this" item parent (direct or indirect) if given child?
|
||||
bool isParentOf(RootItem *child);
|
||||
|
||||
// Returns flat list of all items from subtree where this item is a root.
|
||||
// Returned list includes this item too.
|
||||
QList<RootItem*> getSubTree();
|
||||
@ -182,11 +176,6 @@ class RootItem : public QObject {
|
||||
// Returns the service root node which is direct or indirect parent of current item.
|
||||
ServiceRoot *getParentServiceRoot();
|
||||
|
||||
// Removes particular child at given index.
|
||||
// NOTE: Child is NOT freed from the memory.
|
||||
bool removeChild(int index);
|
||||
bool removeChild(RootItem *child);
|
||||
|
||||
inline RootItemKind::Kind kind() const {
|
||||
return m_kind;
|
||||
}
|
||||
@ -238,11 +227,21 @@ class RootItem : public QObject {
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
QFont normalFont() const;
|
||||
void setNormalFont(const QFont &normal_font);
|
||||
inline QFont normalFont() const {
|
||||
return m_normalFont;
|
||||
}
|
||||
|
||||
QFont boldFont() const;
|
||||
void setBoldFont(const QFont &bold_font);
|
||||
inline void setNormalFont(const QFont &normal_font) {
|
||||
m_normalFont = normal_font;
|
||||
}
|
||||
|
||||
inline QFont boldFont() const {
|
||||
return m_boldFont;
|
||||
}
|
||||
|
||||
inline void setBoldFont(const QFont &bold_font) {
|
||||
m_boldFont = bold_font;
|
||||
}
|
||||
|
||||
// Converters
|
||||
Category *toCategory();
|
||||
|
@ -39,7 +39,6 @@ class StandardRecycleBin : public RootItem {
|
||||
int countOfUnreadMessages() const;
|
||||
int countOfAllMessages() const;
|
||||
QVariant data(int column, int role) const;
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
|
||||
bool empty();
|
||||
|
Loading…
x
Reference in New Issue
Block a user