mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-10 07:13:32 +01:00
Added context menu for feeds.
This commit is contained in:
parent
0e83739327
commit
10c0c67105
@ -5,12 +5,14 @@
|
||||
#include "core/feedsmodel.h"
|
||||
#include "core/feedsproxymodel.h"
|
||||
#include "core/feedsmodelrootitem.h"
|
||||
#include "gui/formmain.h"
|
||||
|
||||
|
||||
#include <QMenu>
|
||||
#include <QHeaderView>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
|
||||
FeedsView::FeedsView(QWidget *parent) : QTreeView(parent) {
|
||||
FeedsView::FeedsView(QWidget *parent) : QTreeView(parent), m_contextMenu(NULL) {
|
||||
m_proxyModel = new FeedsProxyModel(this);
|
||||
m_sourceModel = m_proxyModel->sourceModel();
|
||||
|
||||
@ -82,6 +84,14 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||
m_sourceModel->reloadWholeLayout();
|
||||
}
|
||||
|
||||
void FeedsView::initializeContextMenu() {
|
||||
m_contextMenu = new QMenu(tr("Context menu for feeds"), this);
|
||||
m_contextMenu->addActions(QList<QAction*>() <<
|
||||
FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds <<
|
||||
FormMain::getInstance()->m_ui->m_actionMarkFeedsAsRead <<
|
||||
FormMain::getInstance()->m_ui->m_actionMarkFeedsAsUnread);
|
||||
}
|
||||
|
||||
void FeedsView::setupAppearance() {
|
||||
#if QT_VERSION >= 0x050000
|
||||
// Setup column resize strategies.
|
||||
@ -121,3 +131,20 @@ void FeedsView::selectionChanged(const QItemSelection &selected,
|
||||
|
||||
emit feedsSelected(m_selectedFeeds);
|
||||
}
|
||||
|
||||
void FeedsView::contextMenuEvent(QContextMenuEvent *event) {
|
||||
QModelIndex clicked_index = indexAt(event->pos());
|
||||
|
||||
if (!clicked_index.isValid()) {
|
||||
qDebug("Context menu for FeedsView will not be shown because "
|
||||
"user clicked on invalid item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_contextMenu == NULL) {
|
||||
// Context menu is not initialized, initialize.
|
||||
initializeContextMenu();
|
||||
}
|
||||
|
||||
m_contextMenu->exec(event->globalPos());
|
||||
}
|
||||
|
@ -40,17 +40,28 @@ class FeedsView : public QTreeView {
|
||||
void updateCountsOfAllFeeds(bool update_total_too = true);
|
||||
|
||||
protected:
|
||||
void initializeContextMenu();
|
||||
|
||||
// Sets up appearance of this widget.
|
||||
void setupAppearance();
|
||||
|
||||
// Make feeds loadable.
|
||||
void selectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected);
|
||||
|
||||
// Show custom context menu.
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
signals:
|
||||
// Emitted if currently selected feeds needs to be reloaded.
|
||||
void feedsNeedToBeReloaded(int mark_current_index_read);
|
||||
|
||||
// Emitted if user selects new feeds.
|
||||
void feedsSelected(const QList<int> &feed_ids);
|
||||
|
||||
private:
|
||||
QMenu *m_contextMenu;
|
||||
|
||||
QList<int> m_selectedFeeds;
|
||||
FeedsModel *m_sourceModel;
|
||||
FeedsProxyModel *m_proxyModel;
|
||||
|
@ -13,6 +13,7 @@ class FormMain : public QMainWindow {
|
||||
friend class TabWidget;
|
||||
friend class FeedMessageViewer;
|
||||
friend class MessagesView;
|
||||
friend class FeedsView;
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
|
Loading…
Reference in New Issue
Block a user