Skip to content

Commit

Permalink
Merge branch 'COVESA:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bunty95 authored Nov 16, 2024
2 parents f3680b1 + 77c0efc commit b9aea14
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 203 deletions.
3 changes: 2 additions & 1 deletion qdlt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ add_library(qdlt SHARED
qdltimporter.cpp
fieldnames.cpp
dltmessagematcher.cpp
dltmessagematcher.h)
dltmessagematcher.h
qdltlrucache.hpp)

target_compile_definitions(qdlt PRIVATE
BYTE_ORDER=LITTLE_ENDIAN
Expand Down
4 changes: 2 additions & 2 deletions qdlt/qdltfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void QDltFile::addFilterIndex (int index)
}

#ifdef USECOLOR
QColor QDltFile::checkMarker(QDltMsg &msg)
QColor QDltFile::checkMarker(const QDltMsg &msg)
{
if(!filterFlag)
{
Expand All @@ -498,7 +498,7 @@ void QDltFile::addFilterIndex (int index)
}

#else
QString QDltFile::checkMarker(QDltMsg &msg)
QString QDltFile::checkMarker(const QDltMsg &msg)
{
if(!filterFlag)
{
Expand Down
4 changes: 2 additions & 2 deletions qdlt/qdltfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ class QDLT_EXPORT QDltFile : public QDlt
\return 0 if message will not be marked, colour if message will be marked
*/
#ifdef USECOLOR
QColor checkMarker(QDltMsg &msg);
QColor checkMarker(const QDltMsg &msg);
#else
QString checkMarker(QDltMsg &msg);
QString checkMarker(const QDltMsg &msg);
#endif

//! Get file name of the underlying file object
Expand Down
2 changes: 1 addition & 1 deletion qdlt/qdltfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool QDltFilter::compileRegexps()
appidRegularExpression.isValid());
}

bool QDltFilter::match(QDltMsg &msg) const
bool QDltFilter::match(const QDltMsg &msg) const
{

if( (true == enableEcuid) && (msg.getEcuid() != ecuid))
Expand Down
2 changes: 1 addition & 1 deletion qdlt/qdltfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class QDLT_EXPORT QDltFilter
/*!
\return true if filter matches the message, else false
*/
bool match(QDltMsg &msg) const;
bool match(const QDltMsg &msg) const;

//! Save filter parameters in XML file.
/*!
Expand Down
4 changes: 2 additions & 2 deletions qdlt/qdltfilterlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void QDltFilterList::addFilter(QDltFilter *_filter)


#ifdef USECOLOR
QColor QDltFilterList::checkMarker(QDltMsg &msg)
QColor QDltFilterList::checkMarker(const QDltMsg &msg)
{
QDltFilter *filter;
QColor color;
Expand All @@ -104,7 +104,7 @@ QColor QDltFilterList::checkMarker(QDltMsg &msg)
return color;
}
#else
QString QDltFilterList::checkMarker(QDltMsg &msg)
QString QDltFilterList::checkMarker(const QDltMsg &msg)
{
QDltFilter *filter;
QString color=""; // invalid colour
Expand Down
4 changes: 2 additions & 2 deletions qdlt/qdltfilterlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class QDLT_EXPORT QDltFilterList
\return 0 if message will not be marked, colour if message will be marked
*/
#ifdef USECOLOR
QColor checkMarker(QDltMsg &msg);
QColor checkMarker(const QDltMsg &msg);
#else
QString checkMarker(QDltMsg &msg);
QString checkMarker(const QDltMsg &msg);
#endif


Expand Down
59 changes: 59 additions & 0 deletions qdlt/qdltlrucache.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef QDLTLRUCACHE_HPP
#define QDLTLRUCACHE_HPP

#include <unordered_map>
#include <list>
#include <stdexcept>

template<typename Key, typename Value>
class QDltLruCache {

struct CacheEntry {
Key key;
Value value;
};

using CacheListIterator = typename std::list<CacheEntry>::iterator;
public:

QDltLruCache(size_t capacity) :
m_capacity(capacity) {
}

void put(const Key& key, const Value& value) {
auto it = m_keyIteratorsMap.find(key);
m_cacheItems.push_front(CacheEntry{key, value});
if (it != m_keyIteratorsMap.end()) {
m_cacheItems.erase(it->second);
m_keyIteratorsMap.erase(it);
}
m_keyIteratorsMap[key] = m_cacheItems.begin();

if (m_keyIteratorsMap.size() > m_capacity) {
auto last = std::prev(m_cacheItems.end());
m_keyIteratorsMap.erase(last->key);
m_cacheItems.pop_back();
}
}

const Value& get(const Key& key) {
auto it = m_keyIteratorsMap.find(key);
if (it == m_keyIteratorsMap.end()) {
throw std::range_error("no such key in cache found");
}

m_cacheItems.splice(m_cacheItems.begin(), m_cacheItems, it->second);
return it->second->value;
}

bool exists(const Key& key) const {
return m_keyIteratorsMap.find(key) != m_keyIteratorsMap.end();
}

private:
std::list<CacheEntry> m_cacheItems;
std::unordered_map<Key, CacheListIterator> m_keyIteratorsMap;
const size_t m_capacity;
};

#endif // QDLTLRUCACHE_HPP
12 changes: 12 additions & 0 deletions src/dlttableview.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "dlttableview.h"

#include <QDebug>
#include <QWheelEvent>

DltTableView::DltTableView(QWidget *parent) :
QTableView(parent)
{
Expand All @@ -17,6 +20,15 @@ void DltTableView::paintEvent(QPaintEvent *event)
}
}

void DltTableView::wheelEvent(QWheelEvent *event)
{
if (event->modifiers().testFlag(Qt::ControlModifier)) {
auto val = event->angleDelta().y();
emit changeFontSize((0 < val) - (val < 0));
event->accept();
}
}

void DltTableView::lock()
{
paintMutex.lock();
Expand Down
6 changes: 5 additions & 1 deletion src/dlttableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ class DltTableView : public QTableView
explicit DltTableView(QWidget *parent = 0);
void lock();
void unlock();

signals:
void changeFontSize(int delta);
private:
QMutex paintMutex;

protected:
void paintEvent(QPaintEvent *e);
void paintEvent(QPaintEvent *e) override;
void wheelEvent(QWheelEvent *event) override;

signals:

Expand Down
11 changes: 10 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,15 @@ void MainWindow::initSignalConnections()
ui->exploreView->scrollTo(
proxyModel->mapFromSource(fsModel->index(recentFiles[0])));
});

connect(ui->tableView, &DltTableView::changeFontSize, this, [this](int direction){
QFont font;
font.fromString(settings->fontName);
int fontSize = font.pointSize() + direction;
font.setPointSize(fontSize);
settings->fontName = font.toString();
ui->tableView->setFont(font);
});
}

void MainWindow::initSearchTable()
Expand Down Expand Up @@ -2066,6 +2075,7 @@ void MainWindow::reloadLogFileFinishFilter()
QList<int> list = dltIndexer->getGetLogInfoList();
QDltMsg msg;

// FIXME: this is slow operation running in the main loop
for(int num=0;num<list.size();num++)
{
if(qfile.getMsg(list[num],msg))
Expand All @@ -2082,7 +2092,6 @@ void MainWindow::reloadLogFileFinishFilter()
// hide progress bar when finished
statusProgressBar->reset();
statusProgressBar->hide();

}

void MainWindow::reloadLogFileFinishDefaultFilter()
Expand Down
8 changes: 4 additions & 4 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ class MainWindow : public QMainWindow
void writeDLTMessageToFile(QByteArray &bufferHeader,char*bufferPayload,quint32 bufferPayloadSize,EcuItem* ecuitem,quint32 sec=0,quint32 use=0);

protected:
void keyPressEvent ( QKeyEvent * event );
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void closeEvent(QCloseEvent *event);
void keyPressEvent ( QKeyEvent * event ) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void closeEvent(QCloseEvent *event) override;

private slots:
void reloadLogFileProgressMax(int num);
Expand Down
Loading

0 comments on commit b9aea14

Please sign in to comment.