1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef OPENPAGESWIDGET_H
5#define OPENPAGESWIDGET_H
6
7#include <QtWidgets/QStyledItemDelegate>
8#include <QtWidgets/QTreeView>
9
10QT_BEGIN_NAMESPACE
11
12class OpenPagesModel;
13
14class OpenPagesDelegate : public QStyledItemDelegate
15{
16 Q_OBJECT
17public:
18 explicit OpenPagesDelegate(QObject *parent = nullptr);
19 void paint(QPainter *painter, const QStyleOptionViewItem &option,
20 const QModelIndex &index) const override;
21
22 mutable QModelIndex pressedIndex;
23};
24
25class OpenPagesWidget : public QTreeView
26{
27 Q_OBJECT
28public:
29 OpenPagesWidget(OpenPagesModel *model);
30 ~OpenPagesWidget() override;
31
32 void selectCurrentPage();
33 void allowContextMenu(bool ok);
34
35signals:
36 void setCurrentPage(const QModelIndex &index);
37 void closePage(const QModelIndex &index);
38 void closePagesExcept(const QModelIndex &index);
39
40private slots:
41 void contextMenuRequested(QPoint pos);
42 void handlePressed(const QModelIndex &index);
43 void handleClicked(const QModelIndex &index);
44
45private:
46 bool eventFilter(QObject *obj, QEvent *event) override;
47
48 bool m_allowContextMenu;
49 OpenPagesDelegate *m_delegate;
50};
51
52QT_END_NAMESPACE
53
54#endif // OPENPAGESWIDGET_H
55

source code of qttools/src/assistant/assistant/openpageswidget.h