OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / subversion / checkoutwizard.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
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 "checkoutwizard.h"
35 #include "checkoutwizardpage.h"
36 #include "subversionplugin.h"
37
38 #include <vcsbase/checkoutjobs.h>
39 #include <vcsbase/vcsbaseconstants.h>
40 #include <utils/qtcassert.h>
41
42 #include <QtGui/QIcon>
43
44 namespace Subversion {
45 namespace Internal {
46
47 CheckoutWizard::CheckoutWizard(QObject *parent) :
48         VCSBase::BaseCheckoutWizard(parent)
49 {
50     setId(QLatin1String(VCSBase::Constants::VCS_ID_SUBVERSION));
51 }
52
53 QIcon CheckoutWizard::icon() const
54 {
55     return QIcon(QLatin1String(":/subversion/images/subversion.png"));
56 }
57
58 QString CheckoutWizard::description() const
59 {
60     return tr("Checks out a Subversion repository and tries to load the contained project.");
61 }
62
63 QString CheckoutWizard::displayName() const
64 {
65     return tr("Subversion Checkout");
66 }
67
68 QList<QWizardPage*> CheckoutWizard::createParameterPages(const QString &path)
69 {
70     CheckoutWizardPage *cwp = new CheckoutWizardPage;
71     cwp->setPath(path);
72     QList<QWizardPage*> rc;
73     rc.push_back(cwp);
74     return rc;
75 }
76
77 QSharedPointer<VCSBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QList<QWizardPage*> &parameterPages,
78                                                                     QString *checkoutPath)
79 {
80     // Collect parameters for the checkout command.
81     const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
82     QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
83     const SubversionSettings settings = SubversionPlugin::subversionPluginInstance()->settings();
84     const QString binary = settings.svnCommand;
85     const QString directory = cwp->directory();
86     QStringList args;
87     args << QLatin1String("checkout") << cwp->repository() << directory;
88     const QString workingDirectory = cwp->path();
89     *checkoutPath = workingDirectory + QLatin1Char('/') + directory;
90     const QStringList completeArgs = settings.hasAuthentication() ?
91                                      SubversionPlugin::addAuthenticationOptions(args, settings.user, settings.password) :
92                                      args;
93     VCSBase::ProcessCheckoutJob *job = new VCSBase::ProcessCheckoutJob;
94     job->addStep(binary, completeArgs, workingDirectory);
95     return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
96 }
97
98 } // namespace Internal
99 } // namespace Subversion