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 Sep 11, 2024
2 parents f91601c + 81a8ef8 commit d863f40
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 30 deletions.
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ add_executable(dlt-viewer
dltfileindexerdefaultfilterthread.cpp
mcudpsocket.cpp
sortfilterproxymodel.cpp
searchform.h
searchform.cpp
${UI_RESOURCES_RCC}
resources/dlt_viewer.rc)
resources/dlt_viewer.rc
)

target_link_libraries(dlt-viewer
qdlt
Expand Down
40 changes: 24 additions & 16 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,26 +509,25 @@ void MainWindow::initView()
statusBar()->addWidget(statusProgressBar);

/* Create search text box */
searchTextbox = new QLineEdit();
searchDlg->appendLineEdit(searchTextbox);
searchInput = new SearchForm;
connect(searchInput, &SearchForm::abortSearch, searchDlg, &SearchDialog::abortSearch);
searchDlg->appendLineEdit(searchInput->input());

connect(searchTextbox, SIGNAL(textChanged(QString)),searchDlg,SLOT(textEditedFromToolbar(QString)));
connect(searchTextbox, SIGNAL(returnPressed()), this, SLOT(on_actionFindNext()));
connect(searchTextbox, SIGNAL(returnPressed()),searchDlg,SLOT(findNextClicked()));
connect(searchInput->input(), SIGNAL(textChanged(QString)),searchDlg,SLOT(textEditedFromToolbar(QString)));
connect(searchInput->input(), SIGNAL(returnPressed()), this, SLOT(on_actionFindNext()));
connect(searchInput->input(), SIGNAL(returnPressed()),searchDlg,SLOT(findNextClicked()));
connect(searchDlg, SIGNAL(searchProgressChanged(bool)), this, SLOT(onSearchProgressChanged(bool)));
connect(searchDlg, &SearchDialog::searchProgressValueChanged, this, [this](int progress){
searchInput->setProgress(progress);
});
connect(settingsDlg, SIGNAL(FilterPathChanged()), this, SLOT(on_actionDefault_Filter_Reload_triggered()));
connect(settingsDlg, SIGNAL(PluginsAutoloadChanged()), this, SLOT(triggerPluginsAutoload()));

QAction *focusSearchTextbox = new QAction(this);
focusSearchTextbox->setShortcut(Qt::Key_L | Qt::CTRL);
connect(focusSearchTextbox, SIGNAL(triggered()), searchTextbox, SLOT(setFocus()));
connect(focusSearchTextbox, SIGNAL(triggered()), searchInput->input(), SLOT(setFocus()));
addAction(focusSearchTextbox);

searchComboBox = new QComboBox();
searchComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
searchComboBox->setLineEdit(searchTextbox);
searchComboBox->setInsertPolicy(QComboBox::InsertAtTop);

/* Initialize toolbars. Most of the construction and connection is done via the
* UI file. See mainwindow.ui, ActionEditor and Signal & Slots editor */
QList<QAction *> mainActions = ui->mainToolBar->actions();
Expand Down Expand Up @@ -581,8 +580,9 @@ void MainWindow::initSignalConnections()
connect(searchDlg,SIGNAL(addActionHistory()),this,SLOT(onAddActionToHistory()));

/* Insert search text box to search toolbar, before previous button */

QAction *before = m_searchActions.at(ToolbarPosition::FindPrevious);
ui->searchToolbar->insertWidget(before, searchComboBox);
ui->searchToolbar->insertWidget(before, searchInput);

/* adding shortcuts - regard: in the search window, the signal is caught by another way, this here only catches the keys when main window is active */
m_shortcut_searchnext = new QShortcut(QKeySequence("F3"), this);
Expand Down Expand Up @@ -2372,9 +2372,9 @@ void MainWindow::on_action_menuFile_Quit_triggered()
void MainWindow::on_actionFindNext()
{
//qDebug() << "on_actionFindNext" << __LINE__;
if(!searchTextbox->text().isEmpty() && !list.contains(searchTextbox->text()))
if(!searchInput->input()->text().isEmpty() && !list.contains(searchInput->input()->text()))
{
list.append(searchTextbox->text());
list.append(searchInput->input()->text());
}
QString title = "Search Results";

Expand All @@ -2385,7 +2385,7 @@ void MainWindow::on_actionFindNext()
ui->dockWidgetSearchIndex->setWindowTitle(title);
ui->dockWidgetSearchIndex->show();
m_CompleterModel.setStringList(list);
searchTextbox->setCompleter(newCompleter);
searchInput->input()->setCompleter(newCompleter);
}

void MainWindow::on_action_menuProject_New_triggered()
Expand Down Expand Up @@ -8411,7 +8411,15 @@ void MainWindow::onSearchProgressChanged(bool isInProgress)
isSearchOngoing = isInProgress;
ui->menuBar->setEnabled(!isInProgress);
ui->mainToolBar->setEnabled(!isInProgress);
ui->searchToolbar->setEnabled(!isInProgress);
if(!isInProgress)
searchInput->resetProgress();

ui->actionFindNext->setEnabled(!isInProgress);
ui->actionFindPrevious->setEnabled(!isInProgress);
ui->actionFind->setEnabled(!isInProgress);
ui->actionRegExp->setEnabled(!isInProgress);
searchInput->setState(isInProgress ? SearchForm::State::PROGRESS : SearchForm::State::INPUT);

ui->dockWidgetProject->setEnabled(!isInProgress);
}

Expand Down
4 changes: 2 additions & 2 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "searchtablemodel.h"
#include "sortfilterproxymodel.h"
#include "ui_mainwindow.h"
#include "searchform.h"


/**
Expand Down Expand Up @@ -148,15 +149,14 @@ class MainWindow : public QMainWindow
SearchDialog *searchDlg;
QShortcut *m_shortcut_searchnext;
QShortcut *m_shortcut_searchprev;
SearchForm* searchInput;

/* Export */
ExporterDialog exporterDialog;

/* Settings dialog containing also the settings parameter itself */
SettingsDialog *settingsDlg;
QDltSettingsManager *settings;
QLineEdit *searchTextbox;
QComboBox *searchComboBox;

/* injections */
QString injectionAplicationId;
Expand Down
23 changes: 12 additions & 11 deletions src/searchdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ void SearchDialog::appendLineEdit(QLineEdit *lineEdit){ lineEdits->append(lineEd

QString SearchDialog::getText() { return ui->lineEditText->text(); }

void SearchDialog::abortSearch()
{
isSearchCancelled = true;
}

bool SearchDialog::getHeader()
{
return (ui->checkBoxHeader->checkState() == Qt::Checked);
Expand Down Expand Up @@ -189,6 +194,8 @@ void SearchDialog::focusRow(long int searchLine)

int SearchDialog::find()
{
isSearchCancelled = false;

emit addActionHistory();
QRegularExpression searchTextRegExpression;
is_TimeStampSearchSelected = false;
Expand Down Expand Up @@ -371,11 +378,6 @@ void SearchDialog::findMessages(long int searchLine, long int searchBorder, QReg

m_searchtablemodel->clear_SearchResults();

QProgressDialog fileprogress("Searching...", "Abort", 0, file->sizeFilter(), this);
fileprogress.setWindowTitle("DLT Viewer");
fileprogress.setWindowModality(Qt::NonModal);
fileprogress.show();

bool msgIdEnabled=QDltSettingsManager::getInstance()->value("startup/showMsgId", true).toBool();
QString msgIdFormat=QDltSettingsManager::getInstance()->value("startup/msgIdFormat", "0x%x").toString();

Expand Down Expand Up @@ -413,15 +415,14 @@ void SearchDialog::findMessages(long int searchLine, long int searchBorder, QReg
}
}

/* Update progress every 0.5% */
if(searchLine%1000==0)
// Update progress every 0.5%
if(searchLine%1000 == 0)
{
fileprogress.setValue(ctr);
if(fileprogress.wasCanceled())
{
QApplication::processEvents();
if (isSearchCancelled) {
break;
}
QApplication::processEvents();
emit searchProgressValueChanged(static_cast<int>(ctr * 100.0 / file->sizeFilter()));
}

/* get the message with the selected item id */
Expand Down
4 changes: 4 additions & 0 deletions src/searchdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class SearchDialog : public QDialog
Ui::SearchDialog *ui;
SearchTableModel *m_searchtablemodel;

bool isSearchCancelled{false};

long int startLine;
long searchseconds;
bool nextClicked;
Expand Down Expand Up @@ -155,11 +157,13 @@ public slots:
void findNextClicked();
void findPreviousClicked();
void loadSearchHistory();
void abortSearch();

signals:
void refreshedSearchIndex();
void addActionHistory();
void searchProgressChanged(bool isInProgress);
void searchProgressValueChanged(int progress);
};

#endif // SEARCHDIALOG_H
48 changes: 48 additions & 0 deletions src/searchform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "searchform.h"
#include "ui_searchform.h"

#include <QLineEdit>

SearchForm::SearchForm(QWidget *parent)
: QWidget(parent)
, ui(new Ui::SearchForm)
{
ui->setupUi(this);

ui->comboBox->setLineEdit(new QLineEdit);
ui->comboBox->setInsertPolicy(QComboBox::InsertAtTop);

connect (ui->abortButton, &QPushButton::clicked, this, &SearchForm::abortSearch);
}

SearchForm::~SearchForm()
{
delete ui;
}

QLineEdit *SearchForm::input() const
{
return ui->comboBox->lineEdit();
}

void SearchForm::setState(State state)
{
switch(state) {
case State::INPUT:
ui->stackedWidget->setCurrentIndex(0);
break;
case State::PROGRESS:
ui->stackedWidget->setCurrentIndex(1);
break;
}
}

void SearchForm::setProgress(int val)
{
ui->progressBar->setValue(val);
}

void SearchForm::resetProgress()
{
setProgress(0);
}
38 changes: 38 additions & 0 deletions src/searchform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef SEARCHFORM_H
#define SEARCHFORM_H

#include <QWidget>

namespace Ui {
class SearchForm;
}

class QLineEdit;

class SearchForm : public QWidget
{
Q_OBJECT

public:
enum class State {
INPUT,
PROGRESS
};

explicit SearchForm(QWidget *parent = nullptr);
~SearchForm();

QLineEdit* input() const;

void setState(State state);
void setProgress(int val);
void resetProgress();

signals:
void abortSearch();

private:
Ui::SearchForm *ui;
};

#endif // SEARCHFORM_H
81 changes: 81 additions & 0 deletions src/searchform.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SearchForm</class>
<widget class="QWidget" name="SearchForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>260</width>
<height>40</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="abortButton">
<property name="text">
<string>Abort</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
3 changes: 3 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ SOURCES += main.cpp \
settingsdialog.cpp \
injectiondialog.cpp \
searchdialog.cpp \
searchform.cpp \
multiplecontextdialog.cpp \
sortfilterproxymodel.cpp \
tablemodel.cpp \
Expand Down Expand Up @@ -161,6 +162,7 @@ HEADERS += mainwindow.h \
settingsdialog.h \
injectiondialog.h \
searchdialog.h \
searchform.h \
sortfilterproxymodel.h \
version.h \
multiplecontextdialog.h \
Expand Down Expand Up @@ -189,6 +191,7 @@ FORMS += mainwindow.ui \
contextdialog.ui \
filterdialog.ui \
plugindialog.ui \
searchform.ui \
settingsdialog.ui \
injectiondialog.ui \
searchdialog.ui \
Expand Down

0 comments on commit d863f40

Please sign in to comment.