diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 40c5071fb2b8743cf681f3a0cf8fe4323a064437..a0f2c321972ee9f3d67ed9a406bdbf0f181cb271 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1967,13 +1967,16 @@ void GitClient::subversionLog(const QString &workingDirectory) executeGit(workingDirectory, arguments, editor); } -bool GitClient::synchronousPush(const QString &workingDirectory) +bool GitClient::synchronousPush(const QString &workingDirectory, const QString &remote) { // Disable UNIX terminals to suppress SSH prompting. const unsigned flags = VCSBase::VCSBasePlugin::SshPasswordPrompt|VCSBase::VCSBasePlugin::ShowStdOutInLogWindow |VCSBase::VCSBasePlugin::ShowSuccessMessage; + QStringList arguments(QLatin1String("push")); + if (!remote.isEmpty()) + arguments << remote; const Utils::SynchronousProcessResponse resp = - synchronousGit(workingDirectory, QStringList(QLatin1String("push")), flags); + synchronousGit(workingDirectory, arguments, flags); return resp.result == Utils::SynchronousProcessResponse::Finished; } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index b97ffe75a9d0a1ec3190ff1e8e1b5abd797eef37..6af47a72fcc1e3ab11cc94e26ed2b483f2d9a63a 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -170,7 +170,7 @@ public: QString vcsGetRepositoryURL(const QString &directory); bool synchronousFetch(const QString &workingDirectory, const QString &remote); bool synchronousPull(const QString &workingDirectory); - bool synchronousPush(const QString &workingDirectory); + bool synchronousPush(const QString &workingDirectory, const QString &remote = QString()); // git svn support (asynchronous). void synchronousSubversionFetch(const QString &workingDirectory); diff --git a/src/plugins/git/remotedialog.cpp b/src/plugins/git/remotedialog.cpp index 5c225ec74d196fda6af804f6a5a8d4249ff0b41b..9dba3bd746c910d56dc90e94d2c8d131cad379ec 100644 --- a/src/plugins/git/remotedialog.cpp +++ b/src/plugins/git/remotedialog.cpp @@ -106,8 +106,14 @@ RemoteDialog::RemoteDialog(QWidget *parent) : connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote())); connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote())); + connect(m_ui->pushButton, SIGNAL(clicked()), this, SLOT(pushToRemote())); connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeRemote())); connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refreshRemotes())); + + connect(m_ui->remoteView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(updateButtonState())); + + updateButtonState(); } RemoteDialog::~RemoteDialog() @@ -163,6 +169,17 @@ void RemoteDialog::removeRemote() } } +void RemoteDialog::pushToRemote() +{ + const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes(); + if (indexList.count() == 0) + return; + + const int row = indexList.at(0).row(); + const QString remoteName = m_remoteModel->remoteName(row); + m_remoteModel->client()->synchronousPush(m_remoteModel->workingDirectory(), remoteName); +} + void RemoteDialog::fetchFromRemote() { const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes(); @@ -174,6 +191,17 @@ void RemoteDialog::fetchFromRemote() m_remoteModel->client()->synchronousFetch(m_remoteModel->workingDirectory(), remoteName); } +void RemoteDialog::updateButtonState() +{ + const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes(); + + const bool haveSelection = (indexList.count() > 0); + m_ui->addButton->setEnabled(true); + m_ui->fetchButton->setEnabled(haveSelection); + m_ui->pushButton->setEnabled(haveSelection); + m_ui->removeButton->setEnabled(haveSelection); +} + void RemoteDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); diff --git a/src/plugins/git/remotedialog.h b/src/plugins/git/remotedialog.h index 213510a68b9c2d60e1c66e36f86a34af8f5751e9..9105f75df49cd3cf4e508cde15a3b59feb84e270 100644 --- a/src/plugins/git/remotedialog.h +++ b/src/plugins/git/remotedialog.h @@ -84,8 +84,11 @@ public slots: void refreshRemotes(); void addRemote(); void removeRemote(); + void pushToRemote(); void fetchFromRemote(); + void updateButtonState(); + private slots: protected: diff --git a/src/plugins/git/remotedialog.ui b/src/plugins/git/remotedialog.ui index deff9e629b7230b89b96257cf0aa3fdfc2cf1c6a..c3a5333cbb13836e78e33d10a27aa21228e799a2 100644 --- a/src/plugins/git/remotedialog.ui +++ b/src/plugins/git/remotedialog.ui @@ -111,6 +111,13 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>&Push</string> + </property> + </widget> + </item> <item> <widget class="QPushButton" name="removeButton"> <property name="text">