Files
qt-creator/src/plugins/projectexplorer/toolchain.cpp

198 lines
4.8 KiB
C++
Raw Normal View History

2009-03-20 14:57:12 +01:00
/**************************************************************************
**
** This file is part of Qt Creator
**
2011-01-11 16:28:15 +01:00
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
2009-03-20 14:57:12 +01:00
**
** Contact: Nokia Corporation (qt-info@nokia.com)
2009-03-20 14:57:12 +01:00
**
2010-12-17 16:01:08 +01:00
** No Commercial Usage
2009-03-20 14:57:12 +01:00
**
2010-12-17 16:01:08 +01:00
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
2009-03-20 14:57:12 +01:00
**
** GNU Lesser General Public License Usage
**
** 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.
**
2010-12-17 16:01:08 +01:00
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
2009-03-20 14:57:12 +01:00
**
**************************************************************************/
#include "toolchain.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/environment.h>
#include <QtCore/QCoreApplication>
static const char *const ID_KEY = "ProjectExplorer.ToolChain.Id";
static const char *const DISPLAY_NAME_KEY = "ProjectExplorer.ToolChain.DisplayName";
namespace ProjectExplorer {
namespace Internal {
// --------------------------------------------------------------------------
// ToolChainPrivate
// --------------------------------------------------------------------------
class ToolChainPrivate
{
public:
ToolChainPrivate(const QString &id, bool autodetect) :
m_id(id),
m_autodetect(autodetect)
{ Q_ASSERT(!id.isEmpty()); }
QString m_id;
bool m_autodetect;
mutable QString m_displayName;
};
} // namespace Internal
// --------------------------------------------------------------------------
// ToolChain
// --------------------------------------------------------------------------
ToolChain::ToolChain(const QString &id, bool autodetect) :
m_d(new Internal::ToolChainPrivate(id, autodetect))
{ }
2010-04-09 18:43:05 +02:00
ToolChain::ToolChain(const ToolChain &other) :
m_d(new Internal::ToolChainPrivate(other.id(), false))
2010-04-09 18:43:05 +02:00
{
// leave the autodetection bit at false.
m_d->m_displayName = QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
.arg(other.displayName());
2010-04-09 18:43:05 +02:00
}
ToolChain::~ToolChain()
2010-04-09 18:43:05 +02:00
{
delete m_d;
2010-04-09 18:43:05 +02:00
}
QString ToolChain::displayName() const
{
if (m_d->m_displayName.isEmpty())
return typeName();
return m_d->m_displayName;
}
void ToolChain::setDisplayName(const QString &name) const
{
m_d->m_displayName = name;
}
bool ToolChain::isAutoDetected() const
{
return m_d->m_autodetect;
}
QString ToolChain::id() const
{
return m_d->m_id;
}
QStringList ToolChain::restrictedToTargets() const
{
return QStringList();
}
bool ToolChain::canClone() const
{
return true;
}
QString ToolChain::defaultMakeTarget() const
{
return QString();
}
bool ToolChain::operator == (const ToolChain &tc) const
{
if (this == &tc)
return true;
return id() == tc.id();
}
QVariantMap ToolChain::toMap() const
{
QVariantMap result;
if (isAutoDetected())
return result;
result.insert(QLatin1String(ID_KEY), id());
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
return result;
}
void ToolChain::setId(const QString &id)
{
Q_ASSERT(!id.isEmpty());
m_d->m_id = id;
}
void ToolChain::setAutoDetected(bool autodetect)
{
m_d->m_autodetect = autodetect;
}
bool ToolChain::fromMap(const QVariantMap &data)
{
Q_ASSERT(!isAutoDetected());
// do not read the id: That is already set anyway.
m_d->m_displayName = data.value(QLatin1String(DISPLAY_NAME_KEY)).toString();
return true;
}
// --------------------------------------------------------------------------
// ToolChainFactory
// --------------------------------------------------------------------------
QList<ToolChain *> ToolChainFactory::autoDetect()
{
return QList<ToolChain *>();
}
bool ToolChainFactory::canCreate()
{
return false;
}
ToolChain *ToolChainFactory::create()
{
return 0;
}
bool ToolChainFactory::canRestore(const QVariantMap &)
{
return false;
}
ToolChain *ToolChainFactory::restore(const QVariantMap &)
{
return 0;
}
QString ToolChainFactory::idFromMap(const QVariantMap &data)
{
return data.value(QLatin1String(ID_KEY)).toString();
}
} // namespace ProjectExplorer