]> git.lyx.org Git - features.git/blob - src/frontends/qt/PanelStack.h
Guard against possible referencing null.
[features.git] / src / frontends / qt / PanelStack.h
1 // -*- C++ -*-
2 /**
3  * \file PanelStack.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef PANELSTACK_H
14 #define PANELSTACK_H
15
16 #include <QHash>
17 #include <QWidget>
18
19 class QHideEvent;
20 class QStackedWidget;
21 class QTimer;
22 class QTreeWidget;
23 class QTreeWidgetItem;
24
25 namespace lyx {
26 namespace frontend {
27
28 class FancyLineEdit;
29
30 class PanelStack : public QWidget
31 {
32         Q_OBJECT
33 public:
34         ///
35         PanelStack(QWidget * parent = 0);
36
37         /// add a category with no associated panel
38         void addCategory(QString const & name, QString const & parent = QString());
39         /// add a widget panel with a given name, under the given parent
40         void addPanel(QWidget * panel, QString const & name,
41                 QString const & parent = QString());
42         /// show or hide panel
43         void showPanel(QString const & name, bool show);
44         /// set current panel by logical name
45         void setCurrentPanel(QString const &);
46         ///
47         bool isCurrentPanel(QString const & name) const;
48         ///
49         QSize sizeHint() const override;
50
51 public Q_SLOTS:
52         /// the option filter changed
53         void filterChanged(QString const & search);
54         /// perform the search
55         void search();
56         /// reset the search box
57         void resetSearch();
58         /// set current panel from an item
59         void switchPanel(QTreeWidgetItem * it, QTreeWidgetItem * previous = 0);
60         /// click on the tree
61         void itemSelected(QTreeWidgetItem *, int);
62
63 protected:
64         /// widget hidden
65         void hideEvent(QHideEvent * event) override;
66
67 private:
68         ///
69         typedef QHash<QString, QTreeWidgetItem *> PanelMap;
70         ///
71         PanelMap panel_map_;
72
73         typedef QHash<QTreeWidgetItem *, QWidget *> WidgetMap;
74
75         WidgetMap widget_map_;
76
77         /// contains the search box
78         FancyLineEdit * search_;
79
80         /// contains the items
81         QTreeWidget * list_;
82
83         /// contains the panes
84         QStackedWidget * stack_;
85
86         // timer to delay the search between options
87         QTimer * delay_search_;
88
89 };
90
91 } // namespace frontend
92 } // namespace lyx
93
94 #endif // PANELSTACK_H