OSDN Git Service

5c8b2697ce1e1a54d31b4d9604066fecba5b99c9
[qt-creator-jp/qt-creator-jp.git] / src / plugins / mercurial / clonewizard.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2009 Brian McGillion
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #include "clonewizard.h"
35 #include "clonewizardpage.h"
36 #include "mercurialplugin.h"
37 #include "mercurialsettings.h"
38
39 #include <vcsbase/checkoutjobs.h>
40 #include <vcsbase/vcsbaseconstants.h>
41
42 #include <QtCore/QDebug>
43
44 using namespace Mercurial::Internal;
45
46 CloneWizard::CloneWizard(QObject *parent)
47         :   VCSBase::BaseCheckoutWizard(parent),
48         m_icon(QIcon(QLatin1String(":/mercurial/images/hg.png")))
49 {
50     setId(QLatin1String(VCSBase::Constants::VCS_ID_MERCURIAL));
51 }
52
53 QIcon CloneWizard::icon() const
54 {
55     return m_icon;
56 }
57
58 QString CloneWizard::description() const
59 {
60     return tr("Clones a Mercurial repository and tries to load the contained project.");
61 }
62
63 QString CloneWizard::displayName() const
64 {
65     return tr("Mercurial Clone");
66 }
67
68 QList<QWizardPage*> CloneWizard::createParameterPages(const QString &path)
69 {
70     QList<QWizardPage*> wizardPageList;
71     CloneWizardPage *page = new CloneWizardPage;
72     page->setPath(path);
73     wizardPageList.push_back(page);
74     return wizardPageList;
75 }
76
77 QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPage *> &parameterPages,
78                                                                     QString *checkoutPath)
79 {
80     const CloneWizardPage *page = qobject_cast<const CloneWizardPage *>(parameterPages.front());
81
82     if (!page)
83         return QSharedPointer<VCSBase::AbstractCheckoutJob>();
84
85     const MercurialSettings &settings = MercurialPlugin::instance()->settings();
86
87     QStringList args = settings.standardArguments();
88     QString path = page->path();
89     QString directory = page->directory();
90
91     args << QLatin1String("clone") << page->repository() << directory;
92     *checkoutPath = path + QLatin1Char('/') + directory;
93     VCSBase::ProcessCheckoutJob *job = new VCSBase::ProcessCheckoutJob;
94     job->addStep(settings.binary(), args, path);
95     return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
96 }