diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp old mode 100644 new mode 100755 index 9e4c2f058..2bcbe5544 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -36,14 +36,6 @@ void FeedsModelCategory::setType(const Type &type) { m_type = type; } -QString FeedsModelCategory::title() const { - return m_title; -} - -void FeedsModelCategory::setTitle(const QString &title) { - m_title = title; -} - QString FeedsModelCategory::description() const { return m_description; } diff --git a/src/core/feedsmodelcategory.h b/src/core/feedsmodelcategory.h old mode 100644 new mode 100755 index 9d6459112..99311ba62 --- a/src/core/feedsmodelcategory.h +++ b/src/core/feedsmodelcategory.h @@ -33,9 +33,6 @@ class FeedsModelCategory : public FeedsModelRootItem { Type type() const; void setType(const Type &type); - QString title() const; - void setTitle(const QString &title); - QString description() const; void setDescription(const QString &description); @@ -44,7 +41,6 @@ class FeedsModelCategory : public FeedsModelRootItem { protected: Type m_type; - QString m_title; QDateTime m_creationDate; QString m_description; }; diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp old mode 100644 new mode 100755 index 7bffba50e..a913c44d0 --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feedsmodelfeed.cpp @@ -33,11 +33,3 @@ FeedsModelFeed::Type FeedsModelFeed::type() const { void FeedsModelFeed::setType(const Type &type) { m_type = type; } - -void FeedsModelFeed::setTitle(const QString &title) { - m_title = title; -} - -QString FeedsModelFeed::title() const { - return m_title; -} diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h old mode 100644 new mode 100755 index c92bac769..1eabaa5ec --- a/src/core/feedsmodelfeed.h +++ b/src/core/feedsmodelfeed.h @@ -33,12 +33,8 @@ class FeedsModelFeed : public FeedsModelRootItem { Type type() const; void setType(const Type &type); - QString title() const; - void setTitle(const QString &title); - protected: Type m_type; - QString m_title; int m_totalCount; int m_unreadCount; }; diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp old mode 100644 new mode 100755 index 398700389..2eaffd6e0 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -4,7 +4,7 @@ FeedsModelRootItem::FeedsModelRootItem(FeedsModelRootItem *parent_item) - : m_parentItem(parent_item) { + : m_kind(FeedsModelRootItem::RootItem), m_parentItem(parent_item) { } FeedsModelRootItem::~FeedsModelRootItem() { @@ -23,6 +23,10 @@ void FeedsModelRootItem::setParent(FeedsModelRootItem *parent_item) { void FeedsModelRootItem::update() { } +FeedsModelRootItem::Kind FeedsModelRootItem::kind() const { + return m_kind; +} + FeedsModelRootItem *FeedsModelRootItem::child(int row) { return m_childItems.value(row); } @@ -75,3 +79,12 @@ int FeedsModelRootItem::id() const { void FeedsModelRootItem::setId(int id) { m_id = id; } + +QString FeedsModelRootItem::title() const { + return m_title; +} + +void FeedsModelRootItem::setTitle(const QString &title) { + m_title = title; +} + diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h old mode 100644 new mode 100755 index bdb11c236..016e6b669 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -11,6 +11,12 @@ class FeedsModelRootItem { friend class FeedsModel; public: + enum Kind { + RootItem, + Feed, + Category + }; + // Constructors and destructors. explicit FeedsModelRootItem(FeedsModelRootItem *parent_item = NULL); virtual ~FeedsModelRootItem(); @@ -32,6 +38,8 @@ class FeedsModelRootItem { // Each item can be "updated". virtual void update(); + virtual Kind kind() const; + // Each item has icon. void setIcon(const QIcon &icon); @@ -39,7 +47,12 @@ class FeedsModelRootItem { int id() const; void setId(int id); + QString title() const; + void setTitle(const QString &title); + protected: + Kind m_kind; + QString m_title; int m_id; QIcon m_icon; QList m_childItems; diff --git a/src/core/feedsmodelstandardcategory.cpp b/src/core/feedsmodelstandardcategory.cpp old mode 100644 new mode 100755 index 4ef2d50ba..6d76ee59e --- a/src/core/feedsmodelstandardcategory.cpp +++ b/src/core/feedsmodelstandardcategory.cpp @@ -8,6 +8,7 @@ FeedsModelStandardCategory::FeedsModelStandardCategory(FeedsModelRootItem *parent_item) : FeedsModelCategory(parent_item) { + m_kind = FeedsModelRootItem::Category; m_type = Standard; } diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp old mode 100644 new mode 100755 index 6a3f112f4..cfe737709 --- a/src/core/feedsmodelstandardfeed.cpp +++ b/src/core/feedsmodelstandardfeed.cpp @@ -8,6 +8,7 @@ FeedsModelStandardFeed::FeedsModelStandardFeed(FeedsModelRootItem *parent_item) : FeedsModelFeed(parent_item) { + m_kind = FeedsModelRootItem::Category; } FeedsModelStandardFeed::~FeedsModelStandardFeed() { diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp old mode 100644 new mode 100755 index 20cd2a3a8..d27781601 --- a/src/core/feedsproxymodel.cpp +++ b/src/core/feedsproxymodel.cpp @@ -9,13 +9,11 @@ FeedsProxyModel::FeedsProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { m_sourceModel = new FeedsModel(this); - - setObjectName("FeedsProxyModel"); setSortRole(Qt::EditRole); setSortCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive); - setFilterKeyColumn(-1); + setFilterKeyColumn(0); setFilterRole(Qt::EditRole); setDynamicSortFilter(true); setSourceModel(m_sourceModel); @@ -32,34 +30,27 @@ FeedsModel *FeedsProxyModel::sourceModel() { bool FeedsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { if (left.isValid() && right.isValid()) { + // Make necessary castings. FeedsModelRootItem *left_item = static_cast(left.internalPointer()); FeedsModelRootItem *right_item = static_cast(right.internalPointer()); - FeedsModelFeed *left_feed = dynamic_cast(left_item); - FeedsModelFeed *right_feed = dynamic_cast(right_item); + // NOTE: Here we want to accomplish that ALL + // categories are queued one after another and all + // feeds are queued one after another too. + // Moreover, sort everything alphabetically. - FeedsModelCategory *left_category = dynamic_cast(left_item); - FeedsModelCategory *right_category = dynamic_cast(right_item); - - if (left_feed != NULL && right_feed != NULL) { - // Both items are feeds. - return left_feed->title() < right_feed->title(); + if (left_item->kind() == right_item->kind()) { + // Both items are feeds or both items are categories. + return left_item->title() < right_item->title(); } - else if (left_category != NULL && right_category != NULL) { - // Both items are categories. - return left_category->title() < right_category->title(); - } - else if (left_feed != NULL) { + else if (left_item->kind() == FeedsModelRootItem::Feed) { // Left item is feed, right item is category. return false; } else { - // Left item is category, right item is feed. + // Left item is category, right item is feed.*/ return true; } - - - return true; } else { return false; diff --git a/src/core/feedsproxymodel.h b/src/core/feedsproxymodel.h old mode 100644 new mode 100755 index 9a08ba1b7..e8743a5b7 --- a/src/core/feedsproxymodel.h +++ b/src/core/feedsproxymodel.h @@ -14,6 +14,7 @@ class FeedsProxyModel : public QSortFilterProxyModel { explicit FeedsProxyModel(QObject *parent = 0); virtual ~FeedsProxyModel(); + // Access to the source model. FeedsModel *sourceModel(); protected: diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index c045f483e..d00d874cf 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -184,6 +184,7 @@ void FormMain::setupIcons() { m_ui->m_actionDeleteSelectedFeeds->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete")); m_ui->m_actionDeleteSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-delete")); + m_ui->m_actionAddNewCategory->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new")); m_ui->m_actionAddNewFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("document-new")); m_ui->m_actionEditSelectedFeed->setIcon(IconThemeFactory::getInstance()->fromTheme("document-properties")); m_ui->m_actionMarkAllMessagesAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-read"));