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:
hjk
2010-06-16 11:08:54 +02:00
parent 4cc244469a
commit 6a6cba5518
93 changed files with 5258 additions and 4846 deletions

View File

@@ -28,8 +28,7 @@
**************************************************************************/
#include "moduleshandler.h"
#include "idebuggerengine.h"
#include "debuggerrunner.h"
#include "debuggerengine.h"
#include <utils/qtcassert.h>
@@ -55,7 +54,7 @@ namespace Internal {
class ModulesModel : public QAbstractItemModel
{
public:
explicit ModulesModel(ModulesHandler *parent, DebuggerRunControl *runControl);
explicit ModulesModel(ModulesHandler *parent, DebuggerEngine *engine);
// QAbstractItemModel
int columnCount(const QModelIndex &parent) const
@@ -75,21 +74,19 @@ public:
void setModules(const Modules &m);
const Modules &modules() const { return m_modules; }
IDebuggerEngine *engine() { return m_runControl->engine(); }
const IDebuggerEngine *engine() const { return m_runControl->engine(); }
private:
int indexOfModule(const QString &name) const;
DebuggerRunControl *m_runControl;
DebuggerEngine *m_engine;
const QVariant m_yes;
const QVariant m_no;
Modules m_modules;
};
ModulesModel::ModulesModel(ModulesHandler *parent, DebuggerRunControl *runControl)
ModulesModel::ModulesModel(ModulesHandler *parent, DebuggerEngine *engine)
: QAbstractItemModel(parent),
m_runControl(runControl), m_yes(tr("yes")), m_no(tr("no"))
m_engine(engine), m_yes(tr("yes")), m_no(tr("no"))
{}
QVariant ModulesModel::headerData(int section,
@@ -110,11 +107,11 @@ QVariant ModulesModel::headerData(int section,
QVariant ModulesModel::data(const QModelIndex &index, int role) const
{
if (role == EngineCapabilityRole)
return engine()->debuggerCapabilities();
if (role == EngineCapabilitiesRole)
return m_engine->debuggerCapabilities();
if (role == EngineActionsEnabledRole)
return engine()->debuggerActionsEnabled();
return m_engine->debuggerActionsEnabled();
int row = index.row();
if (row < 0 || row >= m_modules.size())
@@ -152,19 +149,26 @@ QVariant ModulesModel::data(const QModelIndex &index, int role) const
bool ModulesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (role == RequestReloadModulesRole) {
engine()->reloadModules();
return true;
Q_UNUSED(index);
switch (role) {
case RequestReloadModulesRole:
m_engine->reloadModules();
return true;
case RequestModuleSymbolsRole:
m_engine->loadSymbols(value.toString());
return true;
case RequestAllSymbolsRole:
m_engine->loadAllSymbols();
return true;
case RequestOpenFileRole:
m_engine->openFile(value.toString());
return true;
}
if (role == RequestModuleSymbolsRole) {
engine()->loadSymbols(value.toString());
return true;
}
if (role == RequestAllSymbolsRole) {
engine()->loadAllSymbols();
return true;
}
return QAbstractItemModel::setData(index, value, role);
return false;
}
void ModulesModel::addModule(const Module &m)
@@ -213,9 +217,9 @@ void ModulesModel::removeModule(const QString &moduleName)
//
//////////////////////////////////////////////////////////////////
ModulesHandler::ModulesHandler(DebuggerRunControl *runControl)
ModulesHandler::ModulesHandler(DebuggerEngine *engine)
{
m_model = new ModulesModel(this, runControl);
m_model = new ModulesModel(this, engine);
m_proxyModel = new QSortFilterProxyModel(this);
m_proxyModel->setSourceModel(m_model);
}