diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 828dac9ef..e5ec5416d 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -440,11 +440,7 @@ Feed *FeedsModel::feedForIndex(const QModelIndex &index) { } bool FeedsModel::markItemRead(RootItem *item, RootItem::ReadStatus read) { - if (item->canBeMarkedAsReadUnread(read)) { - return item->markAsReadUnread(read); - } - - return false; + return item->markAsReadUnread(read); } bool FeedsModel::markItemCleared(RootItem *item, bool clean_read_only) { diff --git a/src/core/rootitem.cpp b/src/core/rootitem.cpp index 6cd3d9412..4b4ef2493 100755 --- a/src/core/rootitem.cpp +++ b/src/core/rootitem.cpp @@ -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(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::getSubTree() { QList children; QList traversable_items; diff --git a/src/core/rootitem.h b/src/core/rootitem.h index b44864276..d16f3a08a 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -74,19 +74,33 @@ class RootItem : public QObject { // NOTE: Ownership of returned actions is not switched to caller, free them when needed. virtual QList 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 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 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 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(); diff --git a/src/services/standard/standardrecyclebin.h b/src/services/standard/standardrecyclebin.h index 7cbbf2d59..24ec68591 100755 --- a/src/services/standard/standardrecyclebin.h +++ b/src/services/standard/standardrecyclebin.h @@ -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();