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),
|
mNeverExpire(false),
|
||||||
mFadeInactive(false),
|
mFadeInactive(false),
|
||||||
mMuteNotched(false),
|
mMuteNotched(false),
|
||||||
mTimeSequence(0)
|
mTimeSequence(0),
|
||||||
|
mExpireInterval(5000)
|
||||||
{
|
{
|
||||||
QColor TextColor = QApplication::palette().color(QPalette::Text);
|
QColor TextColor = QApplication::palette().color(QPalette::Text);
|
||||||
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
|
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
|
||||||
@@ -28,6 +29,10 @@ SnifferModel::~SnifferModel()
|
|||||||
mFilters.clear();
|
mFilters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SnifferModel::setExpireInterval(int newVal)
|
||||||
|
{
|
||||||
|
mExpireInterval = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
int SnifferModel::columnCount(const QModelIndex &parent) const
|
int SnifferModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
@@ -220,6 +225,17 @@ void SnifferModel::clear()
|
|||||||
endResetModel();
|
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)
|
//Called from window with a timer (currently 200ms)
|
||||||
void SnifferModel::refresh()
|
void SnifferModel::refresh()
|
||||||
{
|
{
|
||||||
@@ -229,13 +245,10 @@ void SnifferModel::refresh()
|
|||||||
|
|
||||||
mTimeSequence++;
|
mTimeSequence++;
|
||||||
|
|
||||||
/* update markers */
|
|
||||||
|
|
||||||
|
|
||||||
for (i = mMap.begin(); i != mMap.end(); ++i)
|
for (i = mMap.begin(); i != mMap.end(); ++i)
|
||||||
{
|
{
|
||||||
i.value()->updateMarker();
|
//i.value()->updateMarker();
|
||||||
if(i.value()->elapsed()>5000 && !mNeverExpire)
|
if(i.value()->elapsed() > mExpireInterval && !mNeverExpire)
|
||||||
toRemove.append(i.key());
|
toRemove.append(i.key());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public:
|
|||||||
void setNeverExpire(bool val);
|
void setNeverExpire(bool val);
|
||||||
void setFadeInactive(bool val);
|
void setFadeInactive(bool val);
|
||||||
void setMuteNotched(bool val);
|
void setMuteNotched(bool val);
|
||||||
|
void setExpireInterval(int newVal);
|
||||||
|
void updateNotchPoint();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -65,6 +67,7 @@ private:
|
|||||||
bool mMuteNotched;
|
bool mMuteNotched;
|
||||||
bool mDarkMode;
|
bool mDarkMode;
|
||||||
quint32 mTimeSequence;
|
quint32 mTimeSequence;
|
||||||
|
quint32 mExpireInterval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SNIFFERMODEL_H
|
#endif // SNIFFERMODEL_H
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
|
|||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::snifferWindow),
|
ui(new Ui::snifferWindow),
|
||||||
mModel(this),
|
mModel(this),
|
||||||
mTimer(this),
|
mGUITimer(this),
|
||||||
mFilter(false)
|
mFilter(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -35,8 +35,12 @@ SnifferWindow::SnifferWindow(QWidget *parent) :
|
|||||||
ui->listWidget->setSortingEnabled(true);
|
ui->listWidget->setSortingEnabled(true);
|
||||||
|
|
||||||
/* connect timer */
|
/* connect timer */
|
||||||
connect(&mTimer, &QTimer::timeout, this, &SnifferWindow::update);
|
connect(&mGUITimer, &QTimer::timeout, this, &SnifferWindow::update);
|
||||||
mTimer.setInterval(200);
|
mGUITimer.setInterval(200);
|
||||||
|
connect(&mNotchTimer, &QTimer::timeout,this, &SnifferWindow::notchTick);
|
||||||
|
mNotchTimer.setInterval(ui->spinNotchInterval->value());
|
||||||
|
|
||||||
|
notchPingPong = false;
|
||||||
|
|
||||||
/* connect buttons */
|
/* connect buttons */
|
||||||
connect(ui->btNotch, &QPushButton::clicked, &mModel, &SnifferModel::notch);
|
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()
|
SnifferWindow::~SnifferWindow()
|
||||||
@@ -113,7 +119,8 @@ void SnifferWindow::showEvent(QShowEvent* event)
|
|||||||
{
|
{
|
||||||
QDialog::showEvent(event);
|
QDialog::showEvent(event);
|
||||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, &mModel, &SnifferModel::update);
|
connect(CANConManager::getInstance(), &CANConManager::framesReceived, &mModel, &SnifferModel::update);
|
||||||
mTimer.start();
|
mGUITimer.start();
|
||||||
|
mNotchTimer.start();
|
||||||
readSettings();
|
readSettings();
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
qDebug() << "show";
|
qDebug() << "show";
|
||||||
@@ -124,7 +131,7 @@ void SnifferWindow::closeEvent(QCloseEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
/* stop timer */
|
/* stop timer */
|
||||||
mTimer.stop();
|
mGUITimer.stop();
|
||||||
/* disconnect reception of frames */
|
/* disconnect reception of frames */
|
||||||
disconnect(CANConManager::getInstance(), 0, this, 0);
|
disconnect(CANConManager::getInstance(), 0, this, 0);
|
||||||
writeSettings();
|
writeSettings();
|
||||||
@@ -161,6 +168,23 @@ void SnifferWindow::update()
|
|||||||
mModel.refresh();
|
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()
|
void SnifferWindow::fltAll()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void update();
|
void update();
|
||||||
|
void notchTick();
|
||||||
void idChange(int, bool);
|
void idChange(int, bool);
|
||||||
void fltAll();
|
void fltAll();
|
||||||
void fltNone();
|
void fltNone();
|
||||||
@@ -52,11 +53,13 @@ private:
|
|||||||
|
|
||||||
Ui::snifferWindow* ui;
|
Ui::snifferWindow* ui;
|
||||||
SnifferModel mModel;
|
SnifferModel mModel;
|
||||||
QTimer mTimer;
|
QTimer mGUITimer;
|
||||||
|
QTimer mNotchTimer;
|
||||||
QMap<int, QListWidgetItem*> mMap;
|
QMap<int, QListWidgetItem*> mMap;
|
||||||
bool mFilter;
|
bool mFilter;
|
||||||
SnifferDelegate *sniffDel;
|
SnifferDelegate *sniffDel;
|
||||||
QAbstractItemDelegate *defaultDel;
|
QAbstractItemDelegate *defaultDel;
|
||||||
|
bool notchPingPong;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SNIFFER_H
|
#endif // SNIFFER_H
|
||||||
|
|||||||
+110
-20
@@ -28,22 +28,6 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0">
|
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Maximum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btNotch">
|
<widget class="QPushButton" name="btNotch">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -82,6 +66,100 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbMuteNotched">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mute notched bits</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Notch Interval</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinNotchInterval">
|
||||||
|
<property name="suffix">
|
||||||
|
<string>ms</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>750</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblNotch">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>4</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Expire Interval</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinExpireInterval">
|
||||||
|
<property name="suffix">
|
||||||
|
<string>ms</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1000</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>200</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>5000</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="cbNoExpire">
|
<widget class="QCheckBox" name="cbNoExpire">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -90,9 +168,21 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="cbMuteNotched">
|
<widget class="Line" name="line_2">
|
||||||
<property name="text">
|
<property name="minimumSize">
|
||||||
<string>Mute notched bits</string>
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>4</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -121,7 +211,7 @@
|
|||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>25</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
|||||||
Reference in New Issue
Block a user