Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some vars and code to SearchForm from MainWindow #607

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
* Must be a "C" include to interpret the imports correctly
* for MSVC compilers.
**/
#include "dlt_common.h"
extern "C" {

#include "dlt_user.h"
}

Expand Down Expand Up @@ -200,8 +198,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionProject->setChecked(ui->dockWidgetContents->isVisible());
ui->actionSearch_Results->setChecked(ui->dockWidgetSearchIndex->isVisible());

newCompleter = new QCompleter(&m_CompleterModel,this);

/* what for do we need the next 2 lines ? */
draw_timer.setSingleShot (true);
connect(&draw_timer, SIGNAL(timeout()), this, SLOT(draw_timeout()));
Expand Down Expand Up @@ -278,7 +274,6 @@ MainWindow::~MainWindow()
delete dltIndexer;
delete m_shortcut_searchnext;
delete m_shortcut_searchprev;
delete newCompleter;
delete sortProxyModel;
}

Expand Down Expand Up @@ -2384,21 +2379,15 @@ void MainWindow::on_action_menuFile_Quit_triggered()

void MainWindow::on_actionFindNext()
{
//qDebug() << "on_actionFindNext" << __LINE__;
if(!searchInput->input()->text().isEmpty() && !list.contains(searchInput->input()->text()))
{
list.append(searchInput->input()->text());
}
QString title = "Search Results";
searchInput->updateHistory();

QString title = "Search Results";
if ( 0 < m_searchtableModel->get_SearchResultListSize())
{
title = QString("Search Results: %L1").arg(m_searchtableModel->get_SearchResultListSize());
title += QStringLiteral(": %L1").arg(m_searchtableModel->get_SearchResultListSize());
}
ui->dockWidgetSearchIndex->setWindowTitle(title);
ui->dockWidgetSearchIndex->show();
m_CompleterModel.setStringList(list);
searchInput->input()->setCompleter(newCompleter);
}

void MainWindow::on_action_menuProject_New_triggered()
Expand Down Expand Up @@ -4488,6 +4477,7 @@ void MainWindow::controlMessage_ReceiveControlMessage(EcuItem *ecuitem, const QD
versionString(msg);
autoloadPluginsVersionEcus.append(msg.getEcuid());
}
break;
}
case DLT_SERVICE_ID_GET_LOG_INFO:
{
Expand Down Expand Up @@ -7871,8 +7861,6 @@ void MainWindow::on_actionJump_To_triggered()
}

jump_to_line(dlg.getIndex());


}


Expand Down Expand Up @@ -8235,18 +8223,10 @@ void MainWindow::on_actionDefault_Filter_Reload_triggered()
/* load the default filter list */
defaultFilter.load(dir.absolutePath());

QStringList completerList;

/* default filter list update combobox */
QDltFilterList *filterList;
foreach(filterList,defaultFilter.defaultFilterList){
// default filter list update combobox
for (const auto *filterList : defaultFilter.defaultFilterList) {
ui->comboBoxFilterSelection->addItem(filterList->getFilename());
completerList << filterList->getFilename();
}
//QCompleter *completer = new QCompleter(completerList, this);
//completer->setFilterMode(Qt::MatchContains);
//completer->setCaseSensitivity(Qt::CaseInsensitive);
//ui->comboBoxFilterSelection->setCompleter(completer);
}

void MainWindow::on_actionDefault_Filter_Create_Index_triggered()
Expand Down
14 changes: 0 additions & 14 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <QColor>
#include <QComboBox>
#include <QProgressBar>
#include <QCompleter>
#include <QStringListModel>

#include "tablemodel.h"
#include "settingsdialog.h"
Expand All @@ -43,14 +41,6 @@
#include "ui_mainwindow.h"
#include "searchform.h"


/**
* When ecu items buffer size exceeds this while using
* serial connection, it will be considered corrupted.
**/

#define DLT_BUFFER_CORRUPT_TRESHOLD 4* 1024

/**
* @brief Namespace to contain the toolbar positions.
* You should always remember to update these enums if you
Expand Down Expand Up @@ -116,7 +106,6 @@ class MainWindow : public QMainWindow

private:
Ui::MainWindow *ui;
QCompleter *newCompleter;
/* Timer for connecting to ECUs */
QTimer timer;

Expand Down Expand Up @@ -374,8 +363,6 @@ class MainWindow : public QMainWindow
/* default filters */
void resetDefaultFilter();

QStringListModel m_CompleterModel;

/* Get path from explorerView model index */
QString getPathFromExplorerViewIndexModel(const QModelIndex &proxyIndex);

Expand Down Expand Up @@ -626,7 +613,6 @@ public slots:
QDltDefaultFilter defaultFilter;

QStringList openFileNames;
QStringList list;

/* store startLoggingDateTime when logging first data */
QDateTime startLoggingDateTime;
Expand Down
12 changes: 12 additions & 0 deletions src/searchform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui_searchform.h"

#include <QLineEdit>
#include <QCompleter>

SearchForm::SearchForm(QWidget *parent)
: QWidget(parent)
Expand All @@ -12,6 +13,9 @@ SearchForm::SearchForm(QWidget *parent)
ui->comboBox->setLineEdit(new QLineEdit);
ui->comboBox->setInsertPolicy(QComboBox::InsertAtTop);

m_completer = new QCompleter(&m_historyModel, this);
input()->setCompleter(m_completer);

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

Expand Down Expand Up @@ -46,3 +50,11 @@ void SearchForm::resetProgress()
{
setProgress(0);
}

void SearchForm::updateHistory() {
if (auto list = m_historyModel.stringList();
!input()->text().isEmpty() && !list.contains(input()->text())) {
list.append(input()->text());
m_historyModel.setStringList(std::move(list));
}
}
6 changes: 6 additions & 0 deletions src/searchform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#define SEARCHFORM_H

#include <QWidget>
#include <QStringListModel>

namespace Ui {
class SearchForm;
}

class QLineEdit;
class QCompleter;

class SearchForm : public QWidget
{
Expand All @@ -27,12 +29,16 @@ class SearchForm : public QWidget
void setState(State state);
void setProgress(int val);
void resetProgress();
void updateHistory();

signals:
void abortSearch();

private:
Ui::SearchForm *ui;

QCompleter *m_completer{nullptr};
QStringListModel m_historyModel;
};

#endif // SEARCHFORM_H