BibleTime
btbookshelfwidget.h
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2025 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#pragma once
14
15#include <QWidget>
16
17#include <memory>
18#include <QObject>
19#include <QString>
20#include <QStringList>
21#include <Qt>
22
23
27class BtBookshelfView;
29class QAction;
30class QActionGroup;
31class QEvent;
32class QHBoxLayout;
33class QLabel;
34class QLineEdit;
35class QMenu;
36class QModelIndex;
37class QToolButton;
38
40 Q_OBJECT
41 public:
42 explicit BtBookshelfWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
43
44 void setSourceModel(std::shared_ptr<QAbstractItemModel> model);
45
46 // Getters for models:
50
51 // Setters for models:
53
54 // Getters for widgets:
56 QLabel * nameFilterLabel() const { return m_nameFilterLabel; }
61 BtBookshelfView * treeView() const { return m_treeView; }
64 QMenu * contextMenu() const { return m_contextMenu; }
66
67 // Setters for widgets:
70
71 // Getters for actions:
73
74 // Setters for context menus:
75 void setContextMenu(QMenu * newMenu) { m_contextMenu = newMenu; }
76 void setItemContextMenu(QMenu * newMenu)
77 { m_itemContextMenu = newMenu; }
78
79 bool eventFilter(QObject *object, QEvent *event) override;
80
81 void loadBookshelfState();
82 void saveBookshelfState();
83
84 protected:
85 void findExpanded(const QModelIndex& index, QString prefix, QStringList * expandedPaths);
86 void initActions();
87 void initMenus();
88 void initWidgets();
89 void restoreExpanded(const QModelIndex& index, const QStringList& nodeList);
90 void retranslateUi();
91
92 private:
93 // Models:
94 std::shared_ptr<QAbstractItemModel> m_sourceModel;
97
98 // Widgets:
99 QHBoxLayout *m_toolBar;
107
108 // Popup menus:
113 QActionGroup *m_itemActionGroup;
121};
BtBookshelfTreeModel * treeModel() const
void setContextMenu(QMenu *newMenu)
QToolButton * showHideButton() const
QToolButton * m_showHideButton
void restoreExpanded(const QModelIndex &index, const QStringList &nodeList)
QActionGroup * m_itemActionGroup
void setRightCornerWidget(QWidget *w)
QLabel * nameFilterLabel() const
QAction * showHideAction() const
QHBoxLayout * m_toolBar
QWidget * rightCornerWidget() const
QLineEdit * m_nameFilterEdit
QWidget * leftCornerWidget() const
QLineEdit * nameFilterEdit() const
bool eventFilter(QObject *object, QEvent *event) override
BtBookshelfView * treeView() const
void setTreeModel(BtBookshelfTreeModel *model)
void setSourceModel(std::shared_ptr< QAbstractItemModel > model)
void findExpanded(const QModelIndex &index, QString prefix, QStringList *expandedPaths)
std::shared_ptr< QAbstractItemModel > m_sourceModel
BtBookshelfTreeModel * m_treeModel
void setLeftCornerWidget(QWidget *w)
BtBookshelfFilterModel * m_postFilterModel
BtBookshelfFilterModel * postFilterModel() const
BtBookshelfGroupingMenu * m_groupingMenu
BtBookshelfGroupingMenu * groupingMenu() const
QAction * m_itemEditPlainAction
QMenu * itemContextMenu() const
BtBookshelfView * m_treeView
QToolButton * groupingButton() const
void setItemContextMenu(QMenu *newMenu)
QMenu * contextMenu() const
QToolButton * m_groupingButton