OSDN Git Service

fc698a1726bf2b9c2cc3caf7277e3599b33eb1fd
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / dialogs / settingsdialog.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef SETTINGSDIALOG_H
35 #define SETTINGSDIALOG_H
36
37 #include "coreplugin/dialogs/ioptionspage.h"
38
39 #include <QtCore/QList>
40 #include <QtCore/QSet>
41 #include <QtCore/QPointer>
42 #include <QtCore/QEventLoop>
43 #include <QtGui/QDialog>
44
45 QT_BEGIN_NAMESPACE
46 class QModelIndex;
47 class QSortFilterProxyModel;
48 class QStackedLayout;
49 class QLabel;
50 class QListView;
51 QT_END_NAMESPACE
52
53 namespace Utils {
54     class FilterLineEdit;
55 }
56
57 namespace Core {
58 namespace Internal {
59
60 class Category;
61 class CategoryModel;
62
63 class SettingsDialog : public QDialog
64 {
65     Q_OBJECT
66
67 public:
68
69     // Returns a settings dialog. This makes sure that always only
70     // a single settings dialog instance is running.
71     // The dialog will be deleted automatically on close.
72     static SettingsDialog *getSettingsDialog(QWidget *parent,
73                                const QString &initialCategory = QString(),
74                                const QString &initialPage = QString());
75     // Run the dialog and wait for it to finish.
76     // Returns if the changes have been applied.
77     bool execDialog();
78
79     virtual QSize sizeHint() const;
80
81 public slots:
82     void done(int);
83
84 private slots:
85     void accept();
86     void reject();
87     void apply();
88     void currentChanged(const QModelIndex &current);
89     void currentTabChanged(int);
90     void filter(const QString &text);
91     void ensureAllCategoryWidgets();
92
93 private:
94     SettingsDialog(QWidget *parent);
95     ~SettingsDialog();
96
97     void createGui();
98     void showCategory(int index);
99     void showPage(const QString &categoryId, const QString &pageId);
100     void updateEnabledTabs(Category *category, const QString &searchText);
101     void ensureCategoryWidget(Category *category);
102     void disconnectTabWidgets();
103
104     const QList<Core::IOptionsPage*> m_pages;
105
106     QSet<Core::IOptionsPage*> m_visitedPages;
107     QSortFilterProxyModel *m_proxyModel;
108     CategoryModel *m_model;
109     QString m_currentCategory;
110     QString m_currentPage;
111     QStackedLayout *m_stackedLayout;
112     Utils::FilterLineEdit *m_filterLineEdit;
113     QListView *m_categoryList;
114     QLabel *m_headerLabel;
115     bool m_running;
116     bool m_applied;
117     QList<QEventLoop *> m_eventLoops;
118     static QPointer<SettingsDialog> m_instance;
119 };
120
121 } // namespace Internal
122 } // namespace Core
123
124 #endif // SETTINGSDIALOG_H