2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-04-24 15:49:09 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 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.
|
|
|
|
|
**
|
|
|
|
|
** 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 "kitinformation.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include "devicesupport/desktopdevice.h"
|
|
|
|
|
#include "devicesupport/devicemanager.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kit.h"
|
|
|
|
|
#include "kitinformationconfigwidget.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "toolchain.h"
|
|
|
|
|
#include "toolchainmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <projectexplorer/abi.h>
|
2013-02-28 14:06:17 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-03-18 14:47:33 +01:00
|
|
|
#include <QFileInfo>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// SysRootInformation:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char SYSROOT_INFORMATION[] = "PE.Profile.SysRoot";
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
SysRootKitInformation::SysRootKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("SysRootInformation"));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id SysRootKitInformation::dataId() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
static const Core::Id id(SYSROOT_INFORMATION);
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
unsigned int SysRootKitInformation::priority() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-02-28 17:05:15 +01:00
|
|
|
return 31000;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant SysRootKitInformation::defaultValue(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> SysRootKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
QList<Task> result;
|
2012-09-03 18:31:44 +02:00
|
|
|
const Utils::FileName dir = SysRootKitInformation::sysRoot(k);
|
|
|
|
|
if (!dir.toFileInfo().isDir() && SysRootKitInformation::hasSysRoot(k)) {
|
2012-07-27 15:43:00 +02:00
|
|
|
result << Task(Task::Error, tr("Sys Root \"%1\" is not a directory.").arg(dir.toUserOutput()),
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
2012-07-27 15:43:00 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *SysRootKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-05-06 17:11:33 +02:00
|
|
|
return new Internal::SysRootInformationConfigWidget(k, isSticky(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList SysRootKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
return ItemList() << qMakePair(tr("Sys Root"), sysRoot(k).toUserOutput());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
bool SysRootKitInformation::hasSysRoot(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (k)
|
|
|
|
|
return !k->value(Core::Id(SYSROOT_INFORMATION)).toString().isEmpty();
|
2012-06-28 21:29:46 +02:00
|
|
|
return false;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Utils::FileName SysRootKitInformation::sysRoot(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return Utils::FileName();
|
2012-09-03 18:31:44 +02:00
|
|
|
return Utils::FileName::fromString(k->value(Core::Id(SYSROOT_INFORMATION)).toString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void SysRootKitInformation::setSysRoot(Kit *k, const Utils::FileName &v)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
k->setValue(Core::Id(SYSROOT_INFORMATION), v.toString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// ToolChainInformation:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char TOOLCHAIN_INFORMATION[] = "PE.Profile.ToolChain";
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChainKitInformation::ToolChainKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("ToolChainInformation"));
|
2013-02-28 15:07:01 +01:00
|
|
|
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
|
|
|
|
|
this, SLOT(kitsWereLoaded()));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id ToolChainKitInformation::dataId() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
static const Core::Id id(TOOLCHAIN_INFORMATION);
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
unsigned int ToolChainKitInformation::priority() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return 30000;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant ToolChainKitInformation::defaultValue(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<ToolChain *> tcList = ToolChainManager::instance()->toolChains();
|
|
|
|
|
if (tcList.isEmpty())
|
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Abi abi = ProjectExplorer::Abi::hostAbi();
|
|
|
|
|
|
|
|
|
|
foreach (ToolChain *tc, tcList) {
|
|
|
|
|
if (tc->targetAbi() == abi)
|
|
|
|
|
return tc->id();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tcList.at(0)->id();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> ToolChainKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
QList<Task> result;
|
2013-03-21 12:27:18 +01:00
|
|
|
|
|
|
|
|
const ToolChain* toolchain = toolChain(k);
|
|
|
|
|
if (!toolchain) {
|
2012-09-03 18:31:44 +02:00
|
|
|
result << Task(Task::Error, ToolChainKitInformation::msgNoToolChainInTarget(),
|
2012-04-24 15:49:09 +02:00
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM));
|
2013-03-21 12:27:18 +01:00
|
|
|
} else {
|
|
|
|
|
result << toolchain->validateKit(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
void ToolChainKitInformation::fix(Kit *k)
|
|
|
|
|
{
|
2013-02-28 15:07:01 +01:00
|
|
|
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
|
2012-10-11 13:47:23 +02:00
|
|
|
if (toolChain(k))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-05-07 14:58:23 +02:00
|
|
|
qWarning("No tool chain set from kit \"%s\".",
|
2012-10-11 13:47:23 +02:00
|
|
|
qPrintable(k->displayName()));
|
|
|
|
|
setToolChain(k, 0); // make sure to clear out no longer known tool chains
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-22 12:47:07 +01:00
|
|
|
void ToolChainKitInformation::setup(Kit *k)
|
|
|
|
|
{
|
2013-02-28 15:07:01 +01:00
|
|
|
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
|
2013-01-22 12:47:07 +01:00
|
|
|
const QString id = k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString();
|
|
|
|
|
if (id.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ToolChain *tc = ToolChainManager::instance()->findToolChain(id);
|
|
|
|
|
if (tc)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// ID is not found: Might be an ABI string...
|
|
|
|
|
foreach (ToolChain *current, ToolChainManager::instance()->toolChains()) {
|
|
|
|
|
if (current->targetAbi().toString() == id)
|
|
|
|
|
return setToolChain(k, current);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *ToolChainKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-05-06 17:11:33 +02:00
|
|
|
return new Internal::ToolChainInformationConfigWidget(k, isSticky(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString ToolChainKitInformation::displayNamePostfix(const Kit *k) const
|
2012-08-07 13:09:56 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = toolChain(k);
|
2012-08-07 13:09:56 +02:00
|
|
|
return tc ? tc->displayName() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList ToolChainKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = toolChain(k);
|
2012-08-24 08:31:01 +02:00
|
|
|
return ItemList() << qMakePair(tr("Compiler"), tc ? tc->displayName() : tr("None"));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = toolChain(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (tc)
|
|
|
|
|
tc->addToEnvironment(env);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
ToolChain *tc = toolChain(k);
|
|
|
|
|
if (tc)
|
|
|
|
|
return tc->outputParser();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-02-28 15:07:01 +01:00
|
|
|
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return 0);
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return 0;
|
2013-01-22 12:47:07 +01:00
|
|
|
return ToolChainManager::instance()
|
|
|
|
|
->findToolChain(k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void ToolChainKitInformation::setToolChain(Kit *k, ToolChain *tc)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
k->setValue(Core::Id(TOOLCHAIN_INFORMATION), tc ? tc->id() : QString());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString ToolChainKitInformation::msgNoToolChainInTarget()
|
2012-07-27 15:43:00 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
return tr("No compiler set in kit.");
|
2012-07-27 15:43:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-02-28 15:07:01 +01:00
|
|
|
void ToolChainKitInformation::kitsWereLoaded()
|
2012-10-17 17:27:17 +02:00
|
|
|
{
|
|
|
|
|
foreach (Kit *k, KitManager::instance()->kits())
|
2013-02-28 15:07:01 +01:00
|
|
|
fix(k);
|
|
|
|
|
|
|
|
|
|
connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
|
|
|
|
|
this, SLOT(toolChainRemoved(ProjectExplorer::ToolChain*)));
|
|
|
|
|
connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
|
|
|
|
|
this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolChainKitInformation::toolChainUpdated(ProjectExplorer::ToolChain *tc)
|
|
|
|
|
{
|
|
|
|
|
ToolChainMatcher m(tc);
|
|
|
|
|
foreach (Kit *k, KitManager::instance()->kits(&m))
|
|
|
|
|
notifyAboutUpdate(k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolChainKitInformation::toolChainRemoved(ProjectExplorer::ToolChain *tc)
|
2012-10-17 17:27:17 +02:00
|
|
|
{
|
2013-02-28 15:07:01 +01:00
|
|
|
Q_UNUSED(tc);
|
2012-10-17 17:27:17 +02:00
|
|
|
foreach (Kit *k, KitManager::instance()->kits())
|
2013-02-28 15:07:01 +01:00
|
|
|
fix(k);
|
2012-10-17 17:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// DeviceTypeInformation:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char DEVICETYPE_INFORMATION[] = "PE.Profile.DeviceType";
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
DeviceTypeKitInformation::DeviceTypeKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("DeviceTypeInformation"));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id DeviceTypeKitInformation::dataId() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
static const Core::Id id(DEVICETYPE_INFORMATION);
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
unsigned int DeviceTypeKitInformation::priority() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return 33000;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant DeviceTypeKitInformation::defaultValue(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return QByteArray(Constants::DESKTOP_DEVICE_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> DeviceTypeKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-11 18:17:15 +02:00
|
|
|
Q_UNUSED(k);
|
|
|
|
|
return QList<Task>();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *DeviceTypeKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-05-06 17:11:33 +02:00
|
|
|
return new Internal::DeviceTypeInformationConfigWidget(k, isSticky(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList DeviceTypeKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id type = deviceTypeId(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
QString typeDisplayName = tr("Unknown device type");
|
|
|
|
|
if (type.isValid()) {
|
|
|
|
|
QList<IDeviceFactory *> factories
|
|
|
|
|
= ExtensionSystem::PluginManager::instance()->getObjects<IDeviceFactory>();
|
|
|
|
|
foreach (IDeviceFactory *factory, factories) {
|
|
|
|
|
if (factory->availableCreationIds().contains(type)) {
|
|
|
|
|
typeDisplayName = factory->displayNameForId(type);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ItemList() << qMakePair(tr("Device type"), typeDisplayName);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
const Core::Id DeviceTypeKitInformation::deviceTypeId(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-03-19 18:52:29 +01:00
|
|
|
return k ? Core::Id::fromSetting(k->value(DEVICETYPE_INFORMATION)) : Core::Id();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void DeviceTypeKitInformation::setDeviceTypeId(Kit *k, Core::Id type)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-03-19 18:52:29 +01:00
|
|
|
k->setValue(DEVICETYPE_INFORMATION, type.toSetting());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// DeviceInformation:
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char DEVICE_INFORMATION[] = "PE.Profile.Device";
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
DeviceKitInformation::DeviceKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("DeviceInformation"));
|
2013-02-28 14:06:17 +01:00
|
|
|
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
|
|
|
|
|
this, SLOT(kitsWereLoaded()));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id DeviceKitInformation::dataId() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
static const Core::Id id(DEVICE_INFORMATION);
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
unsigned int DeviceKitInformation::priority() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return 32000;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QVariant DeviceKitInformation::defaultValue(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-11 18:17:15 +02:00
|
|
|
Core::Id type = DeviceTypeKitInformation::deviceTypeId(k);
|
|
|
|
|
IDevice::ConstPtr dev = DeviceManager::instance()->defaultDevice(type);
|
|
|
|
|
return dev.isNull() ? QString() : dev->id().toString();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<Task> DeviceKitInformation::validate(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-10-11 18:17:15 +02:00
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<Task> result;
|
2012-10-11 18:17:15 +02:00
|
|
|
if (!dev.isNull() && dev->type() != DeviceTypeKitInformation::deviceTypeId(k))
|
|
|
|
|
result.append(Task(Task::Error, tr("Device does not match device type."),
|
|
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
|
|
|
|
if (dev.isNull())
|
2013-02-12 15:36:59 +01:00
|
|
|
result.append(Task(Task::Warning, tr("No device set."),
|
2012-10-11 18:17:15 +02:00
|
|
|
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
2012-04-24 15:49:09 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
void DeviceKitInformation::fix(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
2012-10-11 18:17:15 +02:00
|
|
|
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
|
2012-10-11 13:47:23 +02:00
|
|
|
return;
|
|
|
|
|
|
2013-02-28 17:06:36 +01:00
|
|
|
qWarning("Device is no longer known, removing from kit \"%s\".", qPrintable(k->displayName()));
|
2013-02-28 14:06:17 +01:00
|
|
|
setDeviceId(k, Core::Id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceKitInformation::setup(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(DeviceManager::instance()->isLoaded(), return);
|
|
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
|
|
|
|
if (!dev.isNull() && dev->type() == DeviceTypeKitInformation::deviceTypeId(k))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-01-18 12:10:22 +01:00
|
|
|
setDeviceId(k, Core::Id::fromSetting(defaultValue(k)));
|
2012-10-11 13:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
KitConfigWidget *DeviceKitInformation::createConfigWidget(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-05-06 17:11:33 +02:00
|
|
|
return new Internal::DeviceInformationConfigWidget(k, isSticky(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString DeviceKitInformation::displayNamePostfix(const Kit *k) const
|
2012-08-07 13:09:56 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr dev = device(k);
|
2012-08-07 13:09:56 +02:00
|
|
|
return dev.isNull() ? QString() : dev->displayName();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 16:56:04 +01:00
|
|
|
KitInformation::ItemList DeviceKitInformation::toUserOutput(const Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr dev = device(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return ItemList() << qMakePair(tr("Device"), dev.isNull() ? tr("Unconfigured") : dev->displayName());
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr DeviceKitInformation::device(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-02-28 14:06:17 +01:00
|
|
|
QTC_ASSERT(DeviceManager::instance()->isLoaded(), return IDevice::ConstPtr());
|
2013-02-28 17:07:05 +01:00
|
|
|
return DeviceManager::instance()->find(deviceId(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Core::Id DeviceKitInformation::deviceId(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-01-18 12:29:40 +01:00
|
|
|
return k ? Core::Id::fromSetting(k->value(DEVICE_INFORMATION)) : Core::Id();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void DeviceKitInformation::setDevice(Kit *k, IDevice::ConstPtr dev)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-01-18 12:29:40 +01:00
|
|
|
setDeviceId(k, dev ? dev->id() : Core::Id());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void DeviceKitInformation::setDeviceId(Kit *k, const Core::Id id)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-01-18 12:29:40 +01:00
|
|
|
k->setValue(DEVICE_INFORMATION, id.toSetting());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-02-28 14:06:17 +01:00
|
|
|
void DeviceKitInformation::kitsWereLoaded()
|
2012-10-17 17:27:17 +02:00
|
|
|
{
|
|
|
|
|
foreach (Kit *k, KitManager::instance()->kits())
|
2013-02-28 14:06:17 +01:00
|
|
|
fix(k);
|
|
|
|
|
|
2013-07-08 16:39:03 +02:00
|
|
|
DeviceManager *dm = DeviceManager::instance();
|
|
|
|
|
connect(dm, SIGNAL(deviceListChanged()), this, SLOT(devicesChanged()));
|
|
|
|
|
connect(dm, SIGNAL(deviceAdded(Core::Id)), this, SLOT(devicesChanged()));
|
|
|
|
|
connect(dm, SIGNAL(deviceRemoved(Core::Id)), this, SLOT(devicesChanged()));
|
|
|
|
|
connect(dm, SIGNAL(deviceUpdated(Core::Id)), this, SLOT(deviceUpdated(Core::Id)));
|
2013-02-28 18:29:16 +01:00
|
|
|
|
|
|
|
|
connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
|
|
|
|
this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
|
|
|
|
|
connect(KitManager::instance(), SIGNAL(unmanagedKitUpdated(ProjectExplorer::Kit*)),
|
|
|
|
|
this, SLOT(kitUpdated(ProjectExplorer::Kit*)));
|
2013-02-28 14:06:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeviceKitInformation::deviceUpdated(const Core::Id &id)
|
|
|
|
|
{
|
|
|
|
|
foreach (Kit *k, KitManager::instance()->kits()) {
|
2012-10-17 17:27:17 +02:00
|
|
|
if (deviceId(k) == id)
|
|
|
|
|
notifyAboutUpdate(k);
|
2013-02-28 14:06:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-28 18:29:16 +01:00
|
|
|
void DeviceKitInformation::kitUpdated(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
setup(k); // Set default device if necessary
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-08 16:39:03 +02:00
|
|
|
void DeviceKitInformation::devicesChanged()
|
2013-02-28 14:06:17 +01:00
|
|
|
{
|
2013-07-08 16:39:03 +02:00
|
|
|
foreach (Kit *k, KitManager::instance()->kits())
|
2013-02-28 18:29:16 +01:00
|
|
|
setup(k); // Set default device if necessary
|
2012-10-17 17:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace ProjectExplorer
|