diff --git a/flowviewwindow.cpp b/flowviewwindow.cpp index 8798af5..23fbdbd 100644 --- a/flowviewwindow.cpp +++ b/flowviewwindow.cpp @@ -67,7 +67,13 @@ void FlowViewWindow::showEvent(QShowEvent* event) { QDialog::showEvent(event); refreshIDList(); + if (ui->listFrameID->count() > 0) + { + changeID(ui->listFrameID->item(0)->text()); + ui->listFrameID->setCurrentRow(0); + } updateFrameLabel(); + qDebug() << "FlowView show event was processed"; } FlowViewWindow::~FlowViewWindow() diff --git a/frameinfowindow.cpp b/frameinfowindow.cpp index c6c9526..8c9ffe5 100644 --- a/frameinfowindow.cpp +++ b/frameinfowindow.cpp @@ -1,5 +1,6 @@ #include "frameinfowindow.h" #include "ui_frameinfowindow.h" +#include "mainwindow.h" #include FrameInfoWindow::FrameInfoWindow(QVector *frames, QWidget *parent) : @@ -8,12 +9,20 @@ FrameInfoWindow::FrameInfoWindow(QVector *frames, QWidget *parent) : { ui->setupUi(this); modelFrames = frames; + + connect(ui->listFrameID, SIGNAL(currentTextChanged(QString)), this, SLOT(updateDetailsWindow(QString))); + connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); } void FrameInfoWindow::showEvent(QShowEvent* event) { QDialog::showEvent(event); refreshIDList(); + if (ui->listFrameID->count() > 0) + { + updateDetailsWindow(ui->listFrameID->item(0)->text()); + ui->listFrameID->setCurrentRow(0); + } } FrameInfoWindow::~FrameInfoWindow() @@ -21,7 +30,31 @@ FrameInfoWindow::~FrameInfoWindow() delete ui; } -void FrameInfoWindow::updateDetailsWindow(QListWidgetItem *item) +//remember, negative numbers are special -1 = all frames deleted, -2 = totally new set of frames. +void FrameInfoWindow::updatedFrames(int numFrames) +{ + if (numFrames == -1) //all frames deleted. Kill the display + { + ui->listFrameID->clear(); + ui->treeDetails->clear(); + refreshIDList(); + } + else if (numFrames == -2) //all new set of frames. Reset + { + refreshIDList(); + if (ui->listFrameID->count() > 0) + { + updateDetailsWindow(ui->listFrameID->item(0)->text()); + ui->listFrameID->setCurrentRow(0); + } + } + else //just got some new frames. See if they are relevant. + { + //not done yet. :( + } +} + +void FrameInfoWindow::updateDetailsWindow(QString newID) { int idx, numFrames, targettedID; int minLen, maxLen, thisLen; @@ -31,7 +64,9 @@ void FrameInfoWindow::updateDetailsWindow(QListWidgetItem *item) int dataHistogram[256][8]; QTreeWidgetItem *baseNode, *dataBase, *histBase, *numBase, *tempItem; - targettedID = item->text().toInt(NULL, 16); + targettedID = newID.toInt(NULL, 16); + + if (modelFrames->count() == 0) return; qDebug() << "Started update details window with id " << targettedID; @@ -50,7 +85,7 @@ void FrameInfoWindow::updateDetailsWindow(QListWidgetItem *item) ui->treeDetails->clear(); baseNode = new QTreeWidgetItem(); - baseNode->setText(0, QString("ID: 0x") + ui->listFrameID->currentItem()->text()); + baseNode->setText(0, QString("ID: 0x") + newID ); if (frameCache[0].extended) //if these frames seem to be extended then try for J1939 decoding { diff --git a/frameinfowindow.h b/frameinfowindow.h index a2f2155..e7fb050 100644 --- a/frameinfowindow.h +++ b/frameinfowindow.h @@ -19,7 +19,8 @@ public: void showEvent(QShowEvent*); private slots: - void updateDetailsWindow(QListWidgetItem *); + void updateDetailsWindow(QString); + void updatedFrames(int); private: Ui::FrameInfoWindow *ui; diff --git a/frameinfowindow.ui b/frameinfowindow.ui index 5451d52..17ddefc 100644 --- a/frameinfowindow.ui +++ b/frameinfowindow.ui @@ -64,24 +64,7 @@ - - - listFrameID - itemClicked(QListWidgetItem*) - FrameInfoWindow - updateDetailsWindow(QListWidgetItem*) - - - 139 - 258 - - - 396 - 246 - - - - + updateDetailsWindow(QListWidgetItem*) diff --git a/mainwindow.cpp b/mainwindow.cpp index 88104ca..3cce0da 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,15 +22,16 @@ fuzzy scope - Try to find potential places where a given value might be stored - Things currently broken or in need of attention: -1. Need to standardize application where things might differ. All byte and bit references -should be 0-7 not 1-8. All timings should be in microseconds. -2. The windows that deal with canbus data should update based on incoming frames. It should not be required to load files to use these windows -3. Test CRTD output to make sure it saves properly now -4. Screens like flowview seem to sometimes stick with the old data after you've already cleared and loaded a different file -5. Each screen should mention which file is loaded so that it's easier to keep track of what you're doing. +1. Each screen should mention which file is loaded so that it's easier to keep track of what you're doing. */ QString MainWindow::loadedFileName = ""; +MainWindow *MainWindow::selfRef = NULL; + +MainWindow *MainWindow::getReference() +{ + return selfRef; +} MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -38,6 +39,8 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); + selfRef = this; + this->setWindowTitle("Savvy CAN V" + QString::number(VERSION)); model = new CANFrameModel(); @@ -194,6 +197,7 @@ void MainWindow::gotFrames(int FPS, int framesSinceLastUpdate) if (framesSinceLastUpdate > 0) { bDirty = true; + emit framesUpdated(framesSinceLastUpdate); //anyone care that frames were updated? } } @@ -214,6 +218,8 @@ void MainWindow::clearFrames() ui->lbNumFrames->setText(QString::number(model->rowCount())); bDirty = false; loadedFileName = ""; + updateFileStatus(); + emit framesUpdated(-1); } void MainWindow::changeBaudRates() @@ -306,6 +312,7 @@ void MainWindow::loadCRTDFile(QString filename) if (ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom(); updateFileStatus(); + emit framesUpdated(-2); } void MainWindow::saveCRTDFile(QString filename) @@ -397,6 +404,7 @@ void MainWindow::loadNativeCSVFile(QString filename) if (ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom(); updateFileStatus(); + emit framesUpdated(-2); } void MainWindow::saveNativeCSVFile(QString filename) @@ -487,6 +495,7 @@ void MainWindow::loadGenericCSVFile(QString filename) if (ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom(); updateFileStatus(); + emit framesUpdated(-2); } void MainWindow::saveGenericCSVFile(QString filename) @@ -566,6 +575,7 @@ void MainWindow::loadLogFile(QString filename) if (ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom(); updateFileStatus(); + emit framesUpdated(-2); } void MainWindow::saveLogFile(QString filename) @@ -631,6 +641,7 @@ void MainWindow::loadMicrochipFile(QString filename) if (ui->cbAutoScroll->isChecked()) ui->canFramesView->scrollToBottom(); updateFileStatus(); + emit framesUpdated(-2); } void MainWindow::saveMicrochipFile(QString filename) diff --git a/mainwindow.h b/mainwindow.h index 456f071..8b9b693 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -27,6 +27,7 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = 0); static QString loadedFileName; + static MainWindow *getReference(); ~MainWindow(); private slots: @@ -63,11 +64,13 @@ signals: void sendCANFrame(const CANFrame *, int); void stopFrameCapturing(); void startFrameCapturing(); - void gotNewFrames(); + //-1 = frames cleared, -2 = a new file has been loaded (so all frames are different), otherwise # of new frames + void framesUpdated(int numFrames); //something has updated the frame list private: Ui::MainWindow *ui; + static MainWindow *selfRef; //canbus related data CANFrameModel *model;