Changed scrollTo() to center the view on selected item

This commit is contained in:
Nikolaj Schlej 2014-11-09 13:49:47 +01:00
parent fa280c0f36
commit 1b40fa32d7

View File

@ -17,7 +17,7 @@
UEFITool::UEFITool(QWidget *parent) : UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::UEFITool), ui(new Ui::UEFITool),
version(tr("0.19.1")) version(tr("0.19.1.1"))
{ {
clipboard = QApplication::clipboard(); clipboard = QApplication::clipboard();
@ -631,7 +631,7 @@ void UEFITool::scrollTreeView(QListWidgetItem* item)
MessageListItem* messageItem = static_cast<MessageListItem*>(item); MessageListItem* messageItem = static_cast<MessageListItem*>(item);
QModelIndex index = messageItem->index(); QModelIndex index = messageItem->index();
if (index.isValid()) { if (index.isValid()) {
ui->structureTreeView->scrollTo(index); ui->structureTreeView->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->clearSelection(); ui->structureTreeView->selectionModel()->clearSelection();
ui->structureTreeView->selectionModel()->select(index, QItemSelectionModel::Select); ui->structureTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
} }