Skip to content

Commit

Permalink
Added ability to maintain bus and msg filters when clearing frames
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Huska committed Sep 19, 2022
1 parent 461bd92 commit 3183659
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
13 changes: 11 additions & 2 deletions canframemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ CANFrameModel::CANFrameModel(QObject *parent)
dbcHandler = DBCHandler::getReference();
interpretFrames = false;
overwriteDups = false;
filtersPersistDuringClear = false;
useHexMode = true;
timeSeconds = false;
timeOffset = 0;
Expand Down Expand Up @@ -200,6 +201,11 @@ void CANFrameModel::setOverwriteMode(bool mode)
endResetModel();
}

void CANFrameModel::setClearMode(bool mode)
{
filtersPersistDuringClear = mode;
}

void CANFrameModel::setFilterState(unsigned int ID, bool state)
{
if (!filters.contains(ID)) return;
Expand Down Expand Up @@ -832,8 +838,11 @@ void CANFrameModel::clearFrames()
this->beginResetModel();
frames.clear();
filteredFrames.clear();
filters.clear();
busFilters.clear();
if(filtersPersistDuringClear == false)
{
filters.clear();
busFilters.clear();
}
frames.reserve(preallocSize);
filteredFrames.reserve(preallocSize);
this->endResetModel();
Expand Down
2 changes: 2 additions & 0 deletions canframemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CANFrameModel: public QAbstractTableModel
bool getInterpretMode();
void setOverwriteMode(bool);
void setHexMode(bool);
void setClearMode(bool mode);
void setSysTimeMode(bool);
void setMillisMode(bool mode);
void setIgnoreDBCColors(bool mode);
Expand Down Expand Up @@ -89,6 +90,7 @@ public slots:
QMutex mutex;
bool interpretFrames; //should we use the dbcHandler?
bool overwriteDups; //should we display all frames or only the newest for each ID?
bool filtersPersistDuringClear;
QString timeFormat;
bool useHexMode;
bool timeSeconds;
Expand Down
13 changes: 13 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ MainWindow::MainWindow(QWidget *parent) :

connect(ui->cbInterpret, &QAbstractButton::toggled, this, &MainWindow::interpretToggled);
connect(ui->cbOverwrite, &QAbstractButton::toggled, this, &MainWindow::overwriteToggled);
connect(ui->cbPersistentFilters, &QAbstractButton::toggled, this, &MainWindow::presistentFiltersToggled);
connect(ui->listFilters, &QListWidget::itemChanged, this, &MainWindow::filterListItemChanged);
connect(ui->listBusFilters, &QListWidget::itemChanged, this, &MainWindow::busFilterListItemChanged);

Expand Down Expand Up @@ -616,6 +617,18 @@ void MainWindow::overwriteToggled(bool state)
}
}

void MainWindow::presistentFiltersToggled(bool state)
{
if (state)
{
model->setClearMode(true);
}
else
{
model->setClearMode(false);
}
}

void MainWindow::updateFilterList()
{
if (model == nullptr) return;
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private slots:
void setupSendToLatestGraphWindow();
void interpretToggled(bool);
void overwriteToggled(bool);
void presistentFiltersToggled(bool state);
void logReceivedFrame(CANConnection*, QVector<CANFrame>);
void tickGUIUpdate();
void toggleCapture();
Expand Down
7 changes: 7 additions & 0 deletions ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbPersistentFilters">
<property name="text">
<string>Keep Filters When Clearing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbAutoScroll">
<property name="text">
Expand Down

0 comments on commit 3183659

Please sign in to comment.