kit.cpp 15.7 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
#include "kit.h"
Tobias Hunger's avatar
Tobias Hunger committed
31

Tobias Hunger's avatar
Tobias Hunger committed
32
#include "kitmanager.h"
33
#include "ioutputparser.h"
34
#include "osparser.h"
Tobias Hunger's avatar
Tobias Hunger committed
35

36
37
#include <utils/fileutils.h>

Tobias Hunger's avatar
Tobias Hunger committed
38
#include <QApplication>
39
#include <QFileInfo>
Tobias Hunger's avatar
Tobias Hunger committed
40
41
42
43
44
#include <QIcon>
#include <QStyle>
#include <QTextStream>
#include <QUuid>

45
46
using namespace Core;

Tobias Hunger's avatar
Tobias Hunger committed
47
48
49
50
51
namespace {

const char ID_KEY[] = "PE.Profile.Id";
const char DISPLAYNAME_KEY[] = "PE.Profile.Name";
const char AUTODETECTED_KEY[] = "PE.Profile.AutoDetected";
52
const char AUTODETECTIONSOURCE_KEY[] = "PE.Profile.AutoDetectionSource";
Daniel Teske's avatar
Daniel Teske committed
53
const char SDK_PROVIDED_KEY[] = "PE.Profile.SDK";
Tobias Hunger's avatar
Tobias Hunger committed
54
55
const char DATA_KEY[] = "PE.Profile.Data";
const char ICON_KEY[] = "PE.Profile.Icon";
56
const char MUTABLE_INFO_KEY[] = "PE.Profile.MutableInfo";
57
const char STICKY_INFO_KEY[] = "PE.Profile.StickyInfo";
Tobias Hunger's avatar
Tobias Hunger committed
58
59
60
61
62
63

} // namespace

namespace ProjectExplorer {

// -------------------------------------------------------------------------
Tobias Hunger's avatar
Tobias Hunger committed
64
// KitPrivate
Tobias Hunger's avatar
Tobias Hunger committed
65
66
67
68
// -------------------------------------------------------------------------

namespace Internal {

Tobias Hunger's avatar
Tobias Hunger committed
69
class KitPrivate
Tobias Hunger's avatar
Tobias Hunger committed
70
71
{
public:
72
    KitPrivate(Id id) :
73
        m_id(id),
Tobias Hunger's avatar
Tobias Hunger committed
74
        m_nestedBlockingLevel(0),
Tobias Hunger's avatar
Tobias Hunger committed
75
        m_autodetected(false),
76
        m_autoDetectionSource(QString()),
Daniel Teske's avatar
Daniel Teske committed
77
        m_sdkProvided(false),
78
        m_isValid(true),
79
        m_hasWarning(false),
Tobias Hunger's avatar
Tobias Hunger committed
80
        m_hasValidityInfo(false),
81
82
        m_mustNotify(false),
        m_mustNotifyAboutDisplayName(false)
83
84
    {
        if (!id.isValid())
85
            m_id = Id::fromString(QUuid::createUuid().toString());
86
87

        m_displayName = QCoreApplication::translate("ProjectExplorer::Kit", "Unnamed");
88
        m_iconPath = Utils::FileName::fromLatin1(":///DESKTOP///");
89
    }
Tobias Hunger's avatar
Tobias Hunger committed
90
91

    QString m_displayName;
92
    Id m_id;
Tobias Hunger's avatar
Tobias Hunger committed
93
    int m_nestedBlockingLevel;
Tobias Hunger's avatar
Tobias Hunger committed
94
    bool m_autodetected;
95
    QString m_autoDetectionSource;
Daniel Teske's avatar
Daniel Teske committed
96
    bool m_sdkProvided;
Tobias Hunger's avatar
Tobias Hunger committed
97
    bool m_isValid;
98
    bool m_hasWarning;
Tobias Hunger's avatar
Tobias Hunger committed
99
    bool m_hasValidityInfo;
100
    bool m_mustNotify;
101
    bool m_mustNotifyAboutDisplayName;
Tobias Hunger's avatar
Tobias Hunger committed
102
103
    QIcon m_icon;
    Utils::FileName m_iconPath;
Tobias Hunger's avatar
Tobias Hunger committed
104
105

    QHash<Core::Id, QVariant> m_data;
106
    QSet<Core::Id> m_sticky;
107
    QSet<Core::Id> m_mutable;
Tobias Hunger's avatar
Tobias Hunger committed
108
109
110
111
112
};

} // namespace Internal

// -------------------------------------------------------------------------
Tobias Hunger's avatar
Tobias Hunger committed
113
// Kit:
Tobias Hunger's avatar
Tobias Hunger committed
114
115
// -------------------------------------------------------------------------

116
117
Kit::Kit(Core::Id id) :
    d(new Internal::KitPrivate(id))
Tobias Hunger's avatar
Tobias Hunger committed
118
{
119
    foreach (KitInformation *sti, KitManager::kitInformation())
120
        d->m_data.insert(sti->id(), sti->defaultValue(this));
Tobias Hunger's avatar
Tobias Hunger committed
121

122
    d->m_icon = icon(d->m_iconPath);
Tobias Hunger's avatar
Tobias Hunger committed
123
124
}

125
126
127
128
129
130
Kit::Kit(const QVariantMap &data) :
    d(new Internal::KitPrivate(Core::Id()))
{
    d->m_id = Id::fromSetting(data.value(QLatin1String(ID_KEY)));

    d->m_autodetected = data.value(QLatin1String(AUTODETECTED_KEY)).toBool();
131
    d->m_autoDetectionSource = data.value(QLatin1String(AUTODETECTIONSOURCE_KEY)).toString();
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

    // if we don't have that setting assume that autodetected implies sdk
    QVariant value = data.value(QLatin1String(SDK_PROVIDED_KEY));
    if (value.isValid())
        d->m_sdkProvided = value.toBool();
    else
        d->m_sdkProvided = d->m_autodetected;

    d->m_displayName = data.value(QLatin1String(DISPLAYNAME_KEY),
                                  d->m_displayName).toString();
    d->m_iconPath = Utils::FileName::fromString(data.value(QLatin1String(ICON_KEY),
                                                           d->m_iconPath.toString()).toString());
    d->m_icon = icon(d->m_iconPath);

    QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap();
    d->m_data.clear(); // remove default values
    const QVariantMap::ConstIterator cend = extra.constEnd();
    for (QVariantMap::ConstIterator it = extra.constBegin(); it != cend; ++it)
        d->m_data.insert(Id::fromString(it.key()), it.value());

    QStringList mutableInfoList = data.value(QLatin1String(MUTABLE_INFO_KEY)).toStringList();
    foreach (const QString &mutableInfo, mutableInfoList)
        d->m_mutable.insert(Core::Id::fromString(mutableInfo));
155
156
157
158

    QStringList stickyInfoList = data.value(QLatin1String(STICKY_INFO_KEY)).toStringList();
    foreach (const QString &stickyInfo, stickyInfoList)
        d->m_sticky.insert(Core::Id::fromString(stickyInfo));
159
160
}

Tobias Hunger's avatar
Tobias Hunger committed
161
Kit::~Kit()
Tobias Hunger's avatar
Tobias Hunger committed
162
{
163
    delete d;
Tobias Hunger's avatar
Tobias Hunger committed
164
165
}

166
167
168
169
170
171
172
173
174
175
void Kit::blockNotification()
{
    ++d->m_nestedBlockingLevel;
}

void Kit::unblockNotification()
{
    --d->m_nestedBlockingLevel;
    if (d->m_nestedBlockingLevel > 0)
        return;
176
177
178
    if (d->m_mustNotifyAboutDisplayName)
        kitDisplayNameChanged();
    else if (d->m_mustNotify)
179
180
        kitUpdated();
    d->m_mustNotify = false;
181
    d->m_mustNotifyAboutDisplayName = false;
182
183
}

Tobias Hunger's avatar
Tobias Hunger committed
184
Kit *Kit::clone(bool keepName) const
Tobias Hunger's avatar
Tobias Hunger committed
185
{
186
    Kit *k = new Kit;
Tobias Hunger's avatar
Tobias Hunger committed
187
    if (keepName)
188
        k->d->m_displayName = d->m_displayName;
Tobias Hunger's avatar
Tobias Hunger committed
189
    else
190
        k->d->m_displayName = QCoreApplication::translate("ProjectExplorer::Kit", "Clone of %1")
Tobias Hunger's avatar
Tobias Hunger committed
191
                .arg(d->m_displayName);
192
193
194
195
196
    k->d->m_autodetected = false;
    k->d->m_data = d->m_data;
    k->d->m_isValid = d->m_isValid;
    k->d->m_icon = d->m_icon;
    k->d->m_iconPath = d->m_iconPath;
197
    k->d->m_sticky = d->m_sticky;
198
    k->d->m_mutable = d->m_mutable;
199
    return k;
Tobias Hunger's avatar
Tobias Hunger committed
200
201
}

202
203
void Kit::copyFrom(const Kit *k)
{
204
    KitGuard g(this);
205
206
207
208
    d->m_data = k->d->m_data;
    d->m_iconPath = k->d->m_iconPath;
    d->m_icon = k->d->m_icon;
    d->m_autodetected = k->d->m_autodetected;
209
    d->m_autoDetectionSource = k->d->m_autoDetectionSource;
210
    d->m_displayName = k->d->m_displayName;
211
    d->m_mustNotify = true;
212
    d->m_mustNotifyAboutDisplayName = true;
213
    d->m_sticky = k->d->m_sticky;
214
    d->m_mutable = k->d->m_mutable;
215
216
}

Tobias Hunger's avatar
Tobias Hunger committed
217
bool Kit::isValid() const
Tobias Hunger's avatar
Tobias Hunger committed
218
{
Tobias Hunger's avatar
Tobias Hunger committed
219
220
221
222
223
224
225
    if (!d->m_id.isValid())
        return false;

    if (!d->m_hasValidityInfo)
        validate();

    return d->m_isValid;
Tobias Hunger's avatar
Tobias Hunger committed
226
227
}

228
229
bool Kit::hasWarning() const
{
Tobias Hunger's avatar
Tobias Hunger committed
230
231
232
    if (!d->m_hasValidityInfo)
        validate();

233
234
235
    return d->m_hasWarning;
}

236
QList<Task> Kit::validate() const
Tobias Hunger's avatar
Tobias Hunger committed
237
238
{
    QList<Task> result;
239
    QList<KitInformation *> infoList = KitManager::kitInformation();
240
    d->m_isValid = true;
241
    d->m_hasWarning = false;
242
243
244
245
246
    foreach (KitInformation *i, infoList) {
        QList<Task> tmp = i->validate(this);
        foreach (const Task &t, tmp) {
            if (t.type == Task::Error)
                d->m_isValid = false;
247
248
            if (t.type == Task::Warning)
                d->m_hasWarning = true;
249
250
251
252
        }
        result.append(tmp);
    }
    qSort(result);
Tobias Hunger's avatar
Tobias Hunger committed
253
    d->m_hasValidityInfo = true;
Tobias Hunger's avatar
Tobias Hunger committed
254
255
256
    return result;
}

257
258
259
void Kit::fix()
{
    KitGuard g(this);
260
    foreach (KitInformation *i, KitManager::kitInformation())
261
262
263
        i->fix(this);
}

264
265
266
void Kit::setup()
{
    KitGuard g(this);
Tobias Hunger's avatar
Tobias Hunger committed
267
268
    // Process the KitInfos in reverse order: They may only be based on other information lower in
    // the stack.
269
    QList<KitInformation *> info = KitManager::kitInformation();
Tobias Hunger's avatar
Tobias Hunger committed
270
271
    for (int i = info.count() - 1; i >= 0; --i)
        info.at(i)->setup(this);
272
273
}

Tobias Hunger's avatar
Tobias Hunger committed
274
QString Kit::displayName() const
Tobias Hunger's avatar
Tobias Hunger committed
275
276
277
278
{
    return d->m_displayName;
}

Tobias Hunger's avatar
Tobias Hunger committed
279
280
281
282
static QString candidateName(const QString &name, const QString &postfix)
{
    if (name.contains(postfix))
        return QString();
283
284
285
286
287
    QString candidate = name;
    if (!candidate.isEmpty())
        candidate.append(QLatin1Char('-'));
    candidate.append(postfix);
    return candidate;
Tobias Hunger's avatar
Tobias Hunger committed
288
289
}

Tobias Hunger's avatar
Tobias Hunger committed
290
void Kit::setDisplayName(const QString &name)
Tobias Hunger's avatar
Tobias Hunger committed
291
{
292
293
294
295
296
    if (d->m_displayName == name)
        return;
    d->m_displayName = name;
    kitDisplayNameChanged();
}
Tobias Hunger's avatar
Tobias Hunger committed
297

298
299
300
301
QStringList Kit::candidateNameList(const QString &base) const
{
    QStringList result;
    result << base;
302
    foreach (KitInformation *ki, KitManager::kitInformation()) {
Tobias Hunger's avatar
Tobias Hunger committed
303
        const QString postfix = ki->displayNamePostfix(this);
304
305
306
307
308
        if (!postfix.isEmpty()) {
            QString tmp = candidateName(base, postfix);
            if (!tmp.isEmpty())
                result << candidateName(base, postfix);
        }
309
    }
310
    return result;
Tobias Hunger's avatar
Tobias Hunger committed
311
312
}

313
314
QString Kit::fileSystemFriendlyName() const
{
315
    QString name = Utils::FileUtils::qmakeFriendlyName(displayName());
316
    foreach (Kit *i, KitManager::kits()) {
317
318
        if (i == this)
            continue;
319
        if (name == Utils::FileUtils::qmakeFriendlyName(i->displayName())) {
320
321
            // append part of the kit id: That should be unique enough;-)
            // Leading { will be turned into _ which should be fine.
322
            name = Utils::FileUtils::qmakeFriendlyName(name + QLatin1Char('_') + (id().toString().left(7)));
323
324
325
326
327
328
            break;
        }
    }
    return name;
}

Tobias Hunger's avatar
Tobias Hunger committed
329
bool Kit::isAutoDetected() const
Tobias Hunger's avatar
Tobias Hunger committed
330
331
332
333
{
    return d->m_autodetected;
}

334
335
336
337
338
QString Kit::autoDetectionSource() const
{
    return d->m_autoDetectionSource;
}

Daniel Teske's avatar
Daniel Teske committed
339
340
341
342
343
bool Kit::isSdkProvided() const
{
    return d->m_sdkProvided;
}

344
Id Kit::id() const
Tobias Hunger's avatar
Tobias Hunger committed
345
346
347
348
{
    return d->m_id;
}

Tobias Hunger's avatar
Tobias Hunger committed
349
QIcon Kit::icon() const
Tobias Hunger's avatar
Tobias Hunger committed
350
351
352
353
{
    return d->m_icon;
}

354
QIcon Kit::icon(const Utils::FileName &path)
355
356
357
{
    if (path.isEmpty())
        return QIcon();
358
    if (path == Utils::FileName::fromLatin1(":///DESKTOP///"))
359
360
        return qApp->style()->standardIcon(QStyle::SP_ComputerIcon);

361
    QFileInfo fi(path.toString());
362
    if (fi.isFile() && fi.isReadable())
363
        return QIcon(path.toString());
364
365
366
    return QIcon();
}

367
Utils::FileName Kit::iconPath() const
Tobias Hunger's avatar
Tobias Hunger committed
368
369
370
371
{
    return d->m_iconPath;
}

372
void Kit::setIconPath(const Utils::FileName &path)
Tobias Hunger's avatar
Tobias Hunger committed
373
374
375
376
{
    if (d->m_iconPath == path)
        return;
    d->m_iconPath = path;
377
    d->m_icon = icon(path);
Tobias Hunger's avatar
Tobias Hunger committed
378
    kitUpdated();
Tobias Hunger's avatar
Tobias Hunger committed
379
380
}

381
QVariant Kit::value(Id key, const QVariant &unset) const
Tobias Hunger's avatar
Tobias Hunger committed
382
383
384
385
{
    return d->m_data.value(key, unset);
}

386
bool Kit::hasValue(Id key) const
Tobias Hunger's avatar
Tobias Hunger committed
387
388
389
390
{
    return d->m_data.contains(key);
}

391
void Kit::setValue(Id key, const QVariant &value)
Tobias Hunger's avatar
Tobias Hunger committed
392
393
394
395
{
    if (d->m_data.value(key) == value)
        return;
    d->m_data.insert(key, value);
Tobias Hunger's avatar
Tobias Hunger committed
396
    kitUpdated();
Tobias Hunger's avatar
Tobias Hunger committed
397
398
}

399
void Kit::removeKey(Id key)
Tobias Hunger's avatar
Tobias Hunger committed
400
401
402
403
{
    if (!d->m_data.contains(key))
        return;
    d->m_data.remove(key);
404
    d->m_sticky.remove(key);
405
    d->m_mutable.remove(key);
Tobias Hunger's avatar
Tobias Hunger committed
406
    kitUpdated();
Tobias Hunger's avatar
Tobias Hunger committed
407
408
}

409
410
411
412
413
bool Kit::isSticky(Core::Id id) const
{
    return d->m_sticky.contains(id);
}

Tobias Hunger's avatar
Tobias Hunger committed
414
415
416
417
418
419
420
421
422
bool Kit::isDataEqual(const Kit *other) const
{
    return d->m_data == other->d->m_data;
}

bool Kit::isEqual(const Kit *other) const
{
    return isDataEqual(other)
            && d->m_iconPath == other->d->m_iconPath
423
424
425
            && d->m_displayName == other->d->m_displayName
            && d->m_mutable == other->d->m_mutable;

Tobias Hunger's avatar
Tobias Hunger committed
426
427
}

Tobias Hunger's avatar
Tobias Hunger committed
428
QVariantMap Kit::toMap() const
Tobias Hunger's avatar
Tobias Hunger committed
429
{
430
431
    typedef QHash<Core::Id, QVariant>::ConstIterator IdVariantConstIt;

Tobias Hunger's avatar
Tobias Hunger committed
432
433
434
435
    QVariantMap data;
    data.insert(QLatin1String(ID_KEY), QString::fromLatin1(d->m_id.name()));
    data.insert(QLatin1String(DISPLAYNAME_KEY), d->m_displayName);
    data.insert(QLatin1String(AUTODETECTED_KEY), d->m_autodetected);
436
    data.insert(QLatin1String(AUTODETECTIONSOURCE_KEY), d->m_autoDetectionSource);
Daniel Teske's avatar
Daniel Teske committed
437
    data.insert(QLatin1String(SDK_PROVIDED_KEY), d->m_sdkProvided);
438
    data.insert(QLatin1String(ICON_KEY), d->m_iconPath.toString());
Tobias Hunger's avatar
Tobias Hunger committed
439

440
    QStringList mutableInfo;
441
    foreach (const Core::Id &id, d->m_mutable)
442
443
444
        mutableInfo << id.toString();
    data.insert(QLatin1String(MUTABLE_INFO_KEY), mutableInfo);

445
446
447
448
449
    QStringList stickyInfo;
    foreach (const Core::Id &id, d->m_sticky)
        stickyInfo << id.toString();
    data.insert(QLatin1String(STICKY_INFO_KEY), stickyInfo);

Tobias Hunger's avatar
Tobias Hunger committed
450
    QVariantMap extra;
451
452
453
454

    const IdVariantConstIt cend = d->m_data.constEnd();
    for (IdVariantConstIt it = d->m_data.constBegin(); it != cend; ++it)
        extra.insert(QString::fromLatin1(it.key().name().constData()), it.value());
Tobias Hunger's avatar
Tobias Hunger committed
455
456
457
458
459
    data.insert(QLatin1String(DATA_KEY), extra);

    return data;
}

Tobias Hunger's avatar
Tobias Hunger committed
460
void Kit::addToEnvironment(Utils::Environment &env) const
Tobias Hunger's avatar
Tobias Hunger committed
461
{
462
    QList<KitInformation *> infoList = KitManager::kitInformation();
Tobias Hunger's avatar
Tobias Hunger committed
463
464
    foreach (KitInformation *ki, infoList)
        ki->addToEnvironment(this, env);
Tobias Hunger's avatar
Tobias Hunger committed
465
466
}

467
468
IOutputParser *Kit::createOutputParser() const
{
469
    IOutputParser *first = new OsParser;
470
    QList<KitInformation *> infoList = KitManager::kitInformation();
471
472
    foreach (KitInformation *ki, infoList)
        first->appendOutputParser(ki->createOutputParser(this));
473
474
475
    return first;
}

476
QString Kit::toHtml() const
Tobias Hunger's avatar
Tobias Hunger committed
477
478
479
480
481
482
483
{
    QString rc;
    QTextStream str(&rc);
    str << "<html><body>";
    str << "<h3>" << displayName() << "</h3>";
    str << "<table>";

484
    if (!isValid() || hasWarning()) {
Tobias Hunger's avatar
Tobias Hunger committed
485
486
487
488
489
490
        QList<Task> issues = validate();
        str << "<p>";
        foreach (const Task &t, issues) {
            str << "<b>";
            switch (t.type) {
            case Task::Error:
491
                str << QCoreApplication::translate("ProjectExplorer::Kit", "Error:") << " ";
Tobias Hunger's avatar
Tobias Hunger committed
492
493
                break;
            case Task::Warning:
494
                str << QCoreApplication::translate("ProjectExplorer::Kit", "Warning:") << " ";
Tobias Hunger's avatar
Tobias Hunger committed
495
496
497
498
499
500
501
502
503
504
                break;
            case Task::Unknown:
            default:
                break;
            }
            str << "</b>" << t.description << "<br>";
        }
        str << "</p>";
    }

505
    QList<KitInformation *> infoList = KitManager::kitInformation();
Tobias Hunger's avatar
Tobias Hunger committed
506
507
508
    foreach (KitInformation *ki, infoList) {
        KitInformation::ItemList list = ki->toUserOutput(this);
        foreach (const KitInformation::Item &j, list)
Tobias Hunger's avatar
Tobias Hunger committed
509
510
511
512
513
514
            str << "<tr><td><b>" << j.first << ":</b></td><td>" << j.second << "</td></tr>";
    }
    str << "</table></body></html>";
    return rc;
}

Tobias Hunger's avatar
Tobias Hunger committed
515
void Kit::setAutoDetected(bool detected)
Tobias Hunger's avatar
Tobias Hunger committed
516
517
518
519
{
    d->m_autodetected = detected;
}

520
521
522
523
524
void Kit::setAutoDetectionSource(const QString &autoDetectionSource)
{
    d->m_autoDetectionSource = autoDetectionSource;
}

Daniel Teske's avatar
Daniel Teske committed
525
526
527
528
529
void Kit::setSdkProvided(bool sdkProvided)
{
    d->m_sdkProvided = sdkProvided;
}

530
531
void Kit::makeSticky()
{
532
    foreach (KitInformation *ki, KitManager::kitInformation()) {
533
534
        if (hasValue(ki->id()))
            setSticky(ki->id(), true);
535
536
537
    }
}

538
void Kit::setSticky(Core::Id id, bool b)
539
{
540
541
542
543
    if (b)
        d->m_sticky.insert(id);
    else
        d->m_sticky.remove(id);
544
545
}

546
547
548
549
550
void Kit::makeUnSticky()
{
    d->m_sticky.clear();
}

551
552
553
554
555
556
557
558
559
560
561
562
563
void Kit::setMutable(Id id, bool b)
{
    if (b)
        d->m_mutable.insert(id);
    else
        d->m_mutable.remove(id);
}

bool Kit::isMutable(Id id) const
{
    return d->m_mutable.contains(id);
}

Tobias Hunger's avatar
Tobias Hunger committed
564
void Kit::kitUpdated()
Tobias Hunger's avatar
Tobias Hunger committed
565
{
566
    if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) {
567
568
569
        d->m_mustNotify = true;
        return;
    }
Tobias Hunger's avatar
Tobias Hunger committed
570
    d->m_hasValidityInfo = false;
571
    KitManager::notifyAboutUpdate(this);
Tobias Hunger's avatar
Tobias Hunger committed
572
573
}

574
575
576
577
578
579
580
void Kit::kitDisplayNameChanged()
{
    if (d->m_nestedBlockingLevel > 0) {
        d->m_mustNotifyAboutDisplayName = true;
        d->m_mustNotify = false;
        return;
    }
Tobias Hunger's avatar
Tobias Hunger committed
581
    d->m_hasValidityInfo = false;
582
    KitManager::notifyAboutDisplayNameChange(this);
583
584
}

Tobias Hunger's avatar
Tobias Hunger committed
585
} // namespace ProjectExplorer