forked from qt-creator/qt-creator
debugger: The DebuggerEngine refactoring.
This replaces the (de facto) singleton engines and data handlers by classes that are instantiated per run. The DebuggerRunControl will now create an object of (a class derived from) DebuggerEngine that contains all the relevant "dynamic" data. DebuggerManager is no more. The "singleton" bits are merged into DebuggerPlugin, whereas the data bits went to DebuggerEngine. There is no formal notion of a "current" DebuggerEngine. However, as there's only one DebuggerEngine at a time that has its data models connected to the view, there's still some "de facto" notion of a "current" engine. Calling SomeModel::setData(int role, QVariant data) with custom role is used as the primary dispatch mechanism from the views to the "current" data models (and the engine, as all data models know their engine).
This commit is contained in:
@@ -29,7 +29,10 @@
|
||||
|
||||
#include "registerhandler.h"
|
||||
|
||||
#include "debuggeractions.h"
|
||||
#include "debuggeragents.h"
|
||||
#include "debuggerconstants.h"
|
||||
#include "debuggerengine.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -49,8 +52,8 @@ using namespace Debugger::Constants;
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
RegisterHandler::RegisterHandler(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
RegisterHandler::RegisterHandler(DebuggerEngine *engine)
|
||||
: m_engine(engine)
|
||||
{
|
||||
setNumberBase(16);
|
||||
}
|
||||
@@ -67,8 +70,19 @@ int RegisterHandler::columnCount(const QModelIndex &parent) const
|
||||
|
||||
QVariant RegisterHandler::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == RegisterNumberBaseRole)
|
||||
return m_base;
|
||||
switch (role) {
|
||||
case EngineStateRole:
|
||||
return m_engine->state();
|
||||
|
||||
case EngineCapabilitiesRole:
|
||||
return m_engine->debuggerCapabilities();
|
||||
|
||||
case EngineActionsEnabledRole:
|
||||
return m_engine->debuggerActionsEnabled();
|
||||
|
||||
case RegisterNumberBaseRole:
|
||||
return m_base;
|
||||
}
|
||||
|
||||
if (!index.isValid() || index.row() >= m_registers.size())
|
||||
return QVariant();
|
||||
@@ -136,6 +150,26 @@ Qt::ItemFlags RegisterHandler::flags(const QModelIndex &idx) const
|
||||
return notEditable;
|
||||
}
|
||||
|
||||
bool RegisterHandler::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
switch (role) {
|
||||
case RequestSetRegisterRole:
|
||||
m_engine->setRegisterValue(index.row(), value.toString());
|
||||
return true;
|
||||
|
||||
case RequestReloadRegistersRole:
|
||||
m_engine->reloadRegisters();
|
||||
return true;
|
||||
|
||||
case RequestShowMemoryRole:
|
||||
(void) new MemoryViewAgent(m_engine, value.toString());
|
||||
return true;
|
||||
|
||||
default:
|
||||
return QAbstractTableModel::setData(index, value, role);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterHandler::removeAll()
|
||||
{
|
||||
m_registers.clear();
|
||||
|
||||
Reference in New Issue
Block a user