1 #pragma once
2 
3 #include <QListWidget>
4 #include <QAbstractListModel>
5 
6 class TabWidget;
7 
8 // -----------------------------------------------------------------------------------------------------------
9 
10 class AppModel : public QAbstractListModel
11 {
12     Q_OBJECT
13 public:
14     AppModel(QObject* parent, TabWidget* tabs);
15 
16 protected:
17     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
18     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
19 
20 private:
21     struct AppInfo {
22         QString name;
23         int index;
24     };
25 
26     QList<AppInfo> m_list;
27 };
28 
29 // -----------------------------------------------------------------------------------------------------------
30 
31 class TabSwitcher: public QListView
32 {
33     Q_OBJECT
34 
35 public:
36     TabSwitcher(TabWidget* tabs);
37     ~TabSwitcher() override;
38     void selectItem(bool forward = true);
39 
40 signals:
41     void activateTab(int index) const;
42 
43 protected:
44     void keyReleaseEvent(QKeyEvent *event) override;
45     void closeEvent(QCloseEvent *) override;
46 
47 private:
48     void showSwitcher();
49     void timer();
50 
51 private:
52     QTimer *m_timer;
53     TabWidget* m_tabs;
54 };
55 
56 // -----------------------------------------------------------------------------------------------------------
57 
58