diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index be0401aead0641461bbaf36bd3934f2ef898b703..38b6a956d8856b2f8fd4d90ee8b86963c62fdf80 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -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); diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 50072d497b43354d9e21f3a92d85ec1dbcd42273..c8d5c4d556519fac9e6b5a6a3e8213d3d9fd0361 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -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; diff --git a/src/plugins/vcsbase/cleandialog.cpp b/src/plugins/vcsbase/cleandialog.cpp index c7159c03f87655f7cc226b0bf50e0cad53dc4e9d..cbf04a4869f08fa4a29130be81f2e7fa944e9763 100644 --- a/src/plugins/vcsbase/cleandialog.cpp +++ b/src/plugins/vcsbase/cleandialog.cpp @@ -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);