1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
***************************************************************************/
#ifndef QTVERSIONMANAGER_H
#define QTVERSIONMANAGER_H
#include <QtCore/QPointer>
#include <QtGui/QWidget>
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h>
#include <projectexplorer/ProjectExplorerInterfaces>
#include <QDebug>
#include "ui_qtversionmanager.h"
namespace Qt4ProjectManager {
namespace Internal {
class QtDirWidget;
class QtVersion {
friend class QtDirWidget; //for changing name and path
friend class QtVersionManager;
public:
QtVersion(const QString &name, const QString &path);
QtVersion(const QString &name, const QString &path, int id, bool isSystemVersion = false);
QtVersion()
:m_name(QString::null), m_path(QString::null), m_id(-1)
{ }
bool isValid() const; //TOOD check that the dir exists and the name is non empty
bool isInstalled() const;
bool isSystemVersion() const { return m_isSystemVersion; }
QString name() const;
QString path() const;
QString sourcePath() const;
QString mkspec() const;
QString makeCommand() const;
QString qmakeCommand() const;
// Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information
QHash<QString,QString> versionInfo() const;
enum ToolchainType { MinGW, MSVC, WINCE, OTHER, INVALID };
ToolchainType toolchainType() const;
QString mingwDirectory() const;
void setMingwDirectory(const QString &directory);
QString prependPath() const;
void setPrependPath(const QString &string);
QString msvcVersion() const;
void setMsvcVersion(const QString &version);
ProjectExplorer::Environment addToEnvironment(const ProjectExplorer::Environment &env);
int uniqueId() const;
enum QmakeBuildConfig
{
NoBuild = 1,
DebugBuild = 2,
BuildAll = 8
};
QmakeBuildConfig defaultBuildConfig() const;
private:
static int getUniqueId();
void setName(const QString &name);
void setPath(const QString &path);
void updateSourcePath();
void updateVersionInfo() const;
void updateMkSpec() const;
QString m_name;
mutable bool m_versionInfoUpToDate;
mutable bool m_mkspecUpToDate;
QString m_path;
QString m_sourcePath;
mutable QString m_mkspec; // updated lazily
QString m_mingwDirectory;
QString m_prependPath;
QString m_msvcVersion;
mutable QHash<QString,QString> m_versionInfo; // updated lazily
int m_id;
bool m_isSystemVersion;
mutable bool m_notInstalled;
mutable bool m_defaultConfigIsDebug;
mutable bool m_defaultConfigIsDebugAndRelease;
mutable QString m_qmakeCommand;
Q_DISABLE_COPY(QtVersion);
};
class QtDirWidget : public QWidget
{
Q_OBJECT
public:
QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defaultVersion);
QList<QtVersion *> versions() const;
int defaultVersion() const;
void finish();
private:
void showEnvironmentPage(QTreeWidgetItem * item);
void fixQtVersionName(int index);
Ui::QtVersionManager m_ui;
QList<QtVersion *> m_versions;
int m_defaultVersion;
QString m_specifyNameString;
QString m_specifyPathString;
private slots:
void versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old);
void addQtDir();
void removeQtDir();
void updateState();
void browse();
void mingwBrowse();
void defaultChanged(int index);
void updateCurrentQtName();
void updateCurrentQtPath();
void updateCurrentMingwDirectory();
void msvcVersionChanged();
};
class QtVersionManager : public Core::IOptionsPage
{
Q_OBJECT
public:
QtVersionManager();
~QtVersionManager();
QString name() const;
QString category() const;
QString trCategory() const;
QWidget *createPage(QWidget *parent);
void finished(bool accepted);
void writeVersionsIntoSettings();
QList<QtVersion *> versions() const;
QtVersion * version(int id) const;
QtVersion * currentQtVersion() const;
// internal
int getUniqueId();
QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);
QString findQtVersionFromMakefile(const QString &directory);
QtVersion *qtVersionForDirectory(const QString &directory);
// Used by the projectloadwizard
void addVersion(QtVersion *version);
// returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
static QStringList possibleQMakeCommands();
// return true if the qmake at qmakePath is qt4 (used by QtVersion)
static bool checkQMakeVersion(const QString &qmakePath);
signals:
void defaultQtVersionChanged();
void qtVersionsChanged();
private:
void addNewVersionsFromInstaller();
void updateSystemVersion();
void updateDocumentation();
QString findSystemQt() const;
static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list);
void updateUniqueIdToIndexMap();
Core::ICore *m_core;
QPointer<QtDirWidget> m_widget;
QtVersion *m_emptyVersion;
int m_defaultVersion;
QList<QtVersion *> m_versions;
QMap<int, int> m_uniqueIdToIndex;
int m_idcount;
};
} //namespace Internal
} //namespace Qt4ProjectManager
#endif //QTVERSIONMANAGER_H
|