-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraceui.cpp
More file actions
142 lines (107 loc) · 5.04 KB
/
Copy pathtraceui.cpp
File metadata and controls
142 lines (107 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Copyright (c) 2015 Dmitry Osipenko <digetx@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <QScrollBar>
#include "tracesrc.h"
#include "ui_mainwindow.h"
TraceUI::TraceUI(MainWindow *window, QString name, TraceSRC *parent) :
QObject(parent), m_mainwindow(window), m_activeDevice(NULL), m_tracesrc(parent)
{
TraceTabWidget *tab = window->getUi()->tabWidgetTrace;
m_tableViewDevices = tab->findChild<QTableView *>("tableViewDevices_" + name);
m_tableViewBitDetails = tab->findChild<QTableView *>("tableViewBitDetails_" + name);
m_treeWidgetDevices = tab->findChild<QTreeWidget *>("treeWidgetDevices_" + name);
m_tableViewTrace = tab->findChild<TraceDevView *>("tableWidgetTrace_" + name);
m_textRegDesc = tab->findChild<QTextEdit *>("textRegDesc_" + name);
m_regFilter = tab->findChild<QLineEdit *>("lineEditRegFilter_" + name);
m_rec_button = window->findChild<QPushButton *>("pushButton_Record" + name);
connect(m_treeWidgetDevices,
SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(ActiveDeviceChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
connect(m_tableViewTrace, SIGNAL(selected(const QModelIndex &)),
this, SLOT(ActiveRegChanged(const QModelIndex &)));
if (m_tableViewDevices != NULL) {
m_tableViewDevices->setModel(m_tracesrc);
connect(m_tableViewDevices->selectionModel(),
SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(ActiveDeviceChanged(const QModelIndex &, const QModelIndex &)));
}
m_tableViewBitDetails->setVisible(false);
}
void TraceUI::addDevice(TraceDev *dev)
{
ErrorsTableWidget *e = m_mainwindow->getUi()->tableWidgetErrors;
TraceTabWidget *tab = m_mainwindow->getUi()->tabWidgetTrace;
if (m_treeWidgetDevices != NULL) {
m_treeWidgetDevices->addTopLevelItem(dev);
}
if (m_tableViewDevices != NULL) {
m_tableViewDevices->resizeColumnsToContents();
}
connect(dev, SIGNAL(ErrorUnknownReg(const QString, const Device::log_entry)),
e, SLOT(AddEntry(const QString, const Device::log_entry)));
connect(dev, SIGNAL(ErrorCustom(const QString, const QString, const u_int32_t)),
e, SLOT(AddCustomEntry(const QString, const QString, const u_int32_t)));
connect(dev, SIGNAL(ErrorUnknownReg(const QString, const Device::log_entry)),
tab, SLOT(OnError(void)));
connect(dev, SIGNAL(ErrorCustom(const QString, const QString, const u_int32_t)),
tab, SLOT(OnError(void)));
}
void TraceUI::ActiveRegChanged(const QModelIndex &index)
{
QString reg_desc = m_activeDevice->updateDetails(index.row());
m_tableViewBitDetails->setVisible(
m_activeDevice->hasCap(TraceDev::BITS_DESC) );
if (m_tableViewBitDetails->model() == NULL && m_activeDevice != NULL)
m_tableViewBitDetails->setModel(m_activeDevice->getBitDetailsModel());
if (m_tableViewBitDetails->model() == NULL)
return;
for (int i = 0; i < m_tableViewBitDetails->model()->columnCount() - 1; i++)
m_tableViewBitDetails->resizeColumnToContents(i);
m_tableViewBitDetails->resizeRowsToContents();
m_textRegDesc->setPlainText(reg_desc);
m_textRegDesc->setVisible(
m_activeDevice->hasCap(TraceDev::REG_DESC) && !reg_desc.isEmpty());
}
void TraceUI::ActiveDeviceChanged(QTreeWidgetItem *item, QTreeWidgetItem *)
{
ActiveDeviceChanged( static_cast<TraceDev *> (item) );
}
void TraceUI::ActiveDeviceChanged(const QModelIndex &index, const QModelIndex &)
{
ActiveDeviceChanged( m_tracesrc->getDevAt(index.row()) );
}
void TraceUI::ActiveDeviceChanged(TraceDev *dev)
{
disconnect(m_regFilter, SIGNAL(textEdited(const QString)),
m_activeDevice, SLOT(regFilterChanged(const QString)));
m_activeDevice = dev;
m_tableViewTrace->setModel(m_activeDevice);
m_tableViewTrace->resizeColumnToContents(1);
m_tableViewTrace->resizeColumnToContents(2);
m_tableViewBitDetails->setModel(NULL);
m_textRegDesc->setVisible(false);
m_textRegDesc->setPlainText("");
connect(m_regFilter, SIGNAL(textEdited(const QString)),
m_activeDevice, SLOT(regFilterChanged(const QString)));
m_activeDevice->regFilterChanged( m_regFilter->text() );
}
void TraceUI::resetUI(void)
{
TraceTabWidget *tab = m_mainwindow->getUi()->tabWidgetTrace;
tab->ClearErrorState();
m_textRegDesc->setPlainText("");
}