OSDN Git Service

44bc46c09a949e866e9fe19d96a8a079a6b9b50d
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / toolchainoptionspage.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 TOOLCHAINOPTIONSPAGE_H
35 #define TOOLCHAINOPTIONSPAGE_H
36
37 #include "ui_toolchainoptionspage.h"
38
39 #include <coreplugin/dialogs/ioptionspage.h>
40
41 #include <QtCore/QAbstractItemModel>
42
43 QT_BEGIN_NAMESPACE
44 class QTreeWidgetItem;
45 class QWidget;
46 QT_END_NAMESPACE
47
48 namespace ProjectExplorer {
49
50 class ToolChain;
51 class ToolChainConfigWidget;
52 class ToolChainFactory;
53 class ToolChainManager;
54
55 namespace Internal {
56
57 class ToolChainNode;
58 // --------------------------------------------------------------------------
59 // ToolChainModel
60 // --------------------------------------------------------------------------
61
62 class ToolChainModel : public QAbstractItemModel
63 {
64     Q_OBJECT
65
66 public:
67     explicit ToolChainModel(QWidget *configWidgetParent, QObject *parent = 0);
68     ~ToolChainModel();
69
70     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
71     QModelIndex parent(const QModelIndex &index) const;
72     int rowCount(const QModelIndex &parent = QModelIndex()) const;
73     int columnCount(const QModelIndex &parent = QModelIndex()) const;
74
75     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
76     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
77     Qt::ItemFlags flags(const QModelIndex &index) const;
78     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
79
80     ToolChain *toolChain(const QModelIndex &);
81     int manualToolChains() const;
82
83     ToolChainConfigWidget *widget(const QModelIndex &);
84
85     bool isDirty() const;
86     bool isDirty(ToolChain *) const;
87
88     void apply();
89
90     void markForRemoval(ToolChain *);
91     void markForAddition(ToolChain *);
92
93 signals:
94     void toolChainStateChanged();
95
96 private slots:
97     void addToolChain(ProjectExplorer::ToolChain *);
98     void removeToolChain(ProjectExplorer::ToolChain *);
99     void setDirty(ProjectExplorer::ToolChain *);
100
101 private:
102     QModelIndex index(ToolChainNode *, int column = 0) const;
103     ToolChainNode *createNode(ToolChainNode *parent, ToolChain *tc, bool changed);
104
105     ToolChainNode * m_root;
106     ToolChainNode * m_autoRoot;
107     ToolChainNode * m_manualRoot;
108
109     QList<ToolChainNode *> m_toAddList;
110     QList<ToolChainNode *> m_toRemoveList;
111
112     QWidget *m_configWidgetParent;
113 };
114
115 // --------------------------------------------------------------------------
116 // ToolChainOptionsPage
117 // --------------------------------------------------------------------------
118
119 class ToolChainOptionsPage : public Core::IOptionsPage
120 {
121     Q_OBJECT
122
123 public:
124     ToolChainOptionsPage();
125
126     virtual QString id() const;
127     virtual QString displayName() const;
128     virtual QString category() const;
129     virtual QString displayCategory() const;
130     virtual QIcon categoryIcon() const;
131
132     virtual QWidget *createPage(QWidget *parent);
133     virtual void apply();
134     virtual void finish();
135     virtual bool matches(const QString &) const;
136
137 private slots:
138     void toolChainSelectionChanged(const QModelIndex &, const QModelIndex &);
139     void createToolChain(QObject *);
140     void removeToolChain();
141     void updateState();
142
143 private:
144     Ui::ToolChainOptionsPage *m_ui;
145     QWidget *m_configWidget;
146     QString m_searchKeywords;
147
148     ToolChainModel *m_model;
149     QList<ToolChainFactory *> m_factories;
150     QItemSelectionModel * m_selectionModel;
151     ToolChainConfigWidget *m_currentTcWidget;
152 };
153
154 } // namespace Internal
155 } // namespace ProjectExplorer
156
157 #endif // TOOLCHAINOPTIONSPAGE_H