2021-09-01 14:01:00 -05:00
|
|
|
#include "SeerVariableLoggerBrowserWidget.h"
|
|
|
|
|
#include "SeerUtl.h"
|
|
|
|
|
#include <QtWidgets/QTreeWidget>
|
|
|
|
|
#include <QtWidgets/QTreeWidgetItemIterator>
|
|
|
|
|
#include <QtWidgets/QApplication>
|
2023-10-15 12:33:43 -05:00
|
|
|
#include <QtWidgets/QMenu>
|
2023-10-15 10:19:10 -05:00
|
|
|
#include <QtGui/QFontDatabase>
|
2023-10-15 12:33:43 -05:00
|
|
|
#include <QtGui/QClipboard>
|
2021-09-01 14:01:00 -05:00
|
|
|
#include <QtCore/QTime>
|
|
|
|
|
#include <QtCore/QDebug>
|
2023-10-15 12:33:43 -05:00
|
|
|
#include <QAction>
|
2021-09-01 14:01:00 -05:00
|
|
|
|
|
|
|
|
SeerVariableLoggerBrowserWidget::SeerVariableLoggerBrowserWidget (QWidget* parent) : QWidget(parent) {
|
|
|
|
|
|
|
|
|
|
// Construct the UI.
|
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
|
|
// Setup the widgets
|
2021-10-10 12:57:30 -05:00
|
|
|
variablesTreeWidget->setMouseTracking(true);
|
2021-09-01 14:01:00 -05:00
|
|
|
variablesTreeWidget->setSortingEnabled(false);
|
2023-10-15 12:33:43 -05:00
|
|
|
variablesTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
2021-09-01 14:01:00 -05:00
|
|
|
variablesTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
2023-11-15 16:30:47 -06:00
|
|
|
variablesTreeWidget->resizeColumnToContents(0); // timestamp
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(1); // name
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(2); // value
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(3); // id
|
|
|
|
|
variablesTreeWidget->setColumnHidden(3, true); // Hide the 'id' column.
|
2021-09-01 14:01:00 -05:00
|
|
|
variablesTreeWidget->clear();
|
|
|
|
|
|
|
|
|
|
// Connect things.
|
2021-10-10 12:57:30 -05:00
|
|
|
QObject::connect(this, &SeerVariableLoggerBrowserWidget::evaluateVariableExpression, this, &SeerVariableLoggerBrowserWidget::handleEvaluateVariableExpression);
|
2022-08-10 20:17:07 -05:00
|
|
|
QObject::connect(variableAddLineEdit, &QLineEdit::returnPressed, this, &SeerVariableLoggerBrowserWidget::handleAddLineEdit);
|
2021-10-10 12:57:30 -05:00
|
|
|
QObject::connect(variableDeleteToolButton, &QToolButton::clicked, this, &SeerVariableLoggerBrowserWidget::handleDeleteToolButton);
|
|
|
|
|
QObject::connect(variableDeleteAllToolButton, &QToolButton::clicked, this, &SeerVariableLoggerBrowserWidget::handleDeleteAllToolButton);
|
2023-11-15 16:30:47 -06:00
|
|
|
QObject::connect(variablesTreeWidget, &QTreeWidget::itemCollapsed, this, &SeerVariableLoggerBrowserWidget::handleItemCollapsed);
|
|
|
|
|
QObject::connect(variablesTreeWidget, &QTreeWidget::itemExpanded, this, &SeerVariableLoggerBrowserWidget::handleItemExpanded);
|
2021-10-10 12:57:30 -05:00
|
|
|
QObject::connect(variablesTreeWidget, &QTreeWidget::itemEntered, this, &SeerVariableLoggerBrowserWidget::handleItemEntered);
|
2023-10-15 12:33:43 -05:00
|
|
|
QObject::connect(variablesTreeWidget, &QTreeWidget::customContextMenuRequested, this, &SeerVariableLoggerBrowserWidget::handleContextMenu);
|
2021-09-01 14:01:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SeerVariableLoggerBrowserWidget::~SeerVariableLoggerBrowserWidget () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SeerVariableLoggerBrowserWidget::handleText (const QString& text) {
|
|
|
|
|
|
|
|
|
|
QApplication::setOverrideCursor(Qt::BusyCursor);
|
|
|
|
|
|
2023-05-05 17:00:08 -04:00
|
|
|
if (text.contains(QRegularExpression("^([0-9]+)\\^done,value="))) {
|
2021-09-01 14:01:00 -05:00
|
|
|
|
|
|
|
|
// "6^done,value=\"\\\"abc\\\"\""
|
|
|
|
|
|
|
|
|
|
QString id_text = text.section('^', 0,0);
|
|
|
|
|
QString value_text = Seer::parseFirst(text, "value=", '"', '"', false);
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
if (_ids.contains(id_text.toInt()) == false) {
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-09-01 14:01:00 -05:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
QList<QTreeWidgetItem*> matches = variablesTreeWidget->findItems(id_text, Qt::MatchExactly, 3);
|
2022-12-24 15:42:07 -06:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
if (matches.size() > 0) {
|
|
|
|
|
|
|
|
|
|
QTreeWidgetItem* match = matches[0];
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(match->parent() == NULL);
|
|
|
|
|
|
|
|
|
|
QString timestamp_text = match->text(0);
|
|
|
|
|
QString name_text = match->text(1);
|
|
|
|
|
|
|
|
|
|
// Populate the tree.
|
|
|
|
|
handleItemCreate(match, id_text, timestamp_text, name_text, value_text);
|
2021-09-01 14:01:00 -05:00
|
|
|
}
|
|
|
|
|
|
2023-05-05 17:00:08 -04:00
|
|
|
}else if (text.contains(QRegularExpression("^([0-9]+)\\^error,msg="))) {
|
2021-09-01 14:01:00 -05:00
|
|
|
|
|
|
|
|
// "1^error,msg=\"No symbol \\\"j\\\" in current context.\""
|
|
|
|
|
|
|
|
|
|
QString id_text = text.section('^', 0,0);
|
|
|
|
|
QString msg_text = Seer::parseFirst(text, "msg=", '"', '"', false);
|
|
|
|
|
|
2022-12-24 15:42:07 -06:00
|
|
|
if (_ids.contains(id_text.toInt()) == true) {
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
QList<QTreeWidgetItem*> matches = variablesTreeWidget->findItems(id_text, Qt::MatchExactly, 3);
|
2021-09-01 14:01:00 -05:00
|
|
|
|
2022-12-24 15:42:07 -06:00
|
|
|
if (matches.size() > 0) {
|
2023-11-15 16:30:47 -06:00
|
|
|
matches.first()->setText(1, ""); // Overwrite "name" with "" because it's not a valid "name".
|
|
|
|
|
matches.first()->setText(2, Seer::filterEscapes(msg_text));
|
2022-12-24 15:42:07 -06:00
|
|
|
}
|
2021-09-01 14:01:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else if (text.startsWith("^error,msg=\"No registers.\"")) {
|
2022-12-24 15:42:07 -06:00
|
|
|
|
2021-09-01 14:01:00 -05:00
|
|
|
variablesTreeWidget->clear();
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
// Ignore others.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Resize columns.
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(0);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(1);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(2);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(3);
|
|
|
|
|
|
|
|
|
|
// Scroll to the bottom.
|
|
|
|
|
QTreeWidgetItem* lastItem = variablesTreeWidget->topLevelItem(variablesTreeWidget->topLevelItemCount()-1);
|
|
|
|
|
if (lastItem) {
|
|
|
|
|
variablesTreeWidget->scrollToItem(lastItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the cursor back.
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-20 09:33:31 -05:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleSessionTerminated () {
|
|
|
|
|
|
|
|
|
|
// Delete previous contents.
|
|
|
|
|
variablesTreeWidget->clear();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 14:01:00 -05:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleEvaluateVariableExpression (int expressionid, QString expression) {
|
|
|
|
|
|
|
|
|
|
QString id_text = QString::number(expressionid);
|
|
|
|
|
|
2022-12-24 15:42:07 -06:00
|
|
|
if (_ids.contains(id_text.toInt()) == false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
// Add new item. Will be filled in by handleText().
|
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
|
|
|
|
item->setText(0, QTime::currentTime().toString(Qt::TextDate));
|
|
|
|
|
item->setText(1, expression);
|
|
|
|
|
item->setText(2, "");
|
|
|
|
|
item->setText(3, id_text);
|
2021-09-01 14:01:00 -05:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
item->setFont(2, QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
2023-10-15 10:19:10 -05:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
variablesTreeWidget->addTopLevelItem(item);
|
2021-09-01 14:01:00 -05:00
|
|
|
|
2023-10-14 20:06:48 -05:00
|
|
|
// Resize columns done later in handleText().
|
2021-09-01 14:01:00 -05:00
|
|
|
}
|
|
|
|
|
|
2021-11-03 16:10:25 -05:00
|
|
|
void SeerVariableLoggerBrowserWidget::addVariableExpression (QString expression) {
|
|
|
|
|
|
|
|
|
|
if (expression != "") {
|
|
|
|
|
|
|
|
|
|
int id = Seer::createID();
|
|
|
|
|
|
2022-12-25 09:02:40 -06:00
|
|
|
_ids.insert(id); // Keep track of which ones are entered.
|
|
|
|
|
|
2021-11-03 16:10:25 -05:00
|
|
|
emit evaluateVariableExpression(id, expression);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 14:01:00 -05:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleAddLineEdit () {
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
QString expression = variableAddLineEdit->text();
|
2021-09-01 14:01:00 -05:00
|
|
|
|
|
|
|
|
variableAddLineEdit->clear();
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
if (expression != "") {
|
2021-09-01 14:01:00 -05:00
|
|
|
|
|
|
|
|
int id = Seer::createID();
|
|
|
|
|
|
2022-12-24 15:42:07 -06:00
|
|
|
_ids.insert(id); // Keep track of which ones are entered.
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
emit evaluateVariableExpression(id, expression);
|
2021-09-01 14:01:00 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SeerVariableLoggerBrowserWidget::handleDeleteToolButton () {
|
|
|
|
|
|
|
|
|
|
// Get selected tree items.
|
|
|
|
|
QList<QTreeWidgetItem*> items = variablesTreeWidget->selectedItems();
|
|
|
|
|
|
|
|
|
|
// Remove them.
|
2025-03-29 11:24:27 -05:00
|
|
|
for (int i=0; i<items.size(); i++) {
|
2021-09-01 14:01:00 -05:00
|
|
|
delete items[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Resize columns.
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(0);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(1);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(2);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SeerVariableLoggerBrowserWidget::handleDeleteAllToolButton () {
|
|
|
|
|
|
|
|
|
|
// Remove all.
|
|
|
|
|
variablesTreeWidget->clear();
|
|
|
|
|
|
|
|
|
|
// Resize columns.
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(0);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(1);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(2);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(3);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleItemExpanded (QTreeWidgetItem* item) {
|
|
|
|
|
|
|
|
|
|
Q_UNUSED(item);
|
|
|
|
|
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(0);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(1);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(2);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SeerVariableLoggerBrowserWidget::handleItemCollapsed (QTreeWidgetItem* item) {
|
|
|
|
|
|
|
|
|
|
Q_UNUSED(item);
|
|
|
|
|
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(0);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(1);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(2);
|
|
|
|
|
variablesTreeWidget->resizeColumnToContents(3);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-10 12:57:30 -05:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleItemEntered (QTreeWidgetItem* item, int column) {
|
|
|
|
|
|
2022-04-28 20:20:37 -05:00
|
|
|
Q_UNUSED(column);
|
|
|
|
|
|
2023-12-02 11:12:41 -06:00
|
|
|
item->setToolTip(0, item->text(0) + " : " + item->text(1) + " : " + Seer::elideText(item->text(2), Qt::ElideRight, 100));
|
2021-10-10 12:57:30 -05:00
|
|
|
|
|
|
|
|
for (int i=1; i<variablesTreeWidget->columnCount(); i++) { // Copy tooltip to other columns.
|
|
|
|
|
item->setToolTip(i, item->toolTip(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleItemCreate (QTreeWidgetItem* parentItem, const QString& id_text, const QString& timestamp_text, const QString& name_text, const QString& value_text) {
|
2023-11-12 09:04:21 -06:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
// Add the complex entry to the tree.
|
2023-11-12 09:04:21 -06:00
|
|
|
if (Seer::hasBookends(value_text, '{', '}')) {
|
|
|
|
|
|
|
|
|
|
// Remove bookends
|
|
|
|
|
QString text = Seer::filterBookends(value_text, '{', '}');
|
|
|
|
|
|
|
|
|
|
// Set the flatvalue text.
|
2023-11-15 16:30:47 -06:00
|
|
|
parentItem->setText(0, timestamp_text);
|
|
|
|
|
parentItem->setText(1, name_text);
|
|
|
|
|
parentItem->setText(2, Seer::filterEscapes(text));
|
|
|
|
|
parentItem->setFont(2, QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
|
|
|
|
parentItem->setText(3, id_text);
|
2023-11-12 09:04:21 -06:00
|
|
|
|
|
|
|
|
// Convert to a list of name/value pairs.
|
|
|
|
|
QStringList nv_pairs = Seer::parseCommaList(text, '{', '}');
|
|
|
|
|
|
|
|
|
|
// Go through each pair and add the name and its value to the tree.
|
|
|
|
|
for (const auto& nv : nv_pairs) {
|
|
|
|
|
|
|
|
|
|
QStringPair pair = Seer::parseNameValue(nv, '=');
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
// Create a new item and attach it to the parent.
|
|
|
|
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
2023-11-12 09:04:21 -06:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
handleItemCreate(item, id_text, timestamp_text, pair.first, pair.second);
|
2023-11-12 09:04:21 -06:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
parentItem->addChild(item);
|
2023-11-12 09:04:21 -06:00
|
|
|
}
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
// Add the simple entry to the tree.
|
|
|
|
|
}else{
|
|
|
|
|
parentItem->setText(0, timestamp_text);
|
|
|
|
|
parentItem->setText(1, name_text);
|
|
|
|
|
parentItem->setText(2, Seer::filterEscapes(value_text));
|
|
|
|
|
parentItem->setFont(2, QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
|
|
|
|
parentItem->setText(3, id_text);
|
2023-11-12 09:04:21 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-15 12:33:43 -05:00
|
|
|
void SeerVariableLoggerBrowserWidget::handleContextMenu (const QPoint& pos) {
|
|
|
|
|
|
|
|
|
|
// Get the item at the cursor.
|
|
|
|
|
QTreeWidgetItem* item = variablesTreeWidget->itemAt(pos);
|
|
|
|
|
|
|
|
|
|
// Construct the menu.
|
2023-12-17 16:54:13 -06:00
|
|
|
QAction* addMemoryVisualizerAction = new QAction();
|
|
|
|
|
QAction* addMemoryAsteriskVisualizerAction = new QAction();
|
|
|
|
|
QAction* addMemoryAmpersandVisualizerAction = new QAction();
|
|
|
|
|
QAction* addArrayVisualizerAction = new QAction();
|
|
|
|
|
QAction* addArrayAsteriskVisualizerAction = new QAction();
|
|
|
|
|
QAction* addArrayAmpersandVisualizerAction = new QAction();
|
|
|
|
|
QAction* addStructVisualizerAction = new QAction();
|
|
|
|
|
QAction* addStructAsteriskVisualizerAction = new QAction();
|
|
|
|
|
QAction* addStructAmpersandVisualizerAction = new QAction();
|
|
|
|
|
|
|
|
|
|
QMenu menu("Options", this);
|
|
|
|
|
|
|
|
|
|
QMenu memoryVisualizerMenu("Add variable to a Memory Visualizer");
|
|
|
|
|
memoryVisualizerMenu.addAction(addMemoryVisualizerAction);
|
|
|
|
|
memoryVisualizerMenu.addAction(addMemoryAsteriskVisualizerAction);
|
|
|
|
|
memoryVisualizerMenu.addAction(addMemoryAmpersandVisualizerAction);
|
|
|
|
|
menu.addMenu(&memoryVisualizerMenu);
|
|
|
|
|
|
|
|
|
|
QMenu arrayVisualizerMenu("Add variable to an Array Visualizer");
|
|
|
|
|
arrayVisualizerMenu.addAction(addArrayVisualizerAction);
|
|
|
|
|
arrayVisualizerMenu.addAction(addArrayAsteriskVisualizerAction);
|
|
|
|
|
arrayVisualizerMenu.addAction(addArrayAmpersandVisualizerAction);
|
|
|
|
|
menu.addMenu(&arrayVisualizerMenu);
|
|
|
|
|
|
|
|
|
|
QMenu structVisualizerMenu("Add variable to a Struct Visualizer");
|
|
|
|
|
structVisualizerMenu.addAction(addStructVisualizerAction);
|
|
|
|
|
structVisualizerMenu.addAction(addStructAsteriskVisualizerAction);
|
|
|
|
|
structVisualizerMenu.addAction(addStructAmpersandVisualizerAction);
|
|
|
|
|
menu.addMenu(&structVisualizerMenu);
|
|
|
|
|
|
|
|
|
|
QAction* copyAction = menu.addAction("Copy selected");
|
|
|
|
|
QAction* copyAllAction = menu.addAction("Copy all");
|
|
|
|
|
|
|
|
|
|
QString actionText;
|
|
|
|
|
if (item != 0) {
|
|
|
|
|
actionText = item->text(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString variable;
|
|
|
|
|
if (item != 0) {
|
|
|
|
|
// Build up a variable string, incase it is a nested struct.
|
|
|
|
|
QTreeWidgetItem* i = item;
|
|
|
|
|
variable = item->text(1);
|
|
|
|
|
while (i->parent() != 0) {
|
|
|
|
|
variable = i->parent()->text(1) + "." + variable;
|
|
|
|
|
i = i->parent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addMemoryVisualizerAction->setText(QString("\"%1\"").arg(actionText));
|
|
|
|
|
addMemoryAsteriskVisualizerAction->setText(QString("\"*%1\"").arg(actionText));
|
|
|
|
|
addMemoryAmpersandVisualizerAction->setText(QString("\"&&%1\"").arg(actionText));
|
|
|
|
|
addArrayVisualizerAction->setText(QString("\"%1\"").arg(actionText));
|
|
|
|
|
addArrayAsteriskVisualizerAction->setText(QString("\"*%1\"").arg(actionText));
|
|
|
|
|
addArrayAmpersandVisualizerAction->setText(QString("\"&&%1\"").arg(actionText));
|
|
|
|
|
addStructVisualizerAction->setText(QString("\"%1\"").arg(actionText));
|
|
|
|
|
addStructAsteriskVisualizerAction->setText(QString("\"*%1\"").arg(actionText));
|
|
|
|
|
addStructAmpersandVisualizerAction->setText(QString("\"&&%1\"").arg(actionText));
|
2023-10-15 12:33:43 -05:00
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
|
|
|
|
|
// If no selected item, disable everything but allow 'copyall'.
|
2023-10-15 12:33:43 -05:00
|
|
|
if (item == 0) {
|
2023-12-17 16:54:13 -06:00
|
|
|
memoryVisualizerMenu.setEnabled(false);
|
|
|
|
|
arrayVisualizerMenu.setEnabled(false);
|
|
|
|
|
structVisualizerMenu.setEnabled(false);
|
2023-10-15 12:33:43 -05:00
|
|
|
copyAction->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Execute the menu. Return if nothing.
|
2023-12-17 16:54:13 -06:00
|
|
|
QAction* action = menu.exec(variablesTreeWidget->mapToGlobal(pos));
|
2023-10-15 12:33:43 -05:00
|
|
|
|
|
|
|
|
if (action == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
if (action == copyAction || action == copyAction) {
|
|
|
|
|
// Get selected tree items.
|
|
|
|
|
QList<QTreeWidgetItem*> items;
|
|
|
|
|
|
|
|
|
|
// Get list of 'select' items.
|
|
|
|
|
if (action == copyAction) {
|
|
|
|
|
items = variablesTreeWidget->selectedItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get list of 'all' items.
|
|
|
|
|
if (action == copyAllAction) {
|
|
|
|
|
items = variablesTreeWidget->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Populate the clipboard.
|
|
|
|
|
if (items.size() == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QClipboard* clipboard = QGuiApplication::clipboard();
|
|
|
|
|
|
|
|
|
|
QString text;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<items.size(); i++) {
|
|
|
|
|
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
text += '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text += items[i]->text(1) + ":" + items[i]->text(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clipboard->setText(text, QClipboard::Clipboard);
|
|
|
|
|
clipboard->setText(text, QClipboard::Selection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle adding memory to visualize.
|
|
|
|
|
if (action == addMemoryVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addMemoryVisualize(variable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-10-15 12:33:43 -05:00
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Handle adding memory to visualize.
|
|
|
|
|
if (action == addMemoryAsteriskVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addMemoryVisualize(QString("*") + variable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
2023-10-15 12:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Handle adding memory to visualize.
|
|
|
|
|
if (action == addMemoryAmpersandVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addMemoryVisualize(QString("&") + variable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
2023-10-15 12:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Handle adding array to visualize.
|
|
|
|
|
if (action == addArrayVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addArrayVisualize(variable);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-15 12:33:43 -05:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Handle adding array to visualize.
|
|
|
|
|
if (action == addArrayAsteriskVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addArrayVisualize(QString("*") + variable);
|
|
|
|
|
}
|
2023-10-15 12:33:43 -05:00
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
return;
|
|
|
|
|
}
|
2023-10-15 12:33:43 -05:00
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Handle adding array to visualize.
|
|
|
|
|
if (action == addArrayAmpersandVisualizerAction) {
|
2023-10-15 12:33:43 -05:00
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addArrayVisualize(QString("&") + variable);
|
2023-10-15 12:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
return;
|
2023-10-15 12:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
2023-12-17 16:54:13 -06:00
|
|
|
// Handle adding struct to visualize.
|
|
|
|
|
if (action == addStructVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addStructVisualize(variable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle adding array to visualize.
|
|
|
|
|
if (action == addStructAsteriskVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addStructVisualize(QString("*") + variable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle adding array to visualize.
|
|
|
|
|
if (action == addStructAmpersandVisualizerAction) {
|
|
|
|
|
|
|
|
|
|
// Emit the signals.
|
|
|
|
|
if (variable != "") {
|
|
|
|
|
emit addStructVisualize(QString("&") + variable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-10-15 12:33:43 -05:00
|
|
|
}
|
|
|
|
|
|