Skip to content

Commit

Permalink
Merge pull request #220 from svlad-90/dev/vladyslav-goncharuk/ISSUE-131
Browse files Browse the repository at this point in the history
[ISSUE #131][SEARCH] Length of search box
  • Loading branch information
svlad-90 authored Nov 13, 2024
2 parents 00d10f8 + b38fb35 commit b9b881b
Show file tree
Hide file tree
Showing 99 changed files with 1,572 additions and 1,089 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ New features in release v.1.0.29:
- [Groups nesting ordering](./md/grouped_view/grouped_view.md#groups-nesting-ordering)
- [Plot legend scrolling](./md/plot_view/plot_view.md#legend-scrolling)
- [Regex group name glossary](./md/search/search.md#regex-group-name-glossary)
- [Regex text editor with the automatic height adjustment](./md/search/search.md#regex-text-editor)

----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class CFiltersModel;
class CFilterItemDelegate;
class CRegexHistoryTextEdit;

class CFiltersView : public QTreeView,
public CSettingsManagerClient
Expand All @@ -22,7 +23,7 @@ class CFiltersView : public QTreeView,

void setSpecificModel( CFiltersModel* pModel );
void highlightInvalidRegex(const QModelIndex &index);
void setRegexInputField(QLineEdit* pRegexInputField);
void setRegexInputField(CRegexHistoryTextEdit* pRegexTextEdit);

protected:
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
Expand Down Expand Up @@ -51,6 +52,6 @@ class CFiltersView : public QTreeView,
bool mbIsVerticalScrollBarVisible;
bool mbResizeOnExpandCollapse;
bool mbSkipFirstUpdateWidth;
QLineEdit* mpRegexInputField;
CRegexHistoryTextEdit* mpRegexTextEdit;
CFilterItemDelegate* mpFilterItemDelegate;
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#include "QLineEdit"
#include "QKeyEvent"
#include "QActionGroup"
#include "QTextEdit"

#include "CFiltersModel.hpp"
#include "components/settings/api/ISettingsManager.hpp"
#include "components/log/api/CLog.hpp"
#include "common/CQtHelper.hpp"
#include "components/regexHistory/api/CRegexHistoryTextEdit.hpp"

#include "CFilterItemDelegate.hpp"
#include "../api/CFiltersView.hpp"
Expand Down Expand Up @@ -64,18 +66,18 @@ CFiltersView::CFiltersView(QWidget *parent):
});
}

void CFiltersView::setRegexInputField(QLineEdit* pRegexInputField)
void CFiltersView::setRegexInputField(CRegexHistoryTextEdit* pRegexTextEdit)
{
mpRegexInputField = pRegexInputField;
mpRegexTextEdit = pRegexTextEdit;
}

void CFiltersView::copySelectedRowToClipboard()
{
QClipboard* pClipboard = QApplication::clipboard();

if(nullptr != pClipboard && nullptr != mpRegexInputField)
if(nullptr != pClipboard && nullptr != mpRegexTextEdit)
{
pClipboard->setText(mpRegexInputField->selectedText());
pClipboard->setText(mpRegexTextEdit->textCursor().selectedText());
}
}

Expand All @@ -86,10 +88,10 @@ void CFiltersView::currentChanged(const QModelIndex &current, const QModelIndex
auto pTreeItem = static_cast<CTreeItem*>(current.internalPointer());

if(nullptr != pTreeItem &&
nullptr != mpRegexInputField)
nullptr != mpRegexTextEdit)
{
auto range = pTreeItem->data(static_cast<int>(eRegexFiltersColumn::Range)).get<tIntRange>();
mpRegexInputField->setSelection(range.from, range.to - range.from + 1);
mpRegexTextEdit->setSelection(range.from, range.to - range.from + 1);
}
}

Expand Down Expand Up @@ -267,9 +269,9 @@ void CFiltersView::keyPressEvent ( QKeyEvent * event )
{
if(true == NShortcuts::isEnter(event))
{
if(nullptr != mpRegexInputField)
if(nullptr != mpRegexTextEdit)
{
mpRegexInputField->setFocus();
mpRegexTextEdit->setFocus();
}
}
else if(true == NShortcuts::isCopyShortcut(event))
Expand Down Expand Up @@ -325,9 +327,9 @@ void CFiltersView::handleSettingsManagerChange()
pAction->setShortcut(QKeySequence(tr("Enter")));
connect(pAction, &QAction::triggered, [this]()
{
if(nullptr != mpRegexInputField)
if(nullptr != mpRegexTextEdit)
{
mpRegexInputField->setFocus();
mpRegexTextEdit->setFocus();
}
});
contextMenu.addAction(pAction);
Expand Down Expand Up @@ -556,6 +558,6 @@ PUML_PACKAGE_BEGIN(DMA_FiltersView_API)
PUML_INHERITANCE_CHECKED(CSettingsManagerClient, extends)
PUML_COMPOSITION_DEPENDENCY_CHECKED(CFilterItemDelegate, 1, 1, contains)
PUML_AGGREGATION_DEPENDENCY_CHECKED(CFiltersModel, 1, 1, uses)
PUML_AGGREGATION_DEPENDENCY_CHECKED(QLineEdit, 1, 1, regex input field)
PUML_AGGREGATION_DEPENDENCY_CHECKED(CRegexHistoryTextEdit, 1, 1, regex input field)
PUML_CLASS_END()
PUML_PACKAGE_END()
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "components/settings/api/ISettingsManager.hpp"
#include "components/analyzer/api/IDLTMessageAnalyzerController.hpp"
#include "components/regexHistory/api/IRegexHistoryProvider.hpp"
#include "components/regexHistory/api/CRegexHistoryLineEdit.hpp"
#include "components/regexHistory/api/CRegexHistoryTextEdit.hpp"

class CPatternsView;

Expand All @@ -36,7 +36,7 @@ class CRegexHistoryComponent : public DMA::IComponent
* @param pDLTMessageAnalyzerController Shared pointer to the DLT message analyzer controller.
*/
CRegexHistoryComponent( const tSettingsManagerPtr& pSettingsManager,
CRegexHistoryLineEdit* pRegexHistoryLineEdit,
CRegexHistoryTextEdit* pRegexHistoryLineEdit,
CPatternsView* pPatternsView,
const tDLTMessageAnalyzerControllerPtr& pDLTMessageAnalyzerController);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#pragma once

#include "QTextEdit"
#include "QKeyEvent"
#include "QWidget"

#include "components/settings/api/CSettingsManagerClient.hpp"

class QCompleter;

#include "components/regexHistory/api/IRegexHistoryProvider.hpp"

/**
* @brief A custom QTextEdit with regex history support.
*
* This class extends QTextEdit to include features for managing regex history
* and handling specific key events.
*/
class CRegexHistoryTextEdit : public QTextEdit,
public CSettingsManagerClient
{
Q_OBJECT

public:

/**
* @brief Constructs a CRegexHistoryTextEdit object.
*
* @param parent The parent widget for the text edit. Defaults to nullptr.
*/
explicit CRegexHistoryTextEdit(QWidget *parent = nullptr);

/**
* @brief Sets the regex history provider.
*
* This method associates a regex history provider.
*
* @param pRegexHistoryProviderPtr Shared pointer to the regex history provider.
*/
void setRegexHistoryProvider(const tRegexHistoryProviderPtr& pRegexHistoryProviderPtr);

/**
* @brief Sets whether to ignore return key events.
*
* This method allows control over whether the line edit should handle
* return (Enter) key events or ignore them.
*
* @param val True to ignore return key events, false otherwise.
*/
void setIgnoreReturnKeyEvent(bool val);

/**
* @brief Checks whether return key events are ignored.
*
* This method returns whether the line edit is currently set to ignore
* return key events.
*
* @return bool True if return key events are ignored, false otherwise.
*/
bool getIgnoreReturnKeyEvent() const;

/**
* @brief Activates regex history.
*
* This method activates the regex history.
*/
void activateRegexHistory();

/**
* @brief Sets the completer for the text edit.
*
* This method allows setting a QCompleter to provide text completions.
*
* @param pCompleter Pointer to the QCompleter instance.
*/
void setCompleter(QCompleter* pCompleter);

/**
* @brief Gets the current completer.
*
* This method returns the current QCompleter instance used by the text edit.
*
* @return QCompleter* Pointer to the current QCompleter.
*/
QCompleter *completer() const;

/**
* @brief Sets the selection range within the text.
*
* This method allows setting a selection starting at a given position with
* a specified length.
*
* @param start The starting position of the selection.
* @param length The length of the selection.
*/
void setSelection(int start, int length);

signals:
/**
* @brief Signal emitted when the return key is pressed.
*/
void returnPressed();

private slots:
void insertCompletion(const QString &completion);

protected:
void insertFromMimeData(const QMimeData *source) override;
void resizeEvent(QResizeEvent *event) override;
virtual void focusInEvent(QFocusEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void handleSettingsManagerChange() override;

private:
QString textUnderCursor() const;
void adjustHeightToContent();

private:
tRegexHistoryProviderPtr mpRegexHistoryProvider;
bool mbIgnoreReturnKeyEvent;
QCompleter* mpCompleter;
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
set(WRAP_SRC ../api/IRegexHistoryProvider.hpp
CRegexHistoryProvider.hpp
../api/CRegexHistoryLineEdit.hpp)
../api/CRegexHistoryTextEdit.hpp)

DMA_qt_wrap_cpp(PROCESSED_MOCS WRAP_SRC)

add_library(DMA_regexHistory STATIC
CRegexHistoryComponent.cpp
CRegexHistoryProvider.cpp
IRegexHistoryProvider.cpp
CRegexHistoryLineEdit.cpp
CRegexHistoryTextEdit.cpp
${PROCESSED_MOCS})

target_link_libraries( DMA_regexHistory PUBLIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "dma/base/ForceLink.hpp"

CRegexHistoryComponent::CRegexHistoryComponent( const tSettingsManagerPtr& pSettingsManager,
CRegexHistoryLineEdit* pRegexHistoryLineEdit, CPatternsView* pPatternsView,
CRegexHistoryTextEdit* pRegexHistoryLineEdit, CPatternsView* pPatternsView,
const tDLTMessageAnalyzerControllerPtr& pDLTMessageAnalyzerController ):
mpRegexHistoryProvider(std::make_shared<CRegexHistoryProvider>(pSettingsManager,
pRegexHistoryLineEdit,
Expand All @@ -21,6 +21,7 @@ mpRegexHistoryProvider(std::make_shared<CRegexHistoryProvider>(pSettingsManager,
if(nullptr != pRegexHistoryLineEdit)
{
pRegexHistoryLineEdit->setRegexHistoryProvider(mpRegexHistoryProvider);
pRegexHistoryLineEdit->setSettingsManager(pSettingsManager);
}
}

Expand Down Expand Up @@ -76,7 +77,7 @@ PUML_PACKAGE_BEGIN(DMA_RegexHistory_API)
PUML_INHERITANCE_CHECKED(DMA::IComponent, implements)
PUML_AGGREGATION_DEPENDENCY_CHECKED(CPatternsView, 1, 1, uses)
PUML_USE_DEPENDENCY_CHECKED(ISettingsManager, 1, 1, passes)
PUML_USE_DEPENDENCY_CHECKED(CRegexHistoryLineEdit, 1, 1, passes)
PUML_USE_DEPENDENCY_CHECKED(CRegexHistoryTextEdit, 1, 1, passes)
PUML_USE_DEPENDENCY_CHECKED(IDLTMessageAnalyzerController, 1, 1, passes)
PUML_COMPOSITION_DEPENDENCY_CHECKED(CRegexHistoryProvider, 1, 1, creates)
PUML_CLASS_END()
Expand Down
Loading

0 comments on commit b9b881b

Please sign in to comment.