Skip to content
Open
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
18 changes: 17 additions & 1 deletion src/searchdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ void SearchDialog::findNextClicked()
for(int i=0; i<lineEdits.size();i++)
{
setSearchColour(lineEdits.at(i),result);




}
}

Expand Down Expand Up @@ -569,6 +573,10 @@ void SearchDialog::textEditedFromToolbar(QString newText)

void SearchDialog::on_buttonHighlightColor_clicked()
{




QString color = QDltSettingsManager::getInstance()->value("other/searchResultColor", QString("#00AAFF")).toString();
QColor oldColor(color);
QColor newColor = QColorDialog::getColor(oldColor, this, "Pick color for Search Highlight");
Expand Down Expand Up @@ -659,7 +667,7 @@ void SearchDialog::saveSearchHistory(QStringList& searchHistory) {

void SearchDialog::loadSearchHistoryList(QStringList& searchHistory)
{
//To retrive the search history once DLT Viewer restarts
//To retrive the search history once DLT Viewer restarts
QSettings settings("MyApp", "SearchHistory");
searchHistory.clear();
int size = settings.beginReadArray("history");
Expand All @@ -675,12 +683,15 @@ void SearchDialog::on_checkBoxHeader_toggled(bool checked)
QDltSettingsManager::getInstance()->setValue("other/search/checkBoxHeader", checked);
}



void SearchDialog::on_checkBoxFindAll_toggled(bool checked)
{
QDltSettingsManager::getInstance()->setValue("other/search/checkBoxSearchIndex", checked);
setStartLine(-1);
}


void SearchDialog::on_checkBoxCaseSensitive_toggled(bool checked)
{
QDltSettingsManager::getInstance()->setValue("other/search/checkBoxCasesensitive", checked);
Expand All @@ -692,3 +703,8 @@ void SearchDialog::on_checkBoxRegExp_toggled(bool checked)
}







195 changes: 186 additions & 9 deletions src/searchdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,78 @@ namespace Ui {
class SearchDialog;
}

class SearchDialog : public QDialog {
/**
* @class SearchDialog
* @brief Provides a dialog for searching messages in DLT Viewer.
* * Handles search parameters, search execution, result highlighting, and search history.
*/
class SearchDialog : public QDialog
{

Q_OBJECT

public:

/**
* @brief Constructor for SearchDialog.
* @param parent Parent widget.
*/
explicit SearchDialog(QWidget *parent = nullptr);
/**
* @brief Destructor for SearchDialog.
*/

~SearchDialog();

/**
* @brief Focuses the specified row in the table.
* @param searchLine Row number.
*/
void focusRow(long int searchLine);

/**
* @brief Selects and focuses the search text field.
*/
void selectText();
/**
* @brief Sets the match flag.
* @param matched True if matched.
*/
void setMatch(bool matched);
/**
* @brief Sets the start line for search.
* @param start Line number.
*/
void setStartLine(long int start);
/**
* @brief Sets the once clicked flag.
* @param clicked True if clicked once.
*/
void setOnceClicked(bool clicked);
/**
* @brief Appends a QLineEdit to the list of line edits.
* @param lineEdit Pointer to QLineEdit.
*/
void appendLineEdit(QLineEdit *lineEdit);
/**
* @brief Caches the current search history.
*/
void cacheSearchHistory();
/**
* @brief Clears the cached search history.
*/
void clearCacheHistory();
/**
* @brief Gets the search text.
* @return Search text as QString.
*/
QString getText();

void registerSearchTableModel(SearchTableModel *model);
/**
* @brief foundLine
* @param searchLine
* @return true, if search can be breaked here, false if it should continue
* @brief Registers the search table model.
* @param model Pointer to SearchTableModel.
*/
void registerSearchTableModel(SearchTableModel *model);

QDltFile *file;
QTableView *table;
Expand Down Expand Up @@ -88,55 +137,183 @@ class SearchDialog : public QDialog {

QHash<QString, QList <unsigned long>> cachedHistoryKey;

/**
* @brief Sets the regular expression checkbox state.
* @param regExp True to check, false to uncheck.
*/
void setRegExp(bool regExp);
/**
* @brief Adds a found line to the search index.
* @param searchLine Line number.
*/
void addToSearchIndex(long int searchLine);
/**
* @brief Iterates through messages and finds matches.
* @param searchLine Start line.
* @param searchBorder Border line.
* @param searchTextRegExp Regular expression for search.
*/
void findMessages(long int searchLine, long int searchBorder, QRegularExpression &searchTextRegExp);
/**
* @brief Updates the color button icon.
*/
void updateColorbutton();
/**
* @brief Sets the color of the search box based on result.
* @param lineEdit Pointer to QLineEdit.
* @param result Result code.
*/
void setSearchColour(QLineEdit *lineEdit,int result);
/**
* @brief Sets the header checkbox state.
* @param header True to check, false to uncheck.
*/
void setHeader(bool header);
/**
* @brief Sets the payload checkbox state.
* @param payload True to check, false to uncheck.
*/
void setPayload(bool payload);
/**
* @brief Sets the case sensitivity checkbox state.
* @param caseSensitive True to check, false to uncheck.
*/
void setCaseSensitive(bool caseSensitive);
void setNextClicked(bool next);
/**
* @brief Sets the search direction (next/previous).
* @param next True for next, false for previous.
*/
void setNextClicked(bool next);

/**
* @brief Main function to perform search.
* @return Result code.
*/
int find();

/**
* @brief Checks if search should start from beginning.
* @return True if enabled.
*/
bool getSearchFromBeginning();
/**
* @brief Checks if header search is enabled.
* @return True if enabled.
*/
bool getHeader();
/**
* @brief Checks if payload search is enabled.
* @return True if enabled.
*/
bool getPayload();
/**
* @brief Checks if case sensitive search is enabled.
* @return True if enabled.
*/
bool getCaseSensitive();
/**
* @brief Checks if regular expression search is enabled.
* @return True if enabled.
*/
bool getRegExp();
/**
* @brief Gets the search direction.
* @return True if next, false if previous.
*/
bool getNextClicked();
bool getClicked();

/**
* @brief Checks if search to index is enabled.
* @return True if enabled.
*/

bool searchtoIndex();
/**
* @brief Handles actions when a matching line is found.
* @param searchLine Line number.
* @return True to break search, false to continue.
*/
bool foundLine(long int searchLine);
/**
* @brief Gets the APID text.
* @return APID as QString.
*/
QString getApIDText();
/**
* @brief Gets the CTID text.
* @return CTID as QString.
*/
QString getCtIDText();
/**
* @brief Gets the start timestamp text.
* @return Start timestamp as QString.
*/
QString getTimeStampStart();
/**
* @brief Gets the end timestamp text.
* @return End timestamp as QString.
*/
QString getTimeStampEnd();
QString getPayLoadStampStart();
QString getPayLoadStampEnd();
QList < QList <unsigned long>> m_searchHistory;
QList<QLineEdit*> lineEdits;

private slots:

void on_lineEditSearch_textEdited(QString newText);
void on_buttonHighlightColor_clicked();

void on_checkBoxFindAll_toggled(bool checked);

void on_checkBoxHeader_toggled(bool checked);
/**
* @brief Slot for header checkbox toggled.
* @param checked Checkbox state.
*/

void on_checkBoxHeader_toggled(bool checked);
/**
* @brief Slot for case sensitivity checkbox toggled.
* @param checked Checkbox state.
*/
void on_checkBoxCaseSensitive_toggled(bool checked);

/**
* @brief Slot for regular expression checkbox toggled.
* @param checked Checkbox state.
*/
void on_checkBoxRegExp_toggled(bool checked);

public slots:
/**
* @brief Slot for text edited from toolbar.
* @param newText New text.
*/
void textEditedFromToolbar(QString newText);
/**
* @brief Slot for Find Next action.
*/
void findNextClicked();
/**
* @brief Slot for Find Previous action.
*/
void findPreviousClicked();
/**
* @brief Loads search history from cache.
*/
void loadSearchHistory();
/**
* @brief Aborts the ongoing search.
*/
void abortSearch();
/**
* @brief Saves search history to persistent storage.
* @param searchHistory Reference to QStringList of history.
*/
void saveSearchHistory(QStringList& searchHistory);
/**
* @brief Loads search history from persistent storage.
* @param searchHistory Reference to QStringList to populate.
*/
void loadSearchHistoryList(QStringList& searchHistory);

signals:
Expand Down
Loading