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
|
||||
|
||||
+110
-20
@@ -28,22 +28,6 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0">
|
||||
<item>
|
||||
<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>
|
||||
<widget class="QPushButton" name="btNotch">
|
||||
<property name="sizePolicy">
|
||||
@@ -82,6 +66,100 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QCheckBox" name="cbNoExpire">
|
||||
<property name="text">
|
||||
@@ -90,9 +168,21 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbMuteNotched">
|
||||
<property name="text">
|
||||
<string>Mute notched bits</string>
|
||||
<widget class="Line" name="line_2">
|
||||
<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>
|
||||
@@ -121,7 +211,7 @@
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
||||
Reference in New Issue
Block a user