forked from qt-creator/qt-creator
VCSBase: Add common functionality, make checkout use page lists.
Move GitClient::filterUntrackedFilesOfProject into submit editor. Make checkout wizards use page lists for greater flexibility.
This commit is contained in:
@@ -59,19 +59,21 @@ QString CheckoutWizard::name() const
|
|||||||
return tr("CVS Checkout");
|
return tr("CVS Checkout");
|
||||||
}
|
}
|
||||||
|
|
||||||
QWizardPage *CheckoutWizard::createParameterPage(const QString &path)
|
QList<QWizardPage*> CheckoutWizard::createParameterPages(const QString &path)
|
||||||
{
|
{
|
||||||
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
||||||
cwp->setPath(path);
|
cwp->setPath(path);
|
||||||
return cwp;
|
QList<QWizardPage*> rc;
|
||||||
|
rc.push_back(cwp);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<VCSBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QWizardPage *parameterPage,
|
QSharedPointer<VCSBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QList<QWizardPage*> ¶meterPages,
|
||||||
QString *checkoutPath)
|
QString *checkoutPath)
|
||||||
{
|
{
|
||||||
// Collect parameters for the checkout command.
|
// Collect parameters for the checkout command.
|
||||||
// CVS does not allow for checking out into a different directory.
|
// CVS does not allow for checking out into a different directory.
|
||||||
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPage);
|
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
|
||||||
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
|
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
|
||||||
const CVSSettings settings = CVSPlugin::cvsPluginInstance()->settings();
|
const CVSSettings settings = CVSPlugin::cvsPluginInstance()->settings();
|
||||||
const QString binary = settings.cvsCommand;
|
const QString binary = settings.cvsCommand;
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BaseCheckoutWizard
|
// BaseCheckoutWizard
|
||||||
virtual QWizardPage *createParameterPage(const QString &path);
|
virtual QList<QWizardPage*> createParameterPages(const QString &path);
|
||||||
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QWizardPage *parameterPage,
|
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QList<QWizardPage*> ¶meterPage,
|
||||||
QString *checkoutPath);
|
QString *checkoutPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -60,18 +60,20 @@ QString CloneWizard::name() const
|
|||||||
return tr("Git Repository Clone");
|
return tr("Git Repository Clone");
|
||||||
}
|
}
|
||||||
|
|
||||||
QWizardPage *CloneWizard::createParameterPage(const QString &path)
|
QList<QWizardPage*> CloneWizard::createParameterPages(const QString &path)
|
||||||
{
|
{
|
||||||
CloneWizardPage *cwp = new CloneWizardPage;
|
CloneWizardPage *cwp = new CloneWizardPage;
|
||||||
cwp->setPath(path);
|
cwp->setPath(path);
|
||||||
return cwp;
|
QList<QWizardPage*> rc;
|
||||||
|
rc.push_back(cwp);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QWizardPage *parameterPage,
|
QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPage*> ¶meterPages,
|
||||||
QString *checkoutPath)
|
QString *checkoutPath)
|
||||||
{
|
{
|
||||||
// Collect parameters for the clone command.
|
// Collect parameters for the clone command.
|
||||||
const CloneWizardPage *cwp = qobject_cast<const CloneWizardPage *>(parameterPage);
|
const CloneWizardPage *cwp = qobject_cast<const CloneWizardPage *>(parameterPages.front());
|
||||||
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
|
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
|
||||||
const GitClient *client = GitPlugin::instance()->gitClient();
|
const GitClient *client = GitPlugin::instance()->gitClient();
|
||||||
QStringList args = client->binary();
|
QStringList args = client->binary();
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BaseCheckoutWizard
|
// BaseCheckoutWizard
|
||||||
virtual QWizardPage *createParameterPage(const QString &path);
|
virtual QList<QWizardPage*> createParameterPages(const QString &path);
|
||||||
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QWizardPage *parameterPage,
|
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QList<QWizardPage*> ¶meterPages,
|
||||||
QString *checkoutPath);
|
QString *checkoutPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -684,25 +684,6 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory,
|
|||||||
return StatusChanged;
|
return StatusChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out untracked files that are not part of the project
|
|
||||||
static void filterUntrackedFilesOfProject(const QString &repoDir, QStringList *l)
|
|
||||||
{
|
|
||||||
if (l->empty())
|
|
||||||
return;
|
|
||||||
const QStringList nativeProjectFiles = VCSBase::VCSBaseSubmitEditor::currentProjectFiles(true);
|
|
||||||
if (nativeProjectFiles.empty())
|
|
||||||
return;
|
|
||||||
const QDir repoDirectory(repoDir);
|
|
||||||
for (QStringList::iterator it = l->begin(); it != l->end(); ) {
|
|
||||||
const QString path = QDir::toNativeSeparators(repoDirectory.absoluteFilePath(*it));
|
|
||||||
if (nativeProjectFiles.contains(path)) {
|
|
||||||
++it;
|
|
||||||
} else {
|
|
||||||
it = l->erase(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GitClient::getCommitData(const QString &workingDirectory,
|
bool GitClient::getCommitData(const QString &workingDirectory,
|
||||||
QString *commitTemplate,
|
QString *commitTemplate,
|
||||||
CommitData *d,
|
CommitData *d,
|
||||||
@@ -771,7 +752,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Filter out untracked files that are not part of the project
|
// Filter out untracked files that are not part of the project
|
||||||
filterUntrackedFilesOfProject(repoDirectory, &d->untrackedFiles);
|
VCSBase::VCSBaseSubmitEditor::filterUntrackedFilesOfProject(repoDirectory, &d->untrackedFiles);
|
||||||
if (d->filesEmpty()) {
|
if (d->filesEmpty()) {
|
||||||
*errorMessage = msgNoChangedFiles();
|
*errorMessage = msgNoChangedFiles();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -59,18 +59,20 @@ QString CheckoutWizard::name() const
|
|||||||
return tr("Subversion Checkout");
|
return tr("Subversion Checkout");
|
||||||
}
|
}
|
||||||
|
|
||||||
QWizardPage *CheckoutWizard::createParameterPage(const QString &path)
|
QList<QWizardPage*> CheckoutWizard::createParameterPages(const QString &path)
|
||||||
{
|
{
|
||||||
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
CheckoutWizardPage *cwp = new CheckoutWizardPage;
|
||||||
cwp->setPath(path);
|
cwp->setPath(path);
|
||||||
return cwp;
|
QList<QWizardPage*> rc;
|
||||||
|
rc.push_back(cwp);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<VCSBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QWizardPage *parameterPage,
|
QSharedPointer<VCSBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QList<QWizardPage*> ¶meterPages,
|
||||||
QString *checkoutPath)
|
QString *checkoutPath)
|
||||||
{
|
{
|
||||||
// Collect parameters for the checkout command.
|
// Collect parameters for the checkout command.
|
||||||
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPage);
|
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
|
||||||
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
|
QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
|
||||||
const SubversionSettings settings = SubversionPlugin::subversionPluginInstance()->settings();
|
const SubversionSettings settings = SubversionPlugin::subversionPluginInstance()->settings();
|
||||||
const QString binary = settings.svnCommand;
|
const QString binary = settings.svnCommand;
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// BaseCheckoutWizard
|
// BaseCheckoutWizard
|
||||||
virtual QWizardPage *createParameterPage(const QString &path);
|
virtual QList<QWizardPage*> createParameterPages(const QString &path);
|
||||||
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QWizardPage *parameterPage,
|
virtual QSharedPointer<VCSBase::AbstractCheckoutJob> createJob(const QList<QWizardPage*> ¶meterPage,
|
||||||
QString *checkoutPath);
|
QString *checkoutPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,17 +43,17 @@
|
|||||||
namespace VCSBase {
|
namespace VCSBase {
|
||||||
|
|
||||||
struct BaseCheckoutWizardPrivate {
|
struct BaseCheckoutWizardPrivate {
|
||||||
BaseCheckoutWizardPrivate() : dialog(0), parameterPage(0) {}
|
BaseCheckoutWizardPrivate() : dialog(0) {}
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
Internal::CheckoutWizardDialog *dialog;
|
Internal::CheckoutWizardDialog *dialog;
|
||||||
QWizardPage *parameterPage;
|
QList<QWizardPage *> parameterPages;
|
||||||
QString checkoutPath;
|
QString checkoutPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
void BaseCheckoutWizardPrivate::clear()
|
void BaseCheckoutWizardPrivate::clear()
|
||||||
{
|
{
|
||||||
parameterPage = 0;
|
parameterPages.clear();
|
||||||
dialog = 0;
|
dialog = 0;
|
||||||
checkoutPath.clear();
|
checkoutPath.clear();
|
||||||
}
|
}
|
||||||
@@ -87,8 +87,8 @@ QString BaseCheckoutWizard::trCategory() const
|
|||||||
QStringList BaseCheckoutWizard::runWizard(const QString &path, QWidget *parent)
|
QStringList BaseCheckoutWizard::runWizard(const QString &path, QWidget *parent)
|
||||||
{
|
{
|
||||||
// Create dialog and launch
|
// Create dialog and launch
|
||||||
d->parameterPage = createParameterPage(path);
|
d->parameterPages = createParameterPages(path);
|
||||||
Internal::CheckoutWizardDialog dialog(d->parameterPage, parent);
|
Internal::CheckoutWizardDialog dialog(d->parameterPages, parent);
|
||||||
d->dialog = &dialog;
|
d->dialog = &dialog;
|
||||||
connect(&dialog, SIGNAL(progressPageShown()), this, SLOT(slotProgressPageShown()));
|
connect(&dialog, SIGNAL(progressPageShown()), this, SLOT(slotProgressPageShown()));
|
||||||
dialog.setWindowTitle(name());
|
dialog.setWindowTitle(name());
|
||||||
@@ -142,7 +142,7 @@ QString BaseCheckoutWizard::openProject(const QString &path, QString *errorMessa
|
|||||||
|
|
||||||
void BaseCheckoutWizard::slotProgressPageShown()
|
void BaseCheckoutWizard::slotProgressPageShown()
|
||||||
{
|
{
|
||||||
const QSharedPointer<AbstractCheckoutJob> job = createJob(d->parameterPage, &(d->checkoutPath));
|
const QSharedPointer<AbstractCheckoutJob> job = createJob(d->parameterPages, &(d->checkoutPath));
|
||||||
if (!job.isNull())
|
if (!job.isNull())
|
||||||
d->dialog->start(job);
|
d->dialog->start(job);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <coreplugin/dialogs/iwizard.h>
|
#include <coreplugin/dialogs/iwizard.h>
|
||||||
|
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QWizardPage;
|
class QWizardPage;
|
||||||
@@ -76,8 +77,8 @@ public:
|
|||||||
static QString openProject(const QString &path, QString *errorMessage);
|
static QString openProject(const QString &path, QString *errorMessage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QWizardPage *createParameterPage(const QString &path) = 0;
|
virtual QList<QWizardPage *> createParameterPages(const QString &path) = 0;
|
||||||
virtual QSharedPointer<AbstractCheckoutJob> createJob(const QWizardPage *parameterPage,
|
virtual QSharedPointer<AbstractCheckoutJob> createJob(const QList<QWizardPage *> ¶meterPages,
|
||||||
QString *checkoutPath) = 0;
|
QString *checkoutPath) = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@@ -39,16 +39,17 @@
|
|||||||
namespace VCSBase {
|
namespace VCSBase {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
enum PageId { ParameterPageId, ProgressPageId };
|
CheckoutWizardDialog::CheckoutWizardDialog(const QList<QWizardPage *> ¶meterPages,
|
||||||
|
|
||||||
CheckoutWizardDialog::CheckoutWizardDialog(QWizardPage *parameterPage,
|
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
QWizard(parent),
|
QWizard(parent),
|
||||||
m_progressPage(new CheckoutProgressWizardPage)
|
m_progressPage(new CheckoutProgressWizardPage),
|
||||||
|
m_progressPageId(-1)
|
||||||
{
|
{
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
setPage(ParameterPageId, parameterPage);
|
foreach(QWizardPage *wp, parameterPages)
|
||||||
setPage(ProgressPageId, m_progressPage);
|
addPage(wp);
|
||||||
|
m_progressPageId = parameterPages.size();
|
||||||
|
setPage(m_progressPageId, m_progressPage);
|
||||||
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotPageChanged(int)));
|
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotPageChanged(int)));
|
||||||
connect(m_progressPage, SIGNAL(terminated(bool)), this, SLOT(slotTerminated(bool)));
|
connect(m_progressPage, SIGNAL(terminated(bool)), this, SLOT(slotTerminated(bool)));
|
||||||
Core::BaseFileWizard::setupWizard(this);
|
Core::BaseFileWizard::setupWizard(this);
|
||||||
@@ -56,7 +57,7 @@ CheckoutWizardDialog::CheckoutWizardDialog(QWizardPage *parameterPage,
|
|||||||
|
|
||||||
void CheckoutWizardDialog::slotPageChanged(int id)
|
void CheckoutWizardDialog::slotPageChanged(int id)
|
||||||
{
|
{
|
||||||
if (id == ProgressPageId)
|
if (id == m_progressPageId)
|
||||||
emit progressPageShown();
|
emit progressPageShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,15 +75,10 @@ void CheckoutWizardDialog::start(const QSharedPointer<AbstractCheckoutJob> &job)
|
|||||||
button(QWizard::BackButton)->setEnabled(false);
|
button(QWizard::BackButton)->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QWizardPage *CheckoutWizardDialog::parameterPage() const
|
|
||||||
{
|
|
||||||
return page(ParameterPageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckoutWizardDialog::reject()
|
void CheckoutWizardDialog::reject()
|
||||||
{
|
{
|
||||||
// First click kills, 2nd closes
|
// First click kills, 2nd closes
|
||||||
if (currentId() == ProgressPageId && m_progressPage->isRunning()) {
|
if (currentId() == m_progressPageId && m_progressPage->isRunning()) {
|
||||||
m_progressPage->terminate();
|
m_progressPage->terminate();
|
||||||
} else {
|
} else {
|
||||||
QWizard::reject();
|
QWizard::reject();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#define CHECKOUTWIZARDDIALOG_H
|
#define CHECKOUTWIZARDDIALOG_H
|
||||||
|
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QtCore/QList>
|
||||||
#include <QtGui/QWizard>
|
#include <QtGui/QWizard>
|
||||||
|
|
||||||
namespace VCSBase {
|
namespace VCSBase {
|
||||||
@@ -46,11 +47,10 @@ class CheckoutProgressWizardPage;
|
|||||||
class CheckoutWizardDialog : public QWizard {
|
class CheckoutWizardDialog : public QWizard {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CheckoutWizardDialog(QWizardPage *parameterPage,
|
CheckoutWizardDialog(const QList<QWizardPage *> ¶meterPages,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
|
|
||||||
void start(const QSharedPointer<AbstractCheckoutJob> &job);
|
void start(const QSharedPointer<AbstractCheckoutJob> &job);
|
||||||
const QWizardPage *parameterPage() const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void progressPageShown();
|
void progressPageShown();
|
||||||
@@ -62,6 +62,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CheckoutProgressWizardPage *m_progressPage;
|
CheckoutProgressWizardPage *m_progressPage;
|
||||||
|
int m_progressPageId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -576,6 +576,7 @@ QIcon VCSBaseSubmitEditor::submitIcon()
|
|||||||
return QIcon(QLatin1String(":/vcsbase/images/submit.png"));
|
return QIcon(QLatin1String(":/vcsbase/images/submit.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile a list if files in the current projects. TODO: Recurse down qrc files?
|
||||||
QStringList VCSBaseSubmitEditor::currentProjectFiles(bool nativeSeparators, QString *name)
|
QStringList VCSBaseSubmitEditor::currentProjectFiles(bool nativeSeparators, QString *name)
|
||||||
{
|
{
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -606,6 +607,26 @@ QStringList VCSBaseSubmitEditor::currentProjectFiles(bool nativeSeparators, QStr
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce a list of untracked files reported by a VCS down to the files
|
||||||
|
// that are actually part of the current project(s).
|
||||||
|
void VCSBaseSubmitEditor::filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles)
|
||||||
|
{
|
||||||
|
if (untrackedFiles->empty())
|
||||||
|
return;
|
||||||
|
const QStringList nativeProjectFiles = VCSBase::VCSBaseSubmitEditor::currentProjectFiles(true);
|
||||||
|
if (nativeProjectFiles.empty())
|
||||||
|
return;
|
||||||
|
const QDir repoDir(repositoryDirectory);
|
||||||
|
for (QStringList::iterator it = untrackedFiles->begin(); it != untrackedFiles->end(); ) {
|
||||||
|
const QString path = QDir::toNativeSeparators(repoDir.absoluteFilePath(*it));
|
||||||
|
if (nativeProjectFiles.contains(path)) {
|
||||||
|
++it;
|
||||||
|
} else {
|
||||||
|
it = untrackedFiles->erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Helper to raise an already open submit editor to prevent opening twice.
|
// Helper to raise an already open submit editor to prevent opening twice.
|
||||||
bool VCSBaseSubmitEditor::raiseSubmitEditor()
|
bool VCSBaseSubmitEditor::raiseSubmitEditor()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ public:
|
|||||||
// be restricted to them
|
// be restricted to them
|
||||||
static QStringList currentProjectFiles(bool nativeSeparators, QString *name = 0);
|
static QStringList currentProjectFiles(bool nativeSeparators, QString *name = 0);
|
||||||
|
|
||||||
|
// Reduce a list of untracked files reported by a VCS down to the files
|
||||||
|
// that are actually part of the current project(s).
|
||||||
|
static void filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles);
|
||||||
|
|
||||||
virtual bool isTemporary() const { return true; }
|
virtual bool isTemporary() const { return true; }
|
||||||
|
|
||||||
// Helper to raise an already open submit editor to prevent opening twice.
|
// Helper to raise an already open submit editor to prevent opening twice.
|
||||||
|
|||||||
Reference in New Issue
Block a user