mirror of
https://github.com/holub/mame
synced 2025-04-25 17:56:43 +03:00
qt/debug: Device tree view. Looks cool with mu100 or lindbios [O. Galibert]
This commit is contained in:
parent
3ef1938bef
commit
09ec9d6006
@ -25,6 +25,7 @@
|
||||
#include "qt/debugqtdasmwindow.h"
|
||||
#include "qt/debugqtmemorywindow.h"
|
||||
#include "qt/debugqtbreakpointswindow.h"
|
||||
#include "qt/debugqtdeviceswindow.h"
|
||||
#include "debugqt.h"
|
||||
|
||||
|
||||
@ -90,6 +91,7 @@ static void xml_configuration_load(running_machine &machine, int config_type, xm
|
||||
case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(new DasmWindowQtConfig()); break;
|
||||
case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(new LogWindowQtConfig()); break;
|
||||
case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); break;
|
||||
case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(new DevicesWindowQtConfig()); break;
|
||||
default: continue;
|
||||
}
|
||||
xmlConfigurations.back()->recoverFromXmlNode(wnode);
|
||||
@ -145,6 +147,8 @@ static void gather_save_configurations()
|
||||
xmlConfigurations.push_back(new LogWindowQtConfig());
|
||||
else if (dynamic_cast<BreakpointsWindow*>(widget))
|
||||
xmlConfigurations.push_back(new BreakpointsWindowQtConfig());
|
||||
else if (dynamic_cast<DevicesWindow*>(widget))
|
||||
xmlConfigurations.push_back(new DevicesWindowQtConfig());
|
||||
|
||||
xmlConfigurations.back()->buildFromQWidget(widget);
|
||||
}
|
||||
@ -187,6 +191,8 @@ static void setup_additional_startup_windows(running_machine& machine, std::vect
|
||||
foo = new LogWindow(&machine); break;
|
||||
case WindowQtConfig::WIN_TYPE_BREAK_POINTS:
|
||||
foo = new BreakpointsWindow(&machine); break;
|
||||
case WindowQtConfig::WIN_TYPE_DEVICES:
|
||||
foo = new DevicesWindow(&machine); break;
|
||||
default: break;
|
||||
}
|
||||
config->applyToQWidget(foo);
|
||||
|
162
src/osd/modules/debugger/qt/debugqtdeviceswindow.c
Normal file
162
src/osd/modules/debugger/qt/debugqtdeviceswindow.c
Normal file
@ -0,0 +1,162 @@
|
||||
#define NO_MEM_TRACKING
|
||||
|
||||
#include "debugqtdeviceswindow.h"
|
||||
|
||||
DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent)
|
||||
{
|
||||
m_machine = machine;
|
||||
}
|
||||
|
||||
DevicesWindowModel::~DevicesWindowModel()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(!index.isValid() || role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
device_t *dev = static_cast<device_t *>(index.internalPointer());
|
||||
switch(index.column()) {
|
||||
case 0: return QString(dev->basetag()); break;
|
||||
case 1: return QString(dev->name()); break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
return 0;
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(role != Qt::DisplayRole || section < 0 || section >= 2)
|
||||
return QVariant();
|
||||
return QString(section ? "Name" : "Tag");
|
||||
}
|
||||
|
||||
QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if(!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
device_t *target = NULL;
|
||||
|
||||
if(!parent.isValid()) {
|
||||
if(row == 0)
|
||||
target = &m_machine->root_device();
|
||||
|
||||
} else {
|
||||
device_t *dparent = static_cast<device_t *>(parent.internalPointer());
|
||||
int count = row;
|
||||
for(target = dparent->first_subdevice(); count && target; target = target->next())
|
||||
count--;
|
||||
}
|
||||
|
||||
if(target)
|
||||
return createIndex(row, column, target);
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if(!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
device_t *dchild = static_cast<device_t *>(index.internalPointer());
|
||||
device_t *dparent = dchild->owner();
|
||||
|
||||
if(!dparent)
|
||||
return QModelIndex();
|
||||
|
||||
device_t *dpp = dparent->owner();
|
||||
int row = 0;
|
||||
if(dpp) {
|
||||
for(device_t *child = dpp->first_subdevice(); child && child != dparent; child = child->next())
|
||||
row++;
|
||||
}
|
||||
return createIndex(row, 0, dparent);
|
||||
}
|
||||
|
||||
int DevicesWindowModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if(!parent.isValid())
|
||||
return 1;
|
||||
|
||||
device_t *dparent = static_cast<device_t *>(parent.internalPointer());
|
||||
int count = 0;
|
||||
for(device_t *child = dparent->first_subdevice(); child; child = child->next())
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int DevicesWindowModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) :
|
||||
WindowQt(machine, NULL),
|
||||
m_devices_model(machine)
|
||||
{
|
||||
setWindowTitle("Debug: All Devices");
|
||||
|
||||
if (parent != NULL)
|
||||
{
|
||||
QPoint parentPos = parent->pos();
|
||||
setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400);
|
||||
}
|
||||
|
||||
//
|
||||
// The tree widget
|
||||
//
|
||||
m_devices_view = new QTreeView(this);
|
||||
m_devices_view->setModel(&m_devices_model);
|
||||
m_devices_view->expandAll();
|
||||
m_devices_view->resizeColumnToContents(0);
|
||||
setCentralWidget(m_devices_view);
|
||||
}
|
||||
|
||||
|
||||
DevicesWindow::~DevicesWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// DevicesWindowQtConfig
|
||||
//=========================================================================
|
||||
void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget)
|
||||
{
|
||||
WindowQtConfig::buildFromQWidget(widget);
|
||||
// DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget);
|
||||
}
|
||||
|
||||
|
||||
void DevicesWindowQtConfig::applyToQWidget(QWidget* widget)
|
||||
{
|
||||
WindowQtConfig::applyToQWidget(widget);
|
||||
// DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget);
|
||||
}
|
||||
|
||||
|
||||
void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const
|
||||
{
|
||||
WindowQtConfig::addToXmlDataNode(node);
|
||||
}
|
||||
|
||||
|
||||
void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node)
|
||||
{
|
||||
WindowQtConfig::recoverFromXmlNode(node);
|
||||
}
|
74
src/osd/modules/debugger/qt/debugqtdeviceswindow.h
Normal file
74
src/osd/modules/debugger/qt/debugqtdeviceswindow.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef __DEBUG_QT_DEVICES_WINDOW_H__
|
||||
#define __DEBUG_QT_DEVICES_WINDOW_H__
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
#include "debugqtwindow.h"
|
||||
|
||||
|
||||
//============================================================
|
||||
// The model for the treeview
|
||||
//============================================================
|
||||
|
||||
class DevicesWindowModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DevicesWindowModel(running_machine *machine, QObject *parent = 0);
|
||||
~DevicesWindowModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
private:
|
||||
running_machine *m_machine;
|
||||
};
|
||||
|
||||
//============================================================
|
||||
// The Devices Window.
|
||||
//============================================================
|
||||
class DevicesWindow : public WindowQt
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DevicesWindow(running_machine* machine, QWidget* parent=NULL);
|
||||
virtual ~DevicesWindow();
|
||||
|
||||
private:
|
||||
QTreeView *m_devices_view;
|
||||
DevicesWindowModel m_devices_model;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// A way to store the configuration of a window long enough to read/write.
|
||||
//=========================================================================
|
||||
class DevicesWindowQtConfig : public WindowQtConfig
|
||||
{
|
||||
public:
|
||||
DevicesWindowQtConfig() :
|
||||
WindowQtConfig(WIN_TYPE_DEVICES)
|
||||
{
|
||||
}
|
||||
|
||||
~DevicesWindowQtConfig() {}
|
||||
|
||||
void buildFromQWidget(QWidget* widget);
|
||||
void applyToQWidget(QWidget* widget);
|
||||
void addToXmlDataNode(xml_data_node* node) const;
|
||||
void recoverFromXmlNode(xml_data_node* node);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -5,6 +5,7 @@
|
||||
#include "debugqtdasmwindow.h"
|
||||
#include "debugqtmemorywindow.h"
|
||||
#include "debugqtbreakpointswindow.h"
|
||||
#include "debugqtdeviceswindow.h"
|
||||
|
||||
bool WindowQt::s_refreshAll = false;
|
||||
bool WindowQt::s_hideAll = false;
|
||||
@ -38,6 +39,10 @@ WindowQt::WindowQt(running_machine* machine, QWidget* parent) :
|
||||
debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B"));
|
||||
connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints()));
|
||||
|
||||
QAction* debugActOpenDevices = new QAction("New D&evices Window", this);
|
||||
debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D"));
|
||||
connect(debugActOpenDevices, SIGNAL(triggered()), this, SLOT(debugActOpenDevices()));
|
||||
|
||||
QAction* dbgActRun = new QAction("Run", this);
|
||||
dbgActRun->setShortcut(Qt::Key_F5);
|
||||
connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun()));
|
||||
@ -92,6 +97,7 @@ WindowQt::WindowQt(running_machine* machine, QWidget* parent) :
|
||||
debugMenu->addAction(debugActOpenDasm);
|
||||
debugMenu->addAction(debugActOpenLog);
|
||||
debugMenu->addAction(debugActOpenPoints);
|
||||
debugMenu->addAction(debugActOpenDevices);
|
||||
debugMenu->addSeparator();
|
||||
debugMenu->addAction(dbgActRun);
|
||||
debugMenu->addAction(dbgActRunAndHide);
|
||||
@ -155,6 +161,16 @@ void WindowQt::debugActOpenPoints()
|
||||
}
|
||||
|
||||
|
||||
void WindowQt::debugActOpenDevices()
|
||||
{
|
||||
DevicesWindow* foo = new DevicesWindow(m_machine, this);
|
||||
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
|
||||
// foo->setWindowFlags(Qt::Dialog);
|
||||
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
|
||||
foo->show();
|
||||
}
|
||||
|
||||
|
||||
void WindowQt::debugActRun()
|
||||
{
|
||||
debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
|
||||
|
@ -34,6 +34,7 @@ protected slots:
|
||||
void debugActOpenDasm();
|
||||
void debugActOpenLog();
|
||||
void debugActOpenPoints();
|
||||
void debugActOpenDevices();
|
||||
void debugActRun();
|
||||
void debugActRunAndHide();
|
||||
void debugActRunToNextCpu();
|
||||
@ -64,12 +65,14 @@ class WindowQtConfig
|
||||
public:
|
||||
enum WindowType
|
||||
{
|
||||
WIN_TYPE_MAIN = 0x01,
|
||||
WIN_TYPE_MEMORY = 0x02,
|
||||
WIN_TYPE_DASM = 0x04,
|
||||
WIN_TYPE_LOG = 0x08,
|
||||
WIN_TYPE_BREAK_POINTS = 0x10,
|
||||
WIN_TYPE_UNKNOWN = 0x20
|
||||
WIN_TYPE_UNKNOWN,
|
||||
WIN_TYPE_MAIN,
|
||||
WIN_TYPE_MEMORY,
|
||||
WIN_TYPE_DASM,
|
||||
WIN_TYPE_LOG,
|
||||
WIN_TYPE_BREAK_POINTS,
|
||||
WIN_TYPE_DEVICES,
|
||||
WIN_TYPE_DEVICE_INFORMATION
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -679,13 +679,15 @@ DEBUGOBJS = \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtview.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtwindow.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o \
|
||||
$(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.moc.o
|
||||
endif
|
||||
|
||||
ifeq ($(NO_DEBUGGER),1)
|
||||
|
Loading…
Reference in New Issue
Block a user