Previous 199869 Revisions Next

r33959 Friday 19th December, 2014 at 17:26:46 UTC by Olivier Galibert
qt/debug: Device tree view.  Looks cool with mu100 or lindbios [O. Galibert]
[src/osd/modules/debugger]debugqt.c
[src/osd/modules/debugger/qt]debugqtdeviceswindow.c* debugqtdeviceswindow.h* debugqtwindow.c debugqtwindow.h
[src/osd/sdl]sdl.mak

trunk/src/osd/modules/debugger/debugqt.c
r242470r242471
2525#include "qt/debugqtdasmwindow.h"
2626#include "qt/debugqtmemorywindow.h"
2727#include "qt/debugqtbreakpointswindow.h"
28#include "qt/debugqtdeviceswindow.h"
2829#include "debugqt.h"
2930
3031
r242470r242471
9091         case WindowQtConfig::WIN_TYPE_DASM:         xmlConfigurations.push_back(new DasmWindowQtConfig()); break;
9192         case WindowQtConfig::WIN_TYPE_LOG:          xmlConfigurations.push_back(new LogWindowQtConfig()); break;
9293         case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); break;
94         case WindowQtConfig::WIN_TYPE_DEVICES:      xmlConfigurations.push_back(new DevicesWindowQtConfig()); break;
9395         default: continue;
9496      }
9597      xmlConfigurations.back()->recoverFromXmlNode(wnode);
r242470r242471
145147         xmlConfigurations.push_back(new LogWindowQtConfig());
146148      else if (dynamic_cast<BreakpointsWindow*>(widget))
147149         xmlConfigurations.push_back(new BreakpointsWindowQtConfig());
150      else if (dynamic_cast<DevicesWindow*>(widget))
151         xmlConfigurations.push_back(new DevicesWindowQtConfig());
148152
149153      xmlConfigurations.back()->buildFromQWidget(widget);
150154   }
r242470r242471
187191            foo = new LogWindow(&machine); break;
188192         case WindowQtConfig::WIN_TYPE_BREAK_POINTS:
189193            foo = new BreakpointsWindow(&machine); break;
194         case WindowQtConfig::WIN_TYPE_DEVICES:
195            foo = new DevicesWindow(&machine); break;
190196         default: break;
191197      }
192198      config->applyToQWidget(foo);
trunk/src/osd/modules/debugger/qt/debugqtdeviceswindow.c
r0r242471
1#define NO_MEM_TRACKING
2
3#include "debugqtdeviceswindow.h"
4
5DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent)
6{
7   m_machine = machine;
8}
9
10DevicesWindowModel::~DevicesWindowModel()
11{
12}
13
14QVariant 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
28Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const
29{
30   if(!index.isValid())
31      return 0;
32
33   return QAbstractItemModel::flags(index);
34}
35
36QVariant 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
43QModelIndex 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
67QModelIndex 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
87int 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
100int DevicesWindowModel::columnCount(const QModelIndex &parent) const
101{
102   return 2;
103}
104
105
106
107DevicesWindow::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
130DevicesWindow::~DevicesWindow()
131{
132}
133
134
135
136//=========================================================================
137//  DevicesWindowQtConfig
138//=========================================================================
139void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget)
140{
141   WindowQtConfig::buildFromQWidget(widget);
142   //   DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget);
143}
144
145
146void DevicesWindowQtConfig::applyToQWidget(QWidget* widget)
147{
148   WindowQtConfig::applyToQWidget(widget);
149   //   DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget);
150}
151
152
153void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const
154{
155   WindowQtConfig::addToXmlDataNode(node);
156}
157
158
159void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node)
160{
161   WindowQtConfig::recoverFromXmlNode(node);
162}
trunk/src/osd/modules/debugger/qt/debugqtdeviceswindow.h
r0r242471
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
13class DevicesWindowModel : public QAbstractItemModel
14{
15   Q_OBJECT
16
17public:
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   
31private:
32   running_machine *m_machine;
33};
34
35//============================================================
36//  The Devices Window.
37//============================================================
38class DevicesWindow : public WindowQt
39{
40   Q_OBJECT
41
42public:
43   DevicesWindow(running_machine* machine, QWidget* parent=NULL);
44   virtual ~DevicesWindow();
45
46private:
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//=========================================================================
57class DevicesWindowQtConfig : public WindowQtConfig
58{
59public:
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
r242470r242471
55#include "debugqtdasmwindow.h"
66#include "debugqtmemorywindow.h"
77#include "debugqtbreakpointswindow.h"
8#include "debugqtdeviceswindow.h"
89
910bool WindowQt::s_refreshAll = false;
1011bool WindowQt::s_hideAll = false;
r242470r242471
3839   debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B"));
3940   connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints()));
4041
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
4146   QAction* dbgActRun = new QAction("Run", this);
4247   dbgActRun->setShortcut(Qt::Key_F5);
4348   connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun()));
r242470r242471
9297   debugMenu->addAction(debugActOpenDasm);
9398   debugMenu->addAction(debugActOpenLog);
9499   debugMenu->addAction(debugActOpenPoints);
100   debugMenu->addAction(debugActOpenDevices);
95101   debugMenu->addSeparator();
96102   debugMenu->addAction(dbgActRun);
97103   debugMenu->addAction(dbgActRunAndHide);
r242470r242471
155161}
156162
157163
164void 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
158174void WindowQt::debugActRun()
159175{
160176   debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
trunk/src/osd/modules/debugger/qt/debugqtwindow.h
r242470r242471
3434   void debugActOpenDasm();
3535   void debugActOpenLog();
3636   void debugActOpenPoints();
37   void debugActOpenDevices();
3738   void debugActRun();
3839   void debugActRunAndHide();
3940   void debugActRunToNextCpu();
r242470r242471
6465public:
6566   enum WindowType
6667   {
67      WIN_TYPE_MAIN         = 0x01,
68      WIN_TYPE_MEMORY       = 0x02,
69      WIN_TYPE_DASM         = 0x04,
70      WIN_TYPE_LOG          = 0x08,
71      WIN_TYPE_BREAK_POINTS = 0x10,
72      WIN_TYPE_UNKNOWN      = 0x20
68      WIN_TYPE_UNKNOWN,
69      WIN_TYPE_MAIN,
70      WIN_TYPE_MEMORY,
71      WIN_TYPE_DASM,
72      WIN_TYPE_LOG,
73      WIN_TYPE_BREAK_POINTS,
74      WIN_TYPE_DEVICES,
75      WIN_TYPE_DEVICE_INFORMATION
7376   };
7477
7578public:
trunk/src/osd/sdl/sdl.mak
r242470r242471
679679   $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.o \
680680   $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.o \
681681   $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.o \
682   $(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.o \
682683   $(OSDOBJ)/modules/debugger/qt/debugqtview.moc.o \
683684   $(OSDOBJ)/modules/debugger/qt/debugqtwindow.moc.o \
684685   $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.moc.o \
685686   $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.moc.o \
686687   $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.moc.o \
687688   $(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
689691endif
690692
691693ifeq ($(NO_DEBUGGER),1)


Previous 199869 Revisions Next


© 1997-2024 The MAME Team