Files
qt-creator/src/plugins/nim/project/nimrunconfigurationfactory.cpp
hjk dfd4ad8c2d ProjectExplorer: Simplify IRunConfigurationFactory::clone() use
Change-Id: I005d6c87142d26dfc7ae1349329737a68f54c427
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-14 10:58:30 +00:00

103 lines
3.2 KiB
C++

/****************************************************************************
**
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "nimrunconfigurationfactory.h"
#include "nimproject.h"
#include "nimrunconfiguration.h"
#include "../nimconstants.h"
#include <debugger/debuggerrunconfigurationaspect.h>
#include <projectexplorer/target.h>
#include <memory>
using namespace ProjectExplorer;
namespace Nim {
NimRunConfigurationFactory::NimRunConfigurationFactory()
{
registerRunConfiguration<NimRunConfiguration>();
}
QList<Core::Id> NimRunConfigurationFactory::availableCreationIds(Target *parent,
IRunConfigurationFactory::CreationMode mode) const
{
Q_UNUSED(mode);
QList<Core::Id> result;
if (canHandle(parent))
result.append(Constants::C_NIMRUNCONFIGURATION_ID);
return result;
}
QString NimRunConfigurationFactory::displayNameForId(Core::Id id) const
{
return id.toString() + QStringLiteral("-TempRunConf");
}
bool NimRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
{
Q_UNUSED(id);
return canHandle(parent);
}
bool NimRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
{
Q_UNUSED(parent);
Q_UNUSED(map);
return canHandle(parent);
}
bool NimRunConfigurationFactory::canClone(Target *parent, RunConfiguration *product) const
{
QTC_ASSERT(parent, return false);
QTC_ASSERT(product, return false);
return canHandle(parent);
}
bool NimRunConfigurationFactory::canHandle(Target *parent) const
{
Q_UNUSED(parent);
if (!parent->project()->supportsKit(parent->kit()))
return false;
return qobject_cast<NimProject *>(parent->project());
}
RunConfiguration *NimRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{
return createHelper<NimRunConfiguration>(parent, id);
}
RunConfiguration *NimRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
{
Q_UNUSED(map);
auto result = createHelper<NimRunConfiguration>(parent, idFromMap(map));
result->fromMap(map);
return result;
}
}