2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-04-24 15:49:09 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kit.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitmanager.h"
|
2012-11-02 12:45:09 +01:00
|
|
|
#include "ioutputparser.h"
|
2013-08-21 11:21:17 +02:00
|
|
|
#include "osparser.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2013-08-16 17:10:45 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <QApplication>
|
2013-08-21 12:12:27 +02:00
|
|
|
#include <QFileInfo>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <QIcon>
|
|
|
|
|
#include <QStyle>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QUuid>
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
const char ID_KEY[] = "PE.Profile.Id";
|
|
|
|
|
const char DISPLAYNAME_KEY[] = "PE.Profile.Name";
|
2014-04-25 15:18:36 +02:00
|
|
|
const char FILESYSTEMFRIENDLYNAME_KEY[] = "PE.Profile.FileSystemFriendlyName";
|
2012-04-24 15:49:09 +02:00
|
|
|
const char AUTODETECTED_KEY[] = "PE.Profile.AutoDetected";
|
2013-12-10 11:08:02 +01:00
|
|
|
const char AUTODETECTIONSOURCE_KEY[] = "PE.Profile.AutoDetectionSource";
|
2013-02-21 13:00:18 +01:00
|
|
|
const char SDK_PROVIDED_KEY[] = "PE.Profile.SDK";
|
2012-04-24 15:49:09 +02:00
|
|
|
const char DATA_KEY[] = "PE.Profile.Data";
|
|
|
|
|
const char ICON_KEY[] = "PE.Profile.Icon";
|
2013-09-09 17:11:59 +02:00
|
|
|
const char MUTABLE_INFO_KEY[] = "PE.Profile.MutableInfo";
|
2014-03-17 12:21:11 +01:00
|
|
|
const char STICKY_INFO_KEY[] = "PE.Profile.StickyInfo";
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2012-09-03 18:31:44 +02:00
|
|
|
// KitPrivate
|
2012-04-24 15:49:09 +02:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
class KitPrivate
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2013-01-18 12:10:22 +01:00
|
|
|
KitPrivate(Id id) :
|
2012-10-11 11:40:56 +02:00
|
|
|
m_id(id),
|
2013-10-16 14:29:38 +02:00
|
|
|
m_nestedBlockingLevel(0),
|
2012-04-24 15:49:09 +02:00
|
|
|
m_autodetected(false),
|
2013-12-10 11:08:02 +01:00
|
|
|
m_autoDetectionSource(QString()),
|
2013-02-21 13:00:18 +01:00
|
|
|
m_sdkProvided(false),
|
2012-10-11 18:12:45 +02:00
|
|
|
m_isValid(true),
|
2013-02-06 18:20:47 +01:00
|
|
|
m_hasWarning(false),
|
2013-10-16 14:29:38 +02:00
|
|
|
m_hasValidityInfo(false),
|
2013-03-14 10:50:41 +01:00
|
|
|
m_mustNotify(false),
|
|
|
|
|
m_mustNotifyAboutDisplayName(false)
|
2012-10-11 11:40:56 +02:00
|
|
|
{
|
|
|
|
|
if (!id.isValid())
|
2013-01-18 12:10:22 +01:00
|
|
|
m_id = Id::fromString(QUuid::createUuid().toString());
|
2013-10-16 16:45:23 +02:00
|
|
|
|
|
|
|
|
m_displayName = QCoreApplication::translate("ProjectExplorer::Kit", "Unnamed");
|
2014-02-07 15:46:36 +01:00
|
|
|
m_iconPath = Utils::FileName::fromLatin1(":///DESKTOP///");
|
2012-10-11 11:40:56 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
QString m_displayName;
|
2014-04-25 15:18:36 +02:00
|
|
|
QString m_fileSystemFriendlyName;
|
2013-01-18 12:10:22 +01:00
|
|
|
Id m_id;
|
2013-10-16 14:29:38 +02:00
|
|
|
int m_nestedBlockingLevel;
|
2012-04-24 15:49:09 +02:00
|
|
|
bool m_autodetected;
|
2013-12-10 11:08:02 +01:00
|
|
|
QString m_autoDetectionSource;
|
2013-02-21 13:00:18 +01:00
|
|
|
bool m_sdkProvided;
|
2012-04-24 15:49:09 +02:00
|
|
|
bool m_isValid;
|
2013-02-06 18:20:47 +01:00
|
|
|
bool m_hasWarning;
|
2013-10-16 14:29:38 +02:00
|
|
|
bool m_hasValidityInfo;
|
2012-10-11 18:12:45 +02:00
|
|
|
bool m_mustNotify;
|
2013-03-14 10:50:41 +01:00
|
|
|
bool m_mustNotifyAboutDisplayName;
|
2013-10-16 14:29:38 +02:00
|
|
|
QIcon m_icon;
|
|
|
|
|
Utils::FileName m_iconPath;
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
QHash<Core::Id, QVariant> m_data;
|
2013-05-06 17:11:33 +02:00
|
|
|
QSet<Core::Id> m_sticky;
|
2013-09-09 17:11:59 +02:00
|
|
|
QSet<Core::Id> m_mutable;
|
2012-04-24 15:49:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2012-09-03 18:31:44 +02:00
|
|
|
// Kit:
|
2012-04-24 15:49:09 +02:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
2012-10-11 11:40:56 +02:00
|
|
|
Kit::Kit(Core::Id id) :
|
|
|
|
|
d(new Internal::KitPrivate(id))
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (KitInformation *sti, KitManager::kitInformation())
|
2013-10-16 14:31:45 +02:00
|
|
|
d->m_data.insert(sti->id(), sti->defaultValue(this));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-16 14:31:45 +02:00
|
|
|
d->m_icon = icon(d->m_iconPath);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 16:45:23 +02:00
|
|
|
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();
|
2013-12-10 11:08:02 +01:00
|
|
|
d->m_autoDetectionSource = data.value(QLatin1String(AUTODETECTIONSOURCE_KEY)).toString();
|
2013-10-16 16:45:23 +02:00
|
|
|
|
|
|
|
|
// 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();
|
2014-04-25 15:18:36 +02:00
|
|
|
d->m_fileSystemFriendlyName = data.value(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY)).toString();
|
2013-10-16 16:45:23 +02:00
|
|
|
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));
|
2014-03-17 12:21:11 +01:00
|
|
|
|
|
|
|
|
QStringList stickyInfoList = data.value(QLatin1String(STICKY_INFO_KEY)).toStringList();
|
|
|
|
|
foreach (const QString &stickyInfo, stickyInfoList)
|
|
|
|
|
d->m_sticky.insert(Core::Id::fromString(stickyInfo));
|
2013-10-16 16:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit::~Kit()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-06-28 15:38:23 +02:00
|
|
|
delete d;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 18:12:45 +02:00
|
|
|
void Kit::blockNotification()
|
|
|
|
|
{
|
|
|
|
|
++d->m_nestedBlockingLevel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Kit::unblockNotification()
|
|
|
|
|
{
|
|
|
|
|
--d->m_nestedBlockingLevel;
|
|
|
|
|
if (d->m_nestedBlockingLevel > 0)
|
|
|
|
|
return;
|
2013-03-14 10:50:41 +01:00
|
|
|
if (d->m_mustNotifyAboutDisplayName)
|
|
|
|
|
kitDisplayNameChanged();
|
|
|
|
|
else if (d->m_mustNotify)
|
2012-10-11 18:12:45 +02:00
|
|
|
kitUpdated();
|
|
|
|
|
d->m_mustNotify = false;
|
2013-03-14 10:50:41 +01:00
|
|
|
d->m_mustNotifyAboutDisplayName = false;
|
2012-10-11 18:12:45 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *Kit::clone(bool keepName) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
Kit *k = new Kit;
|
2012-08-07 13:09:56 +02:00
|
|
|
if (keepName)
|
2012-09-09 20:41:30 +03:00
|
|
|
k->d->m_displayName = d->m_displayName;
|
2012-08-07 13:09:56 +02:00
|
|
|
else
|
2012-09-09 20:41:30 +03:00
|
|
|
k->d->m_displayName = QCoreApplication::translate("ProjectExplorer::Kit", "Clone of %1")
|
2012-08-07 13:09:56 +02:00
|
|
|
.arg(d->m_displayName);
|
2012-09-09 20:41:30 +03:00
|
|
|
k->d->m_autodetected = false;
|
|
|
|
|
k->d->m_data = d->m_data;
|
2014-04-25 15:18:36 +02:00
|
|
|
// Do not clone m_fileSystemFriendlyName, needs to be unique
|
2012-09-09 20:41:30 +03:00
|
|
|
k->d->m_isValid = d->m_isValid;
|
|
|
|
|
k->d->m_icon = d->m_icon;
|
|
|
|
|
k->d->m_iconPath = d->m_iconPath;
|
2013-05-06 17:11:33 +02:00
|
|
|
k->d->m_sticky = d->m_sticky;
|
2013-09-09 17:11:59 +02:00
|
|
|
k->d->m_mutable = d->m_mutable;
|
2012-09-09 20:41:30 +03:00
|
|
|
return k;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 12:14:49 +02:00
|
|
|
void Kit::copyFrom(const Kit *k)
|
|
|
|
|
{
|
2012-10-11 18:12:45 +02:00
|
|
|
KitGuard g(this);
|
2012-10-11 12:14:49 +02:00
|
|
|
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;
|
2013-12-10 11:08:02 +01:00
|
|
|
d->m_autoDetectionSource = k->d->m_autoDetectionSource;
|
2012-10-11 12:14:49 +02:00
|
|
|
d->m_displayName = k->d->m_displayName;
|
2014-04-25 15:18:36 +02:00
|
|
|
d->m_fileSystemFriendlyName = k->d->m_fileSystemFriendlyName;
|
2012-10-17 16:32:08 +02:00
|
|
|
d->m_mustNotify = true;
|
2013-03-14 10:50:41 +01:00
|
|
|
d->m_mustNotifyAboutDisplayName = true;
|
2013-05-06 17:11:33 +02:00
|
|
|
d->m_sticky = k->d->m_sticky;
|
2013-09-09 17:11:59 +02:00
|
|
|
d->m_mutable = k->d->m_mutable;
|
2012-10-11 12:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
bool Kit::isValid() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-10-16 14:29:38 +02:00
|
|
|
if (!d->m_id.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!d->m_hasValidityInfo)
|
|
|
|
|
validate();
|
|
|
|
|
|
|
|
|
|
return d->m_isValid;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-02-06 18:20:47 +01:00
|
|
|
bool Kit::hasWarning() const
|
|
|
|
|
{
|
2013-10-16 14:29:38 +02:00
|
|
|
if (!d->m_hasValidityInfo)
|
|
|
|
|
validate();
|
|
|
|
|
|
2013-02-06 18:20:47 +01:00
|
|
|
return d->m_hasWarning;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> Kit::validate() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
QList<Task> result;
|
2013-08-21 12:48:46 +02:00
|
|
|
QList<KitInformation *> infoList = KitManager::kitInformation();
|
2012-10-11 12:31:48 +02:00
|
|
|
d->m_isValid = true;
|
2013-02-06 18:20:47 +01:00
|
|
|
d->m_hasWarning = false;
|
2012-10-11 12:31:48 +02:00
|
|
|
foreach (KitInformation *i, infoList) {
|
|
|
|
|
QList<Task> tmp = i->validate(this);
|
|
|
|
|
foreach (const Task &t, tmp) {
|
|
|
|
|
if (t.type == Task::Error)
|
|
|
|
|
d->m_isValid = false;
|
2013-02-06 18:20:47 +01:00
|
|
|
if (t.type == Task::Warning)
|
|
|
|
|
d->m_hasWarning = true;
|
2012-10-11 12:31:48 +02:00
|
|
|
}
|
|
|
|
|
result.append(tmp);
|
|
|
|
|
}
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(result);
|
2013-10-16 14:29:38 +02:00
|
|
|
d->m_hasValidityInfo = true;
|
2012-04-24 15:49:09 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 18:15:21 +02:00
|
|
|
void Kit::fix()
|
|
|
|
|
{
|
|
|
|
|
KitGuard g(this);
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (KitInformation *i, KitManager::kitInformation())
|
2012-10-11 18:15:21 +02:00
|
|
|
i->fix(this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-22 12:47:07 +01:00
|
|
|
void Kit::setup()
|
|
|
|
|
{
|
|
|
|
|
KitGuard g(this);
|
2013-02-28 16:16:24 +01:00
|
|
|
// Process the KitInfos in reverse order: They may only be based on other information lower in
|
|
|
|
|
// the stack.
|
2013-08-21 12:48:46 +02:00
|
|
|
QList<KitInformation *> info = KitManager::kitInformation();
|
2013-02-28 16:16:24 +01:00
|
|
|
for (int i = info.count() - 1; i >= 0; --i)
|
|
|
|
|
info.at(i)->setup(this);
|
2013-01-22 12:47:07 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString Kit::displayName() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_displayName;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-07 13:09:56 +02:00
|
|
|
static QString candidateName(const QString &name, const QString &postfix)
|
|
|
|
|
{
|
|
|
|
|
if (name.contains(postfix))
|
|
|
|
|
return QString();
|
2012-11-28 18:09:21 +01:00
|
|
|
QString candidate = name;
|
|
|
|
|
if (!candidate.isEmpty())
|
|
|
|
|
candidate.append(QLatin1Char('-'));
|
|
|
|
|
candidate.append(postfix);
|
|
|
|
|
return candidate;
|
2012-08-07 13:09:56 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void Kit::setDisplayName(const QString &name)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-03-14 10:50:41 +01:00
|
|
|
if (d->m_displayName == name)
|
|
|
|
|
return;
|
|
|
|
|
d->m_displayName = name;
|
|
|
|
|
kitDisplayNameChanged();
|
|
|
|
|
}
|
2012-08-07 13:09:56 +02:00
|
|
|
|
2013-03-14 10:50:41 +01:00
|
|
|
QStringList Kit::candidateNameList(const QString &base) const
|
|
|
|
|
{
|
|
|
|
|
QStringList result;
|
|
|
|
|
result << base;
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
2012-09-03 18:31:44 +02:00
|
|
|
const QString postfix = ki->displayNamePostfix(this);
|
2013-10-14 13:28:46 +02:00
|
|
|
if (!postfix.isEmpty()) {
|
|
|
|
|
QString tmp = candidateName(base, postfix);
|
|
|
|
|
if (!tmp.isEmpty())
|
|
|
|
|
result << candidateName(base, postfix);
|
|
|
|
|
}
|
2012-07-02 15:28:36 +02:00
|
|
|
}
|
2013-03-14 10:50:41 +01:00
|
|
|
return result;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-25 15:18:36 +02:00
|
|
|
void Kit::setCustomFileSystemFriendlyName(const QString &fileSystemFriendlyName)
|
|
|
|
|
{
|
|
|
|
|
d->m_fileSystemFriendlyName = fileSystemFriendlyName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Kit::customFileSystemFriendlyName() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_fileSystemFriendlyName;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-04 14:40:29 +02:00
|
|
|
QString Kit::fileSystemFriendlyName() const
|
|
|
|
|
{
|
2014-04-25 15:18:36 +02:00
|
|
|
QString name = customFileSystemFriendlyName();
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
name = Utils::FileUtils::qmakeFriendlyName(displayName());
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (Kit *i, KitManager::kits()) {
|
2012-10-04 14:40:29 +02:00
|
|
|
if (i == this)
|
|
|
|
|
continue;
|
2013-12-09 12:56:24 +01:00
|
|
|
if (name == Utils::FileUtils::qmakeFriendlyName(i->displayName())) {
|
2012-10-04 14:40:29 +02:00
|
|
|
// append part of the kit id: That should be unique enough;-)
|
|
|
|
|
// Leading { will be turned into _ which should be fine.
|
2013-12-09 12:56:24 +01:00
|
|
|
name = Utils::FileUtils::qmakeFriendlyName(name + QLatin1Char('_') + (id().toString().left(7)));
|
2012-10-04 14:40:29 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
bool Kit::isAutoDetected() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_autodetected;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 11:08:02 +01:00
|
|
|
QString Kit::autoDetectionSource() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_autoDetectionSource;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 13:00:18 +01:00
|
|
|
bool Kit::isSdkProvided() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_sdkProvided;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
Id Kit::id() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QIcon Kit::icon() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_icon;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 13:04:00 +02:00
|
|
|
QIcon Kit::icon(const Utils::FileName &path)
|
2013-08-21 12:12:27 +02:00
|
|
|
{
|
|
|
|
|
if (path.isEmpty())
|
|
|
|
|
return QIcon();
|
2014-02-07 15:46:36 +01:00
|
|
|
if (path == Utils::FileName::fromLatin1(":///DESKTOP///"))
|
2013-08-21 12:12:27 +02:00
|
|
|
return qApp->style()->standardIcon(QStyle::SP_ComputerIcon);
|
|
|
|
|
|
2013-08-21 13:04:00 +02:00
|
|
|
QFileInfo fi(path.toString());
|
2013-08-21 12:12:27 +02:00
|
|
|
if (fi.isFile() && fi.isReadable())
|
2013-08-21 13:04:00 +02:00
|
|
|
return QIcon(path.toString());
|
2013-08-21 12:12:27 +02:00
|
|
|
return QIcon();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 13:04:00 +02:00
|
|
|
Utils::FileName Kit::iconPath() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_iconPath;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 13:04:00 +02:00
|
|
|
void Kit::setIconPath(const Utils::FileName &path)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
if (d->m_iconPath == path)
|
|
|
|
|
return;
|
|
|
|
|
d->m_iconPath = path;
|
2013-08-21 12:12:27 +02:00
|
|
|
d->m_icon = icon(path);
|
2012-09-03 18:31:44 +02:00
|
|
|
kitUpdated();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
QVariant Kit::value(Id key, const QVariant &unset) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_data.value(key, unset);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
bool Kit::hasValue(Id key) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_data.contains(key);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
void Kit::setValue(Id key, const QVariant &value)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
if (d->m_data.value(key) == value)
|
|
|
|
|
return;
|
|
|
|
|
d->m_data.insert(key, value);
|
2012-09-03 18:31:44 +02:00
|
|
|
kitUpdated();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
void Kit::removeKey(Id key)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
if (!d->m_data.contains(key))
|
|
|
|
|
return;
|
|
|
|
|
d->m_data.remove(key);
|
2013-05-06 17:11:33 +02:00
|
|
|
d->m_sticky.remove(key);
|
2013-09-09 17:11:59 +02:00
|
|
|
d->m_mutable.remove(key);
|
2012-09-03 18:31:44 +02:00
|
|
|
kitUpdated();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-06 17:11:33 +02:00
|
|
|
bool Kit::isSticky(Core::Id id) const
|
|
|
|
|
{
|
|
|
|
|
return d->m_sticky.contains(id);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 12:00:11 +02:00
|
|
|
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
|
2013-09-09 17:11:59 +02:00
|
|
|
&& d->m_displayName == other->d->m_displayName
|
2014-04-25 15:18:36 +02:00
|
|
|
&& d->m_fileSystemFriendlyName == other->d->m_fileSystemFriendlyName
|
2013-09-09 17:11:59 +02:00
|
|
|
&& d->m_mutable == other->d->m_mutable;
|
|
|
|
|
|
2012-10-11 12:00:11 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariantMap Kit::toMap() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-03-14 14:14:48 +01:00
|
|
|
typedef QHash<Core::Id, QVariant>::ConstIterator IdVariantConstIt;
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
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);
|
2014-04-25 15:18:36 +02:00
|
|
|
if (!d->m_fileSystemFriendlyName.isEmpty())
|
|
|
|
|
data.insert(QLatin1String(FILESYSTEMFRIENDLYNAME_KEY), d->m_fileSystemFriendlyName);
|
2013-12-10 11:08:02 +01:00
|
|
|
data.insert(QLatin1String(AUTODETECTIONSOURCE_KEY), d->m_autoDetectionSource);
|
2013-02-21 13:00:18 +01:00
|
|
|
data.insert(QLatin1String(SDK_PROVIDED_KEY), d->m_sdkProvided);
|
2013-08-21 13:04:00 +02:00
|
|
|
data.insert(QLatin1String(ICON_KEY), d->m_iconPath.toString());
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-09-09 17:11:59 +02:00
|
|
|
QStringList mutableInfo;
|
2013-12-16 15:54:02 +01:00
|
|
|
foreach (const Core::Id &id, d->m_mutable)
|
2013-09-09 17:11:59 +02:00
|
|
|
mutableInfo << id.toString();
|
|
|
|
|
data.insert(QLatin1String(MUTABLE_INFO_KEY), mutableInfo);
|
|
|
|
|
|
2014-03-17 12:21:11 +01:00
|
|
|
QStringList stickyInfo;
|
|
|
|
|
foreach (const Core::Id &id, d->m_sticky)
|
|
|
|
|
stickyInfo << id.toString();
|
|
|
|
|
data.insert(QLatin1String(STICKY_INFO_KEY), stickyInfo);
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap extra;
|
2013-03-14 14:14:48 +01:00
|
|
|
|
|
|
|
|
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());
|
2012-04-24 15:49:09 +02:00
|
|
|
data.insert(QLatin1String(DATA_KEY), extra);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void Kit::addToEnvironment(Utils::Environment &env) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
QList<KitInformation *> infoList = KitManager::kitInformation();
|
2012-09-03 18:31:44 +02:00
|
|
|
foreach (KitInformation *ki, infoList)
|
|
|
|
|
ki->addToEnvironment(this, env);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *Kit::createOutputParser() const
|
|
|
|
|
{
|
2013-08-21 11:21:17 +02:00
|
|
|
IOutputParser *first = new OsParser;
|
2013-08-21 12:48:46 +02:00
|
|
|
QList<KitInformation *> infoList = KitManager::kitInformation();
|
2013-08-21 11:21:17 +02:00
|
|
|
foreach (KitInformation *ki, infoList)
|
|
|
|
|
first->appendOutputParser(ki->createOutputParser(this));
|
2012-11-02 12:45:09 +01:00
|
|
|
return first;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
QString Kit::toHtml() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
QTextStream str(&rc);
|
|
|
|
|
str << "<html><body>";
|
|
|
|
|
str << "<h3>" << displayName() << "</h3>";
|
|
|
|
|
str << "<table>";
|
|
|
|
|
|
2013-02-06 18:20:47 +01:00
|
|
|
if (!isValid() || hasWarning()) {
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<Task> issues = validate();
|
|
|
|
|
str << "<p>";
|
|
|
|
|
foreach (const Task &t, issues) {
|
|
|
|
|
str << "<b>";
|
|
|
|
|
switch (t.type) {
|
|
|
|
|
case Task::Error:
|
2013-01-22 14:40:22 +01:00
|
|
|
str << QCoreApplication::translate("ProjectExplorer::Kit", "Error:") << " ";
|
2012-04-24 15:49:09 +02:00
|
|
|
break;
|
|
|
|
|
case Task::Warning:
|
2013-01-22 14:40:22 +01:00
|
|
|
str << QCoreApplication::translate("ProjectExplorer::Kit", "Warning:") << " ";
|
2012-04-24 15:49:09 +02:00
|
|
|
break;
|
|
|
|
|
case Task::Unknown:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
str << "</b>" << t.description << "<br>";
|
|
|
|
|
}
|
|
|
|
|
str << "</p>";
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
QList<KitInformation *> infoList = KitManager::kitInformation();
|
2012-09-03 18:31:44 +02:00
|
|
|
foreach (KitInformation *ki, infoList) {
|
|
|
|
|
KitInformation::ItemList list = ki->toUserOutput(this);
|
|
|
|
|
foreach (const KitInformation::Item &j, list)
|
2012-04-24 15:49:09 +02:00
|
|
|
str << "<tr><td><b>" << j.first << ":</b></td><td>" << j.second << "</td></tr>";
|
|
|
|
|
}
|
|
|
|
|
str << "</table></body></html>";
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void Kit::setAutoDetected(bool detected)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
d->m_autodetected = detected;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 11:08:02 +01:00
|
|
|
void Kit::setAutoDetectionSource(const QString &autoDetectionSource)
|
|
|
|
|
{
|
|
|
|
|
d->m_autoDetectionSource = autoDetectionSource;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 13:00:18 +01:00
|
|
|
void Kit::setSdkProvided(bool sdkProvided)
|
|
|
|
|
{
|
|
|
|
|
d->m_sdkProvided = sdkProvided;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-06 17:11:33 +02:00
|
|
|
void Kit::makeSticky()
|
|
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
2013-09-09 17:10:41 +02:00
|
|
|
if (hasValue(ki->id()))
|
|
|
|
|
setSticky(ki->id(), true);
|
2013-05-06 17:11:33 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-02 15:38:31 +02:00
|
|
|
void Kit::setSticky(Core::Id id, bool b)
|
2013-05-06 17:11:33 +02:00
|
|
|
{
|
2013-09-02 15:38:31 +02:00
|
|
|
if (b)
|
|
|
|
|
d->m_sticky.insert(id);
|
|
|
|
|
else
|
|
|
|
|
d->m_sticky.remove(id);
|
2013-05-06 17:11:33 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-28 13:34:24 +02:00
|
|
|
void Kit::makeUnSticky()
|
|
|
|
|
{
|
|
|
|
|
d->m_sticky.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 17:11:59 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void Kit::kitUpdated()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-03-14 10:50:41 +01:00
|
|
|
if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) {
|
2012-10-11 18:12:45 +02:00
|
|
|
d->m_mustNotify = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-10-16 14:29:38 +02:00
|
|
|
d->m_hasValidityInfo = false;
|
2013-08-21 12:48:46 +02:00
|
|
|
KitManager::notifyAboutUpdate(this);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-14 10:50:41 +01:00
|
|
|
void Kit::kitDisplayNameChanged()
|
|
|
|
|
{
|
|
|
|
|
if (d->m_nestedBlockingLevel > 0) {
|
|
|
|
|
d->m_mustNotifyAboutDisplayName = true;
|
|
|
|
|
d->m_mustNotify = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-10-16 14:29:38 +02:00
|
|
|
d->m_hasValidityInfo = false;
|
2013-08-21 12:48:46 +02:00
|
|
|
KitManager::notifyAboutDisplayNameChange(this);
|
2013-03-14 10:50:41 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace ProjectExplorer
|