Commit b488deeb authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

CVS: Add checkout wizard.

parent 998beeb1
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#include "checkoutwizard.h"
#include "checkoutwizardpage.h"
#include "cvsplugin.h"
#include <vcsbase/checkoutjobs.h>
#include <utils/qtcassert.h>
#include <QtGui/QIcon>
namespace CVS {
namespace Internal {
CheckoutWizard::CheckoutWizard(QObject *parent) :
VCSBase::BaseCheckoutWizard(parent)
{
}
QIcon CheckoutWizard::icon() const
{
return QIcon();
}
QString CheckoutWizard::description() const
{
return tr("Check-out a project from a CVS repository.");
}
QString CheckoutWizard::name() const
{
return tr("CVS Checkout");
}
QWizardPage *CheckoutWizard::createParameterPage(const QString &path)
{
CheckoutWizardPage *cwp = new CheckoutWizardPage;
cwp->setPath(path);
return cwp;
}
QSharedPointer<VCSBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QWizardPage *parameterPage,
QString *checkoutPath)
{
// Collect parameters for the checkout command.
// CVS does not allow for checking out into a different directory.
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPage);
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
const CVSSettings settings = CVSPlugin::cvsPluginInstance()->settings();
const QString binary = settings.cvsCommand;
QStringList args;
const QString repository = cwp->repository();
args << QLatin1String("checkout") << repository;
const QString workingDirectory = cwp->path();
*checkoutPath = workingDirectory + QLatin1Char('/') + repository;
VCSBase::AbstractCheckoutJob *job = new VCSBase::ProcessCheckoutJob(binary, settings.addOptions(args),
workingDirectory);
return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
}
} // namespace Internal
} // namespace CVS
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#ifndef CHECKOUTWIZARD_H
#define CHECKOUTWIZARD_H
#include <vcsbase/basecheckoutwizard.h>
namespace CVS {
namespace Internal {
class CheckoutWizard : public VCSBase::BaseCheckoutWizard
{
public:
explicit CheckoutWizard(QObject *parent = 0);
// IWizard
virtual QIcon icon() const;
virtual QString description() const;
virtual QString name() const;
protected:
// BaseCheckoutWizard
virtual QWizardPage *createParameterPage(const QString &path);
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QWizardPage *parameterPage,
QString *checkoutPath);
};
} // namespace Internal
} // namespace CVS
#endif // CHECKOUTWIZARD_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#include "checkoutwizardpage.h"
namespace CVS {
namespace Internal {
CheckoutWizardPage::CheckoutWizardPage(QWidget *parent) :
VCSBase::BaseCheckoutWizardPage(parent)
{
setSubTitle(tr("Specify repository and path."));
setRepositoryLabel(tr("Repository:"));
setDirectoryVisible(false);
}
} // namespace Internal
} // namespace CVS
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#ifndef CHECKOUTWIZARDPAGE_H
#define CHECKOUTWIZARDPAGE_H
#include <vcsbase/basecheckoutwizardpage.h>
namespace CVS {
namespace Internal {
class CheckoutWizardPage : public VCSBase::BaseCheckoutWizardPage {
Q_OBJECT
public:
CheckoutWizardPage(QWidget *parent = 0);
};
} // namespace Internal
} // namespace CVS
#endif // CHECKOUTWIZARDPAGE_H
......@@ -17,7 +17,9 @@ HEADERS += annotationhighlighter.h \
cvssubmiteditor.h \
cvssettings.h \
cvsutils.h \
cvsconstants.h
cvsconstants.h \
checkoutwizard.h \
checkoutwizardpage.h
SOURCES += annotationhighlighter.cpp \
cvsplugin.cpp \
......@@ -27,7 +29,9 @@ SOURCES += annotationhighlighter.cpp \
cvseditor.cpp \
cvssubmiteditor.cpp \
cvssettings.cpp \
cvsutils.cpp
cvsutils.cpp \
checkoutwizard.cpp \
checkoutwizardpage.cpp
FORMS += settingspage.ui
......
......@@ -34,6 +34,7 @@
#include "cvssubmiteditor.h"
#include "cvsconstants.h"
#include "cvscontrol.h"
#include "checkoutwizard.h"
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseeditor.h>
......@@ -241,6 +242,8 @@ bool CVSPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_cvsOutputWindow = new CVSOutputWindow(this);
addAutoReleasedObject(m_cvsOutputWindow);
addAutoReleasedObject(new CheckoutWizard);
//register actions
Core::ActionManager *ami = core->actionManager();
Core::ActionContainer *toolsContainer = ami->actionContainer(M_TOOLS);
......
......@@ -39,7 +39,6 @@ QT_END_NAMESPACE
namespace CVS {
namespace Internal {
// Todo: Add user name and password?
struct CVSSettings
{
CVSSettings();
......
......@@ -57,7 +57,7 @@ QString CloneWizard::description() const
QString CloneWizard::name() const
{
return tr("Git Checkout");
return tr("Git Repository Clone");
}
QWizardPage *CloneWizard::createParameterPage(const QString &path)
......
......@@ -83,6 +83,12 @@ void BaseCheckoutWizardPage::setDirectory(const QString &dir)
d->ui.checkoutDirectoryLineEdit->setText(dir);
}
void BaseCheckoutWizardPage::setDirectoryVisible(bool v)
{
d->ui.checkoutDirectoryLabel->setVisible(v);
d->ui.checkoutDirectoryLineEdit->setVisible(v);
}
QString BaseCheckoutWizardPage::repository() const
{
return d->ui.repositoryLineEdit->text().trimmed();
......@@ -95,13 +101,16 @@ void BaseCheckoutWizardPage::setRepository(const QString &r)
void BaseCheckoutWizardPage::slotRepositoryChanged(const QString &repo)
{
/* Try to figure out a good directory name from something like:
* "svn://<server>/path1/project" -> project */
if (d->m_directoryEdited)
return;
d->ui.checkoutDirectoryLineEdit->setText(directoryFromRepository(repo));
}
QString BaseCheckoutWizardPage::directoryFromRepository(const QString &r) const
{
return r;
}
void BaseCheckoutWizardPage::slotDirectoryEdited()
{
d->m_directoryEdited = true;
......
......@@ -68,10 +68,11 @@ protected:
void changeEvent(QEvent *e);
void setRepositoryLabel(const QString &l);
void setDirectoryVisible(bool v);
/* Determine a checkout directory name from
* repository URL, that is, "protocol:/project" -> "project". */
virtual QString directoryFromRepository(const QString &r) const = 0;
virtual QString directoryFromRepository(const QString &r) const;
private slots:
void slotRepositoryChanged(const QString &url);
......
......@@ -87,7 +87,8 @@ ProcessCheckoutJob::~ProcessCheckoutJob()
void ProcessCheckoutJob::slotOutput()
{
const QString s = QString::fromLocal8Bit(d->process.readAllStandardOutput());
const QByteArray data = d->process.readAllStandardOutput();
const QString s = QString::fromLocal8Bit(data, data.endsWith('\n') ? data.size() - 1: data.size());
if (debug)
qDebug() << s;
emit output(s);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment