From 3d59902aeba258ebd1eb2f4e63635c630cdf2a55 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 6 Nov 2015 09:41:36 +0100 Subject: [PATCH] RootItem now inherits QObject, fetching metadata works for standard feeds, custom context menus moved to interface so that each item can provide specific menu items. --- CMakeLists.txt | 20 ++++- src/core/feedsmodel.cpp | 5 ++ src/core/feedsmodel.h | 3 + src/core/rootitem.cpp | 4 + src/core/rootitem.h | 11 ++- src/gui/dialogs/formmain.cpp | 14 +--- src/gui/dialogs/formmain.ui | 49 +++--------- src/gui/feedmessageviewer.cpp | 17 +---- src/gui/feedsview.cpp | 74 +++++++++---------- src/gui/feedsview.h | 5 +- src/services/abstract/category.h | 2 + src/services/abstract/feed.h | 2 + src/services/abstract/serviceroot.h | 2 + src/services/standard/standardcategory.h | 2 +- src/services/standard/standardfeed.cpp | 10 ++- src/services/standard/standardfeed.h | 4 +- src/services/standard/standarditem.cpp | 18 ----- src/services/standard/standarditem.h | 19 ----- src/services/standard/standardrecyclebin.h | 2 +- src/services/standard/standardserviceroot.cpp | 12 +++ src/services/standard/standardserviceroot.h | 4 +- src/services/tt-rss/ttrssserviceroot.h | 2 +- 22 files changed, 131 insertions(+), 150 deletions(-) delete mode 100755 src/services/standard/standarditem.cpp delete mode 100755 src/services/standard/standarditem.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e387d3d8..9af5020df 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,16 +422,15 @@ set(APP_SOURCES src/services/abstract/serviceroot.cpp # STANDARD feed service sources. - src/services/standard/standardfeed.cpp - src/services/standard/standardfeedsimportexportmodel.cpp - src/services/standard/standardcategory.cpp src/services/standard/gui/formstandardcategorydetails.cpp src/services/standard/gui/formstandardfeeddetails.cpp src/services/standard/gui/formstandardimportexport.cpp + src/services/standard/standardfeedsimportexportmodel.cpp src/services/standard/standardserviceentrypoint.cpp + src/services/standard/standardcategory.cpp + src/services/standard/standardfeed.cpp src/services/standard/standardserviceroot.cpp src/services/standard/standardrecyclebin.cpp - src/services/standard/standarditem.cpp # TT-RSS feed service sources. src/services/tt-rss/ttrssserviceentrypoint.cpp @@ -531,12 +530,25 @@ set(APP_HEADERS src/core/feedsmodel.h src/core/feedsproxymodel.h src/core/feeddownloader.h + src/core/rootitem.h + + # ABSTRACT service headers. + src/services/abstract/feed.h + src/services/abstract/category.h + src/services/abstract/serviceroot.h # STANDARD service headers. src/services/standard/standardfeedsimportexportmodel.h src/services/standard/gui/formstandardcategorydetails.h src/services/standard/gui/formstandardfeeddetails.h src/services/standard/gui/formstandardimportexport.h + src/services/standard/standardcategory.h + src/services/standard/standardfeed.h + src/services/standard/standardserviceroot.h + src/services/standard/standardrecyclebin.h + + # TT-RSS service headers. + src/services/tt-rss/ttrssserviceroot.h # NETWORK-WEB headers. src/network-web/webpage.h diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 7899416eb..53b424c29 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -392,6 +392,11 @@ void FeedsModel::reloadChangedLayout(QModelIndexList list) { } } +void FeedsModel::reloadChangedItem(RootItem *item) { + QModelIndex index_item = indexForItem(item); + reloadChangedLayout(QModelIndexList() << index_item); +} + QStringList FeedsModel::textualFeedIds(const QList &feeds) { QStringList stringy_ids; stringy_ids.reserve(feeds.size()); diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 004e66b25..1fdc26b72 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -144,6 +144,9 @@ class FeedsModel : public QAbstractItemModel { // NOTE: This reloads all parent valid indexes too. void reloadChangedLayout(QModelIndexList list); + // Invalidates data under index for the item. + void reloadChangedItem(RootItem *item); + private slots: // Is executed when next auto-update round could be done. void executeNextAutoUpdate(); diff --git a/src/core/rootitem.cpp b/src/core/rootitem.cpp index 4546b4172..dc48504c4 100755 --- a/src/core/rootitem.cpp +++ b/src/core/rootitem.cpp @@ -41,6 +41,10 @@ RootItem::~RootItem() { qDeleteAll(m_childItems); } +QList RootItem::specificActions() { + return QList(); +} + void RootItem::setupFonts() { m_normalFont = Application::font("FeedsView"); m_boldFont = m_normalFont; diff --git a/src/core/rootitem.h b/src/core/rootitem.h index 482519dee..8d25ecf89 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -26,6 +26,7 @@ class Category; class Feed; class ServiceRoot; +class QAction; namespace RootItemKind { // Describes the kind of the item. @@ -45,7 +46,9 @@ namespace RootItemKind { // Represents ROOT item of FeedsModel. // NOTE: This class is derived to add functionality for // all other non-root items of FeedsModel. -class RootItem { +class RootItem : public QObject { + Q_OBJECT + public: // Constructors and destructors. explicit RootItem(RootItem *parent_item = NULL); @@ -73,6 +76,12 @@ class RootItem { child->setParent(this); } + // Returns list of specific actions which can be done with the item. + // NOTE: This method should always create new actions in memory + // before returning them because caller takes ownership of any + // actions returned from here. + virtual QList specificActions(); + // TODO: pracovat s těmito věcmi virtual bool canBeEdited() { return false; diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 4baef3183..738509e84 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -125,16 +125,13 @@ QList FormMain::allActions() { actions << m_ui->m_actionDeleteSelectedMessages; actions << m_ui->m_actionUpdateAllFeeds; actions << m_ui->m_actionUpdateSelectedFeeds; - actions << m_ui->m_actionEditSelectedFeedCategory; - actions << m_ui->m_actionDeleteSelectedFeedCategory; + actions << m_ui->m_actionEditSelectedItem; + actions << m_ui->m_actionDeleteSelectedItem; actions << m_ui->m_actionViewSelectedItemsNewspaperMode; - actions << m_ui->m_actionAddCategory; - actions << m_ui->m_actionAddFeed; actions << m_ui->m_actionSelectNextFeedCategory; actions << m_ui->m_actionSelectPreviousFeedCategory; actions << m_ui->m_actionSelectNextMessage; actions << m_ui->m_actionSelectPreviousMessage; - actions << m_ui->m_actionFetchFeedMetadata; actions << m_ui->m_actionExpandCollapseFeedCategory; return actions; @@ -248,11 +245,9 @@ void FormMain::setupIcons() { m_ui->m_actionUpdateSelectedFeeds->setIcon(icon_theme_factory->fromTheme(QSL("item-update-selected"))); m_ui->m_actionClearSelectedFeeds->setIcon(icon_theme_factory->fromTheme(QSL("mail-remove"))); m_ui->m_actionClearAllFeeds->setIcon(icon_theme_factory->fromTheme(QSL("mail-remove"))); - m_ui->m_actionDeleteSelectedFeedCategory->setIcon(icon_theme_factory->fromTheme(QSL("item-remove"))); + m_ui->m_actionDeleteSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("item-remove"))); m_ui->m_actionDeleteSelectedMessages->setIcon(icon_theme_factory->fromTheme(QSL("mail-remove"))); - m_ui->m_actionAddCategory->setIcon(icon_theme_factory->fromTheme(QSL("folder-category"))); - m_ui->m_actionAddFeed->setIcon(icon_theme_factory->fromTheme(QSL("folder-feed"))); - m_ui->m_actionEditSelectedFeedCategory->setIcon(icon_theme_factory->fromTheme(QSL("item-edit"))); + m_ui->m_actionEditSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("item-edit"))); m_ui->m_actionMarkAllFeedsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read"))); m_ui->m_actionMarkSelectedFeedsAsRead->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-read"))); m_ui->m_actionMarkSelectedFeedsAsUnread->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread"))); @@ -269,7 +264,6 @@ void FormMain::setupIcons() { m_ui->m_actionSelectNextMessage->setIcon(icon_theme_factory->fromTheme(QSL("go-down"))); m_ui->m_actionSelectPreviousMessage->setIcon(icon_theme_factory->fromTheme(QSL("go-up"))); m_ui->m_actionShowOnlyUnreadFeeds->setIcon(icon_theme_factory->fromTheme(QSL("mail-mark-unread"))); - m_ui->m_actionFetchFeedMetadata->setIcon(icon_theme_factory->fromTheme(QSL("download-manager"))); m_ui->m_actionExpandCollapseFeedCategory->setIcon(icon_theme_factory->fromTheme(QSL("expand-collapse"))); // Setup icons for underlying components: opened web browsers... diff --git a/src/gui/dialogs/formmain.ui b/src/gui/dialogs/formmain.ui index cf173caa5..974aadb67 100755 --- a/src/gui/dialogs/formmain.ui +++ b/src/gui/dialogs/formmain.ui @@ -132,18 +132,15 @@ - Add &new feed/category + Add &new item - - - - - + + @@ -272,7 +269,7 @@ - Update &all feeds + Update &all items Ctrl+Shift+U @@ -280,20 +277,20 @@ - Update &selected feeds + Update &selected items Ctrl+U - + - &Edit selected feed/category + &Edit selected item - + - &Delete selected feed/category + &Delete selected item @@ -340,14 +337,6 @@ Deletes all messages from selected feeds. - - - New &feed - - - Add new feed. - - Open selected source articles in &external browser @@ -363,14 +352,6 @@ Open selected source articles in &internal browser - - - New &category - - - Add new category. - - No actions available @@ -436,7 +417,7 @@ - Select &next feed/category + Select &next item S @@ -444,7 +425,7 @@ - Select &previous feed/category + Select &previous item A @@ -649,14 +630,6 @@ Ctrl+Shift+U - - - &Fetch feed metadata - - - Ctrl+Shift+F - - &Expand/collapse selected feed/category diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 6bb8cc241..1c2cb6c56 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -309,20 +309,17 @@ void FeedMessageViewer::updateFeedButtonsAvailability() { bool feed_selected = !m_feedsView->selectionModel()->selectedRows().isEmpty(); FormMain *form_main = qApp->mainForm(); - form_main->m_ui->m_actionAddCategory->setEnabled(!critical_action_running); - form_main->m_ui->m_actionAddFeed->setEnabled(!critical_action_running); form_main->m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running); form_main->m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running); form_main->m_ui->m_actionClearSelectedFeeds->setEnabled(feed_selected); - form_main->m_ui->m_actionDeleteSelectedFeedCategory->setEnabled(!critical_action_running && feed_selected); - form_main->m_ui->m_actionEditSelectedFeedCategory->setEnabled(!critical_action_running && feed_selected); + form_main->m_ui->m_actionDeleteSelectedItem->setEnabled(!critical_action_running && feed_selected); + form_main->m_ui->m_actionEditSelectedItem->setEnabled(!critical_action_running && feed_selected); form_main->m_ui->m_actionImportFeeds->setEnabled(!critical_action_running); form_main->m_ui->m_actionMarkSelectedFeedsAsRead->setEnabled(feed_selected); form_main->m_ui->m_actionMarkSelectedFeedsAsUnread->setEnabled(feed_selected); form_main->m_ui->m_actionUpdateAllFeeds->setEnabled(!critical_action_running); form_main->m_ui->m_actionUpdateSelectedFeeds->setEnabled(!critical_action_running && feed_selected); form_main->m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(feed_selected); - form_main->m_ui->m_actionFetchFeedMetadata->setEnabled(feed_selected); form_main->m_ui->m_actionExpandCollapseFeedCategory->setEnabled(feed_selected); form_main->m_ui->m_menuAddItem->setEnabled(!critical_action_running); } @@ -395,8 +392,6 @@ void FeedMessageViewer::createConnections() { SIGNAL(triggered()), m_feedsView, SLOT(markSelectedFeedsRead())); connect(form_main->m_ui->m_actionExpandCollapseFeedCategory, SIGNAL(triggered()), m_feedsView, SLOT(expandCollapseCurrentItem())); - connect(form_main->m_ui->m_actionFetchFeedMetadata, SIGNAL(triggered()), - m_feedsView, SLOT(fetchMetadataForSelectedFeed())); connect(form_main->m_ui->m_actionMarkSelectedFeedsAsUnread, SIGNAL(triggered()), m_feedsView, SLOT(markSelectedFeedsUnread())); connect(form_main->m_ui->m_actionClearSelectedFeeds, @@ -407,15 +402,11 @@ void FeedMessageViewer::createConnections() { SIGNAL(triggered()), m_feedsView, SLOT(updateSelectedFeeds())); connect(form_main->m_ui->m_actionUpdateAllFeeds, SIGNAL(triggered()), m_feedsView, SLOT(updateAllFeeds())); - connect(form_main->m_ui->m_actionAddCategory, - SIGNAL(triggered()), m_feedsView, SLOT(addNewCategory())); - connect(form_main->m_ui->m_actionAddFeed, - SIGNAL(triggered()), m_feedsView, SLOT(addNewFeed())); - connect(form_main->m_ui->m_actionEditSelectedFeedCategory, + connect(form_main->m_ui->m_actionEditSelectedItem, SIGNAL(triggered()), m_feedsView, SLOT(editSelectedItem())); connect(form_main->m_ui->m_actionViewSelectedItemsNewspaperMode, SIGNAL(triggered()), m_feedsView, SLOT(openSelectedFeedsInNewspaperMode())); - connect(form_main->m_ui->m_actionDeleteSelectedFeedCategory, + connect(form_main->m_ui->m_actionDeleteSelectedItem, SIGNAL(triggered()), m_feedsView, SLOT(deleteSelectedItem())); connect(form_main->m_ui->m_actionSwitchFeedsList, SIGNAL(triggered()), this, SLOT(switchFeedComponentVisibility())); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 705ffb3e7..ab3a57ac6 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -355,18 +355,6 @@ void FeedsView::markAllFeedsRead() { markAllFeedsReadStatus(1); } -void FeedsView::fetchMetadataForSelectedFeed() { - // TODO: fix - /* - StandardFeed *selected_feed = (StandardFeed*) selectedFeed(); - - if (selected_feed != NULL) { - selected_feed->fetchMetadataForItself(); - m_sourceModel->reloadChangedLayout(QModelIndexList() << m_proxyModel->mapToSource(selectionModel()->selectedRows(0).at(0))); - } - */ -} - void FeedsView::clearAllReadMessages() { m_sourceModel->markFeedsDeleted(allFeeds(), 1, 1); } @@ -495,40 +483,58 @@ void FeedsView::selectPreviousItem() { } } -void FeedsView::initializeContextMenuCategories() { - m_contextMenuCategories = new QMenu(tr("Context menu for categories"), this); +void FeedsView::initializeContextMenuCategories(RootItem *clicked_item) { + if (m_contextMenuCategories == NULL) { + m_contextMenuCategories = new QMenu(tr("Context menu for categories"), this); + } + else { + m_contextMenuCategories->clear(); + } + + QList specific_actions = clicked_item->specificActions(); + m_contextMenuCategories->addActions(QList() << qApp->mainForm()->m_ui->m_actionUpdateSelectedFeeds << - qApp->mainForm()->m_ui->m_actionEditSelectedFeedCategory << + qApp->mainForm()->m_ui->m_actionEditSelectedItem << qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode << qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsUnread << - qApp->mainForm()->m_ui->m_actionDeleteSelectedFeedCategory); - m_contextMenuCategories->addSeparator(); - m_contextMenuCategories->addActions(QList() << - qApp->mainForm()->m_ui->m_actionAddCategory << - qApp->mainForm()->m_ui->m_actionAddFeed); + qApp->mainForm()->m_ui->m_actionDeleteSelectedItem); + + if (!specific_actions.isEmpty()) { + m_contextMenuCategories->addSeparator(); + m_contextMenuCategories->addActions(specific_actions); + } } -void FeedsView::initializeContextMenuFeeds() { - m_contextMenuFeeds = new QMenu(tr("Context menu for categories"), this); +void FeedsView::initializeContextMenuFeeds(RootItem *clicked_item) { + if (m_contextMenuFeeds == NULL) { + m_contextMenuFeeds = new QMenu(tr("Context menu for categories"), this); + } + else { + m_contextMenuFeeds->clear(); + } + + QList specific_actions = clicked_item->specificActions(); + m_contextMenuFeeds->addActions(QList() << qApp->mainForm()->m_ui->m_actionUpdateSelectedFeeds << - qApp->mainForm()->m_ui->m_actionEditSelectedFeedCategory << + qApp->mainForm()->m_ui->m_actionEditSelectedItem << qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode << qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsRead << qApp->mainForm()->m_ui->m_actionMarkSelectedFeedsAsUnread << - qApp->mainForm()->m_ui->m_actionDeleteSelectedFeedCategory << - qApp->mainForm()->m_ui->m_actionFetchFeedMetadata); + qApp->mainForm()->m_ui->m_actionDeleteSelectedItem); + + if (!specific_actions.isEmpty()) { + m_contextMenuFeeds->addSeparator(); + m_contextMenuFeeds->addActions(specific_actions); + } } void FeedsView::initializeContextMenuEmptySpace() { m_contextMenuEmptySpace = new QMenu(tr("Context menu for empty space"), this); m_contextMenuEmptySpace->addAction(qApp->mainForm()->m_ui->m_actionUpdateAllFeeds); m_contextMenuEmptySpace->addSeparator(); - m_contextMenuEmptySpace->addActions(QList() << - qApp->mainForm()->m_ui->m_actionAddCategory << - qApp->mainForm()->m_ui->m_actionAddFeed); } void FeedsView::setupAppearance() { @@ -590,20 +596,12 @@ void FeedsView::contextMenuEvent(QContextMenuEvent *event) { if (clicked_item->kind() == RootItemKind::Category) { // Display context menu for categories. - if (m_contextMenuCategories == NULL) { - // Context menu is not initialized, initialize. - initializeContextMenuCategories(); - } - + initializeContextMenuCategories(clicked_item); m_contextMenuCategories->exec(event->globalPos()); } else if (clicked_item->kind() == RootItemKind::Feed) { // Display context menu for feeds. - if (m_contextMenuFeeds == NULL) { - // Context menu is not initialized, initialize. - initializeContextMenuFeeds(); - } - + initializeContextMenuFeeds(clicked_item); m_contextMenuFeeds->exec(event->globalPos()); } } diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 885bafcf4..1b01477b2 100755 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -69,7 +69,6 @@ class FeedsView : public QTreeView { public slots: void invalidateReadFeedsFilter(bool set_new_value = false, bool show_unread_only = false); void expandCollapseCurrentItem(); - void fetchMetadataForSelectedFeed(); // Feed updating. void updateAllFeeds(); @@ -136,8 +135,8 @@ class FeedsView : public QTreeView { protected: // Initializes context menus. - void initializeContextMenuCategories(); - void initializeContextMenuFeeds(); + void initializeContextMenuCategories(RootItem *clicked_item); + void initializeContextMenuFeeds(RootItem *clicked_item); void initializeContextMenuEmptySpace(); // Sets up appearance of this widget. diff --git a/src/services/abstract/category.h b/src/services/abstract/category.h index cff422dda..961eed509 100755 --- a/src/services/abstract/category.h +++ b/src/services/abstract/category.h @@ -22,6 +22,8 @@ class Category : public RootItem { + Q_OBJECT + public: explicit Category(RootItem *parent = NULL); virtual ~Category(); diff --git a/src/services/abstract/feed.h b/src/services/abstract/feed.h index 64aecd6f8..6083c5b86 100755 --- a/src/services/abstract/feed.h +++ b/src/services/abstract/feed.h @@ -25,6 +25,8 @@ // Base class for "feed" nodes. class Feed : public RootItem { + Q_OBJECT + public: // Specifies the auto-update strategy for the feed. enum AutoUpdateType { diff --git a/src/services/abstract/serviceroot.h b/src/services/abstract/serviceroot.h index 94e6b472e..86315accc 100755 --- a/src/services/abstract/serviceroot.h +++ b/src/services/abstract/serviceroot.h @@ -27,6 +27,8 @@ class FeedsModel; // NOTE: The root usually contains some core functionality of the // service like service account username/password etc. class ServiceRoot : public RootItem { + Q_OBJECT + public: explicit ServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL); virtual ~ServiceRoot(); diff --git a/src/services/standard/standardcategory.h b/src/services/standard/standardcategory.h index b7c8d7ae1..1edab3bab 100755 --- a/src/services/standard/standardcategory.h +++ b/src/services/standard/standardcategory.h @@ -31,7 +31,7 @@ class StandardServiceRoot; // NOTE: This class should be derived to create PARTICULAR category types. // NOTE: This class should not be instantiated directly. class StandardCategory : public Category { - Q_DECLARE_TR_FUNCTIONS(StandardCategory) + Q_OBJECT public: // Constructors and destructors diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index 82e7f4c23..7f9511148 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -99,6 +99,10 @@ int StandardFeed::countOfUnreadMessages() const { return m_unreadCount; } +QList StandardFeed::specificActions() { + return serviceRoot()->getMenuForFeed(this); +} + StandardServiceRoot *StandardFeed::serviceRoot() { return static_cast(getParentServiceRoot()); } @@ -201,10 +205,14 @@ void StandardFeed::fetchMetadataForItself() { editItself(metadata.first); delete metadata.first; + + // Notify the model about fact, that it needs to reload new information about + // this item, particularly the icon. + serviceRoot()->feedsModel()->reloadChangedItem(this); } else { qApp->showGuiMessage(tr("Metadata not fetched"), - tr("Metadata was not fetched because: %1").arg(NetworkFactory::networkErrorText(metadata.second)), + tr("Metadata was not fetched because: %1.").arg(NetworkFactory::networkErrorText(metadata.second)), QSystemTrayIcon::Critical); } } diff --git a/src/services/standard/standardfeed.h b/src/services/standard/standardfeed.h index 710f6ae3f..2abb87439 100755 --- a/src/services/standard/standardfeed.h +++ b/src/services/standard/standardfeed.h @@ -35,7 +35,7 @@ class StandardServiceRoot; // Represents BASE class for feeds contained in FeedsModel. // NOTE: This class should be derived to create PARTICULAR feed types. class StandardFeed : public Feed { - Q_DECLARE_TR_FUNCTIONS(StandardFeed) + Q_OBJECT public: // Describes possible types of feeds. @@ -61,6 +61,8 @@ class StandardFeed : public Feed { int countOfAllMessages() const; int countOfUnreadMessages() const; + QList specificActions(); + bool canBeEdited() { return true; } diff --git a/src/services/standard/standarditem.cpp b/src/services/standard/standarditem.cpp deleted file mode 100755 index bde2b13d8..000000000 --- a/src/services/standard/standarditem.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "services/standard/standarditem.h" - -#include "services/standard/standardserviceroot.h" - - -StandardItem::StandardItem(StandardServiceRoot *service_root) : m_serviceRoot(service_root) { -} - -StandardItem::~StandardItem() { -} - -StandardServiceRoot *StandardItem::serviceRoot() const { - return m_serviceRoot; -} - -void StandardItem::setServiceRoot(StandardServiceRoot *service_root) { - m_serviceRoot = service_root; -} diff --git a/src/services/standard/standarditem.h b/src/services/standard/standarditem.h deleted file mode 100755 index efe3210d1..000000000 --- a/src/services/standard/standarditem.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef STANDARDITEM_H -#define STANDARDITEM_H - - -class StandardServiceRoot; - -class StandardItem { - public: - explicit StandardItem(StandardServiceRoot *service_root); - virtual ~StandardItem(); - - StandardServiceRoot *serviceRoot() const; - void setServiceRoot(StandardServiceRoot *service_root); - - protected: - StandardServiceRoot *m_serviceRoot; -}; - -#endif // STANDARDITEM_H diff --git a/src/services/standard/standardrecyclebin.h b/src/services/standard/standardrecyclebin.h index 1675b9e5c..393e58ee9 100755 --- a/src/services/standard/standardrecyclebin.h +++ b/src/services/standard/standardrecyclebin.h @@ -24,7 +24,7 @@ class StandardRecycleBin : public RootItem { - Q_DECLARE_TR_FUNCTIONS(StandardRecycleBin) + Q_OBJECT public: explicit StandardRecycleBin(RootItem *parent = NULL); diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 1777337f3..d776f406f 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -20,6 +20,7 @@ #include "definitions/definitions.h" #include "miscellaneous/application.h" #include "miscellaneous/settings.h" +#include "miscellaneous/iconfactory.h" #include "core/feedsmodel.h" #include "services/standard/standardserviceentrypoint.h" #include "services/standard/standardrecyclebin.h" @@ -208,6 +209,17 @@ QHash StandardServiceRoot::allCategories() { return categoriesForItem(this); } +QList StandardServiceRoot::getMenuForFeed(StandardFeed *feed) { + QList list; + + // Fetch feed metadata. + QAction *action_fetch_metadata = new QAction(qApp->icons()->fromTheme(QSL("download-manager")), tr("Fetch metadata"), NULL); + connect(action_fetch_metadata, SIGNAL(triggered()), feed, SLOT(fetchMetadataForItself())); + + list.append(action_fetch_metadata); + return list; +} + void StandardServiceRoot::assembleFeeds(FeedAssignment feeds) { QHash categories = categoriesForItem(this); diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index f43d08239..835b9c81a 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -35,7 +35,7 @@ typedef QList > FeedAssignment; typedef QPair FeedAssignmentItem; class StandardServiceRoot : public ServiceRoot { - Q_DECLARE_TR_FUNCTIONS(StandardServiceRoot) + Q_OBJECT public: explicit StandardServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL); @@ -53,6 +53,8 @@ class StandardServiceRoot : public ServiceRoot { // consists of ID of parent item and pointer to category. QHash allCategories(); + QList getMenuForFeed(StandardFeed *feed); + // Access to standard recycle bin. StandardRecycleBin *recycleBin() const; diff --git a/src/services/tt-rss/ttrssserviceroot.h b/src/services/tt-rss/ttrssserviceroot.h index a5df9c6a2..957517850 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(TtRssServiceRoot) + Q_OBJECT public: explicit TtRssServiceRoot(FeedsModel *feeds_model, RootItem *parent = NULL);