Skip to content

Commit

Permalink
Add config parameter to make all data columns equal size in Sniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
collin80 committed Nov 6, 2024
1 parent 225e248 commit abfc86a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 20 deletions.
4 changes: 4 additions & 0 deletions mainsettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", true).toBool());
ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool());

ui->cbEqualSniffer->setChecked(settings.value("Main/EqualDataSniff", false).toBool());

int maxFramesDefault;
if (QSysInfo::WordSize > 32)
{
Expand Down Expand Up @@ -132,6 +134,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
connect(ui->lineRemotePassword, SIGNAL(editingFinished()), this, SLOT(updateSettings()));
connect(ui->cbLoadConnections, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbFilterLabeling, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbEqualSniffer, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbHexGraphFlow, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbIgnoreDBCColors, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
Expand Down Expand Up @@ -196,6 +199,7 @@ void MainSettingsDialog::updateSettings()
settings.setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex());
settings.setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked());
settings.setValue("Main/UseOpenGL", ui->cbUseOpenGL->isChecked());
settings.setValue("Main/EqualDataSniff", ui->cbEqualSniffer->isChecked());
settings.setValue("Main/TimeFormat", ui->lineClockFormat->text());
settings.setValue("Main/FontSize", ui->spinFontSize->value());
settings.setValue("Remote/Host", ui->lineRemoteHost->text());
Expand Down
61 changes: 45 additions & 16 deletions re/sniffer/snifferwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
mGUITimer(this),
mFilter(false)
{

inhibitSectionResizeEvent = false;

ui->setupUi(this);
setWindowFlags(Qt::Window);
ui->treeView->setModel(&mModel);
Expand All @@ -31,6 +34,9 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
ui->treeView->header()->setDefaultAlignment(Qt::AlignCenter);
//ui->treeView->setItemDelegate(new SnifferDelegate());

QHeaderView *header = ui->treeView->header();
connect(header, &QHeaderView::sectionResized, this, &SnifferWindow::sectionResized);

/* activate sorting */
ui->listWidget->setSortingEnabled(true);

Expand Down Expand Up @@ -84,14 +90,22 @@ void SnifferWindow::readSettings()
ui->treeView->setColumnWidth(0, settings.value("Sniffer/DeltaColumn", 110).toUInt());
ui->treeView->setColumnWidth(1, settings.value("Sniffer/FrequencyColumn", 110).toUInt());
ui->treeView->setColumnWidth(2, settings.value("Sniffer/IDColumn", 70).toUInt());
ui->treeView->setColumnWidth(3, settings.value("Sniffer/Data0Column", 92).toUInt());
ui->treeView->setColumnWidth(4, settings.value("Sniffer/Data1Column", 92).toUInt());
ui->treeView->setColumnWidth(5, settings.value("Sniffer/Data2Column", 92).toUInt());
ui->treeView->setColumnWidth(6, settings.value("Sniffer/Data3Column", 92).toUInt());
ui->treeView->setColumnWidth(7, settings.value("Sniffer/Data4Column", 92).toUInt());
ui->treeView->setColumnWidth(8, settings.value("Sniffer/Data5Column", 92).toUInt());
ui->treeView->setColumnWidth(9, settings.value("Sniffer/Data6Column", 92).toUInt());
ui->treeView->setColumnWidth(10, settings.value("Sniffer/Data7Column", 92).toUInt());
if (!settings.value("Main/EqualDataSniff", false).toBool())
{
for (int i = 0; i < MAX_BYTES; i++)
{
QString key = "Sniffer/Data" + QString::number(i).trimmed() + "Column";
ui->treeView->setColumnWidth(3+i, settings.value(key, 50).toUInt());
}
}
else //set all columns equal to column Data0 size
{
int colSize = settings.value("Sniffer/Data0Column", 50).toUInt();
for (int i = 0; i < MAX_BYTES; i++)
{
ui->treeView->setColumnWidth(3+i, colSize);
}
}
}
}

Expand All @@ -106,14 +120,12 @@ void SnifferWindow::writeSettings()
settings.setValue("Sniffer/DeltaColumn", ui->treeView->columnWidth(0));
settings.setValue("Sniffer/FrequencyColumn", ui->treeView->columnWidth(1));
settings.setValue("Sniffer/IDColumn", ui->treeView->columnWidth(2));
settings.setValue("Sniffer/Data0Column", ui->treeView->columnWidth(3));
settings.setValue("Sniffer/Data1Column", ui->treeView->columnWidth(4));
settings.setValue("Sniffer/Data2Column", ui->treeView->columnWidth(5));
settings.setValue("Sniffer/Data3Column", ui->treeView->columnWidth(6));
settings.setValue("Sniffer/Data4Column", ui->treeView->columnWidth(7));
settings.setValue("Sniffer/Data5Column", ui->treeView->columnWidth(8));
settings.setValue("Sniffer/Data6Column", ui->treeView->columnWidth(9));
settings.setValue("Sniffer/Data7Column", ui->treeView->columnWidth(10));

for (int i = 0; i < MAX_BYTES; i++)
{
QString key = "Sniffer/Data" + QString::number(i).trimmed() + "Column";
settings.setValue(key, ui->treeView->columnWidth(i+3));
}
}
}

Expand Down Expand Up @@ -170,6 +182,23 @@ void SnifferWindow::update()
mModel.refresh();
}

void SnifferWindow::sectionResized(int idx, int oldSize, int newSize)
{
QSettings settings;

//nothing to do if we're not enforcing equal column sizes
if (!settings.value("Main/EqualDataSniff", false).toBool()) return;
if (inhibitSectionResizeEvent) return;

//we're enforcing equal sizes so change the size of all columns to match.
inhibitSectionResizeEvent = true;
for (int i = 0; i < MAX_BYTES; i++)
{
ui->treeView->setColumnWidth(3+i, newSize);
}
inhibitSectionResizeEvent = false;
}

void SnifferWindow::notchTick()
{
notchPingPong = !notchPingPong;
Expand Down
4 changes: 4 additions & 0 deletions re/sniffer/snifferwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public slots:
void fltNone();
void itemChanged(QListWidgetItem*);

private slots:
void sectionResized(int idx, int oldSize, int newSize);

private:
void filter(bool pFilter);
bool eventFilter(QObject *obj, QEvent *event);
Expand All @@ -117,6 +120,7 @@ public slots:
SnifferDelegate *sniffDel;
QAbstractItemDelegate *defaultDel;
bool notchPingPong;
bool inhibitSectionResizeEvent;
};

#endif // SNIFFER_H
24 changes: 20 additions & 4 deletions ui/mainsettingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -288,7 +288,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -399,6 +399,22 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
<string>Data Columns</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QCheckBox" name="cbEqualSniffer">
<property name="text">
<string>Equal size data columns in Sniffer Window</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="enabled">
Expand Down Expand Up @@ -448,7 +464,7 @@
<item row="3" column="1">
<widget class="QLineEdit" name="lineRemotePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
<enum>QLineEdit::EchoMode::Password</enum>
</property>
</widget>
</item>
Expand All @@ -468,7 +484,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down

0 comments on commit abfc86a

Please sign in to comment.