Add field viewer
This commit is contained in:
parent
df47a6a1bf
commit
95e5bb7baf
@ -3,13 +3,13 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>nostalgia-studio</string>
|
<string>bullock</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>Nostalgia Studio</string>
|
<string>Bullock</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string></string>
|
<string></string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>net.drinkingtea.nostalgia.studio</string>
|
<string>net.drinkingtea.bullock</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
|
@ -15,6 +15,23 @@
|
|||||||
|
|
||||||
#include "traceview.hpp"
|
#include "traceview.hpp"
|
||||||
|
|
||||||
|
static QTreeWidgetItem *treeItem(const Field &field, QTreeWidget *treeWidget, QTreeWidgetItem *parent = nullptr) {
|
||||||
|
QTreeWidgetItem *item = nullptr;
|
||||||
|
if (parent) {
|
||||||
|
item = new QTreeWidgetItem(parent);
|
||||||
|
parent->addChild(item);
|
||||||
|
} else {
|
||||||
|
item = new QTreeWidgetItem(treeWidget);
|
||||||
|
//treeWidget->addChild(item);
|
||||||
|
}
|
||||||
|
item->setData(0, Qt::DisplayRole, field.name);
|
||||||
|
item->setData(1, Qt::DisplayRole, field.value);
|
||||||
|
for (const auto &f : field.fields) {
|
||||||
|
treeItem(f, treeWidget, item);
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
TraceView::TraceView(QWidget *parent): QWidget(parent) {
|
TraceView::TraceView(QWidget *parent): QWidget(parent) {
|
||||||
auto lyt = new QHBoxLayout;
|
auto lyt = new QHBoxLayout;
|
||||||
setLayout(lyt);
|
setLayout(lyt);
|
||||||
@ -33,22 +50,36 @@ TraceView::TraceView(QWidget *parent): QWidget(parent) {
|
|||||||
[this](const QItemSelection &selected, const QItemSelection &deselected) {
|
[this](const QItemSelection &selected, const QItemSelection &deselected) {
|
||||||
auto indexes = selected.indexes();
|
auto indexes = selected.indexes();
|
||||||
if (indexes.size()) {
|
if (indexes.size()) {
|
||||||
auto row = indexes[0].row();
|
m_selectedEvent = indexes[0].row();
|
||||||
const auto te = m_model->traceEvent(row);
|
const auto te = m_model->traceEvent(m_selectedEvent);
|
||||||
m_callStackModel->setTraceEvent(te);
|
m_frameTableModel->setTraceEvent(te);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_splitter->addWidget(m_eventTable);
|
m_splitter->addWidget(m_eventTable);
|
||||||
|
|
||||||
m_callStack = new QTableView(this);
|
// setup lower pane
|
||||||
m_callStackModel = new CallStackModel;
|
m_lowerSplitter = new QSplitter(this);
|
||||||
m_callStack->setModel(m_callStackModel);
|
|
||||||
m_callStack->horizontalHeader()->setStretchLastSection(true);
|
|
||||||
m_callStack->verticalHeader()->hide();
|
|
||||||
m_callStack->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
||||||
m_callStack->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
||||||
m_splitter->addWidget(m_callStack);
|
|
||||||
|
|
||||||
|
// setup stack trace viewer
|
||||||
|
m_frameTable = new QTableView(this);
|
||||||
|
m_frameTableModel = new CallStackModel;
|
||||||
|
m_frameTable->setModel(m_frameTableModel);
|
||||||
|
m_frameTable->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
m_frameTable->verticalHeader()->hide();
|
||||||
|
m_frameTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
m_frameTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
connect(m_frameTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &TraceView::handleFrameSelection);
|
||||||
|
m_lowerSplitter->addWidget(m_frameTable);
|
||||||
|
|
||||||
|
// setup field viewer
|
||||||
|
m_fieldView = new QTreeWidget(this);
|
||||||
|
m_fieldView->header()->setStretchLastSection(true);
|
||||||
|
m_fieldView->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
m_fieldView->setHeaderLabels({tr("Name"), tr("Value")});
|
||||||
|
m_lowerSplitter->addWidget(m_fieldView);
|
||||||
|
|
||||||
|
|
||||||
|
m_splitter->addWidget(m_lowerSplitter);
|
||||||
m_splitter->setStretchFactor(0, 2);
|
m_splitter->setStretchFactor(0, 2);
|
||||||
|
|
||||||
readState();
|
readState();
|
||||||
@ -63,9 +94,12 @@ void TraceView::readState() {
|
|||||||
settings.beginGroup("TraceView");
|
settings.beginGroup("TraceView");
|
||||||
m_eventTable->horizontalHeader()->restoreState(settings.value("eventTableState").toByteArray());
|
m_eventTable->horizontalHeader()->restoreState(settings.value("eventTableState").toByteArray());
|
||||||
m_eventTable->horizontalHeader()->restoreGeometry(settings.value("eventTableGeometry").toByteArray());
|
m_eventTable->horizontalHeader()->restoreGeometry(settings.value("eventTableGeometry").toByteArray());
|
||||||
m_callStack->horizontalHeader()->restoreState(settings.value("callStackTableState").toByteArray());
|
m_frameTable->horizontalHeader()->restoreState(settings.value("frameTableState").toByteArray());
|
||||||
m_callStack->horizontalHeader()->restoreGeometry(settings.value("callStackTableGeometry").toByteArray());
|
m_frameTable->horizontalHeader()->restoreGeometry(settings.value("frameTableGeometry").toByteArray());
|
||||||
|
m_fieldView->header()->restoreState(settings.value("fieldViewState").toByteArray());
|
||||||
|
m_fieldView->header()->restoreGeometry(settings.value("fieldViewGeometry").toByteArray());
|
||||||
m_splitter->restoreState(settings.value("splitterState").toByteArray());
|
m_splitter->restoreState(settings.value("splitterState").toByteArray());
|
||||||
|
m_lowerSplitter->restoreState(settings.value("lowerSplitterState").toByteArray());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,13 +108,28 @@ void TraceView::writeState() {
|
|||||||
settings.beginGroup("TraceView");
|
settings.beginGroup("TraceView");
|
||||||
settings.setValue("eventTableState", m_eventTable->horizontalHeader()->saveState());
|
settings.setValue("eventTableState", m_eventTable->horizontalHeader()->saveState());
|
||||||
settings.setValue("eventTableGeometry", m_eventTable->horizontalHeader()->saveGeometry());
|
settings.setValue("eventTableGeometry", m_eventTable->horizontalHeader()->saveGeometry());
|
||||||
settings.setValue("callStackTableState", m_callStack->horizontalHeader()->saveState());
|
settings.setValue("frameTableState", m_frameTable->horizontalHeader()->saveState());
|
||||||
settings.setValue("callStackTableGeometry", m_callStack->horizontalHeader()->saveGeometry());
|
settings.setValue("frameTableGeometry", m_frameTable->horizontalHeader()->saveGeometry());
|
||||||
|
settings.setValue("fieldViewState", m_fieldView->header()->saveState());
|
||||||
|
settings.setValue("fieldViewGeometry", m_fieldView->header()->saveGeometry());
|
||||||
settings.setValue("splitterState", m_splitter->saveState());
|
settings.setValue("splitterState", m_splitter->saveState());
|
||||||
|
settings.setValue("lowerSplitterState", m_lowerSplitter->saveState());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceView::setProcessData(ProcessData *data) {
|
void TraceView::setProcessData(ProcessData *data) {
|
||||||
m_model->setProcessData(data);
|
m_model->setProcessData(data);
|
||||||
m_callStackModel->clear();
|
m_frameTableModel->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceView::handleFrameSelection(const QItemSelection &selected, const QItemSelection &deselected) {
|
||||||
|
auto indexes = selected.indexes();
|
||||||
|
m_fieldView->clear();
|
||||||
|
if (indexes.size()) {
|
||||||
|
auto row = indexes[0].row();
|
||||||
|
const auto te = m_model->traceEvent(m_selectedEvent);
|
||||||
|
for (const auto &field : te.frames[row].fields) {
|
||||||
|
treeItem(field, m_fieldView);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
#include <QTreeWidget>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "callstackmodel.hpp"
|
#include "callstackmodel.hpp"
|
||||||
@ -21,10 +22,13 @@ class TraceView: public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_selectedEvent = 0;
|
||||||
QTableView *m_eventTable = nullptr;
|
QTableView *m_eventTable = nullptr;
|
||||||
QTableView *m_callStack = nullptr;
|
QTableView *m_frameTable = nullptr;
|
||||||
|
QTreeWidget *m_fieldView = nullptr;
|
||||||
QSplitter *m_splitter = nullptr;
|
QSplitter *m_splitter = nullptr;
|
||||||
CallStackModel *m_callStackModel = nullptr;
|
QSplitter *m_lowerSplitter = nullptr;
|
||||||
|
CallStackModel *m_frameTableModel = nullptr;
|
||||||
TraceEventModel *m_model = nullptr;
|
TraceEventModel *m_model = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -39,4 +43,7 @@ class TraceView: public QWidget {
|
|||||||
|
|
||||||
void writeState();
|
void writeState();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleFrameSelection(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user