2 // allwatchbrowser.cpp - All Watch
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- -----------------------------------------------------------
10 // JPM 12/07/2017 Created this file
11 // JPM 09/14/2018 Added a status bar, better status report and set information values in a tab
12 // JPM April/2019 Added a sorting filter, tableview unique rows creation
16 // Better presentation
17 // To set the information display at the right
18 // To understand/fix the problem with the sorting filter
19 // Display arrays information
20 // Display structures information
23 //#define AW_SORTINGFILTER // Authorise the sorting filtes
24 //#define AW_DEBUGNUMVARIABLE 4415 // Set the global variable number to debug
25 #ifndef AW_DEBUGNUMVARIABLE
26 #define AW_STARTNUMVARIABLE 0 // Must be kept to 0 in case of no debug is required
28 #define AW_STARTNUMVARIABLE AW_DEBUGNUMVARIABLE - 1
32 #include "debugger/allwatchbrowser.h"
34 #include "debugger/DBGManager.h"
38 AllWatchBrowserWindow::AllWatchBrowserWindow(QWidget
* parent
/*= 0*/) : QWidget(parent
, Qt::Dialog
),
39 layout(new QVBoxLayout
),
41 text(new QTextBrowser
),
43 TableView(new QTableView
),
44 model(new QStandardItemModel
),
47 statusbar(new QStatusBar
),
50 setWindowTitle(tr("All Watch"));
53 QFont
fixedFont("Lucida Console", 8, QFont::Normal
);
54 fixedFont
.setStyleHint(QFont::TypeWriter
);
57 // Set original layout
58 text
->setFont(fixedFont
);
59 layout
->addWidget(text
);
61 // Set the new layout with proper identation and readibility
62 model
->setColumnCount(3);
63 model
->setHeaderData(0, Qt::Horizontal
, QObject::tr("Name"));
64 model
->setHeaderData(1, Qt::Horizontal
, QObject::tr("Value"));
65 model
->setHeaderData(2, Qt::Horizontal
, QObject::tr("Type"));
67 TableView
->setModel(model
);
68 TableView
->setEditTriggers(QAbstractItemView::NoEditTriggers
);
69 TableView
->setShowGrid(0);
70 TableView
->setFont(fixedFont
);
71 TableView
->verticalHeader()->setDefaultSectionSize(TableView
->verticalHeader()->minimumSectionSize());
72 TableView
->verticalHeader()->setDefaultAlignment(Qt::AlignRight
);
73 layout
->addWidget(TableView
);
77 layout
->addWidget(statusbar
);
83 AllWatchBrowserWindow::~AllWatchBrowserWindow(void)
90 void AllWatchBrowserWindow::Reset(void)
99 void AllWatchBrowserWindow::RefreshContents(void)
102 #ifdef AW_LAYOUTTEXTS
106 size_t Error
= AW_NOERROR
;
113 // Pre-catch the information for each global variables
114 if (NbWatch
= DBGManager_GetNbGlobalVariables())
116 PtrWatchInfo
= (WatchInfo
*)calloc(NbWatch
, sizeof(WatchInfo
));
117 #ifndef AW_LAYOUTTEXTS
118 #ifdef AW_SORTINGFILTER
119 TableView
->setSortingEnabled(false);
121 model
->setRowCount(0);
123 for (uint32_t i
= AW_STARTNUMVARIABLE
; i
< NbWatch
; i
++)
125 PtrWatchInfo
[i
].PtrVariableName
= DBGManager_GetGlobalVariableName(i
+ 1);
126 PtrWatchInfo
[i
].TypeTag
= DBGManager_GetGlobalVariableTypeTag(i
+ 1);
127 #ifdef AW_LAYOUTTEXTS
128 PtrWatchInfo
[i
].addr
= DBGManager_GetGlobalVariableAdr(i
+ 1);
129 if (!strlen(PtrWatchInfo
[i
].PtrVariableBaseTypeName
= DBGManager_GetGlobalVariableTypeName(i
+ 1)))
131 PtrWatchInfo
[i
].PtrVariableBaseTypeName
= (char *)"<font color='#ff0000'>N/A</font>";
134 PtrWatchInfo
[i
].PtrVariableBaseTypeName
= DBGManager_GetGlobalVariableTypeName(i
+ 1);
143 for (uint32_t i
= AW_STARTNUMVARIABLE
; i
< NbWatch
; i
++)
145 if ((PtrWatchInfo
[i
].TypeTag
& (DBG_TAG_TYPE_array
| DBG_TAG_TYPE_structure
)))
147 #if defined(AW_SUPPORTARRAY) || defined(AW_SUPPORTSTRUCTURE)
148 //PtrValue = (char *)memcpy(Value, &jaguarMainRAM[PtrWatchInfo[i].addr], 20);
156 PtrValue
= DBGManager_GetGlobalVariableValue(i
+ 1);
158 #ifdef AW_LAYOUTTEXTS
161 WatchAll
+= QString("<br>");
163 sprintf(string
, "%i : %s | %s | 0x%06X | %s", (i
+ 1), PtrWatchInfo
[i
].PtrVariableBaseTypeName
, PtrWatchInfo
[i
].PtrVariableName
, (unsigned int)PtrWatchInfo
[i
].addr
, PtrValue
? PtrValue
: (char *)"<font color='#ff0000'>N/A</font>");
164 WatchAll
+= QString(string
);
166 model
->setItem(i
, 0, new QStandardItem(QString("%1").arg(PtrWatchInfo
[i
].PtrVariableName
)));
167 model
->setItem(i
, 1, new QStandardItem(QString("%1").arg(PtrValue
)));
168 model
->setItem(i
, 2, new QStandardItem(QString("%1").arg(PtrWatchInfo
[i
].PtrVariableBaseTypeName
)));
171 #ifdef AW_LAYOUTTEXTS
173 text
->setText(WatchAll
);
175 #ifdef AW_SORTINGFILTER
176 TableView
->setSortingEnabled(true);
179 sprintf(msg
, "Ready");
183 sprintf(msg
, "No watches");
184 Error
= AW_NOALLWATCH
;
187 // Display status bar
190 if ((Error
& AW_WARNING
))
192 statusbar
->setStyleSheet("background-color: lightyellow; font: bold");
196 statusbar
->setStyleSheet("background-color: tomato; font: bold");
201 statusbar
->setStyleSheet("background-color: lightgreen; font: bold");
203 statusbar
->showMessage(QString(msg
));
209 void AllWatchBrowserWindow::keyPressEvent(QKeyEvent
* e
)
211 if (e
->key() == Qt::Key_Escape
)