qt4target.h 5.32 KB
Newer Older
Tobias Hunger's avatar
Tobias Hunger committed
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
Tobias Hunger's avatar
Tobias Hunger committed
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
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

#ifndef QT4TARGET_H
#define QT4TARGET_H

#include "qt4buildconfiguration.h"
#include <projectexplorer/target.h>

36
37
#include <QtGui/QPixmap>

Tobias Hunger's avatar
Tobias Hunger committed
38
39
40
41
42
43
44
namespace Qt4ProjectManager {

class Qt4Project;

namespace Internal {
class Qt4ProFileNode;
class Qt4TargetFactory;
45
class Qt4BuildConfigurationFactory;
Tobias Hunger's avatar
Tobias Hunger committed
46
class Qt4DeployConfigurationFactory;
Tobias Hunger's avatar
Tobias Hunger committed
47

48
49
struct BuildConfigurationInfo {
    explicit BuildConfigurationInfo(QtVersion *v = 0, QtVersion::QmakeBuildConfigs bc = QtVersion::QmakeBuildConfig(0),
50
                                    const QString &aa = QString(), const QString &d = QString()) :
51
52
53
54
        version(v), buildConfig(bc), additionalArguments(aa), directory(d)
    { }
    QtVersion *version;
    QtVersion::QmakeBuildConfigs buildConfig;
55
    QString additionalArguments;
56
57
    QString directory;
};
58
}
59

Tobias Hunger's avatar
Tobias Hunger committed
60
61
62
class Qt4Target : public ProjectExplorer::Target
{
    Q_OBJECT
Friedemann Kleint's avatar
Friedemann Kleint committed
63
    friend class Internal::Qt4TargetFactory;
Tobias Hunger's avatar
Tobias Hunger committed
64
65

public:
66
    explicit Qt4Target(Qt4Project *parent, const QString &id);
Tobias Hunger's avatar
Tobias Hunger committed
67
68
    virtual ~Qt4Target();

69
70
    ProjectExplorer::BuildConfigWidget *createConfigWidget();

Tobias Hunger's avatar
Tobias Hunger committed
71
72
73
    Qt4BuildConfiguration *activeBuildConfiguration() const;
    Qt4ProjectManager::Qt4Project *qt4Project() const;

74
    Qt4BuildConfiguration *addQt4BuildConfiguration(QString displayName,
Tobias Hunger's avatar
Tobias Hunger committed
75
76
                                                              QtVersion *qtversion,
                                                              QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
77
                                                              QString additionalArguments,
78
                                                              QString directory);
Tobias Hunger's avatar
Tobias Hunger committed
79
80
81
    void addRunConfigurationForPath(const QString &proFilePath);

    Internal::Qt4BuildConfigurationFactory *buildConfigurationFactory() const;
Tobias Hunger's avatar
Tobias Hunger committed
82
    ProjectExplorer::DeployConfigurationFactory *deployConfigurationFactory() const;
Tobias Hunger's avatar
Tobias Hunger committed
83

84
85
    QList<ProjectExplorer::ToolChainType> filterToolChainTypes(const QList<ProjectExplorer::ToolChainType> &candidates) const;
    ProjectExplorer::ToolChainType preferredToolChainType(const QList<ProjectExplorer::ToolChainType> &candidates) const;
Tobias Hunger's avatar
Tobias Hunger committed
86

87
    QString defaultBuildDirectory() const;
88
    static QString defaultShadowBuildDirectory(const QString &projectLocation, const QString &id);
89

90
91
    bool fromMap(const QVariantMap &map);

Tobias Hunger's avatar
Tobias Hunger committed
92
signals:
93
    void buildDirectoryInitialized();
dt's avatar
dt committed
94
95
    /// emitted if the build configuration changed in a way that
    /// should trigger a reevaluation of all .pro files
96
    void proFileEvaluateNeeded(Qt4ProjectManager::Qt4Target *);
Tobias Hunger's avatar
Tobias Hunger committed
97
98
99

private slots:
    void updateQtVersion();
100
    void onAddedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
101
    void onAddedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
con's avatar
con committed
102
    void slotUpdateDeviceInformation();
103
    void onProFileEvaluateNeeded(Qt4ProjectManager::Qt4BuildConfiguration *bc);
dt's avatar
dt committed
104
    void emitProFileEvaluateNeeded();
con's avatar
con committed
105
    void updateToolTipAndIcon();
Tobias Hunger's avatar
Tobias Hunger committed
106
107

private:
108
109
110
    const QPixmap m_connectedPixmap;
    const QPixmap m_disconnectedPixmap;

Tobias Hunger's avatar
Tobias Hunger committed
111
    Internal::Qt4BuildConfigurationFactory *m_buildConfigurationFactory;
Tobias Hunger's avatar
Tobias Hunger committed
112
    Internal::Qt4DeployConfigurationFactory *m_deployConfigurationFactory;
Tobias Hunger's avatar
Tobias Hunger committed
113
114
};

115
namespace Internal {
Tobias Hunger's avatar
Tobias Hunger committed
116
117
118
119
120
121
122
123
class Qt4TargetFactory : public ProjectExplorer::ITargetFactory
{
    Q_OBJECT

public:
    Qt4TargetFactory(QObject *parent = 0);
    ~Qt4TargetFactory();

dt's avatar
dt committed
124
125
    virtual bool supportsTargetId(const QString &id) const;

Tobias Hunger's avatar
Tobias Hunger committed
126
127
128
129
    QStringList availableCreationIds(ProjectExplorer::Project *parent) const;
    QString displayNameForId(const QString &id) const;

    bool canCreate(ProjectExplorer::Project *parent, const QString &id) const;
130
131
132
    Qt4ProjectManager::Qt4Target *create(ProjectExplorer::Project *parent, const QString &id);
    Qt4ProjectManager::Qt4Target *create(ProjectExplorer::Project *parent, const QString &id, QList<QtVersion *> versions);
    Qt4ProjectManager::Qt4Target *create(ProjectExplorer::Project *parent, const QString &id, QList<Internal::BuildConfigurationInfo> infos);
Tobias Hunger's avatar
Tobias Hunger committed
133
    bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const;
134
    Qt4ProjectManager::Qt4Target *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
Tobias Hunger's avatar
Tobias Hunger committed
135
};
136
}
Tobias Hunger's avatar
Tobias Hunger committed
137
138
139
140

} // namespace Qt4ProjectManager

#endif // QT4TARGET_H