forked from qt-creator/qt-creator
VCS[vcs,p4,svn,hg]: Use VCManager for delete operations.
...and its dialog prompt consistently. Rename method and introduce overload taking IVersionControl. Add convenience slot to VCSBasePlugin.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
@@ -133,10 +134,17 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VCSManager::showDeleteDialog(const QString &fileName)
|
bool VCSManager::promptToDelete(const QString &fileName)
|
||||||
{
|
{
|
||||||
IVersionControl *vc = findVersionControlForDirectory(QFileInfo(fileName).absolutePath());
|
if (IVersionControl *vc = findVersionControlForDirectory(QFileInfo(fileName).absolutePath()))
|
||||||
if (!vc || !vc->supportsOperation(IVersionControl::DeleteOperation))
|
return promptToDelete(vc, fileName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VCSManager::promptToDelete(IVersionControl *vc, const QString &fileName)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(vc, return true)
|
||||||
|
if (!vc->supportsOperation(IVersionControl::DeleteOperation))
|
||||||
return true;
|
return true;
|
||||||
const QString title = QCoreApplication::translate("VCSManager", "Version Control");
|
const QString title = QCoreApplication::translate("VCSManager", "Version Control");
|
||||||
const QString msg = QCoreApplication::translate("VCSManager",
|
const QString msg = QCoreApplication::translate("VCSManager",
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ public:
|
|||||||
// Shows a confirmation dialog, whether the file should also be deleted
|
// Shows a confirmation dialog, whether the file should also be deleted
|
||||||
// from revision control Calls sccDelete on the file. Returns false
|
// from revision control Calls sccDelete on the file. Returns false
|
||||||
// if a failure occurs
|
// if a failure occurs
|
||||||
bool showDeleteDialog(const QString &fileName);
|
bool promptToDelete(const QString &fileName);
|
||||||
|
bool promptToDelete(IVersionControl *versionControl, const QString &fileName);
|
||||||
|
|
||||||
friend CORE_EXPORT QDebug operator<<(QDebug in, const VCSManager &);
|
friend CORE_EXPORT QDebug operator<<(QDebug in, const VCSManager &);
|
||||||
|
|
||||||
|
|||||||
@@ -261,14 +261,14 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes
|
|||||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||||
cvsMenu->addAction(command);
|
cvsMenu->addAction(command);
|
||||||
|
|
||||||
m_deleteAction = new Utils::ParameterAction(tr("Delete"), tr("Delete \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||||
cvsMenu->addAction(command);
|
cvsMenu->addAction(command);
|
||||||
|
|
||||||
m_revertAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
|
command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
@@ -524,14 +524,6 @@ void CVSPlugin::addCurrentFile()
|
|||||||
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVSPlugin::deleteCurrentFile()
|
|
||||||
{
|
|
||||||
const VCSBase::VCSBasePluginState state = currentState();
|
|
||||||
QTC_ASSERT(state.hasFile(), return)
|
|
||||||
if (!Core::ICore::instance()->vcsManager()->showDeleteDialog(state.currentFile()))
|
|
||||||
QMessageBox::warning(0, QLatin1String("CVS remove"), tr("The file '%1' could not be deleted.").arg(state.currentFile()), QMessageBox::Ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CVSPlugin::revertCurrentFile()
|
void CVSPlugin::revertCurrentFile()
|
||||||
{
|
{
|
||||||
const VCSBase::VCSBasePluginState state = currentState();
|
const VCSBase::VCSBasePluginState state = currentState();
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addCurrentFile();
|
void addCurrentFile();
|
||||||
void deleteCurrentFile();
|
|
||||||
void revertCurrentFile();
|
void revertCurrentFile();
|
||||||
void diffProject();
|
void diffProject();
|
||||||
void diffCurrentFile();
|
void diffCurrentFile();
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ const char * const COMMITMIMETYPE = "application/vnd.nokia.text.scs_mercurial_co
|
|||||||
|
|
||||||
//menu items
|
//menu items
|
||||||
//File menu actions
|
//File menu actions
|
||||||
|
const char * const ADD = "Mercurial.AddSingleFile";
|
||||||
|
const char * const DELETE = "Mercurial.DeleteSingleFile";
|
||||||
const char * const ANNOTATE = "Mercurial.Annotate";
|
const char * const ANNOTATE = "Mercurial.Annotate";
|
||||||
const char * const DIFF = "Mercurial.DiffSingleFile";
|
const char * const DIFF = "Mercurial.DiffSingleFile";
|
||||||
const char * const LOG = "Mercurial.LogSingleFile";
|
const char * const LOG = "Mercurial.LogSingleFile";
|
||||||
|
|||||||
@@ -38,8 +38,7 @@
|
|||||||
using namespace Mercurial::Internal;
|
using namespace Mercurial::Internal;
|
||||||
|
|
||||||
MercurialControl::MercurialControl(MercurialClient *client)
|
MercurialControl::MercurialControl(MercurialClient *client)
|
||||||
: mercurialClient(client),
|
: mercurialClient(client)
|
||||||
mercurialEnabled(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MercurialClient *mercurialClient;
|
MercurialClient *mercurialClient;
|
||||||
bool mercurialEnabled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace Internal
|
} //namespace Internal
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/basemode.h>
|
#include <coreplugin/basemode.h>
|
||||||
|
#include <coreplugin/vcsmanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
@@ -124,6 +125,8 @@ MercurialPlugin::MercurialPlugin() :
|
|||||||
optionsPage(0),
|
optionsPage(0),
|
||||||
m_client(0),
|
m_client(0),
|
||||||
changeLog(0),
|
changeLog(0),
|
||||||
|
m_addAction(0),
|
||||||
|
m_deleteAction(0),
|
||||||
m_menuAction(0)
|
m_menuAction(0)
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
@@ -225,38 +228,59 @@ void MercurialPlugin::createFileActions(const QList<int> &context)
|
|||||||
{
|
{
|
||||||
Core::Command *command;
|
Core::Command *command;
|
||||||
|
|
||||||
annotateFile = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
annotateFile = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = actionManager->registerAction(annotateFile, QLatin1String(Constants::ANNOTATE), context);
|
command = actionManager->registerAction(annotateFile, QLatin1String(Constants::ANNOTATE), context);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
connect(annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
|
connect(annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
|
||||||
mercurialContainer->addAction(command);
|
mercurialContainer->addAction(command);
|
||||||
|
|
||||||
diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = actionManager->registerAction(diffFile, QLatin1String(Constants::DIFF), context);
|
command = actionManager->registerAction(diffFile, QLatin1String(Constants::DIFF), context);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+D")));
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+D")));
|
||||||
connect(diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
connect(diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
||||||
mercurialContainer->addAction(command);
|
mercurialContainer->addAction(command);
|
||||||
|
|
||||||
logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = actionManager->registerAction(logFile, QLatin1String(Constants::LOG), context);
|
command = actionManager->registerAction(logFile, QLatin1String(Constants::LOG), context);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+L")));
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+L")));
|
||||||
connect(logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
|
connect(logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
|
||||||
mercurialContainer->addAction(command);
|
mercurialContainer->addAction(command);
|
||||||
|
|
||||||
revertFile = new Utils::ParameterAction(tr("Revert Current File"), tr("Revert \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = actionManager->registerAction(revertFile, QLatin1String(Constants::REVERT), context);
|
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
|
||||||
connect(revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
|
||||||
mercurialContainer->addAction(command);
|
|
||||||
|
|
||||||
statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
|
|
||||||
command = actionManager->registerAction(statusFile, QLatin1String(Constants::STATUS), context);
|
command = actionManager->registerAction(statusFile, QLatin1String(Constants::STATUS), context);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+S")));
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+S")));
|
||||||
connect(statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
|
connect(statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
|
||||||
mercurialContainer->addAction(command);
|
mercurialContainer->addAction(command);
|
||||||
|
|
||||||
|
createSeparator(context, QLatin1String("FileDirSeperator1"));
|
||||||
|
|
||||||
|
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
|
command = actionManager->registerAction(m_addAction, QLatin1String(Constants::ADD), context);
|
||||||
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||||
|
mercurialContainer->addAction(command);
|
||||||
|
|
||||||
|
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
|
command = actionManager->registerAction(m_deleteAction, QLatin1String(Constants::DELETE), context);
|
||||||
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||||
|
mercurialContainer->addAction(command);
|
||||||
|
|
||||||
|
revertFile = new Utils::ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
|
command = actionManager->registerAction(revertFile, QLatin1String(Constants::REVERT), context);
|
||||||
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
|
connect(revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
||||||
|
mercurialContainer->addAction(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MercurialPlugin::addCurrentFile()
|
||||||
|
{
|
||||||
|
const VCSBase::VCSBasePluginState state = currentState();
|
||||||
|
QTC_ASSERT(state.hasFile(), return)
|
||||||
|
m_client->add(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MercurialPlugin::annotateCurrentFile()
|
void MercurialPlugin::annotateCurrentFile()
|
||||||
@@ -655,19 +679,15 @@ void MercurialPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const QString filename = currentState().currentFileName();
|
const QString filename = currentState().currentFileName();
|
||||||
const bool fileEnabled = !filename.isEmpty();
|
|
||||||
const bool repoEnabled = currentState().hasTopLevel();
|
const bool repoEnabled = currentState().hasTopLevel();
|
||||||
|
|
||||||
annotateFile->setParameter(filename);
|
annotateFile->setParameter(filename);
|
||||||
annotateFile->setEnabled(fileEnabled);
|
|
||||||
diffFile->setParameter(filename);
|
diffFile->setParameter(filename);
|
||||||
diffFile->setEnabled(fileEnabled);
|
|
||||||
logFile->setParameter(filename);
|
logFile->setParameter(filename);
|
||||||
logFile->setEnabled(fileEnabled);
|
m_addAction->setParameter(filename);
|
||||||
|
m_deleteAction->setParameter(filename);
|
||||||
revertFile->setParameter(filename);
|
revertFile->setParameter(filename);
|
||||||
revertFile->setEnabled(fileEnabled);
|
|
||||||
statusFile->setParameter(filename);
|
statusFile->setParameter(filename);
|
||||||
statusFile->setEnabled(fileEnabled);
|
|
||||||
|
|
||||||
foreach (QAction *repoAction, m_repositoryActionList)
|
foreach (QAction *repoAction, m_repositoryActionList)
|
||||||
repoAction->setEnabled(repoEnabled);
|
repoAction->setEnabled(repoEnabled);
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// File menu action Slots
|
// File menu action Slots
|
||||||
|
void addCurrentFile();
|
||||||
void annotateCurrentFile();
|
void annotateCurrentFile();
|
||||||
void diffCurrentFile();
|
void diffCurrentFile();
|
||||||
void logCurrentFile();
|
void logCurrentFile();
|
||||||
@@ -156,6 +157,8 @@ private:
|
|||||||
QTemporaryFile *changeLog;
|
QTemporaryFile *changeLog;
|
||||||
|
|
||||||
//Menu Items (file actions)
|
//Menu Items (file actions)
|
||||||
|
Utils::ParameterAction *m_addAction;
|
||||||
|
Utils::ParameterAction *m_deleteAction;
|
||||||
Utils::ParameterAction *annotateFile;
|
Utils::ParameterAction *annotateFile;
|
||||||
Utils::ParameterAction *diffFile;
|
Utils::ParameterAction *diffFile;
|
||||||
Utils::ParameterAction *logFile;
|
Utils::ParameterAction *logFile;
|
||||||
|
|||||||
@@ -276,11 +276,11 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e
|
|||||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||||
mperforce->addAction(command);
|
mperforce->addAction(command);
|
||||||
|
|
||||||
m_deleteAction = new Utils::ParameterAction(tr("Delete"), tr("Delete \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = am->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, globalcontext);
|
command = am->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, globalcontext);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
command->setDefaultText(tr("Delete File"));
|
command->setDefaultText(tr("Delete File"));
|
||||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||||
mperforce->addAction(command);
|
mperforce->addAction(command);
|
||||||
|
|
||||||
m_revertFileAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
m_revertFileAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
@@ -451,13 +451,6 @@ void PerforcePlugin::addCurrentFile()
|
|||||||
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerforcePlugin::deleteCurrentFile()
|
|
||||||
{
|
|
||||||
const VCSBase::VCSBasePluginState state = currentState();
|
|
||||||
QTC_ASSERT(state.hasFile(), return)
|
|
||||||
vcsDelete(state.currentFileTopLevel(), state.relativeCurrentFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerforcePlugin::revertCurrentFile()
|
void PerforcePlugin::revertCurrentFile()
|
||||||
{
|
{
|
||||||
const VCSBase::VCSBasePluginState state = currentState();
|
const VCSBase::VCSBasePluginState state = currentState();
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void openCurrentFile();
|
void openCurrentFile();
|
||||||
void addCurrentFile();
|
void addCurrentFile();
|
||||||
void deleteCurrentFile();
|
|
||||||
void revertCurrentFile();
|
void revertCurrentFile();
|
||||||
void printOpenedFileList();
|
void printOpenedFileList();
|
||||||
void diffCurrentFile();
|
void diffCurrentFile();
|
||||||
|
|||||||
@@ -1946,7 +1946,7 @@ void ProjectExplorerPlugin::removeFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove from version control
|
// remove from version control
|
||||||
core->vcsManager()->showDeleteDialog(filePath);
|
core->vcsManager()->promptToDelete(filePath);
|
||||||
|
|
||||||
// remove from file system
|
// remove from file system
|
||||||
if (deleteFile) {
|
if (deleteFile) {
|
||||||
|
|||||||
@@ -292,14 +292,14 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
|
|||||||
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
||||||
subversionMenu->addAction(command);
|
subversionMenu->addAction(command);
|
||||||
|
|
||||||
m_deleteAction = new Utils::ParameterAction(tr("Delete"), tr("Delete \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
||||||
subversionMenu->addAction(command);
|
subversionMenu->addAction(command);
|
||||||
|
|
||||||
m_revertAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
||||||
command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
|
command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
command->setAttribute(Core::Command::CA_UpdateText);
|
command->setAttribute(Core::Command::CA_UpdateText);
|
||||||
@@ -556,13 +556,6 @@ void SubversionPlugin::addCurrentFile()
|
|||||||
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPlugin::deleteCurrentFile()
|
|
||||||
{
|
|
||||||
const VCSBase::VCSBasePluginState state = currentState();
|
|
||||||
QTC_ASSERT(state.hasFile(), return)
|
|
||||||
vcsDelete(state.currentFileTopLevel(), state.relativeCurrentFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SubversionPlugin::revertCurrentFile()
|
void SubversionPlugin::revertCurrentFile()
|
||||||
{
|
{
|
||||||
const VCSBase::VCSBasePluginState state = currentState();
|
const VCSBase::VCSBasePluginState state = currentState();
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addCurrentFile();
|
void addCurrentFile();
|
||||||
void deleteCurrentFile();
|
|
||||||
void revertCurrentFile();
|
void revertCurrentFile();
|
||||||
void diffProject();
|
void diffProject();
|
||||||
void diffCurrentFile();
|
void diffCurrentFile();
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <QtCore/QSharedData>
|
#include <QtCore/QSharedData>
|
||||||
|
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
enum { debug = 0 };
|
enum { debug = 0 };
|
||||||
|
|
||||||
@@ -446,6 +447,15 @@ bool VCSBasePlugin::enableMenuAction(ActionState as, QAction *menuAction)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VCSBasePlugin::promptToDeleteCurrentFile()
|
||||||
|
{
|
||||||
|
const VCSBasePluginState state = currentState();
|
||||||
|
QTC_ASSERT(state.hasFile(), return)
|
||||||
|
const bool rc = Core::ICore::instance()->vcsManager()->promptToDelete(versionControl(), state.currentFile());
|
||||||
|
if (!rc)
|
||||||
|
QMessageBox::warning(0, tr("Version Control"), tr("The file '%1' could not be deleted.").arg(state.currentFile()), QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace VCSBase
|
} // namespace VCSBase
|
||||||
|
|
||||||
#include "vcsbaseplugin.moc"
|
#include "vcsbaseplugin.moc"
|
||||||
|
|||||||
@@ -149,6 +149,11 @@ public:
|
|||||||
const VCSBasePluginState ¤tState() const;
|
const VCSBasePluginState ¤tState() const;
|
||||||
Core::IVersionControl *versionControl() const;
|
Core::IVersionControl *versionControl() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
// Convenience slot for "Delete current file" action. Prompts to
|
||||||
|
// delete the file via VCSManager.
|
||||||
|
void promptToDeleteCurrentFile();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum ActionState { NoVCSEnabled, OtherVCSEnabled, VCSEnabled };
|
enum ActionState { NoVCSEnabled, OtherVCSEnabled, VCSEnabled };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user