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.
This commit is contained in:
parent
5c0f777189
commit
3d59902aeb
@ -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
|
||||
|
@ -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<Feed*> &feeds) {
|
||||
QStringList stringy_ids;
|
||||
stringy_ids.reserve(feeds.size());
|
||||
|
@ -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();
|
||||
|
@ -41,6 +41,10 @@ RootItem::~RootItem() {
|
||||
qDeleteAll(m_childItems);
|
||||
}
|
||||
|
||||
QList<QAction *> RootItem::specificActions() {
|
||||
return QList<QAction*>();
|
||||
}
|
||||
|
||||
void RootItem::setupFonts() {
|
||||
m_normalFont = Application::font("FeedsView");
|
||||
m_boldFont = m_normalFont;
|
||||
|
@ -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<QAction*> specificActions();
|
||||
|
||||
// TODO: pracovat s těmito věcmi
|
||||
virtual bool canBeEdited() {
|
||||
return false;
|
||||
|
@ -125,16 +125,13 @@ QList<QAction*> 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...
|
||||
|
@ -132,18 +132,15 @@
|
||||
</property>
|
||||
<widget class="QMenu" name="m_menuAddItem">
|
||||
<property name="title">
|
||||
<string>Add &new feed/category</string>
|
||||
<string>Add &new item</string>
|
||||
</property>
|
||||
<addaction name="m_actionAddCategory"/>
|
||||
<addaction name="m_actionAddFeed"/>
|
||||
</widget>
|
||||
<addaction name="m_actionUpdateAllFeeds"/>
|
||||
<addaction name="m_actionUpdateSelectedFeeds"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_menuAddItem"/>
|
||||
<addaction name="m_actionEditSelectedFeedCategory"/>
|
||||
<addaction name="m_actionDeleteSelectedFeedCategory"/>
|
||||
<addaction name="m_actionFetchFeedMetadata"/>
|
||||
<addaction name="m_actionEditSelectedItem"/>
|
||||
<addaction name="m_actionDeleteSelectedItem"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionShowOnlyUnreadFeeds"/>
|
||||
<addaction name="m_actionExpandCollapseFeedCategory"/>
|
||||
@ -272,7 +269,7 @@
|
||||
</action>
|
||||
<action name="m_actionUpdateAllFeeds">
|
||||
<property name="text">
|
||||
<string>Update &all feeds</string>
|
||||
<string>Update &all items</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+Shift+U</string>
|
||||
@ -280,20 +277,20 @@
|
||||
</action>
|
||||
<action name="m_actionUpdateSelectedFeeds">
|
||||
<property name="text">
|
||||
<string>Update &selected feeds</string>
|
||||
<string>Update &selected items</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+U</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionEditSelectedFeedCategory">
|
||||
<action name="m_actionEditSelectedItem">
|
||||
<property name="text">
|
||||
<string>&Edit selected feed/category</string>
|
||||
<string>&Edit selected item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionDeleteSelectedFeedCategory">
|
||||
<action name="m_actionDeleteSelectedItem">
|
||||
<property name="text">
|
||||
<string>&Delete selected feed/category</string>
|
||||
<string>&Delete selected item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionMarkSelectedMessagesAsRead">
|
||||
@ -340,14 +337,6 @@
|
||||
<string>Deletes all messages from selected feeds.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionAddFeed">
|
||||
<property name="text">
|
||||
<string>New &feed</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add new feed.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionOpenSelectedSourceArticlesExternally">
|
||||
<property name="text">
|
||||
<string>Open selected source articles in &external browser</string>
|
||||
@ -363,14 +352,6 @@
|
||||
<string>Open selected source articles in &internal browser</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionAddCategory">
|
||||
<property name="text">
|
||||
<string>New &category</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add new category.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionNoActions">
|
||||
<property name="text">
|
||||
<string>No actions available</string>
|
||||
@ -436,7 +417,7 @@
|
||||
</action>
|
||||
<action name="m_actionSelectNextFeedCategory">
|
||||
<property name="text">
|
||||
<string>Select &next feed/category</string>
|
||||
<string>Select &next item</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">S</string>
|
||||
@ -444,7 +425,7 @@
|
||||
</action>
|
||||
<action name="m_actionSelectPreviousFeedCategory">
|
||||
<property name="text">
|
||||
<string>Select &previous feed/category</string>
|
||||
<string>Select &previous item</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">A</string>
|
||||
@ -649,14 +630,6 @@
|
||||
<string notr="true">Ctrl+Shift+U</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionFetchFeedMetadata">
|
||||
<property name="text">
|
||||
<string>&Fetch feed metadata</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+Shift+F</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionExpandCollapseFeedCategory">
|
||||
<property name="text">
|
||||
<string>&Expand/collapse selected feed/category</string>
|
||||
|
@ -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()));
|
||||
|
@ -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<QAction*> specific_actions = clicked_item->specificActions();
|
||||
|
||||
m_contextMenuCategories->addActions(QList<QAction*>() <<
|
||||
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<QAction*>() <<
|
||||
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<QAction*> specific_actions = clicked_item->specificActions();
|
||||
|
||||
m_contextMenuFeeds->addActions(QList<QAction*>() <<
|
||||
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<QAction*>() <<
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
|
||||
class Category : public RootItem {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Category(RootItem *parent = NULL);
|
||||
virtual ~Category();
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -99,6 +99,10 @@ int StandardFeed::countOfUnreadMessages() const {
|
||||
return m_unreadCount;
|
||||
}
|
||||
|
||||
QList<QAction*> StandardFeed::specificActions() {
|
||||
return serviceRoot()->getMenuForFeed(this);
|
||||
}
|
||||
|
||||
StandardServiceRoot *StandardFeed::serviceRoot() {
|
||||
return static_cast<StandardServiceRoot*>(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);
|
||||
}
|
||||
}
|
||||
|
@ -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<QAction*> specificActions();
|
||||
|
||||
bool canBeEdited() {
|
||||
return true;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
class StandardRecycleBin : public RootItem {
|
||||
Q_DECLARE_TR_FUNCTIONS(StandardRecycleBin)
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StandardRecycleBin(RootItem *parent = NULL);
|
||||
|
@ -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<int,StandardCategory*> StandardServiceRoot::allCategories() {
|
||||
return categoriesForItem(this);
|
||||
}
|
||||
|
||||
QList<QAction*> StandardServiceRoot::getMenuForFeed(StandardFeed *feed) {
|
||||
QList<QAction*> 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<int,StandardCategory*> categories = categoriesForItem(this);
|
||||
|
||||
|
@ -35,7 +35,7 @@ typedef QList<QPair<int, StandardFeed*> > FeedAssignment;
|
||||
typedef QPair<int, StandardFeed*> 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<int,StandardCategory*> allCategories();
|
||||
|
||||
QList<QAction*> getMenuForFeed(StandardFeed *feed);
|
||||
|
||||
// Access to standard recycle bin.
|
||||
StandardRecycleBin *recycleBin() const;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user