trunk/src/osd/modules/debugger/debugqt.c
| r242470 | r242471 | |
| 25 | 25 | #include "qt/debugqtdasmwindow.h" |
| 26 | 26 | #include "qt/debugqtmemorywindow.h" |
| 27 | 27 | #include "qt/debugqtbreakpointswindow.h" |
| 28 | #include "qt/debugqtdeviceswindow.h" |
| 28 | 29 | #include "debugqt.h" |
| 29 | 30 | |
| 30 | 31 | |
| r242470 | r242471 | |
| 90 | 91 | case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(new DasmWindowQtConfig()); break; |
| 91 | 92 | case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(new LogWindowQtConfig()); break; |
| 92 | 93 | case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); break; |
| 94 | case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(new DevicesWindowQtConfig()); break; |
| 93 | 95 | default: continue; |
| 94 | 96 | } |
| 95 | 97 | xmlConfigurations.back()->recoverFromXmlNode(wnode); |
| r242470 | r242471 | |
| 145 | 147 | xmlConfigurations.push_back(new LogWindowQtConfig()); |
| 146 | 148 | else if (dynamic_cast<BreakpointsWindow*>(widget)) |
| 147 | 149 | xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); |
| 150 | else if (dynamic_cast<DevicesWindow*>(widget)) |
| 151 | xmlConfigurations.push_back(new DevicesWindowQtConfig()); |
| 148 | 152 | |
| 149 | 153 | xmlConfigurations.back()->buildFromQWidget(widget); |
| 150 | 154 | } |
| r242470 | r242471 | |
| 187 | 191 | foo = new LogWindow(&machine); break; |
| 188 | 192 | case WindowQtConfig::WIN_TYPE_BREAK_POINTS: |
| 189 | 193 | foo = new BreakpointsWindow(&machine); break; |
| 194 | case WindowQtConfig::WIN_TYPE_DEVICES: |
| 195 | foo = new DevicesWindow(&machine); break; |
| 190 | 196 | default: break; |
| 191 | 197 | } |
| 192 | 198 | config->applyToQWidget(foo); |
trunk/src/osd/modules/debugger/qt/debugqtdeviceswindow.c
| r0 | r242471 | |
| 1 | #define NO_MEM_TRACKING |
| 2 | |
| 3 | #include "debugqtdeviceswindow.h" |
| 4 | |
| 5 | DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent) |
| 6 | { |
| 7 | m_machine = machine; |
| 8 | } |
| 9 | |
| 10 | DevicesWindowModel::~DevicesWindowModel() |
| 11 | { |
| 12 | } |
| 13 | |
| 14 | QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const |
| 15 | { |
| 16 | if(!index.isValid() || role != Qt::DisplayRole) |
| 17 | return QVariant(); |
| 18 | |
| 19 | device_t *dev = static_cast<device_t *>(index.internalPointer()); |
| 20 | switch(index.column()) { |
| 21 | case 0: return QString(dev->basetag()); break; |
| 22 | case 1: return QString(dev->name()); break; |
| 23 | } |
| 24 | |
| 25 | return QVariant(); |
| 26 | } |
| 27 | |
| 28 | Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const |
| 29 | { |
| 30 | if(!index.isValid()) |
| 31 | return 0; |
| 32 | |
| 33 | return QAbstractItemModel::flags(index); |
| 34 | } |
| 35 | |
| 36 | QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 37 | { |
| 38 | if(role != Qt::DisplayRole || section < 0 || section >= 2) |
| 39 | return QVariant(); |
| 40 | return QString(section ? "Name" : "Tag"); |
| 41 | } |
| 42 | |
| 43 | QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const |
| 44 | { |
| 45 | if(!hasIndex(row, column, parent)) |
| 46 | return QModelIndex(); |
| 47 | |
| 48 | device_t *target = NULL; |
| 49 | |
| 50 | if(!parent.isValid()) { |
| 51 | if(row == 0) |
| 52 | target = &m_machine->root_device(); |
| 53 | |
| 54 | } else { |
| 55 | device_t *dparent = static_cast<device_t *>(parent.internalPointer()); |
| 56 | int count = row; |
| 57 | for(target = dparent->first_subdevice(); count && target; target = target->next()) |
| 58 | count--; |
| 59 | } |
| 60 | |
| 61 | if(target) |
| 62 | return createIndex(row, column, target); |
| 63 | |
| 64 | return QModelIndex(); |
| 65 | } |
| 66 | |
| 67 | QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const |
| 68 | { |
| 69 | if(!index.isValid()) |
| 70 | return QModelIndex(); |
| 71 | |
| 72 | device_t *dchild = static_cast<device_t *>(index.internalPointer()); |
| 73 | device_t *dparent = dchild->owner(); |
| 74 | |
| 75 | if(!dparent) |
| 76 | return QModelIndex(); |
| 77 | |
| 78 | device_t *dpp = dparent->owner(); |
| 79 | int row = 0; |
| 80 | if(dpp) { |
| 81 | for(device_t *child = dpp->first_subdevice(); child && child != dparent; child = child->next()) |
| 82 | row++; |
| 83 | } |
| 84 | return createIndex(row, 0, dparent); |
| 85 | } |
| 86 | |
| 87 | int DevicesWindowModel::rowCount(const QModelIndex &parent) const |
| 88 | { |
| 89 | if(!parent.isValid()) |
| 90 | return 1; |
| 91 | |
| 92 | device_t *dparent = static_cast<device_t *>(parent.internalPointer()); |
| 93 | int count = 0; |
| 94 | for(device_t *child = dparent->first_subdevice(); child; child = child->next()) |
| 95 | count++; |
| 96 | |
| 97 | return count; |
| 98 | } |
| 99 | |
| 100 | int DevicesWindowModel::columnCount(const QModelIndex &parent) const |
| 101 | { |
| 102 | return 2; |
| 103 | } |
| 104 | |
| 105 | |
| 106 | |
| 107 | DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : |
| 108 | WindowQt(machine, NULL), |
| 109 | m_devices_model(machine) |
| 110 | { |
| 111 | setWindowTitle("Debug: All Devices"); |
| 112 | |
| 113 | if (parent != NULL) |
| 114 | { |
| 115 | QPoint parentPos = parent->pos(); |
| 116 | setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); |
| 117 | } |
| 118 | |
| 119 | // |
| 120 | // The tree widget |
| 121 | // |
| 122 | m_devices_view = new QTreeView(this); |
| 123 | m_devices_view->setModel(&m_devices_model); |
| 124 | m_devices_view->expandAll(); |
| 125 | m_devices_view->resizeColumnToContents(0); |
| 126 | setCentralWidget(m_devices_view); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | DevicesWindow::~DevicesWindow() |
| 131 | { |
| 132 | } |
| 133 | |
| 134 | |
| 135 | |
| 136 | //========================================================================= |
| 137 | // DevicesWindowQtConfig |
| 138 | //========================================================================= |
| 139 | void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget) |
| 140 | { |
| 141 | WindowQtConfig::buildFromQWidget(widget); |
| 142 | // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | void DevicesWindowQtConfig::applyToQWidget(QWidget* widget) |
| 147 | { |
| 148 | WindowQtConfig::applyToQWidget(widget); |
| 149 | // DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const |
| 154 | { |
| 155 | WindowQtConfig::addToXmlDataNode(node); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node) |
| 160 | { |
| 161 | WindowQtConfig::recoverFromXmlNode(node); |
| 162 | } |
trunk/src/osd/modules/debugger/qt/debugqtdeviceswindow.h
| r0 | r242471 | |
| 1 | #ifndef __DEBUG_QT_DEVICES_WINDOW_H__ |
| 2 | #define __DEBUG_QT_DEVICES_WINDOW_H__ |
| 3 | |
| 4 | #include <QtGui/QtGui> |
| 5 | |
| 6 | #include "debugqtwindow.h" |
| 7 | |
| 8 | |
| 9 | //============================================================ |
| 10 | // The model for the treeview |
| 11 | //============================================================ |
| 12 | |
| 13 | class DevicesWindowModel : public QAbstractItemModel |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | |
| 17 | public: |
| 18 | explicit DevicesWindowModel(running_machine *machine, QObject *parent = 0); |
| 19 | ~DevicesWindowModel(); |
| 20 | |
| 21 | QVariant data(const QModelIndex &index, int role) const; |
| 22 | Qt::ItemFlags flags(const QModelIndex &index) const; |
| 23 | QVariant headerData(int section, Qt::Orientation orientation, |
| 24 | int role = Qt::DisplayRole) const; |
| 25 | QModelIndex index(int row, int column, |
| 26 | const QModelIndex &parent = QModelIndex()) const; |
| 27 | QModelIndex parent(const QModelIndex &index) const; |
| 28 | int rowCount(const QModelIndex &parent = QModelIndex()) const; |
| 29 | int columnCount(const QModelIndex &parent = QModelIndex()) const; |
| 30 | |
| 31 | private: |
| 32 | running_machine *m_machine; |
| 33 | }; |
| 34 | |
| 35 | //============================================================ |
| 36 | // The Devices Window. |
| 37 | //============================================================ |
| 38 | class DevicesWindow : public WindowQt |
| 39 | { |
| 40 | Q_OBJECT |
| 41 | |
| 42 | public: |
| 43 | DevicesWindow(running_machine* machine, QWidget* parent=NULL); |
| 44 | virtual ~DevicesWindow(); |
| 45 | |
| 46 | private: |
| 47 | QTreeView *m_devices_view; |
| 48 | DevicesWindowModel m_devices_model; |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | //========================================================================= |
| 55 | // A way to store the configuration of a window long enough to read/write. |
| 56 | //========================================================================= |
| 57 | class DevicesWindowQtConfig : public WindowQtConfig |
| 58 | { |
| 59 | public: |
| 60 | DevicesWindowQtConfig() : |
| 61 | WindowQtConfig(WIN_TYPE_DEVICES) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | ~DevicesWindowQtConfig() {} |
| 66 | |
| 67 | void buildFromQWidget(QWidget* widget); |
| 68 | void applyToQWidget(QWidget* widget); |
| 69 | void addToXmlDataNode(xml_data_node* node) const; |
| 70 | void recoverFromXmlNode(xml_data_node* node); |
| 71 | }; |
| 72 | |
| 73 | |
| 74 | #endif |
trunk/src/osd/modules/debugger/qt/debugqtwindow.c
| r242470 | r242471 | |
| 5 | 5 | #include "debugqtdasmwindow.h" |
| 6 | 6 | #include "debugqtmemorywindow.h" |
| 7 | 7 | #include "debugqtbreakpointswindow.h" |
| 8 | #include "debugqtdeviceswindow.h" |
| 8 | 9 | |
| 9 | 10 | bool WindowQt::s_refreshAll = false; |
| 10 | 11 | bool WindowQt::s_hideAll = false; |
| r242470 | r242471 | |
| 38 | 39 | debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B")); |
| 39 | 40 | connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints())); |
| 40 | 41 | |
| 42 | QAction* debugActOpenDevices = new QAction("New D&evices Window", this); |
| 43 | debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D")); |
| 44 | connect(debugActOpenDevices, SIGNAL(triggered()), this, SLOT(debugActOpenDevices())); |
| 45 | |
| 41 | 46 | QAction* dbgActRun = new QAction("Run", this); |
| 42 | 47 | dbgActRun->setShortcut(Qt::Key_F5); |
| 43 | 48 | connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun())); |
| r242470 | r242471 | |
| 92 | 97 | debugMenu->addAction(debugActOpenDasm); |
| 93 | 98 | debugMenu->addAction(debugActOpenLog); |
| 94 | 99 | debugMenu->addAction(debugActOpenPoints); |
| 100 | debugMenu->addAction(debugActOpenDevices); |
| 95 | 101 | debugMenu->addSeparator(); |
| 96 | 102 | debugMenu->addAction(dbgActRun); |
| 97 | 103 | debugMenu->addAction(dbgActRunAndHide); |
| r242470 | r242471 | |
| 155 | 161 | } |
| 156 | 162 | |
| 157 | 163 | |
| 164 | void WindowQt::debugActOpenDevices() |
| 165 | { |
| 166 | DevicesWindow* foo = new DevicesWindow(m_machine, this); |
| 167 | // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon |
| 168 | // foo->setWindowFlags(Qt::Dialog); |
| 169 | // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); |
| 170 | foo->show(); |
| 171 | } |
| 172 | |
| 173 | |
| 158 | 174 | void WindowQt::debugActRun() |
| 159 | 175 | { |
| 160 | 176 | debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); |
trunk/src/osd/sdl/sdl.mak
| r242470 | r242471 | |
| 679 | 679 | $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.o \ |
| 680 | 680 | $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.o \ |
| 681 | 681 | $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.o \ |
| 682 | $(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.o \ |
| 682 | 683 | $(OSDOBJ)/modules/debugger/qt/debugqtview.moc.o \ |
| 683 | 684 | $(OSDOBJ)/modules/debugger/qt/debugqtwindow.moc.o \ |
| 684 | 685 | $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.moc.o \ |
| 685 | 686 | $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.moc.o \ |
| 686 | 687 | $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.moc.o \ |
| 687 | 688 | $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.moc.o \ |
| 688 | | $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o |
| 689 | $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o \ |
| 690 | $(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.moc.o |
| 689 | 691 | endif |
| 690 | 692 | |
| 691 | 693 | ifeq ($(NO_DEBUGGER),1) |