Git: Preserve current selection on log change refresh

Change-Id: Ic6be652a1d5cca87ae5effdcb3cb5df7b1b73c2c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Orgad Shaneh
2013-06-27 22:01:35 +03:00
committed by Orgad Shaneh
parent d99e14fad8
commit a26c884b70

View File

@@ -76,8 +76,6 @@ bool LogChangeWidget::init(const QString &repository, const QString &commit, boo
GitPlugin::instance()->gitClient()->msgNoCommits(includeRemote));
return false;
}
selectionModel()->select(m_model->index(0, 0),
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
return true;
}
@@ -117,6 +115,8 @@ void LogChangeWidget::emitDoubleClicked(const QModelIndex &index)
bool LogChangeWidget::populateLog(const QString &repository, const QString &commit, bool includeRemote)
{
const QString currentCommit = this->commit();
int selected = currentCommit.isEmpty() ? 0 : -1;
if (const int rowCount = m_model->rowCount())
m_model->removeRows(0, rowCount);
@@ -144,12 +144,15 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
}
row.push_back(item);
}
row[Sha1Column]->setText(line.left(colonPos));
const QString sha1 = line.left(colonPos);
row[Sha1Column]->setText(sha1);
row[SubjectColumn]->setText(line.right(line.size() - colonPos - 1));
m_model->appendRow(row);
if (selected == -1 && currentCommit == sha1)
selected = m_model->rowCount() - 1;
}
}
setCurrentIndex(m_model->index(0, 0));
setCurrentIndex(m_model->index(selected, 0));
return true;
}