Commit 288ece11 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

VCS[git]: Add "Clean project"

in the same fashion as "Clean repository".
parent 47d6195c
......@@ -133,7 +133,8 @@ GitPlugin::GitPlugin() :
m_commitAction(0),
m_pullAction(0),
m_pushAction(0),
m_cleanAction(0),
m_cleanProjectAction(0),
m_cleanRepositoryAction(0),
m_submitCurrentAction(0),
m_diffSelectedFilesAction(0),
m_undoAction(0),
......@@ -304,6 +305,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
gitContainer->addAction(command);
m_commandLocator->appendCommand(command);
m_cleanProjectAction = new Utils::ParameterAction(tr("Clean Project..."), tr("Clean Project \"%1\"..."), Utils::ParameterAction::AlwaysEnabled, this);
command = actionManager->registerAction(m_cleanProjectAction, "Git.CleanProject", globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_cleanProjectAction, SIGNAL(triggered()), this, SLOT(cleanProject()));
gitContainer->addAction(command);
m_commandLocator->appendCommand(command);
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Repository"), this));
m_diffRepositoryAction = new QAction(tr("Diff Repository"), this);
......@@ -334,9 +342,9 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
gitContainer->addAction(command);
m_cleanAction = new QAction(tr("Clean Repository..."), this);
command = actionManager->registerAction(m_cleanAction, "Git.CleanRepository", globalcontext);
connect(m_cleanAction, SIGNAL(triggered()), this, SLOT(cleanRepository()));
m_cleanRepositoryAction = new QAction(tr("Clean Repository..."), this);
command = actionManager->registerAction(m_cleanRepositoryAction, "Git.CleanRepository", globalcontext);
connect(m_cleanRepositoryAction, SIGNAL(triggered()), this, SLOT(cleanRepository()));
gitContainer->addAction(command);
m_commandLocator->appendCommand(command);
......@@ -688,16 +696,27 @@ void GitPlugin::push()
m_gitClient->push(state.topLevel());
}
void GitPlugin::cleanProject()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return)
cleanRepository(state.currentProjectPath());
}
void GitPlugin::cleanRepository()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
cleanRepository(state.topLevel());
}
void GitPlugin::cleanRepository(const QString &directory)
{
// Find files to be deleted
QString errorMessage;
QStringList files;
QApplication::setOverrideCursor(Qt::WaitCursor);
const bool gotFiles = m_gitClient->synchronousCleanList(state.topLevel(), &files, &errorMessage);
const bool gotFiles = m_gitClient->synchronousCleanList(directory, &files, &errorMessage);
QApplication::restoreOverrideCursor();
QWidget *parent = Core::ICore::instance()->mainWindow();
......@@ -720,7 +739,7 @@ void GitPlugin::cleanRepository()
// Show in dialog
VCSBase::CleanDialog dialog(parent);
dialog.setFileList(state.topLevel(), files);
dialog.setFileList(directory, files);
dialog.exec();
}
......@@ -811,6 +830,8 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
m_diffProjectAction->setParameter(projectName);
m_logProjectAction->setEnabled(projectEnabled);
m_logProjectAction->setParameter(projectName);
m_cleanProjectAction->setParameter(projectName);
m_cleanProjectAction->setEnabled(projectEnabled);
m_diffRepositoryAction->setEnabled(repositoryEnabled);
m_statusRepositoryAction->setEnabled(repositoryEnabled);
......@@ -824,7 +845,7 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
m_logRepositoryAction->setEnabled(repositoryEnabled);
m_undoRepositoryAction->setEnabled(repositoryEnabled);
m_pushAction->setEnabled(repositoryEnabled);
m_cleanAction->setEnabled(repositoryEnabled);
m_cleanRepositoryAction->setEnabled(repositoryEnabled);
// Prompts for repo.
m_showAction->setEnabled(true);
......
......@@ -105,6 +105,7 @@ private slots:
void undoRepositoryChanges();
void stageFile();
void unstageFile();
void cleanProject();
void cleanRepository();
void showCommit();
......@@ -125,6 +126,7 @@ private:
bool isCommitEditorOpen() const;
Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd);
void cleanCommitMessageFile();
void cleanRepository(const QString &directory);
static GitPlugin *m_instance;
Core::ICore *m_core;
......@@ -147,7 +149,8 @@ private:
QAction *m_commitAction;
QAction *m_pullAction;
QAction *m_pushAction;
QAction *m_cleanAction;
Utils::ParameterAction *m_cleanProjectAction;
QAction *m_cleanRepositoryAction;
QAction *m_submitCurrentAction;
QAction *m_diffSelectedFilesAction;
......
......@@ -167,6 +167,7 @@ void CleanDialog::setFileList(const QString &workingDirectory, const QStringList
const QString diffSuffix = QLatin1String(".diff");
const QString patchSuffix = QLatin1String(".patch");
const QString proUserSuffix = QLatin1String(".pro.user");
const QString qmlProUserSuffix = QLatin1String(".qmlproject.user");
const QChar slash = QLatin1Char('/');
// Do not initially check patches or 'pro.user' files for deletion.
foreach(const QString &fileName, l) {
......@@ -177,7 +178,8 @@ void CleanDialog::setFileList(const QString &workingDirectory, const QStringList
nameItem->setIcon(isDir ? folderIcon : fileIcon);
const bool saveFile = !isDir && (fileName.endsWith(diffSuffix)
|| fileName.endsWith(patchSuffix)
|| fileName.endsWith(proUserSuffix));
|| fileName.endsWith(proUserSuffix)
|| fileName.endsWith(qmlProUserSuffix));
nameItem->setCheckable(true);
nameItem->setCheckState(saveFile ? Qt::Unchecked : Qt::Checked);
nameItem->setData(QVariant(fi.absoluteFilePath()), fileNameRole);
......
Supports Markdown
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