2015-08-26 09:37:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-06-14 20:33:55 +03:00
|
|
|
#include "nimrunconfigurationfactory.h"
|
|
|
|
|
#include "nimproject.h"
|
|
|
|
|
#include "nimrunconfiguration.h"
|
2015-08-26 09:37:55 +02:00
|
|
|
|
2016-06-14 20:33:55 +03:00
|
|
|
#include "../nimconstants.h"
|
2015-08-26 09:37:55 +02:00
|
|
|
|
|
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace Nim {
|
|
|
|
|
|
|
|
|
|
NimRunConfigurationFactory::NimRunConfigurationFactory()
|
2017-01-21 23:36:14 +01:00
|
|
|
{}
|
2015-08-26 09:37:55 +02:00
|
|
|
|
|
|
|
|
QList<Core::Id> NimRunConfigurationFactory::availableCreationIds(Target *parent,
|
|
|
|
|
IRunConfigurationFactory::CreationMode mode) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(mode);
|
2017-01-21 23:36:14 +01:00
|
|
|
QList<Core::Id> result;
|
2015-08-26 09:37:55 +02:00
|
|
|
if (canHandle(parent))
|
2017-01-21 23:36:14 +01:00
|
|
|
result.append(Constants::C_NIMRUNCONFIGURATION_ID);
|
|
|
|
|
return result;
|
2015-08-26 09:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString NimRunConfigurationFactory::displayNameForId(Core::Id id) const
|
|
|
|
|
{
|
2017-01-21 23:36:14 +01:00
|
|
|
return id.toString() + QStringLiteral("-TempRunConf");
|
2015-08-26 09:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2017-01-21 23:36:14 +01:00
|
|
|
return canHandle(parent);
|
2015-08-26 09:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration *NimRunConfigurationFactory::clone(Target *parent, RunConfiguration *product)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(parent, return nullptr);
|
|
|
|
|
QTC_ASSERT(product, return nullptr);
|
|
|
|
|
std::unique_ptr<NimRunConfiguration> result(new NimRunConfiguration(parent, Constants::C_NIMRUNCONFIGURATION_ID));
|
|
|
|
|
return result->fromMap(product->toMap()) ? result.release() : nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NimRunConfigurationFactory::canHandle(Target *parent) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(parent);
|
2017-01-21 23:36:14 +01:00
|
|
|
if (!parent->project()->supportsKit(parent->kit()))
|
|
|
|
|
return false;
|
2015-08-26 09:37:55 +02:00
|
|
|
return qobject_cast<NimProject *>(parent->project());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration *NimRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(id);
|
2017-01-21 23:36:14 +01:00
|
|
|
return new NimRunConfiguration(parent, id);
|
2015-08-26 09:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration *NimRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(map);
|
|
|
|
|
auto result = new NimRunConfiguration(parent, idFromMap(map));
|
|
|
|
|
result->fromMap(map);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|