clonewizard.cpp 4.16 KB
Newer Older
cerf's avatar
cerf committed
1 2 3 4 5 6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Hugues Delorme
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
cerf's avatar
cerf committed
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
cerf's avatar
cerf committed
18 19
**
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
cerf's avatar
cerf committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
cerf's avatar
cerf committed
28 29 30 31 32 33 34 35 36 37
**
**************************************************************************/

#include "clonewizard.h"
#include "clonewizardpage.h"
#include "cloneoptionspanel.h"
#include "bazaarplugin.h"
#include "bazaarclient.h"
#include "bazaarsettings.h"

38
#include <coreplugin/iversioncontrol.h>
cerf's avatar
cerf committed
39 40
#include <vcsbase/checkoutjobs.h>
#include <vcsbase/vcsbaseconstants.h>
41
#include <vcsbase/vcsconfigurationpage.h>
cerf's avatar
cerf committed
42

43
#include <QDebug>
cerf's avatar
cerf committed
44 45 46 47

using namespace Bazaar::Internal;

CloneWizard::CloneWizard(QObject *parent)
hjk's avatar
hjk committed
48
    : VcsBase::BaseCheckoutWizard(parent),
49
      m_icon(QIcon(QLatin1String(":/bazaar/images/bazaar.png")))
cerf's avatar
cerf committed
50
{
hjk's avatar
hjk committed
51
    setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR));
cerf's avatar
cerf committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65
}

QIcon CloneWizard::icon() const
{
    return m_icon;
}

QString CloneWizard::description() const
{
    return tr("Clones a Bazaar branch and tries to load the contained project.");
}

QString CloneWizard::displayName() const
{
Leena Miettinen's avatar
Leena Miettinen committed
66
    return tr("Bazaar Clone (Or Branch)");
cerf's avatar
cerf committed
67 68
}

cerf's avatar
cerf committed
69
QList<QWizardPage *> CloneWizard::createParameterPages(const QString &path)
cerf's avatar
cerf committed
70
{
cerf's avatar
cerf committed
71
    QList<QWizardPage *> wizardPageList;
72 73
    const Core::IVersionControl *vc = BazaarPlugin::instance()->versionControl();
    if (!vc->isConfigured())
hjk's avatar
hjk committed
74
        wizardPageList.append(new VcsBase::VcsConfigurationPage(vc));
cerf's avatar
cerf committed
75 76 77 78 79 80
    CloneWizardPage *page = new CloneWizardPage;
    page->setPath(path);
    wizardPageList.append(page);
    return wizardPageList;
}

hjk's avatar
hjk committed
81
QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPage *> &parameterPages,
cerf's avatar
cerf committed
82 83 84 85 86
                                                                    QString *checkoutPath)
{
    const CloneWizardPage *page = qobject_cast<const CloneWizardPage *>(parameterPages.front());

    if (!page)
hjk's avatar
hjk committed
87
        return QSharedPointer<VcsBase::AbstractCheckoutJob>();
cerf's avatar
cerf committed
88 89 90 91 92

    const BazaarSettings &settings = BazaarPlugin::instance()->settings();
    *checkoutPath = page->path() + QLatin1Char('/') + page->directory();

    const CloneOptionsPanel *panel = page->cloneOptionsPanel();
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
    QStringList extraOptions;
    if (panel->isUseExistingDirectoryOptionEnabled())
        extraOptions += QLatin1String("--use-existing-dir");
    if (panel->isStackedOptionEnabled())
        extraOptions += QLatin1String("--stacked");
    if (panel->isStandAloneOptionEnabled())
        extraOptions += QLatin1String("--standalone");
    if (panel->isBindOptionEnabled())
        extraOptions += QLatin1String("--bind");
    if (panel->isSwitchOptionEnabled())
        extraOptions += QLatin1String("--switch");
    if (panel->isHardLinkOptionEnabled())
        extraOptions += QLatin1String("--hardlink");
    if (panel->isNoTreeOptionEnabled())
        extraOptions += QLatin1String("--no-tree");
    if (!panel->revision().isEmpty())
        extraOptions << QLatin1String("-r") << panel->revision();
cerf's avatar
cerf committed
110
    const BazaarClient *client = BazaarPlugin::instance()->client();
111
    QStringList args;
cerf's avatar
cerf committed
112
    args << client->vcsCommandString(BazaarClient::CloneCommand)
113
         << extraOptions << page->repository() << page->directory();
cerf's avatar
cerf committed
114

hjk's avatar
hjk committed
115
    VcsBase::ProcessCheckoutJob *job = new VcsBase::ProcessCheckoutJob;
116
    job->addStep(settings.binaryPath(), args, page->path());
hjk's avatar
hjk committed
117
    return QSharedPointer<VcsBase::AbstractCheckoutJob>(job);
cerf's avatar
cerf committed
118
}