diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 06a94e38824ffe0312b773922c293444524d7f8d..3a070507b5f482f2a2141c8d762c83629cac2547 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -88,16 +88,15 @@ static const char * const CMD_ID_DIFF_PROJECT = "CVS.DiffAll"; static const char * const CMD_ID_DIFF_CURRENT = "CVS.DiffCurrent"; static const char * const CMD_ID_SEPARATOR1 = "CVS.Separator1"; static const char * const CMD_ID_COMMIT_ALL = "CVS.CommitAll"; +static const char * const CMD_ID_REVERT_ALL = "CVS.RevertAll"; static const char * const CMD_ID_COMMIT_CURRENT = "CVS.CommitCurrent"; static const char * const CMD_ID_SEPARATOR2 = "CVS.Separator2"; static const char * const CMD_ID_FILELOG_CURRENT = "CVS.FilelogCurrent"; static const char * const CMD_ID_ANNOTATE_CURRENT = "CVS.AnnotateCurrent"; -static const char * const CMD_ID_SEPARATOR3 = "CVS.Separator3"; static const char * const CMD_ID_STATUS = "CVS.Status"; static const char * const CMD_ID_UPDATE = "CVS.Update"; static const char * const CMD_ID_PROJECTLOG = "CVS.ProjectLog"; static const char * const CMD_ID_REPOSITORYLOG = "CVS.RepositoryLog"; -static const char * const CMD_ID_SEPARATOR4 = "CVS.Separator4"; static const VCSBase::VCSBaseEditorParameters editorParameters[] = { { @@ -159,6 +158,7 @@ CVSPlugin::CVSPlugin() : m_logProjectAction(0), m_logRepositoryAction(0), m_commitAllAction(0), + m_revertRepositoryAction(0), m_commitCurrentAction(0), m_filelogCurrentAction(0), m_annotateCurrentAction(0), @@ -253,51 +253,39 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes globalcontext << core->uniqueIDManager()->uniqueIdentifier(C_GLOBAL); Core::Command *command; - m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_addAction, CMD_ID_ADD, - globalcontext); + + m_diffCurrentAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_diffCurrentAction, + CMD_ID_DIFF_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+A"))); - connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); + command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+D"))); + connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); cvsMenu->addAction(command); - m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, - globalcontext); + m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_filelogCurrentAction, + CMD_ID_FILELOG_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); + connect(m_filelogCurrentAction, SIGNAL(triggered()), this, + SLOT(filelogCurrentFile())); cvsMenu->addAction(command); - m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_revertAction, CMD_ID_REVERT, - globalcontext); + m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_annotateCurrentAction, + CMD_ID_ANNOTATE_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); + connect(m_annotateCurrentAction, SIGNAL(triggered()), this, + SLOT(annotateCurrentFile())); cvsMenu->addAction(command); cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR0, globalcontext)); - m_diffProjectAction = new Utils::ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, + m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_addAction, CMD_ID_ADD, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject())); - cvsMenu->addAction(command); - - m_diffCurrentAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_diffCurrentAction, - CMD_ID_DIFF_CURRENT, globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+D"))); - connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); - cvsMenu->addAction(command); - - cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext)); - - m_commitAllAction = new QAction(tr("Commit All Files"), this); - command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL, - globalcontext); - connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll())); + command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+A"))); + connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); cvsMenu->addAction(command); m_commitCurrentAction = new Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); @@ -308,25 +296,28 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile())); cvsMenu->addAction(command); - cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext)); - - m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_filelogCurrentAction, - CMD_ID_FILELOG_CURRENT, globalcontext); + m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, + globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_filelogCurrentAction, SIGNAL(triggered()), this, - SLOT(filelogCurrentFile())); + connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); cvsMenu->addAction(command); - m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_annotateCurrentAction, - CMD_ID_ANNOTATE_CURRENT, globalcontext); + m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_revertAction, CMD_ID_REVERT, + globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_annotateCurrentAction, SIGNAL(triggered()), this, - SLOT(annotateCurrentFile())); + connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); cvsMenu->addAction(command); - cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR3, globalcontext)); + cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext)); + + m_diffProjectAction = new Utils::ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, + globalcontext); + command->setAttribute(Core::Command::CA_UpdateText); + connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject())); + cvsMenu->addAction(command); m_statusProjectAction = new Utils::ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = ami->registerAction(m_statusProjectAction, CMD_ID_STATUS, @@ -347,12 +338,25 @@ bool CVSPlugin::initialize(const QStringList & /*arguments */, QString *errorMes connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject())); cvsMenu->addAction(command); - cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR4, globalcontext)); + cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext)); + m_logRepositoryAction = new QAction(tr("Repository Log"), this); command = ami->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext); connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository())); cvsMenu->addAction(command); + m_commitAllAction = new QAction(tr("Commit All Files"), this); + command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL, + globalcontext); + connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll())); + cvsMenu->addAction(command); + + m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this); + command = ami->registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL, + globalcontext); + connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll())); + cvsMenu->addAction(command); + // Actions of the submit editor QList<int> cvscommitcontext; cvscommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::CVSCOMMITEDITOR); @@ -524,6 +528,24 @@ void CVSPlugin::addCurrentFile() vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile()); } +void CVSPlugin::revertAll() +{ + const VCSBase::VCSBasePluginState state = currentState(); + QTC_ASSERT(state.hasTopLevel(), return) + const QString title = tr("Revert repository"); + if (QMessageBox::warning(0, title, tr("Would you like to revert all changes to the repository?"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) + return; + QStringList args; + args << QLatin1String("update") << QLatin1String("-C") << state.topLevel(); + const CVSResponse revertResponse = runCVS(state.topLevel(), args, m_settings.timeOutMS(), true); + if (revertResponse.result == CVSResponse::Ok) { + cvsVersionControl()->emitRepositoryChanged(state.topLevel()); + } else { + QMessageBox::warning(0, title, tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok); + } +} + void CVSPlugin::revertCurrentFile() { const VCSBase::VCSBasePluginState state = currentState(); diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h index 33cda600febe8ea4c765bba4b00c0eaad359767e..3b310747813f20683d02bf7a453710f99cfb4773 100644 --- a/src/plugins/cvs/cvsplugin.h +++ b/src/plugins/cvs/cvsplugin.h @@ -102,6 +102,7 @@ private slots: void revertCurrentFile(); void diffProject(); void diffCurrentFile(); + void revertAll(); void startCommitAll(); void startCommitCurrentFile(); void filelogCurrentFile(); @@ -158,6 +159,7 @@ private: Utils::ParameterAction *m_logProjectAction; QAction *m_logRepositoryAction; QAction *m_commitAllAction; + QAction *m_revertRepositoryAction; Utils::ParameterAction *m_commitCurrentAction; Utils::ParameterAction *m_filelogCurrentAction; Utils::ParameterAction *m_annotateCurrentAction; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index d22690bd409309ecabf073d7ef03ef2cb08d5ada..34d2f383d2ea505a2dae8c620a37434633f02272 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -158,7 +158,6 @@ static const char * const CMD_ID_UPDATEALL = "Perforce.UpdateAll"; static const char * const CMD_ID_SEPARATOR1 = "Perforce.Separator1"; static const char * const CMD_ID_SEPARATOR2 = "Perforce.Separator2"; static const char * const CMD_ID_SEPARATOR3 = "Perforce.Separator3"; -static const char * const CMD_ID_SEPARATOR4 = "Perforce.Separator4"; //// // PerforcePlugin @@ -213,6 +212,16 @@ static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = { Perforce::Constants::PERFORCESUBMITEDITOR_CONTEXT }; +static inline Core::Command *createSeparator(QObject *parent, + Core::ActionManager *ami, + const char*id, + const QList<int> &globalcontext) +{ + QAction *tmpaction = new QAction(parent); + tmpaction->setSeparator(true); + return ami->registerAction(tmpaction, id, globalcontext); +} + bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * errorMessage) { typedef VCSBase::VCSEditorFactory<PerforceEditor> PerforceEditorFactory; @@ -258,7 +267,30 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e uniqueIdentifier(Constants::PERFORCESUBMITEDITOR_CONTEXT); Core::Command *command; - QAction *tmpaction; + + m_diffFileAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = am->registerAction(m_diffFileAction, CMD_ID_DIFF_CURRENT, globalcontext); + command->setAttribute(Core::Command::CA_UpdateText); + command->setDefaultText(tr("Diff Current File")); + connect(m_diffFileAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); + mperforce->addAction(command); + + m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = am->registerAction(m_annotateCurrentAction, CMD_ID_ANNOTATE_CURRENT, globalcontext); + command->setAttribute(Core::Command::CA_UpdateText); + command->setDefaultText(tr("Annotate Current File")); + connect(m_annotateCurrentAction, SIGNAL(triggered()), this, SLOT(annotateCurrentFile())); + mperforce->addAction(command); + + m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = am->registerAction(m_filelogCurrentAction, CMD_ID_FILELOG_CURRENT, globalcontext); + command->setAttribute(Core::Command::CA_UpdateText); + command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+F"))); + command->setDefaultText(tr("Filelog Current File")); + connect(m_filelogCurrentAction, SIGNAL(triggered()), this, SLOT(filelogCurrentFile())); + mperforce->addAction(command); + + mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Edit", globalcontext)); m_editAction = new Utils::ParameterAction(tr("Edit"), tr("Edit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_editAction, CMD_ID_EDIT, globalcontext); @@ -291,17 +323,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e connect(m_revertFileAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); mperforce->addAction(command); - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - command = am->registerAction(tmpaction, QLatin1String("Perforce.Sep.Edit"), globalcontext); - mperforce->addAction(command); - - m_diffFileAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = am->registerAction(m_diffFileAction, CMD_ID_DIFF_CURRENT, globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultText(tr("Diff Current File")); - connect(m_diffFileAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); - mperforce->addAction(command); + mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Project", globalcontext)); const QString diffProjectDefaultText = tr("Diff Current Project/Session"); m_diffProjectAction = new Utils::ParameterAction(diffProjectDefaultText, tr("Diff Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); @@ -312,22 +334,6 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject())); mperforce->addAction(command); - m_diffAllAction = new QAction(tr("Diff Opened Files"), this); - command = am->registerAction(m_diffAllAction, CMD_ID_DIFF_ALL, globalcontext); - connect(m_diffAllAction, SIGNAL(triggered()), this, SLOT(diffAllOpened())); - mperforce->addAction(command); - - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - command = am->registerAction(tmpaction, QLatin1String("Perforce.Sep.Diff"), globalcontext); - mperforce->addAction(command); - - m_openedAction = new QAction(tr("Opened"), this); - command = am->registerAction(m_openedAction, CMD_ID_OPENED, globalcontext); - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+O"))); - connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList())); - mperforce->addAction(command); - m_logProjectAction = new Utils::ParameterAction(tr("Log Project Log"), tr("Log Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); @@ -341,11 +347,6 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e connect(m_submitProjectAction, SIGNAL(triggered()), this, SLOT(startSubmitProject())); mperforce->addAction(command); - m_pendingAction = new QAction(tr("Pending Changes..."), this); - command = am->registerAction(m_pendingAction, CMD_ID_PENDING_CHANGES, globalcontext); - connect(m_pendingAction, SIGNAL(triggered()), this, SLOT(printPendingChanges())); - mperforce->addAction(command); - const QString updateProjectDefaultText = tr("Update Current Project"); m_updateProjectAction = new Utils::ParameterAction(updateProjectDefaultText, tr("Update Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = am->registerAction(m_updateProjectAction, CMD_ID_UPDATE_PROJECT, globalcontext); @@ -354,68 +355,63 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString * e connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateCurrentProject())); mperforce->addAction(command); + m_revertUnchangedAction = new Utils::ParameterAction(tr("Revert Unchanged"), tr("Revert Unchanged Files of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = am->registerAction(m_revertUnchangedAction, CMD_ID_REVERT_UNCHANGED_PROJECT, globalcontext); + command->setAttribute(Core::Command::CA_UpdateText); + connect(m_revertUnchangedAction, SIGNAL(triggered()), this, SLOT(revertUnchangedCurrentProject())); + mperforce->addAction(command); + m_revertProjectAction = new Utils::ParameterAction(tr("Revert Project"), tr("Revert Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_revertProjectAction, CMD_ID_REVERT_PROJECT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); connect(m_revertProjectAction, SIGNAL(triggered()), this, SLOT(revertCurrentProject())); mperforce->addAction(command); - m_revertUnchangedAction = new Utils::ParameterAction(tr("Revert Unchanged"), tr("Revert Unchanged Files of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = am->registerAction(m_revertUnchangedAction, CMD_ID_REVERT_UNCHANGED_PROJECT, globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); - connect(m_revertUnchangedAction, SIGNAL(triggered()), this, SLOT(revertUnchangedCurrentProject())); + mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Repository", globalcontext)); + + m_diffAllAction = new QAction(tr("Diff Opened Files"), this); + command = am->registerAction(m_diffAllAction, CMD_ID_DIFF_ALL, globalcontext); + connect(m_diffAllAction, SIGNAL(triggered()), this, SLOT(diffAllOpened())); mperforce->addAction(command); - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - command = am->registerAction(tmpaction, QLatin1String("Perforce.Sep.Changes"), globalcontext); + m_openedAction = new QAction(tr("Opened"), this); + command = am->registerAction(m_openedAction, CMD_ID_OPENED, globalcontext); + command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+O"))); + connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList())); + mperforce->addAction(command); + + m_logRepositoryAction = new QAction(tr("Repository Log"), this); + command = am->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext); + connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository())); + mperforce->addAction(command); + + m_pendingAction = new QAction(tr("Pending Changes..."), this); + command = am->registerAction(m_pendingAction, CMD_ID_PENDING_CHANGES, globalcontext); + connect(m_pendingAction, SIGNAL(triggered()), this, SLOT(printPendingChanges())); + mperforce->addAction(command); + + m_updateAllAction = new QAction(tr("Update All"), this); + command = am->registerAction(m_updateAllAction, CMD_ID_UPDATEALL, globalcontext); + connect(m_updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll())); mperforce->addAction(command); + mperforce->addAction(createSeparator(this, am, "Perforce.Sep.Dialogs", globalcontext)); + m_describeAction = new QAction(tr("Describe..."), this); command = am->registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext); connect(m_describeAction, SIGNAL(triggered()), this, SLOT(describeChange())); mperforce->addAction(command); - m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = am->registerAction(m_annotateCurrentAction, CMD_ID_ANNOTATE_CURRENT, globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultText(tr("Annotate Current File")); - connect(m_annotateCurrentAction, SIGNAL(triggered()), this, SLOT(annotateCurrentFile())); - mperforce->addAction(command); - m_annotateAction = new QAction(tr("Annotate..."), this); command = am->registerAction(m_annotateAction, CMD_ID_ANNOTATE, globalcontext); connect(m_annotateAction, SIGNAL(triggered()), this, SLOT(annotate())); mperforce->addAction(command); - m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = am->registerAction(m_filelogCurrentAction, CMD_ID_FILELOG_CURRENT, globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+F"))); - command->setDefaultText(tr("Filelog Current File")); - connect(m_filelogCurrentAction, SIGNAL(triggered()), this, SLOT(filelogCurrentFile())); - mperforce->addAction(command); - m_filelogAction = new QAction(tr("Filelog..."), this); command = am->registerAction(m_filelogAction, CMD_ID_FILELOG, globalcontext); connect(m_filelogAction, SIGNAL(triggered()), this, SLOT(filelog())); mperforce->addAction(command); - tmpaction = new QAction(this); - tmpaction->setSeparator(true); - command = am->registerAction(tmpaction, QLatin1String(CMD_ID_SEPARATOR4), globalcontext); - mperforce->addAction(command); - - m_logRepositoryAction = new QAction(tr("Repository Log"), this); - command = am->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext); - connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository())); - mperforce->addAction(command); - - m_updateAllAction = new QAction(tr("Update All"), this); - command = am->registerAction(m_updateAllAction, CMD_ID_UPDATEALL, globalcontext); - connect(m_updateAllAction, SIGNAL(triggered()), this, SLOT(updateAll())); - mperforce->addAction(command); - m_submitCurrentLogAction = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Submit"), this); command = am->registerAction(m_submitCurrentLogAction, Constants::SUBMIT_CURRENT, perforcesubmitcontext); connect(m_submitCurrentLogAction, SIGNAL(triggered()), this, SLOT(submitCurrentLog())); diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index aef5560eff16124110c06f1424266db6d310dcc0..f0ccf0f6d06bef24e733a40aeac59a773ea97fd2 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -80,6 +80,7 @@ static const char * const CMD_ID_DIFF_PROJECT = "Subversion.DiffAll"; static const char * const CMD_ID_DIFF_CURRENT = "Subversion.DiffCurrent"; static const char * const CMD_ID_SEPARATOR1 = "Subversion.Separator1"; static const char * const CMD_ID_COMMIT_ALL = "Subversion.CommitAll"; +static const char * const CMD_ID_REVERT_ALL = "Subversion.RevertAll"; static const char * const CMD_ID_COMMIT_CURRENT = "Subversion.CommitCurrent"; static const char * const CMD_ID_SEPARATOR2 = "Subversion.Separator2"; static const char * const CMD_ID_FILELOG_CURRENT = "Subversion.FilelogCurrent"; @@ -189,6 +190,7 @@ SubversionPlugin::SubversionPlugin() : m_logProjectAction(0), m_logRepositoryAction(0), m_commitAllAction(0), + m_revertRepositoryAction(0), m_commitCurrentAction(0), m_filelogCurrentAction(0), m_annotateCurrentAction(0), @@ -284,51 +286,39 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e globalcontext << core->uniqueIDManager()->uniqueIdentifier(C_GLOBAL); Core::Command *command; - m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_addAction, CMD_ID_ADD, - globalcontext); + + m_diffCurrentAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_diffCurrentAction, + CMD_ID_DIFF_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+A"))); - connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); + command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+D"))); + connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); subversionMenu->addAction(command); - m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, - globalcontext); + m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_filelogCurrentAction, + CMD_ID_FILELOG_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); + connect(m_filelogCurrentAction, SIGNAL(triggered()), this, + SLOT(filelogCurrentFile())); subversionMenu->addAction(command); - m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_revertAction, CMD_ID_REVERT, - globalcontext); + m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_annotateCurrentAction, + CMD_ID_ANNOTATE_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); + connect(m_annotateCurrentAction, SIGNAL(triggered()), this, + SLOT(annotateCurrentFile())); subversionMenu->addAction(command); subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR0, globalcontext)); - m_diffProjectAction = new Utils::ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, + m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_addAction, CMD_ID_ADD, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject())); - subversionMenu->addAction(command); - - m_diffCurrentAction = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_diffCurrentAction, - CMD_ID_DIFF_CURRENT, globalcontext); - command->setAttribute(Core::Command::CA_UpdateText); - command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+D"))); - connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); - subversionMenu->addAction(command); - - subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext)); - - m_commitAllAction = new QAction(tr("Commit All Files"), this); - command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL, - globalcontext); - connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll())); + command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+A"))); + connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); subversionMenu->addAction(command); m_commitCurrentAction = new Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); @@ -339,30 +329,28 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile())); subversionMenu->addAction(command); - subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext)); - - m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_filelogCurrentAction, - CMD_ID_FILELOG_CURRENT, globalcontext); + m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE, + globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_filelogCurrentAction, SIGNAL(triggered()), this, - SLOT(filelogCurrentFile())); + connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); subversionMenu->addAction(command); - m_annotateCurrentAction = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - command = ami->registerAction(m_annotateCurrentAction, - CMD_ID_ANNOTATE_CURRENT, globalcontext); + m_revertAction = new Utils::ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_revertAction, CMD_ID_REVERT, + globalcontext); command->setAttribute(Core::Command::CA_UpdateText); - connect(m_annotateCurrentAction, SIGNAL(triggered()), this, - SLOT(annotateCurrentFile())); + connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); subversionMenu->addAction(command); - m_describeAction = new QAction(tr("Describe..."), this); - command = ami->registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext); - connect(m_describeAction, SIGNAL(triggered()), this, SLOT(slotDescribe())); - subversionMenu->addAction(command); + subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext)); - subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR3, globalcontext)); + m_diffProjectAction = new Utils::ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); + command = ami->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, + globalcontext); + command->setAttribute(Core::Command::CA_UpdateText); + connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject())); + subversionMenu->addAction(command); m_statusProjectAction = new Utils::ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = ami->registerAction(m_statusProjectAction, CMD_ID_STATUS, @@ -383,12 +371,30 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e command->setAttribute(Core::Command::CA_UpdateText); subversionMenu->addAction(command); - subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR4, globalcontext)); + subversionMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext)); + m_logRepositoryAction = new QAction(tr("Repository Log"), this); command = ami->registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext); connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository())); subversionMenu->addAction(command); + m_describeAction = new QAction(tr("Describe..."), this); + command = ami->registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext); + connect(m_describeAction, SIGNAL(triggered()), this, SLOT(slotDescribe())); + subversionMenu->addAction(command); + + m_commitAllAction = new QAction(tr("Commit All Files"), this); + command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL, + globalcontext); + connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll())); + subversionMenu->addAction(command); + + m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this); + command = ami->registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL, + globalcontext); + connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll())); + subversionMenu->addAction(command); + // Actions of the submit editor QList<int> svncommitcontext; svncommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::SUBVERSIONCOMMITEDITOR); @@ -517,7 +523,6 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction); connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffCommitFiles(QStringList))); submitEditor->setCheckScriptWorkingDirectory(m_commitRepository); - return submitEditor; } @@ -537,6 +542,7 @@ void SubversionPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) const bool repoEnabled = currentState().hasTopLevel(); m_commitAllAction->setEnabled(repoEnabled); m_describeAction->setEnabled(repoEnabled); + m_revertRepositoryAction->setEnabled(repoEnabled); const QString fileName = currentState().currentFileName(); @@ -556,6 +562,25 @@ void SubversionPlugin::addCurrentFile() vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile()); } +void SubversionPlugin::revertAll() +{ + const VCSBase::VCSBasePluginState state = currentState(); + QTC_ASSERT(state.hasTopLevel(), return) + const QString title = tr("Revert repository"); + if (QMessageBox::warning(0, title, tr("Would you like to revert all changes to the repository?"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) + return; + // NoteL: Svn "revert ." doesn not work. + QStringList args; + args << QLatin1String("revert") << QLatin1String("--recursive") << state.topLevel(); + const SubversionResponse revertResponse = runSvn(state.topLevel(), args, m_settings.timeOutMS(), true); + if (revertResponse.error) { + QMessageBox::warning(0, title, tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok); + } else { + subVersionControl()->emitRepositoryChanged(state.topLevel()); + } +} + void SubversionPlugin::revertCurrentFile() { const VCSBase::VCSBasePluginState state = currentState(); diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index 97fda4b06ddd98719948c432d7dc3e3c4435be77..e0ed8e89a10212eee6226bf98b9e853c24cdd981 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -103,6 +103,7 @@ private slots: void diffCurrentFile(); void startCommitAll(); void startCommitCurrentFile(); + void revertAll(); void filelogCurrentFile(); void annotateCurrentFile(); void annotateVersion(const QString &file, const QString &revision, int lineNumber); @@ -153,6 +154,7 @@ private: Utils::ParameterAction *m_logProjectAction; QAction *m_logRepositoryAction; QAction *m_commitAllAction; + QAction *m_revertRepositoryAction; Utils::ParameterAction *m_commitCurrentAction; Utils::ParameterAction *m_filelogCurrentAction; Utils::ParameterAction *m_annotateCurrentAction;