rssguard/src/librssguard/gui/feedsview.h

164 lines
5.2 KiB
C
Raw Normal View History

// For license of this file, see <project-root-folder>/LICENSE.md.
#ifndef FEEDSVIEW_H
#define FEEDSVIEW_H
#include "core/feedsmodel.h"
2024-03-19 10:31:49 +01:00
#include "gui/reusable/basetreeview.h"
2023-02-10 14:18:59 +01:00
#include "gui/toolbars/feedstoolbar.h"
#include <QStyledItemDelegate>
class FeedsProxyModel;
class Feed;
class Category;
class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
2022-05-27 09:12:45 +02:00
Q_OBJECT
2017-09-19 10:18:21 +02:00
public:
2019-06-04 13:16:48 +02:00
explicit FeedsView(QWidget* parent = nullptr);
2017-09-19 10:18:21 +02:00
virtual ~FeedsView();
2020-07-24 10:52:09 +02:00
FeedsProxyModel* model() const;
FeedsModel* sourceModel() const;
2019-06-04 13:16:48 +02:00
void reloadFontSettings();
2017-09-19 10:18:21 +02:00
void setSortingEnabled(bool enable);
2017-09-19 10:18:21 +02:00
// Returns list of selected/all feeds.
// NOTE: This is recursive method which returns all descendants.
QList<Feed*> selectedFeeds(bool recursive) const;
// Returns selected item. If multiple items are selected, returns
// the one of them which is also "current". If none of them is
// "current", returns firs item of selected ones.
2017-09-19 10:18:21 +02:00
RootItem* selectedItem() const;
QList<RootItem*> selectedItems() const;
2017-09-19 10:18:21 +02:00
// Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings.
void saveAllExpandStates();
void loadAllExpandStates();
2017-09-19 10:18:21 +02:00
public slots:
2020-04-21 08:43:30 +02:00
void copyUrlOfSelectedFeeds() const;
2017-09-19 10:18:21 +02:00
void sortByColumn(int column, Qt::SortOrder order);
2017-09-19 10:18:21 +02:00
void addFeedIntoSelectedAccount();
void addCategoryIntoSelectedAccount();
2021-04-20 08:38:11 +02:00
void expandCollapseCurrentItem(bool recursive);
2017-09-19 10:18:21 +02:00
// Feed updating.
void updateSelectedItems();
2017-09-19 10:18:21 +02:00
// Feed read/unread manipulators.
void markSelectedItemRead();
void markSelectedItemUnread();
void markAllItemsRead();
2017-09-19 10:18:21 +02:00
// Feed clearers.
void clearSelectedItems();
void clearAllItems();
2017-09-19 10:18:21 +02:00
// Base manipulators.
void editItems(const QList<RootItem*>& items);
void editSelectedItems();
void editChildFeeds();
void editRecursiveFeeds();
2017-09-19 10:18:21 +02:00
void deleteSelectedItem();
// Sort order manipulations.
void moveSelectedItemUp();
void moveSelectedItemTop();
void moveSelectedItemBottom();
2022-03-14 09:24:52 +01:00
void moveSelectedItemDown();
2023-04-21 13:06:53 +02:00
void rearrangeCategoriesOfSelectedItem();
void rearrangeFeedsOfSelectedItem();
2017-09-19 10:18:21 +02:00
// Selects next/previous item (feed/category) in the list.
void selectNextItem();
void selectPreviousItem();
2017-09-10 10:40:33 +02:00
void selectNextUnreadItem();
2017-09-19 10:18:21 +02:00
// Switches visibility of the widget.
void switchVisibility();
2023-02-10 14:18:59 +01:00
void filterItems(SearchLineEdit::SearchMode mode,
Qt::CaseSensitivity sensitivity,
int custom_criteria,
const QString& phrase);
void toggleFeedSortingMode(bool sort_alphabetically);
2022-01-08 17:30:37 +01:00
void invalidateReadFeedsFilter(bool set_new_value = false, bool show_unread_only = false);
2017-09-19 10:18:21 +02:00
signals:
void itemSelected(RootItem* item);
2017-09-10 10:40:33 +02:00
void requestViewNextUnreadMessage();
2017-09-19 10:18:21 +02:00
protected:
2020-07-24 10:52:09 +02:00
void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const;
2017-10-22 19:54:22 +02:00
void focusInEvent(QFocusEvent* event);
2017-09-19 10:18:21 +02:00
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void keyPressEvent(QKeyEvent* event);
void contextMenuEvent(QContextMenuEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
2017-09-19 10:18:21 +02:00
private slots:
2022-01-07 12:49:05 +01:00
void onIndexExpanded(const QModelIndex& idx);
void onIndexCollapsed(const QModelIndex& idx);
void expandItemDelayed(const QModelIndex& source_idx);
2017-09-19 10:18:21 +02:00
void markSelectedItemReadStatus(RootItem::ReadStatus read);
void markAllItemsReadStatus(RootItem::ReadStatus read);
2017-09-19 10:18:21 +02:00
void saveSortState(int column, Qt::SortOrder order);
void validateItemAfterDragDrop(const QModelIndex& source_index);
void onItemExpandRequested(const QList<RootItem*>& items, bool exp);
void onItemExpandStateSaveRequested(RootItem* item);
2017-09-19 10:18:21 +02:00
private:
2021-08-25 13:59:37 +02:00
QModelIndex nextPreviousUnreadItem(const QModelIndex& default_row);
QModelIndex nextUnreadItem(const QModelIndex& default_row);
2017-09-10 10:40:33 +02:00
2017-09-19 10:18:21 +02:00
// Initializes context menus.
QMenu* initializeContextMenuBin(RootItem* clicked_item);
QMenu* initializeContextMenuService(RootItem* clicked_item);
2017-09-19 10:18:21 +02:00
QMenu* initializeContextMenuCategories(RootItem* clicked_item);
QMenu* initializeContextMenuFeeds(RootItem* clicked_item);
QMenu* initializeContextMenuImportant(RootItem* clicked_item);
2017-09-19 10:18:21 +02:00
QMenu* initializeContextMenuEmptySpace();
QMenu* initializeContextMenuOtherItem(RootItem* clicked_item);
2020-10-07 20:22:50 +02:00
QMenu* initializeContextMenuLabel(RootItem* clicked_item);
QMenu* initializeContextMenuProbe(RootItem* clicked_item);
2017-09-19 10:18:21 +02:00
void setupAppearance();
void saveExpandStates(RootItem* item);
QMenu* m_contextMenuService;
QMenu* m_contextMenuBin;
2017-09-19 10:18:21 +02:00
QMenu* m_contextMenuCategories;
QMenu* m_contextMenuFeeds;
QMenu* m_contextMenuImportant;
2017-09-19 10:18:21 +02:00
QMenu* m_contextMenuEmptySpace;
QMenu* m_contextMenuOtherItems;
2020-10-07 20:22:50 +02:00
QMenu* m_contextMenuLabel;
QMenu* m_contextMenuProbe;
2017-09-19 10:18:21 +02:00
FeedsModel* m_sourceModel;
FeedsProxyModel* m_proxyModel;
2022-01-08 17:30:37 +01:00
bool m_dontSaveExpandState;
2023-05-05 08:55:58 +02:00
// QTreeView interface
protected:
virtual void drawRow(QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index) const;
};
2020-07-24 10:52:09 +02:00
inline FeedsProxyModel* FeedsView::model() const {
return m_proxyModel;
}
inline FeedsModel* FeedsView::sourceModel() const {
return m_sourceModel;
}
#endif // FEEDSVIEW_H