1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Assistant module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef OPENPAGESMANAGER_H
30#define OPENPAGESMANAGER_H
31
32#include <QtCore/QObject>
33
34QT_BEGIN_NAMESPACE
35
36class QAbstractItemView;
37class QModelIndex;
38class QUrl;
39
40class HelpViewer;
41class OpenPagesModel;
42class OpenPagesSwitcher;
43class OpenPagesWidget;
44
45class OpenPagesManager : public QObject
46{
47 Q_OBJECT
48public:
49 static OpenPagesManager *createInstance(QObject *parent,
50 bool defaultCollection, const QUrl &cmdLineUrl);
51 static OpenPagesManager *instance();
52
53 bool pagesOpenForNamespace(const QString &nameSpace) const;
54 void closePages(const QString &nameSpace);
55 void reloadPages(const QString &nameSpace);
56
57 QAbstractItemView* openPagesWidget() const;
58
59 int pageCount() const;
60 void setCurrentPage(int index);
61
62public slots:
63 HelpViewer *createPage(const QUrl &url, bool fromSearch = false);
64 HelpViewer *createNewPageFromSearch(const QUrl &url);
65 HelpViewer *createBlankPage();
66 void closeCurrentPage();
67
68 void nextPage();
69 void nextPageWithSwitcher();
70 void previousPage();
71 void previousPageWithSwitcher();
72
73 void closePage(HelpViewer *page);
74 void setCurrentPage(HelpViewer *page);
75
76signals:
77 void aboutToAddPage();
78 void pageAdded(int index);
79
80 void pageClosed();
81 void aboutToClosePage(int index);
82
83private slots:
84 void setCurrentPage(const QModelIndex &index);
85 void closePage(const QModelIndex &index);
86 void closePagesExcept(const QModelIndex &index);
87
88private:
89 OpenPagesManager(QObject *parent, bool defaultCollection,
90 const QUrl &cmdLineUrl);
91 ~OpenPagesManager();
92
93 void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl);
94 void closeOrReloadPages(const QString &nameSpace, bool tryReload);
95 void removePage(int index);
96
97 void nextOrPreviousPage(int offset);
98 void showSwitcherOrSelectPage() const;
99
100 OpenPagesModel *m_model;
101 OpenPagesWidget *m_openPagesWidget = nullptr;
102 OpenPagesSwitcher *m_openPagesSwitcher = nullptr;
103
104 static OpenPagesManager *m_instance;
105};
106
107QT_END_NAMESPACE
108
109#endif // OPENPAGESMANAGER_H
110

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