OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / dialogs / externaltoolconfig.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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef EXTERNALTOOLCONFIG_H
34 #define EXTERNALTOOLCONFIG_H
35
36 #include "coreplugin/externaltool.h"
37
38 #include <QtGui/QWidget>
39 #include <QtCore/QAbstractItemModel>
40
41 namespace Core {
42 namespace Internal {
43
44 namespace Ui {
45     class ExternalToolConfig;
46 }
47
48 class ExternalToolModel : public QAbstractItemModel
49 {
50     Q_OBJECT
51
52 public:
53     explicit ExternalToolModel(QObject *parent);
54     ~ExternalToolModel();
55
56     int columnCount(const QModelIndex &parent = QModelIndex()) const;
57     QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const;
58     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
59     QModelIndex parent(const QModelIndex &child) const;
60     int rowCount(const QModelIndex &parent = QModelIndex()) const;
61     Qt::ItemFlags flags(const QModelIndex &modelIndex) const;
62     bool setData(const QModelIndex &modelIndex, const QVariant &value, int role = Qt::EditRole);
63
64     QMimeData *mimeData(const QModelIndexList &indexes) const;
65     bool dropMimeData(const QMimeData *data,
66                       Qt::DropAction action,
67                       int row,
68                       int column,
69                       const QModelIndex &parent);
70     QStringList mimeTypes() const;
71
72     void setTools(const QMap<QString, QList<ExternalTool *> > &tools);
73     QMap<QString, QList<ExternalTool *> > tools() const;
74
75     ExternalTool *toolForIndex(const QModelIndex &modelIndex) const;
76     QString categoryForIndex(const QModelIndex &modelIndex) const;
77     void revertTool(const QModelIndex &modelIndex);
78     QModelIndex addCategory();
79     QModelIndex addTool(const QModelIndex &atIndex);
80     void removeTool(const QModelIndex &modelIndex);
81     Qt::DropActions supportedDropActions() const;
82 private:
83     QVariant data(ExternalTool *tool, int role = Qt::DisplayRole) const;
84     QVariant data(const QString &category, int role = Qt::DisplayRole) const;
85
86     QMap<QString, QList<ExternalTool *> > m_tools;
87 };
88
89
90 class ExternalToolConfig : public QWidget
91 {
92     Q_OBJECT
93
94 public:
95     explicit ExternalToolConfig(QWidget *parent = 0);
96     ~ExternalToolConfig();
97
98     void setTools(const QMap<QString, QList<ExternalTool *> > &tools);
99     QMap<QString, QList<ExternalTool *> > tools() const;
100     void apply();
101
102     QString searchKeywords() const;
103
104 private slots:
105     void handleCurrentChanged(const QModelIndex &now, const QModelIndex &previous);
106     void showInfoForItem(const QModelIndex &index);
107     void updateItem(const QModelIndex &index);
108     void revertCurrentItem();
109     void updateButtons(const QModelIndex &index);
110     void updateCurrentItem();
111     void addTool();
112     void removeTool();
113     void addCategory();
114
115 private:
116     Ui::ExternalToolConfig *ui;
117     ExternalToolModel *m_model;
118 };
119
120 } // Internal
121 } // Core
122
123
124 #endif // EXTERNALTOOLCONFIG_H