diff --git a/README.md b/README.md index 0ab270a00..716888781 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,4 @@ RSS Guard is written in C++. It is pretty fast even with tons of messages loaded Philosophy ---------- -RSS Guard tends to be independent software. It's free, it's open-source. RSS Guard will never depend on other services - this includes online news aggregators like Feedly, The Old Reader and others. - -That's why RSS Guard will never integrate those services unless someone else codes support for them on his own. Remember, RSS Guard supports online synchronization via MySQL/MariaDB or you can use Dropbox to synchronize SQLite data storage. \ No newline at end of file +RSS Guard tends to be independent software. It's free, it's open-source. RSS Guard accepts donations but only to SUPPORT its development. \ No newline at end of file diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 826eb2d6e..feea8347a 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -416,8 +416,7 @@ void FeedsModel::loadActivatedServiceAccounts() { } QList FeedsModel::feedsForIndex(const QModelIndex &index) { - RootItem *item = itemForIndex(index); - return feedsForItem(item); + return itemForIndex(index)->getSubTreeFeeds(); } Feed *FeedsModel::feedForIndex(const QModelIndex &index) { @@ -535,35 +534,9 @@ bool FeedsModel::markFeedsDeleted(const QList &feeds, int deleted, bool r } QList FeedsModel::allFeeds() { - return feedsForItem(m_rootItem); -} - -QList FeedsModel::feedsForItem(RootItem *root) { - QList children = root->getSubTree(); - QList feeds; - - foreach (RootItem *child, children) { - if (child->kind() == RootItemKind::Feed) { - feeds.append(child->toFeed()); - } - } - - return feeds; + return m_rootItem->getSubTreeFeeds(); } QList FeedsModel::allCategories() { - return categoriesForItem(m_rootItem); -} - -QList FeedsModel::categoriesForItem(RootItem *root) { - QList children = root->getSubTree(); - QList categories; - - foreach (RootItem *child, children) { - if (child->kind() == RootItemKind::Category) { - categories.append(child->toCategory()); - } - } - - return categories; + return m_rootItem->getSubTreeCategories(); } diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 57f413307..c7540410b 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -83,17 +83,9 @@ class FeedsModel : public QAbstractItemModel { // Returns list of all categories contained in the model. QList allCategories(); - // Get list of categories from tree with particular item - // as root. - QList categoriesForItem(RootItem *root); - // Returns list of all feeds contained in the model. QList allFeeds(); - // Get list of feeds from tree with particular item - // as root. - QList feedsForItem(RootItem *root); - // Returns list of ALL CHILD feeds which belong to given parent indexes. //QList feedsForIndexes(const QModelIndexList &indexes); diff --git a/src/core/feedsselection.cpp b/src/core/feedsselection.cpp index 8b3b1c31d..c21d6e0ac 100755 --- a/src/core/feedsselection.cpp +++ b/src/core/feedsselection.cpp @@ -58,13 +58,11 @@ RootItem *FeedsSelection::selectedItem() const { QString FeedsSelection::generateListOfIds() { if (m_selectedItem != NULL && (m_selectedItem->kind() == RootItemKind::Feed || m_selectedItem->kind() == RootItemKind::Category)) { - QList children = m_selectedItem->getSubTree(); + QList children = m_selectedItem->getSubTreeFeeds(); QStringList stringy_ids; - foreach (RootItem *child, children) { - if (child->kind() == RootItemKind::Feed) { - stringy_ids.append(QString::number(child->id())); - } + foreach (Feed *child, children) { + stringy_ids.append(QString::number(child->id())); } return stringy_ids.join(QSL(", ")); diff --git a/src/core/rootitem.cpp b/src/core/rootitem.cpp index 1192110bd..a6b13d141 100755 --- a/src/core/rootitem.cpp +++ b/src/core/rootitem.cpp @@ -76,13 +76,11 @@ int RootItem::countOfAllMessages() const { QList RootItem::getSubTree() { QList children; - - // Root itself is a CATEGORY or ROOT item. QList traversable_items; traversable_items.append(this); - // Iterate all nested categories. + // Iterate all nested items. while (!traversable_items.isEmpty()) { RootItem *active_item = traversable_items.takeFirst(); @@ -93,6 +91,46 @@ QList RootItem::getSubTree() { return children; } +QList RootItem::getSubTreeCategories() { + QList children; + QList traversable_items; + + traversable_items.append(this); + + // Iterate all nested items. + while (!traversable_items.isEmpty()) { + RootItem *active_item = traversable_items.takeFirst(); + + if (active_item->kind() == RootItemKind::Category) { + children.append(active_item->toCategory()); + } + + traversable_items.append(active_item->childItems()); + } + + return children; +} + +QList RootItem::getSubTreeFeeds() { + QList children; + QList traversable_items; + + traversable_items.append(this); + + // Iterate all nested items. + while (!traversable_items.isEmpty()) { + RootItem *active_item = traversable_items.takeFirst(); + + if (active_item->kind() == RootItemKind::Feed) { + children.append(active_item->toFeed()); + } + + traversable_items.append(active_item->childItems()); + } + + return children; +} + bool RootItem::removeChild(RootItem *child) { return m_childItems.removeOne(child); } diff --git a/src/core/rootitem.h b/src/core/rootitem.h index 8f6988be0..9491033e0 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -67,15 +67,21 @@ class RootItem { child->setParent(this); } + // TODO: pracovat s těmito věcmi virtual bool canBeEdited() { return false; } + virtual bool editViaDialog() { + return false; + } + virtual bool canBeDeleted() { return false; } - virtual void editViaDialog() { + virtual bool deleteViaGui() { + return false; } virtual int row() const; @@ -141,6 +147,8 @@ class RootItem { // Returns flat list of all items from subtree where this item is a root. // Returned list includes this item too. QList getSubTree(); + QList getSubTreeCategories(); + QList getSubTreeFeeds(); // Removes particular child at given index. // NOTE: Child is NOT freed from the memory. @@ -151,7 +159,7 @@ class RootItem { return m_kind; } - // Each item has icon. + // Each item can have icon. inline QIcon icon() const { return m_icon; } diff --git a/src/services/abstract/feed.h b/src/services/abstract/feed.h index ad41f8d04..f239b48bc 100755 --- a/src/services/abstract/feed.h +++ b/src/services/abstract/feed.h @@ -44,6 +44,11 @@ class Feed : public RootItem { OtherError = 4 }; + enum ReadStatus { + Read = 0, + Unread = 1 + }; + // Constructors. explicit Feed(RootItem *parent = NULL); virtual ~Feed(); @@ -63,6 +68,8 @@ class Feed : public RootItem { // Get ALL undeleted messages from this feed in one single list. virtual QList undeletedMessages() const = 0; + //virtual bool markRead(ReadStatus read_status) = 0; + inline int autoUpdateInitialInterval() const { return m_autoUpdateInitialInterval; } diff --git a/src/services/standard/standardcategory.cpp b/src/services/standard/standardcategory.cpp index 7d822c215..b321eeed0 100755 --- a/src/services/standard/standardcategory.cpp +++ b/src/services/standard/standardcategory.cpp @@ -126,7 +126,7 @@ QVariant StandardCategory::data(int column, int role) const { } } -void StandardCategory::editViaDialog() { +bool StandardCategory::editViaDialog() { // TODO: předávat service root. /* QPointer form_pointer = new FormStandardCategoryDetails(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel(), @@ -137,6 +137,7 @@ void StandardCategory::editViaDialog() { delete form_pointer.data(); */ + return false; } bool StandardCategory::removeItself() { diff --git a/src/services/standard/standardcategory.h b/src/services/standard/standardcategory.h index b50f2bfaf..4f1cd8e41 100755 --- a/src/services/standard/standardcategory.h +++ b/src/services/standard/standardcategory.h @@ -50,7 +50,7 @@ class StandardCategory : public Category { return true; } - void editViaDialog(); + bool editViaDialog(); // Removes category and all its children from persistent // database. diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index a8bd20436..86104f076 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -98,7 +98,7 @@ int StandardFeed::countOfUnreadMessages() const { return m_unreadCount; } -void StandardFeed::editViaDialog() { +bool StandardFeed::editViaDialog() { // TODO: fix passing of the model /* @@ -108,6 +108,7 @@ void StandardFeed::editViaDialog() { delete form_pointer.data(); */ + return false; } QList StandardFeed::undeletedMessages() const { diff --git a/src/services/standard/standardfeed.h b/src/services/standard/standardfeed.h index 4696709a1..9196f069a 100755 --- a/src/services/standard/standardfeed.h +++ b/src/services/standard/standardfeed.h @@ -66,7 +66,7 @@ class StandardFeed : public Feed { return true; } - void editViaDialog(); + bool editViaDialog(); QList undeletedMessages() const; diff --git a/src/services/tt-rss/ttrssserviceroot.cpp b/src/services/tt-rss/ttrssserviceroot.cpp index f612272d2..fbb350b7b 100755 --- a/src/services/tt-rss/ttrssserviceroot.cpp +++ b/src/services/tt-rss/ttrssserviceroot.cpp @@ -33,8 +33,9 @@ TtRssServiceRoot::TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent) : TtRssServiceRoot::~TtRssServiceRoot() { } -void TtRssServiceRoot::editViaDialog() { +bool TtRssServiceRoot::editViaDialog() { // TODO: zobrazit custom edit dialog pro ttrss + return false; } bool TtRssServiceRoot::canBeEdited() { diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index a747a9773..b8259193d 100755 --- a/src/services/tt-rss/ttrssserviceroot.h +++ b/src/services/tt-rss/ttrssserviceroot.h @@ -26,7 +26,7 @@ class FeedsModel; class TtRssServiceRoot : public ServiceRoot { - Q_DECLARE_TR_FUNCTIONS(StandardServiceRoot) + Q_DECLARE_TR_FUNCTIONS(TtRssServiceRoot) public: explicit TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL); @@ -34,7 +34,7 @@ class TtRssServiceRoot : public ServiceRoot { bool canBeEdited(); bool canBeDeleted(); - void editViaDialog(); + bool editViaDialog(); QVariant data(int column, int role) const; };