diff options
author | hjk <qtc-committer@nokia.com> | 2010-06-16 11:08:54 +0200 |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2010-06-22 10:59:57 +0200 |
commit | 6a6cba5518fb88345c53a7cd645f6cb6466a84e3 (patch) | |
tree | 88d7875ae5bd6f70a3654b11f80c6ed9b9685369 /src/plugins/debugger/stackhandler.cpp | |
parent | 4cc244469a4c7d9fb2b3e598727c6d8a2e7c1813 (diff) | |
download | qt-creator-6a6cba5518fb88345c53a7cd645f6cb6466a84e3.tar.gz |
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).
Diffstat (limited to 'src/plugins/debugger/stackhandler.cpp')
-rw-r--r-- | src/plugins/debugger/stackhandler.cpp | 77 |
1 files changed, 60 insertions, 17 deletions
diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index bdfc7b5c11..3cb1787ead 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -30,6 +30,8 @@ #include "stackhandler.h" #include "debuggeractions.h" +#include "debuggeragents.h" +#include "debuggerengine.h" #include <utils/qtcassert.h> #include <utils/savedaction.h> @@ -37,29 +39,34 @@ #include <QtCore/QAbstractTableModel> #include <QtCore/QDebug> #include <QtCore/QFileInfo> -#include <QtCore/QDir> + namespace Debugger { namespace Internal { - //////////////////////////////////////////////////////////////////////// // // StackHandler // //////////////////////////////////////////////////////////////////////// -StackHandler::StackHandler(QObject *parent) - : QAbstractTableModel(parent), - m_positionIcon(QIcon(":/debugger/images/location_16.png")), +StackHandler::StackHandler(DebuggerEngine *engine) + : m_positionIcon(QIcon(":/debugger/images/location_16.png")), m_emptyIcon(QIcon(":/debugger/images/debugger_empty_14.png")) { + m_engine = engine; + m_disassemblerViewAgent = new DisassemblerViewAgent(engine); m_currentIndex = 0; m_canExpand = false; connect(theDebuggerAction(OperateByInstruction), SIGNAL(triggered()), this, SLOT(resetModel())); } +StackHandler::~StackHandler() +{ + //delete m_disassemblerViewAgent; +} + int StackHandler::rowCount(const QModelIndex &parent) const { // Since the stack is not a tree, row count is 0 for any valid parent @@ -73,6 +80,17 @@ int StackHandler::columnCount(const QModelIndex &parent) const QVariant StackHandler::data(const QModelIndex &index, int role) const { + switch (role) { + case EngineStateRole: + return m_engine->state(); + + case EngineCapabilitiesRole: + return m_engine->debuggerCapabilities(); + + case EngineActionsEnabledRole: + return m_engine->debuggerActionsEnabled(); + } + if (!index.isValid() || index.row() >= m_stackFrames.size() + m_canExpand) return QVariant(); @@ -104,25 +122,51 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const return QVariant(); } - if (role == Qt::ToolTipRole) { - //: Tooltip for variable - return frame.toToolTip(); - } - if (role == Qt::DecorationRole && index.column() == 0) { // Return icon that indicates whether this is the active stack frame return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon; } - if (role == Qt::UserRole) - return QVariant::fromValue(frame); + if (role == StackFrameAddressRole) + return frame.address; + + //: Tooltip for variable + if (role == Qt::ToolTipRole) + return frame.toToolTip(); return QVariant(); } -QVariant StackHandler::headerData(int section, Qt::Orientation orientation, int role) const + +bool StackHandler::setData(const QModelIndex &index, const QVariant &value, int role) { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + switch (role) { + case RequestActivateFrameRole: + m_engine->activateFrame(value.toInt()); + return true; + + case RequestShowMemoryRole: + (void) new MemoryViewAgent(m_engine, value.toString()); + return true; + + case RequestShowDisassemblerRole: { + const StackFrame &frame = m_stackFrames.at(value.toInt()); + m_disassemblerViewAgent->setFrame(frame); + return true; + } + + case RequestReloadFullStackRole: + m_engine->reloadFullStack(); + return true; + + default: + return QAbstractTableModel::setData(index, value, role); + } +} + +QVariant StackHandler::headerData(int section, Qt::Orientation orient, int role) const +{ + if (orient == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case 0: return tr("Level"); case 1: return tr("Function"); @@ -176,7 +220,7 @@ void StackHandler::removeAll() reset(); } -void StackHandler::setFrames(const QList<StackFrame> &frames, bool canExpand) +void StackHandler::setFrames(const StackFrames &frames, bool canExpand) { m_canExpand = canExpand; m_stackFrames = frames; @@ -185,7 +229,7 @@ void StackHandler::setFrames(const QList<StackFrame> &frames, bool canExpand) reset(); } -QList<StackFrame> StackHandler::frames() const +StackFrames StackHandler::frames() const { return m_stackFrames; } @@ -198,6 +242,5 @@ bool StackHandler::isDebuggingDebuggingHelpers() const return false; } - } // namespace Internal } // namespace Debugger |