forked from qt-creator/qt-creator
ProjectExplorer: Improve issues pane behavior
... when the user clicks a link. Apparently, the (unintended?) default item view behavior is to move the scrollbar so that the top of the current item becomes visible, which we don't want here. Fixes: QTCREATORBUG-25101 Change-Id: I4c99ff09ba762b7b375b0bdefd8cebfbda69b0ea Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -78,6 +78,7 @@ class TaskView : public Utils::ListView
|
||||
{
|
||||
public:
|
||||
TaskView(QWidget *parent = nullptr);
|
||||
void setCurrentAndScrollTo(const QModelIndex &index);
|
||||
~TaskView() override;
|
||||
|
||||
private:
|
||||
@@ -202,6 +203,7 @@ TaskView::TaskView(QWidget *parent)
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setMouseTracking(true);
|
||||
setAutoScroll(false); // QTCREATORBUG-25101
|
||||
|
||||
QFontMetrics fm(font());
|
||||
int vStepSize = fm.height() + 3;
|
||||
@@ -211,6 +213,12 @@ TaskView::TaskView(QWidget *parent)
|
||||
verticalScrollBar()->setSingleStep(vStepSize);
|
||||
}
|
||||
|
||||
void TaskView::setCurrentAndScrollTo(const QModelIndex &index)
|
||||
{
|
||||
scrollTo(index);
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
|
||||
TaskView::~TaskView() = default;
|
||||
|
||||
void TaskView::resizeEvent(QResizeEvent *e)
|
||||
@@ -553,7 +561,7 @@ void TaskWindow::showTask(unsigned int id)
|
||||
int sourceRow = d->m_model->rowForId(id);
|
||||
QModelIndex sourceIdx = d->m_model->index(sourceRow, 0);
|
||||
QModelIndex filterIdx = d->m_filter->mapFromSource(sourceIdx);
|
||||
d->m_listview->setCurrentIndex(filterIdx);
|
||||
d->m_listview->setCurrentAndScrollTo(filterIdx);
|
||||
popup(Core::IOutputPane::ModeSwitch);
|
||||
}
|
||||
|
||||
@@ -682,7 +690,7 @@ void TaskWindow::setFocus()
|
||||
if (d->m_filter->rowCount()) {
|
||||
d->m_listview->setFocus();
|
||||
if (d->m_listview->currentIndex() == QModelIndex())
|
||||
d->m_listview->setCurrentIndex(d->m_filter->index(0,0, QModelIndex()));
|
||||
d->m_listview->setCurrentAndScrollTo(d->m_filter->index(0,0, QModelIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,7 +723,7 @@ void TaskWindow::goToNext()
|
||||
} else {
|
||||
currentIndex = d->m_filter->index(0, 0);
|
||||
}
|
||||
d->m_listview->setCurrentIndex(currentIndex);
|
||||
d->m_listview->setCurrentAndScrollTo(currentIndex);
|
||||
triggerDefaultHandler(currentIndex);
|
||||
}
|
||||
|
||||
@@ -738,7 +746,7 @@ void TaskWindow::goToPrev()
|
||||
} else {
|
||||
currentIndex = d->m_filter->index(0, 0);
|
||||
}
|
||||
d->m_listview->setCurrentIndex(currentIndex);
|
||||
d->m_listview->setCurrentAndScrollTo(currentIndex);
|
||||
triggerDefaultHandler(currentIndex);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user