OSDN Git Service

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