summaryrefslogtreecommitdiff
path: root/src/plugins/git/gerrit/gerritplugin.cpp
diff options
context:
space:
mode:
authorPetar Perisin <petar.perisin@gmail.com>2013-04-02 15:07:30 +0300
committerPetar Perisin <petar.perisin@gmail.com>2013-04-05 11:28:05 +0200
commitfe1f7e4bf64f783f5c66cb5da2e2f2112e50d92c (patch)
tree912d05f49a26b9e22fad562ca4e615c5489e2fd8 /src/plugins/git/gerrit/gerritplugin.cpp
parent83d51b26913125e55e9390bd26cf04c4780cdf39 (diff)
downloadqt-creator-fe1f7e4bf64f783f5c66cb5da2e2f2112e50d92c.tar.gz
Gerrit: Added pushToGerrit dialog
Change-Id: Ic16eae2def11343ef7be5ce8378d24b5fd11a386 Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/git/gerrit/gerritplugin.cpp')
-rw-r--r--src/plugins/git/gerrit/gerritplugin.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp
index 4023723079..2337781d64 100644
--- a/src/plugins/git/gerrit/gerritplugin.cpp
+++ b/src/plugins/git/gerrit/gerritplugin.cpp
@@ -32,6 +32,7 @@
#include "gerritdialog.h"
#include "gerritmodel.h"
#include "gerritoptionspage.h"
+#include "gerritpushdialog.h"
#include "../gitplugin.h"
#include "../gitclient.h"
@@ -50,6 +51,7 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <locator/commandlocator.h>
#include <vcsbase/vcsbaseoutputwindow.h>
@@ -70,6 +72,7 @@ enum { debug = 0 };
namespace Gerrit {
namespace Constants {
const char GERRIT_OPEN_VIEW[] = "Gerrit.OpenView";
+const char GERRIT_PUSH[] = "Gerrit.Push";
}
namespace Internal {
@@ -332,10 +335,59 @@ bool GerritPlugin::initialize(Core::ActionContainer *ac)
connect(openViewAction, SIGNAL(triggered()), this, SLOT(openView()));
ac->addAction(command);
+ QAction *pushAction = new QAction(tr("Push to Gerrit..."), this);
+
+ Core::Command *pushCommand =
+ Core::ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH,
+ Core::Context(Core::Constants::C_GLOBAL));
+ connect(pushAction, SIGNAL(triggered()), this, SLOT(push()));
+ ac->addAction(pushCommand);
+
+ m_pushToGerritPair = ActionCommandPair(pushAction, pushCommand);
+
Git::Internal::GitPlugin::instance()->addAutoReleasedObject(new GerritOptionsPage(m_parameters));
return true;
}
+void GerritPlugin::updateActions(bool hasTopLevel)
+{
+ m_pushToGerritPair.first->setEnabled(hasTopLevel);
+}
+
+void GerritPlugin::addToLocator(Locator::CommandLocator *locator)
+{
+ locator->appendCommand(m_pushToGerritPair.second);
+}
+
+void GerritPlugin::push()
+{
+ const QString topLevel = Git::Internal::GitPlugin::instance()->currentState().topLevel();
+
+ QPointer<GerritPushDialog> dialog = new GerritPushDialog(topLevel, Core::ICore::mainWindow());
+
+ if (!dialog->localChangesFound()) {
+ QMessageBox::critical(Core::ICore::mainWindow(), tr("No Local Changes"),
+ tr("Change from HEAD appears to be in remote branch already! Aborting."));
+ return;
+ }
+
+ if (dialog->exec() == QDialog::Rejected)
+ return;
+
+ if (dialog.isNull())
+ return;
+
+ QStringList args;
+
+ args << dialog->selectedRemoteName();
+ args << QLatin1String("HEAD:refs/") + dialog->selectedPushType() +
+ QLatin1Char('/') + dialog->selectedRemoteBranchName();
+
+ Git::Internal::GitPlugin::instance()->gitClient()->synchronousPush(topLevel, args);
+
+ delete dialog;
+}
+
// Open or raise the Gerrit dialog window.
void GerritPlugin::openView()
{