Add ability to set notch and expire intervals for Sniffer Window.
This commit is contained in:
@@ -11,7 +11,8 @@ SnifferModel::SnifferModel(QObject *parent)
|
||||
mNeverExpire(false),
|
||||
mFadeInactive(false),
|
||||
mMuteNotched(false),
|
||||
mTimeSequence(0)
|
||||
mTimeSequence(0),
|
||||
mExpireInterval(5000)
|
||||
{
|
||||
QColor TextColor = QApplication::palette().color(QPalette::Text);
|
||||
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
|
||||
@@ -28,6 +29,10 @@ SnifferModel::~SnifferModel()
|
||||
mFilters.clear();
|
||||
}
|
||||
|
||||
void SnifferModel::setExpireInterval(int newVal)
|
||||
{
|
||||
mExpireInterval = newVal;
|
||||
}
|
||||
|
||||
int SnifferModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
@@ -220,6 +225,17 @@ void SnifferModel::clear()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void SnifferModel::updateNotchPoint()
|
||||
{
|
||||
QMap<quint32, SnifferItem*>::iterator i;
|
||||
|
||||
/* update markers */
|
||||
for (i = mMap.begin(); i != mMap.end(); ++i)
|
||||
{
|
||||
i.value()->updateMarker();
|
||||
}
|
||||
}
|
||||
|
||||
//Called from window with a timer (currently 200ms)
|
||||
void SnifferModel::refresh()
|
||||
{
|
||||
@@ -229,13 +245,10 @@ void SnifferModel::refresh()
|
||||
|
||||
mTimeSequence++;
|
||||
|
||||
/* update markers */
|
||||
|
||||
|
||||
for (i = mMap.begin(); i != mMap.end(); ++i)
|
||||
{
|
||||
i.value()->updateMarker();
|
||||
if(i.value()->elapsed()>5000 && !mNeverExpire)
|
||||
//i.value()->updateMarker();
|
||||
if(i.value()->elapsed() > mExpireInterval && !mNeverExpire)
|
||||
toRemove.append(i.key());
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
void setNeverExpire(bool val);
|
||||
void setFadeInactive(bool val);
|
||||
void setMuteNotched(bool val);
|
||||
void setExpireInterval(int newVal);
|
||||
void updateNotchPoint();
|
||||
|
||||
|
||||
public slots:
|
||||
@@ -65,6 +67,7 @@ private:
|
||||
bool mMuteNotched;
|
||||
bool mDarkMode;
|
||||
quint32 mTimeSequence;
|
||||
quint32 mExpireInterval;
|
||||
};
|
||||
|
||||
#endif // SNIFFERMODEL_H
|
||||
|
||||
@@ -12,7 +12,7 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::snifferWindow),
|
||||
mModel(this),
|
||||
mTimer(this),
|
||||
mGUITimer(this),
|
||||
mFilter(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -35,8 +35,12 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
|
||||
ui->listWidget->setSortingEnabled(true);
|
||||
|
||||
/* connect timer */
|
||||
connect(&mTimer, &QTimer::timeout, this, &SnifferWindow::update);
|
||||
mTimer.setInterval(200);
|
||||
connect(&mGUITimer, &QTimer::timeout, this, &SnifferWindow::update);
|
||||
mGUITimer.setInterval(200);
|
||||
connect(&mNotchTimer, &QTimer::timeout,this, &SnifferWindow::notchTick);
|
||||
mNotchTimer.setInterval(ui->spinNotchInterval->value());
|
||||
|
||||
notchPingPong = false;
|
||||
|
||||
/* connect buttons */
|
||||
connect(ui->btNotch, &QPushButton::clicked, &mModel, &SnifferModel::notch);
|
||||
@@ -59,6 +63,8 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
|
||||
}
|
||||
}
|
||||
);
|
||||
connect(ui->spinNotchInterval, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i){mNotchTimer.setInterval(i);});
|
||||
connect(ui->spinExpireInterval, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i){mModel.setExpireInterval(i);});
|
||||
}
|
||||
|
||||
SnifferWindow::~SnifferWindow()
|
||||
@@ -113,7 +119,8 @@ void SnifferWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, &mModel, &SnifferModel::update);
|
||||
mTimer.start();
|
||||
mGUITimer.start();
|
||||
mNotchTimer.start();
|
||||
readSettings();
|
||||
installEventFilter(this);
|
||||
qDebug() << "show";
|
||||
@@ -124,7 +131,7 @@ void SnifferWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
/* stop timer */
|
||||
mTimer.stop();
|
||||
mGUITimer.stop();
|
||||
/* disconnect reception of frames */
|
||||
disconnect(CANConManager::getInstance(), 0, this, 0);
|
||||
writeSettings();
|
||||
@@ -161,6 +168,23 @@ void SnifferWindow::update()
|
||||
mModel.refresh();
|
||||
}
|
||||
|
||||
void SnifferWindow::notchTick()
|
||||
{
|
||||
notchPingPong = !notchPingPong;
|
||||
if (notchPingPong)
|
||||
{
|
||||
ui->lblNotch->setBackgroundRole(QPalette::Link);
|
||||
ui->lblNotch->repaint();
|
||||
//qDebug() << "Tick";
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lblNotch->setBackgroundRole(QPalette::Background);
|
||||
ui->lblNotch->repaint();
|
||||
//qDebug() << "Tock";
|
||||
}
|
||||
mModel.updateNotchPoint();
|
||||
}
|
||||
|
||||
void SnifferWindow::fltAll()
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void update();
|
||||
void notchTick();
|
||||
void idChange(int, bool);
|
||||
void fltAll();
|
||||
void fltNone();
|
||||
@@ -52,11 +53,13 @@ private:
|
||||
|
||||
Ui::snifferWindow* ui;
|
||||
SnifferModel mModel;
|
||||
QTimer mTimer;
|
||||
QTimer mGUITimer;
|
||||
QTimer mNotchTimer;
|
||||
QMap<int, QListWidgetItem*> mMap;
|
||||
bool mFilter;
|
||||
SnifferDelegate *sniffDel;
|
||||
QAbstractItemDelegate *defaultDel;
|
||||
bool notchPingPong;
|
||||
};
|
||||
|
||||
#endif // SNIFFER_H
|
||||
|
||||
Reference in New Issue
Block a user