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 "qtkitinformation.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "qtkitconfigwidget.h"
|
2012-09-25 10:47:35 +02:00
|
|
|
#include "qtsupportconstants.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "qtversionmanager.h"
|
2012-11-02 12:45:09 +01:00
|
|
|
#include "qtparser.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-07-29 17:04:28 +02:00
|
|
|
#include <utils/buildablehelperlibrary.h>
|
2013-02-28 15:30:35 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
namespace QtSupport {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
const char QT_INFORMATION[] = "QtSupport.QtInformation";
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QtKitInformation::QtKitInformation()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
setObjectName(QLatin1String("QtKitInformation"));
|
2013-02-28 15:30:35 +01:00
|
|
|
connect(ProjectExplorer::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 QtKitInformation::dataId() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
static Core::Id id = Core::Id(Internal::QT_INFORMATION);
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
unsigned int QtKitInformation::priority() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return 26000;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
Q_UNUSED(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
QtVersionManager *mgr = QtVersionManager::instance();
|
|
|
|
|
|
|
|
|
|
// find "Qt in PATH":
|
2013-07-29 17:04:28 +02:00
|
|
|
Utils::FileName qmake = Utils::BuildableHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment());
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
if (qmake.isEmpty())
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
QList<BaseQtVersion *> versionList = mgr->versions();
|
2012-09-25 10:47:35 +02:00
|
|
|
BaseQtVersion *fallBack = 0;
|
2012-04-24 15:49:09 +02:00
|
|
|
foreach (BaseQtVersion *v, versionList) {
|
|
|
|
|
if (qmake == v->qmakeCommand())
|
|
|
|
|
return v->uniqueId();
|
2012-09-25 10:47:35 +02:00
|
|
|
if (v->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) && !fallBack)
|
|
|
|
|
fallBack = v;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
2012-09-25 10:47:35 +02:00
|
|
|
if (fallBack)
|
|
|
|
|
return fallBack->uniqueId();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
QList<ProjectExplorer::Task> QtKitInformation::validate(const ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-02-28 15:30:35 +01:00
|
|
|
QList<ProjectExplorer::Task> result;
|
|
|
|
|
QTC_ASSERT(QtVersionManager::instance()->isLoaded(), return result);
|
2012-10-11 13:47:23 +02:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
|
|
|
|
if (!version)
|
2013-02-28 15:30:35 +01:00
|
|
|
return result;
|
2012-09-09 20:41:30 +03:00
|
|
|
return version->validateKit(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 13:47:23 +02:00
|
|
|
void QtKitInformation::fix(ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
2013-02-28 15:30:35 +01:00
|
|
|
QTC_ASSERT(QtVersionManager::instance()->isLoaded(), return);
|
2012-10-11 13:47:23 +02:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2013-04-04 10:34:18 +02:00
|
|
|
if (!version && qtVersionId(k) >= 0) {
|
2013-02-28 17:06:36 +01:00
|
|
|
qWarning("Qt version is no longer known, removing from kit \"%s\".", qPrintable(k->displayName()));
|
2012-10-11 13:47:23 +02:00
|
|
|
setQtVersionId(k, -1);
|
2013-02-28 17:06:36 +01:00
|
|
|
}
|
2012-10-11 13:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
ProjectExplorer::KitConfigWidget *QtKitInformation::createConfigWidget(ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-05-06 17:11:33 +02:00
|
|
|
return new Internal::QtKitConfigWidget(k, isSticky(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
QString QtKitInformation::displayNamePostfix(const ProjectExplorer::Kit *k) const
|
2012-08-07 13:09:56 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2012-08-07 13:09:56 +02:00
|
|
|
return version ? version->displayName() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
ProjectExplorer::KitInformation::ItemList
|
2013-01-31 16:56:04 +01:00
|
|
|
QtKitInformation::toUserOutput(const ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return ItemList() << qMakePair(tr("Qt version"), version ? version->displayName() : tr("None"));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
void QtKitInformation::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (version)
|
2012-09-09 20:41:30 +03:00
|
|
|
version->addToEnvironment(k, env);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-11-02 12:45:09 +01:00
|
|
|
ProjectExplorer::IOutputParser *QtKitInformation::createOutputParser(const ProjectExplorer::Kit *k) const
|
|
|
|
|
{
|
|
|
|
|
if (qtVersion(k))
|
|
|
|
|
return new QtParser;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
int QtKitInformation::qtVersionId(const ProjectExplorer::Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return -1;
|
2012-09-18 15:47:08 +02:00
|
|
|
|
|
|
|
|
int id = -1;
|
|
|
|
|
QVariant data = k->value(Core::Id(Internal::QT_INFORMATION), -1);
|
|
|
|
|
if (data.type() == QVariant::Int) {
|
|
|
|
|
bool ok;
|
|
|
|
|
id = data.toInt(&ok);
|
|
|
|
|
if (!ok)
|
|
|
|
|
id = -1;
|
|
|
|
|
} else {
|
|
|
|
|
QString source = data.toString();
|
|
|
|
|
foreach (BaseQtVersion *v, QtVersionManager::instance()->versions()) {
|
|
|
|
|
if (v->autodetectionSource() != source)
|
|
|
|
|
continue;
|
|
|
|
|
id = v->uniqueId();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
void QtKitInformation::setQtVersionId(ProjectExplorer::Kit *k, const int id)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
k->setValue(Core::Id(Internal::QT_INFORMATION), id);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *QtKitInformation::qtVersion(const ProjectExplorer::Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
return QtVersionManager::instance()->version(qtVersionId(k));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
void QtKitInformation::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
if (!v)
|
2012-09-09 20:41:30 +03:00
|
|
|
setQtVersionId(k, -1);
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
2012-09-09 20:41:30 +03:00
|
|
|
setQtVersionId(k, v->uniqueId());
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-09 12:05:15 +02:00
|
|
|
QString QtKitInformation::dumperLibrary(const ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
|
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(k);
|
|
|
|
|
if (version)
|
|
|
|
|
return version->gdbDebuggingHelperLibrary();
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList QtKitInformation::dumperLibraryLocations(const ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
|
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(k);
|
|
|
|
|
if (version)
|
|
|
|
|
return version->debuggingHelperLibraryLocations();
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-24 16:22:37 +02:00
|
|
|
void QtKitInformation::makeSticky(ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
|
|
|
|
k->makeSticky(Internal::QT_INFORMATION);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-17 17:27:17 +02:00
|
|
|
void QtKitInformation::qtVersionsChanged(const QList<int> &addedIds,
|
|
|
|
|
const QList<int> &removedIds,
|
|
|
|
|
const QList<int> &changedIds)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(addedIds);
|
|
|
|
|
Q_UNUSED(removedIds);
|
|
|
|
|
foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::instance()->kits())
|
|
|
|
|
if (changedIds.contains(qtVersionId(k)))
|
|
|
|
|
notifyAboutUpdate(k);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-28 15:30:35 +01:00
|
|
|
void QtKitInformation::kitsWereLoaded()
|
|
|
|
|
{
|
|
|
|
|
foreach (ProjectExplorer::Kit *k, ProjectExplorer::KitManager::instance()->kits())
|
|
|
|
|
fix(k);
|
|
|
|
|
|
|
|
|
|
connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
|
|
|
|
|
this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QtPlatformKitMatcher::QtPlatformKitMatcher(const QString &platform) :
|
2012-04-24 15:49:09 +02:00
|
|
|
m_platform(platform)
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
bool QtPlatformKitMatcher::matches(const ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return version && version->platformName() == m_platform;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
bool QtVersionKitMatcher::matches(const ProjectExplorer::Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
BaseQtVersion *version = QtKitInformation::qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!version)
|
|
|
|
|
return false;
|
|
|
|
|
QtVersionNumber current = version->qtVersion();
|
|
|
|
|
if (m_min.majorVersion > -1 && current < m_min)
|
|
|
|
|
return false;
|
|
|
|
|
if (m_max.majorVersion > -1 && current > m_max)
|
|
|
|
|
return false;
|
|
|
|
|
return version->availableFeatures().contains(m_features);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace QtSupport
|