summaryrefslogtreecommitdiff
path: root/src/plugins/git/branchdialog.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-01-07 12:58:31 +0100
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-01-07 12:58:31 +0100
commit352cf143535605d7e5488b33e395ce82c8c413fb (patch)
tree916bf26ecdc482bc88990f82018a2b5ad7f194ea /src/plugins/git/branchdialog.cpp
parent800baec88b60760404a7534ca451fbda506910b5 (diff)
downloadqt-creator-352cf143535605d7e5488b33e395ce82c8c413fb.tar.gz
Fixes: Add way to create a new local branch in the git plugin
Task: 205821 Details: Split up the branch model into remote branch base class and extended local branch class with <New Branch> row.
Diffstat (limited to 'src/plugins/git/branchdialog.cpp')
-rw-r--r--src/plugins/git/branchdialog.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp
index 8d06c871f9..3eeee2347b 100644
--- a/src/plugins/git/branchdialog.cpp
+++ b/src/plugins/git/branchdialog.cpp
@@ -58,8 +58,9 @@ bool BranchDialog::init(GitClient *client, const QString &workingDirectory, QStr
}
m_ui->repositoryFieldLabel->setText(m_repoDirectory);
- m_localModel = new BranchModel(client, BranchModel::LocalBranches, this);
- m_remoteModel = new BranchModel(client, BranchModel::RemoteBranches, this);
+ m_localModel = new LocalBranchModel(client, this);
+ connect(m_localModel, SIGNAL(newBranchCreated(QString)), this, SLOT(slotNewLocalBranchCreated(QString)));
+ m_remoteModel = new RemoteBranchModel(client, this);
if (!m_localModel->refresh(workingDirectory, errorMessage)
|| !m_remoteModel->refresh(workingDirectory, errorMessage))
return false;
@@ -93,13 +94,23 @@ void BranchDialog::slotEnableButtons()
const int selectedLocalRow = selectedLocalBranchIndex();
const int currentLocalBranch = m_localModel->currentBranch();
- const bool hasSelection = selectedLocalRow != -1;
+ const bool hasSelection = selectedLocalRow != -1 && !m_localModel->isNewBranchRow(selectedLocalRow);
const bool currentIsNotSelected = hasSelection && selectedLocalRow != currentLocalBranch;
m_checkoutButton->setEnabled(currentIsNotSelected);
m_deleteButton->setEnabled(currentIsNotSelected);
}
+void BranchDialog::slotNewLocalBranchCreated(const QString &b)
+{
+ // Select the newly created branch
+ const int row = m_localModel->findBranchByName(b);
+ if (row != -1) {
+ const QModelIndex index = m_localModel->index(row);
+ m_ui->localBranchListView->selectionModel()->select(index, QItemSelectionModel::Select);
+ }
+}
+
bool BranchDialog::ask(const QString &title, const QString &what, bool defaultButton)
{
return QMessageBox::question(this, title, what, QMessageBox::Yes|QMessageBox::No,