Skip to content
Snippets Groups Projects
Commit a26c884b authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Preserve current selection on log change refresh


Change-Id: Ic6be652a1d5cca87ae5effdcb3cb5df7b1b73c2c
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent d99e14fa
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment