kit.h 5.01 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
Tobias Hunger's avatar
Tobias Hunger committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
Tobias Hunger's avatar
Tobias Hunger committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
Tobias Hunger's avatar
Tobias Hunger committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
Tobias Hunger's avatar
Tobias Hunger committed
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** 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.
Tobias Hunger's avatar
Tobias Hunger committed
23
**
hjk's avatar
hjk committed
24 25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
Tobias Hunger's avatar
Tobias Hunger committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
Tobias Hunger's avatar
Tobias Hunger committed
29

Tobias Hunger's avatar
Tobias Hunger committed
30 31
#ifndef KIT_H
#define KIT_H
Tobias Hunger's avatar
Tobias Hunger committed
32 33 34 35

#include "projectexplorer_export.h"
#include "task.h"

36 37 38
#include <coreplugin/featureprovider.h>

#include <QSet>
Tobias Hunger's avatar
Tobias Hunger committed
39 40
#include <QVariant>

41 42 43 44
namespace Utils {
class AbstractMacroExpander;
class Environment;
} // namespace Utils
Tobias Hunger's avatar
Tobias Hunger committed
45 46

namespace ProjectExplorer {
47
class IOutputParser;
Tobias Hunger's avatar
Tobias Hunger committed
48 49

namespace Internal {
50
class KitModel;
Tobias Hunger's avatar
Tobias Hunger committed
51
class KitPrivate;
Tobias Hunger's avatar
Tobias Hunger committed
52 53 54
} // namespace Internal

/**
Tobias Hunger's avatar
Tobias Hunger committed
55
 * @brief The Kit class
Tobias Hunger's avatar
Tobias Hunger committed
56
 *
Tobias Hunger's avatar
Tobias Hunger committed
57
 * The kit holds a set of values defining a system targeted by the software
Tobias Hunger's avatar
Tobias Hunger committed
58 59
 * under development.
 */
Tobias Hunger's avatar
Tobias Hunger committed
60
class PROJECTEXPLORER_EXPORT Kit
Tobias Hunger's avatar
Tobias Hunger committed
61 62
{
public:
63
    Kit(Core::Id id = Core::Id());
Tobias Hunger's avatar
Tobias Hunger committed
64

65 66 67 68 69
    // Do not trigger evaluations
    void blockNotification();
    // Trigger evaluations again.
    void unblockNotification();

Tobias Hunger's avatar
Tobias Hunger committed
70
    bool isValid() const;
71
    bool hasWarning() const;
72
    QList<Task> validate() const;
Tobias Hunger's avatar
Tobias Hunger committed
73 74
    void fix(); // Fix the individual kit information: Make sure it contains a valid value.
                // Fix will not look at other information in the kit!
75
    void setup(); // Apply advanced magic(TM). Used only once on each kit during initial setup.
Tobias Hunger's avatar
Tobias Hunger committed
76

77
    QString unexpandedDisplayName() const;
Tobias Hunger's avatar
Tobias Hunger committed
78
    QString displayName() const;
79
    void setUnexpandedDisplayName(const QString &name);
Tobias Hunger's avatar
Tobias Hunger committed
80

81 82
    QStringList candidateNameList(const QString &base) const;

83
    QString fileSystemFriendlyName() const;
84 85
    QString customFileSystemFriendlyName() const;
    void setCustomFileSystemFriendlyName(const QString &fileSystemFriendlyName);
86

Tobias Hunger's avatar
Tobias Hunger committed
87
    bool isAutoDetected() const;
88
    QString autoDetectionSource() const;
Daniel Teske's avatar
Daniel Teske committed
89
    bool isSdkProvided() const;
Tobias Hunger's avatar
Tobias Hunger committed
90 91 92
    Core::Id id() const;

    QIcon icon() const;
93 94 95
    static QIcon icon(const Utils::FileName &path);
    Utils::FileName iconPath() const;
    void setIconPath(const Utils::FileName &path);
Tobias Hunger's avatar
Tobias Hunger committed
96

97 98 99 100
    QVariant value(Core::Id key, const QVariant &unset = QVariant()) const;
    bool hasValue(Core::Id key) const;
    void setValue(Core::Id key, const QVariant &value);
    void removeKey(Core::Id key);
101
    bool isSticky(Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
102

Tobias Hunger's avatar
Tobias Hunger committed
103 104
    bool isDataEqual(const Kit *other) const;
    bool isEqual(const Kit *other) const;
Tobias Hunger's avatar
Tobias Hunger committed
105 106

    void addToEnvironment(Utils::Environment &env) const;
107
    IOutputParser *createOutputParser() const;
Tobias Hunger's avatar
Tobias Hunger committed
108

109
    QString toHtml() const;
Tobias Hunger's avatar
Tobias Hunger committed
110
    Kit *clone(bool keepName = false) const;
111
    void copyFrom(const Kit *k);
Tobias Hunger's avatar
Tobias Hunger committed
112

113
    // Note: Stickyness is *not* saved!
Daniel Teske's avatar
Daniel Teske committed
114
    void setAutoDetected(bool detected);
115
    void setAutoDetectionSource(const QString &autoDetectionSource);
116
    void makeSticky();
117
    void setSticky(Core::Id id, bool b);
118
    void makeUnSticky();
119

120 121 122
    void setMutable(Core::Id id, bool b);
    bool isMutable(Core::Id id) const;

123 124 125 126 127 128
    QSet<QString> availablePlatforms() const;
    bool hasPlatform(const QString &platform) const;
    QString displayNameForPlatform(const QString &platform) const;
    Core::FeatureSet availableFeatures() const;
    bool hasFeatures(const Core::FeatureSet &features) const;

129 130
    Utils::AbstractMacroExpander *macroExpander() const;

Tobias Hunger's avatar
Tobias Hunger committed
131
private:
Daniel Teske's avatar
Daniel Teske committed
132
    void setSdkProvided(bool sdkProvided);
133

134
    ~Kit();
135
    Kit(const QVariantMap &data);
136

137
    // Unimplemented.
Tobias Hunger's avatar
Tobias Hunger committed
138 139
    Kit(const Kit &other);
    void operator=(const Kit &other);
140

141
    void kitDisplayNameChanged();
Tobias Hunger's avatar
Tobias Hunger committed
142
    void kitUpdated();
Tobias Hunger's avatar
Tobias Hunger committed
143 144 145

    QVariantMap toMap() const;

Tobias Hunger's avatar
Tobias Hunger committed
146
    Internal::KitPrivate *const d;
Tobias Hunger's avatar
Tobias Hunger committed
147

148
    friend class KitInformation;
Tobias Hunger's avatar
Tobias Hunger committed
149
    friend class KitManager;
150
    friend class Internal::KitModel; // needed for setAutoDetected() when cloning kits
Tobias Hunger's avatar
Tobias Hunger committed
151 152
};

153 154 155 156 157 158 159 160 161 162 163
class KitGuard
{
public:
    KitGuard(Kit *k) : m_kit(k)
    { k->blockNotification(); }

    ~KitGuard() { m_kit->unblockNotification(); }
private:
    Kit *m_kit;
};

Tobias Hunger's avatar
Tobias Hunger committed
164 165
} // namespace ProjectExplorer

Tobias Hunger's avatar
Tobias Hunger committed
166
Q_DECLARE_METATYPE(ProjectExplorer::Kit *)
Tobias Hunger's avatar
Tobias Hunger committed
167

Tobias Hunger's avatar
Tobias Hunger committed
168
#endif // KIT_H