Debugger: Remove some uses of semi-global currentEngine()

Make use of recent TreeModel improvements in various
tool views, push more operations into the engine-
owned data models, specifically context menu creation.

Change-Id: I479c97102b9fb81611c6461c6df1cec59295179a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2016-07-18 12:36:31 +02:00
committed by hjk
parent 84f1466b01
commit 2d79bdc29c
36 changed files with 2636 additions and 3364 deletions

View File

@@ -25,17 +25,22 @@
#include "threadshandler.h"
#include "debuggeractions.h"
#include "debuggercore.h"
#include "debuggerengine.h"
#include "debuggericons.h"
#include "debuggerprotocol.h"
#include "watchutils.h"
#include <utils/algorithm.h>
#include <utils/basetreeview.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
#include <QCoreApplication>
#include <QDebug>
#include <QIcon>
#include <QMenu>
using namespace Utils;
@@ -225,7 +230,8 @@ public:
represent the running threads in a QTreeView or ComboBox.
*/
ThreadsHandler::ThreadsHandler()
ThreadsHandler::ThreadsHandler(DebuggerEngine *engine)
: m_engine(engine)
{
m_resetLocationScheduled = false;
setObjectName(QLatin1String("ThreadsModel"));
@@ -236,6 +242,24 @@ ThreadsHandler::ThreadsHandler()
});
}
bool ThreadsHandler::setData(const QModelIndex &idx, const QVariant &data, int role)
{
if (role == BaseTreeView::ItemActivatedRole) {
ThreadId id = ThreadId(idx.data(ThreadData::IdRole).toLongLong());
m_engine->selectThread(id);
return true;
}
if (role == BaseTreeView::ItemViewEventRole) {
auto menu = new QMenu;
menu->addAction(action(SettingsDialog));
menu->popup(data.value<ItemViewEvent>().globalPos());
return true;
}
return false;
}
static ThreadItem *itemForThreadId(const ThreadsHandler *handler, ThreadId threadId)
{
const auto matcher = [threadId](ThreadItem *item) { return item->threadData.id == threadId; };