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-2021 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 
27 class BtBookshelfView;
28 class QAbstractItemModel;
29 class QAction;
30 class QActionGroup;
31 class QEvent;
32 class QHBoxLayout;
33 class QLabel;
34 class QLineEdit;
35 class QMenu;
36 class QModelIndex;
37 class QToolButton;
38 
39 class BtBookshelfWidget: public QWidget {
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:
49  { return m_postFilterModel; }
50 
51  // Setters for models:
53 
54  // Getters for widgets:
56  QLabel * nameFilterLabel() const { return m_nameFilterLabel; }
61  BtBookshelfView * treeView() const { return m_treeView; }
63  { return m_groupingMenu; }
64  QMenu * contextMenu() const { return m_contextMenu; }
65  QMenu * itemContextMenu() const { return m_itemContextMenu; }
66 
67  // Setters for widgets:
70 
71  // Getters for actions:
72  QAction * showHideAction() const { return m_showHideAction; }
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 };
BtBookshelfWidget(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
QLabel * nameFilterLabel() const
QToolButton * groupingButton() const
void setContextMenu(QMenu *newMenu)
QWidget * leftCornerWidget() const
QToolButton * m_showHideButton
BtBookshelfView * treeView() const
void restoreExpanded(const QModelIndex &index, const QStringList &nodeList)
QAction * m_itemSearchAction
QActionGroup * m_itemActionGroup
void setRightCornerWidget(QWidget *w)
QAction * m_itemEditHtmlAction
QToolButton * showHideButton() const
QHBoxLayout * m_toolBar
QLineEdit * m_nameFilterEdit
QWidget * m_rightCornerWidget
bool eventFilter(QObject *object, QEvent *event) override
void setTreeModel(BtBookshelfTreeModel *model)
BtBookshelfTreeModel * treeModel() const
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)
QMenu * contextMenu() const
QWidget * rightCornerWidget() const
QLineEdit * nameFilterEdit() const
QMenu * itemContextMenu() const
BtBookshelfFilterModel * m_postFilterModel
BtBookshelfFilterModel * postFilterModel() const
BtBookshelfGroupingMenu * groupingMenu() const
QAction * m_itemUnlockAction
BtBookshelfGroupingMenu * m_groupingMenu
QWidget * m_leftCornerWidget
QAction * showHideAction() const
QAction * m_itemEditPlainAction
BtBookshelfView * m_treeView
void setItemContextMenu(QMenu *newMenu)
QToolButton * m_groupingButton