Debugger: Simplify thread switching more

This moves the thread switcher combobox, the only consumer
of part of the threadhandler interface, into the threadhandler.

Change-Id: Icafd72e7777fad9196ce8fb33a79cae26c29a521
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-08-31 18:30:14 +02:00
parent 944aa963a8
commit 86cd29b13c
5 changed files with 21 additions and 39 deletions

View File

@@ -221,6 +221,13 @@ ThreadsHandler::ThreadsHandler(DebuggerEngine *engine)
tr("Address"), tr("Function"), tr("File"), tr("Line"), tr("State"),
tr("Name"), tr("Target ID"), tr("Details"), tr("Core"),
});
m_comboBox = new QComboBox;
m_comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
m_comboBox->setModel(this);
connect(m_comboBox, QOverload<int>::of(&QComboBox::activated), this, [this](int row) {
setData(index(row, 0), {}, BaseTreeView::ItemActivatedRole);
});
}
QVariant ThreadsHandler::data(const QModelIndex &index, int role) const
@@ -240,8 +247,11 @@ bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int r
{
if (role == BaseTreeView::ItemActivatedRole) {
const Thread thread = itemForIndexAtLevel<1>(idx);
if (thread != m_currentThread)
m_engine->doSelectThread(thread);
if (thread != m_currentThread) {
m_currentThread = thread;
m_comboBox->setCurrentIndex(idx.row());
m_engine->selectThread(thread);
}
return true;
}
@@ -259,11 +269,6 @@ bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int r
return false;
}
int ThreadsHandler::currentThreadIndex() const
{
return rootItem()->indexOf(m_currentThread);
}
void ThreadsHandler::sort(int column, Qt::SortOrder order)
{
rootItem()->sortChildren([order, column](const ThreadItem *item1, const ThreadItem *item2) -> bool {