diff --git a/canframemodel.cpp b/canframemodel.cpp index 69d3b98..94332ec 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -96,6 +96,16 @@ void CANFrameModel::setFilterState(int ID, bool state) sendRefresh(); } +void CANFrameModel::setAllFilters(bool state) +{ + QMap::iterator it; + for (it = filters.begin(); it != filters.end(); ++it) + { + it.value() = state; + } + sendRefresh(); +} + void CANFrameModel::recalcOverwrite() { if (!overwriteDups) return; //no need to do a thing if mode is disabled @@ -301,6 +311,7 @@ void CANFrameModel::addFrame(CANFrame &frame, bool autoRefresh = false) void CANFrameModel::sendRefresh() { + qDebug() << "Sending mass refresh"; beginResetModel(); filteredFrames.clear(); for (int i = 0; i < frames.count(); i++) diff --git a/canframemodel.h b/canframemodel.h index 7dccd21..34cafde 100644 --- a/canframemodel.h +++ b/canframemodel.h @@ -33,6 +33,7 @@ public: void setOverwriteMode(bool); void setHexMode(bool); void setFilterState(int ID, bool state); + void setAllFilters(bool state); void setSecondsMode(bool); void loadFilterFile(QString filename); void saveFilterFile(QString filename); diff --git a/config.h b/config.h index 957b295..ae266f9 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 121 +#define VERSION 122 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/mainsettingsdialog.cpp b/mainsettingsdialog.cpp index 760a9f0..95b6d29 100644 --- a/mainsettingsdialog.cpp +++ b/mainsettingsdialog.cpp @@ -28,6 +28,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : ui->spinPlaybackSpeed->setValue(settings->value("Playback/DefSpeed", 5).toInt()); ui->cbTimeSeconds->setChecked(settings->value("Main/TimeSeconds", false).toBool()); ui->comboSendingBus->setCurrentIndex(settings->value("Playback/SendingBus", 4).toInt()); + ui->cbUseFiltered->setChecked(settings->value("Main/UseFiltered", false).toBool()); //just for simplicity they all call the same function and that function updates all settings at once connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); @@ -41,6 +42,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) : connect(ui->spinPlaybackSpeed, SIGNAL(valueChanged(int)), this, SLOT(updateSettings())); connect(ui->cbTimeSeconds, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->comboSendingBus, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings())); + connect(ui->cbUseFiltered, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); } MainSettingsDialog::~MainSettingsDialog() @@ -67,6 +69,7 @@ void MainSettingsDialog::updateSettings() settings->setValue("Playback/DefSpeed", ui->spinPlaybackSpeed->value()); settings->setValue("Main/TimeSeconds", ui->cbTimeSeconds->isChecked()); settings->setValue("Playback/SendingBus", ui->comboSendingBus->currentIndex()); + settings->setValue("Main/UseFiltered", ui->cbUseFiltered->isChecked()); settings->sync(); } diff --git a/mainsettingsdialog.ui b/mainsettingsdialog.ui index 79914d6..b7f15a3 100644 --- a/mainsettingsdialog.ui +++ b/mainsettingsdialog.ui @@ -48,6 +48,13 @@ + + + + Use filtered frames in sub-windows + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 96e50fe..8eae94f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -115,6 +115,7 @@ MainWindow::MainWindow(QWidget *parent) : settingsDialog = NULL; dbcHandler = new DBCHandler; bDirty = false; + inhibitFilterUpdate = false; model->setDBCHandler(dbcHandler); @@ -148,6 +149,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionPreferences, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); connect(model, SIGNAL(updatedFiltersList()), this, SLOT(updateFilterList())); connect(ui->listFilters, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(filterListItemChanged(QListWidgetItem*))); + connect(ui->btnFilterAll, SIGNAL(clicked(bool)), this, SLOT(filterSetAll())); + connect(ui->btnFilterNone, SIGNAL(clicked(bool)), this, SLOT(filterClearAll())); lbStatusConnected.setText(tr("Not connected")); updateFileStatus(); @@ -249,7 +252,7 @@ void MainWindow::readSettings() QSettings settings; if (settings.value("Main/SaveRestorePositions", false).toBool()) { - resize(settings.value("Main/WindowSize", QSize(800, 572)).toSize()); + resize(settings.value("Main/WindowSize", QSize(800, 682)).toSize()); move(settings.value("Main/WindowPos", QPoint(100, 100)).toPoint()); } if (settings.value("Main/AutoScroll", false).toBool()) @@ -265,6 +268,7 @@ void MainWindow::readUpdateableSettings() useHex = settings.value("Main/UseHex", true).toBool(); model->setHexMode(useHex); model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool()); + useFiltered = settings.value("Main/UseFiltered", false).toBool(); } void MainWindow::writeSettings() @@ -326,6 +330,7 @@ void MainWindow::updateFilterList() void MainWindow::filterListItemChanged(QListWidgetItem *item) { + if (inhibitFilterUpdate) return; //qDebug() << item->text(); int ID; bool isSet = false; @@ -336,6 +341,28 @@ void MainWindow::filterListItemChanged(QListWidgetItem *item) model->setFilterState(ID, isSet); } +void MainWindow::filterSetAll() +{ + inhibitFilterUpdate = true; + for (int i = 0; i < ui->listFilters->count(); i++) + { + ui->listFilters->item(i)->setCheckState(Qt::Checked); + } + inhibitFilterUpdate = false; + model->setAllFilters(true); +} + +void MainWindow::filterClearAll() +{ + inhibitFilterUpdate = true; + for (int i = 0; i < ui->listFilters->count(); i++) + { + ui->listFilters->item(i)->setCheckState(Qt::Unchecked); + } + inhibitFilterUpdate = false; + model->setAllFilters(false); +} + //most of the work is handled elsewhere. Need only to update the # of frames //and maybe auto scroll void MainWindow::gotFrames(int FPS, int framesSinceLastUpdate) @@ -791,9 +818,12 @@ void MainWindow::showSettingsDialog() settingsDialog->show(); } +//always gets unfiltered list. You ask for the graphs so there is no need to send filtered frames void MainWindow::showGraphingWindow() { - if (!graphingWindow) graphingWindow = new GraphingWindow(model->getListReference()); + if (!graphingWindow) { + graphingWindow = new GraphingWindow(model->getListReference()); + } graphingWindow->show(); } @@ -802,14 +832,23 @@ void MainWindow::showFrameDataAnalysis() //only create an instance of the object if we dont have one. Otherwise just display the existing one. if (!frameInfoWindow) { - frameInfoWindow = new FrameInfoWindow(model->getListReference()); + if (!useFiltered) + frameInfoWindow = new FrameInfoWindow(model->getListReference()); + else + frameInfoWindow = new FrameInfoWindow(model->getFilteredListReference()); } frameInfoWindow->show(); } void MainWindow::showFrameSenderWindow() { - if (!frameSenderWindow) frameSenderWindow = new FrameSenderWindow(model->getListReference()); + if (!frameSenderWindow) + { + if (!useFiltered) + frameSenderWindow = new FrameSenderWindow(model->getListReference()); + else + frameSenderWindow = new FrameSenderWindow(model->getFilteredListReference()); + } frameSenderWindow->show(); } @@ -817,9 +856,10 @@ void MainWindow::showPlaybackWindow() { if (!playbackWindow) { - playbackWindow = new FramePlaybackWindow(model->getListReference(), worker); - //connect signal to signal to pass the signal through to whoever is handling the slot - //connect(playbackWindow, SIGNAL(sendCANFrame(const CANFrame*,int)), this, SIGNAL(sendCANFrame(const CANFrame*,int))); + if (!useFiltered) + playbackWindow = new FramePlaybackWindow(model->getListReference(), worker); + else + playbackWindow = new FramePlaybackWindow(model->getFilteredListReference(), worker); } playbackWindow->show(); } @@ -863,11 +903,16 @@ void MainWindow::showFlowViewWindow() { if (!flowViewWindow) { - flowViewWindow = new FlowViewWindow(model->getListReference()); + if (!useFiltered) + flowViewWindow = new FlowViewWindow(model->getListReference()); + else + flowViewWindow = new FlowViewWindow(model->getFilteredListReference()); } flowViewWindow->show(); } + +//this one always gets the unfiltered list intentionally. void MainWindow::showDBCEditor() { if (!dbcMainEditor) diff --git a/mainwindow.h b/mainwindow.h index 3e2efb5..c201eae 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -66,6 +66,8 @@ private slots: void normalizeTiming(); void updateFilterList(); void filterListItemChanged(QListWidgetItem *item); + void filterSetAll(); + void filterClearAll(); public slots: void gotFrames(int, int); @@ -95,9 +97,11 @@ private: QThread serialWorkerThread; SerialWorker *worker; QByteArray inputBuffer; + bool inhibitFilterUpdate; bool useHex; bool allowCapture; bool bDirty; //have frames been added or subtracted since the last save/load? + bool useFiltered; //should sub-windows use the unfiltered or filtered frames list? //References to other windows we can display GraphingWindow *graphingWindow; diff --git a/mainwindow.ui b/mainwindow.ui index 736ee77..51da1ee 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 800 - 572 + 682 @@ -243,7 +243,7 @@ - + @@ -265,6 +265,24 @@ + + + + + + All + + + + + + + None + + + + +