Skip to content
Snippets Groups Projects
maemodeploystepfactory.cpp 2.54 KiB
Newer Older
#include "maemodeploystepfactory.h"

#include "maemodeploystep.h"

#include <projectexplorer/buildconfiguration.h>
Tobias Hunger's avatar
Tobias Hunger committed
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>

#include <QtCore/QCoreApplication>

using namespace ProjectExplorer;

namespace Qt4ProjectManager {
namespace Internal {

MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent)
    : IBuildStepFactory(parent)
{
}

Tobias Hunger's avatar
Tobias Hunger committed
QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const
Tobias Hunger's avatar
Tobias Hunger committed
    if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
        && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)
        && !parent->contains(MaemoDeployStep::Id))
        return QStringList() << MaemoDeployStep::Id;
    return QStringList();
}

Tobias Hunger's avatar
Tobias Hunger committed
QString MaemoDeployStepFactory::displayNameForId(const QString &id) const
Tobias Hunger's avatar
Tobias Hunger committed
    if (id == MaemoDeployStep::Id)
        return QCoreApplication::translate("Qt4ProjectManager::Internal::MaemoDeployStepFactory",
                                           "Deploy to device");
    return QString();
}

Tobias Hunger's avatar
Tobias Hunger committed
bool MaemoDeployStepFactory::canCreate(BuildStepList *parent, const QString &id) const
Tobias Hunger's avatar
Tobias Hunger committed
    return parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
            && id == QLatin1String(MaemoDeployStep::Id)
            && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)
            && !parent->contains(MaemoDeployStep::Id);
Tobias Hunger's avatar
Tobias Hunger committed
BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const QString &id)
Tobias Hunger's avatar
Tobias Hunger committed
    Q_ASSERT(canCreate(parent, id));
    return new MaemoDeployStep(parent);
Tobias Hunger's avatar
Tobias Hunger committed
bool MaemoDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
Tobias Hunger's avatar
Tobias Hunger committed
    return canCreate(parent, idFromMap(map));
Tobias Hunger's avatar
Tobias Hunger committed
BuildStep *MaemoDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
Tobias Hunger's avatar
Tobias Hunger committed
    Q_ASSERT(canRestore(parent, map));
    MaemoDeployStep * const step = new MaemoDeployStep(parent);
    if (!step->fromMap(map)) {
        delete step;
        return 0;
    }
    return step;
}

Tobias Hunger's avatar
Tobias Hunger committed
bool MaemoDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const
Tobias Hunger's avatar
Tobias Hunger committed
    return canCreate(parent, product->id());
Tobias Hunger's avatar
Tobias Hunger committed
BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *product)
Tobias Hunger's avatar
Tobias Hunger committed
    Q_ASSERT(canClone(parent, product));
    return new MaemoDeployStep(parent, static_cast<MaemoDeployStep*>(product));
}

} // namespace Internal
} // namespace Qt4ProjectManager