From 97f7db4e6257c4f71a1a863d1d8aa887629ad273 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Wed, 3 Jun 2015 22:02:40 -0400 Subject: [PATCH] Added dynamic update support to flowView as well. As in the frame details view, it currently does not do realtime updates as frames come in but will update when a new file is loaded. --- flowviewwindow.cpp | 38 ++++++++++++++++++++++++++++++++++++++ flowviewwindow.h | 1 + frameinfowindow.cpp | 21 ++++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/flowviewwindow.cpp b/flowviewwindow.cpp index 23fbdbd..7dc3da5 100644 --- a/flowviewwindow.cpp +++ b/flowviewwindow.cpp @@ -1,5 +1,6 @@ #include "flowviewwindow.h" #include "ui_flowviewwindow.h" +#include "mainwindow.h" const QColor FlowViewWindow::graphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3 Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7 @@ -59,6 +60,8 @@ FlowViewWindow::FlowViewWindow(QVector *frames, QWidget *parent) : connect(ui->listFrameID, SIGNAL(currentTextChanged(QString)), this, SLOT(changeID(QString))); connect(playbackTimer, SIGNAL(timeout()), this, SLOT(timerTriggered())); + connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); + playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control } @@ -84,6 +87,38 @@ FlowViewWindow::~FlowViewWindow() delete playbackTimer; } +void FlowViewWindow::updatedFrames(int numFrames) +{ + if (numFrames == -1) //all frames deleted. Kill the display + { + ui->listFrameID->clear(); + foundID.clear(); + currentPosition = 0; + refreshIDList(); + updateFrameLabel(); + removeAllGraphs(); + memset(refBytes, 0, 8); + memset(currBytes, 0, 8); + updateDataView(); + } + else if (numFrames == -2) //all new set of frames. Reset + { + ui->listFrameID->clear(); + foundID.clear(); + currentPosition = 0; + refreshIDList(); + if (ui->listFrameID->count() > 0) + { + changeID(ui->listFrameID->item(0)->text()); + ui->listFrameID->setCurrentRow(0); + } + updateFrameLabel(); + } + else //just got some new frames. See if they are relevant. + { + } +} + void FlowViewWindow::removeAllGraphs() { ui->graphView->clearGraphs(); @@ -145,6 +180,9 @@ void FlowViewWindow::changeID(QString newID) //parse the ID and then load up the frame cache with just messages with that ID. int id = newID.toInt(NULL, 16); frameCache.clear(); + + if (modelFrames->count() == 0) return; + playbackTimer->stop(); playbackActive = false; for (int x = 0; x < modelFrames->count(); x++) diff --git a/flowviewwindow.h b/flowviewwindow.h index c8ded34..889169d 100644 --- a/flowviewwindow.h +++ b/flowviewwindow.h @@ -28,6 +28,7 @@ private slots: void changeLooping(bool check); void timerTriggered(); void changeID(QString); + void updatedFrames(int); private: Ui::FlowViewWindow *ui; diff --git a/frameinfowindow.cpp b/frameinfowindow.cpp index 8c9ffe5..82a32aa 100644 --- a/frameinfowindow.cpp +++ b/frameinfowindow.cpp @@ -50,7 +50,26 @@ void FrameInfoWindow::updatedFrames(int numFrames) } else //just got some new frames. See if they are relevant. { - //not done yet. :( + int currID = ui->listFrameID->currentItem()->text().toInt(NULL, 16); + bool foundID = false; + for (int x = modelFrames->count() - numFrames; x < modelFrames->count(); x++) + { + if (currID = modelFrames->at(x).ID) + { + foundID = true; + break; + } + } + if (foundID) + { + //the problem here is that it'll blast us out of the details as soon as this + //happens. The only way to do this properly is to actually traverse + //the details structure and change the text. We don't do that yet. + //so, the line is commented out. If people need to see the updated + //data they can click another ID and back and it'll be OK + + //updateDetailsWindow(ui->listFrameID->currentItem()->text()); + } } }