From e7aa167910b3f884f616b853c7aea8b1cf9709ee Mon Sep 17 00:00:00 2001 From: Vladyslav Goncharuk Date: Wed, 5 Jun 2024 13:49:40 +0300 Subject: [PATCH] [ISSUE #191][GROUPED_VIEW] Seeting to turn off the "Grouped view" - Implement feature to turn off grouped view to allow minimization of the RAM consumption in corner cases Signed-off-by: Vladyslav Goncharuk --- .../src/common/Definitions.hpp | 2 - .../IDLTMessageAnalyzerControllerConsumer.hpp | 6 +- .../IDLTMessageAnalyzerControllerConsumer.cpp | 16 ++++- .../searchView/src/CSearchResultView.cpp | 5 ++ .../settings/api/ISettingsManager.hpp | 3 + .../settings/src/CSettingsManager.cpp | 19 ++++- .../settings/src/CSettingsManager.hpp | 5 ++ .../src/plugin/src/CDLTMessageAnalyzer.cpp | 16 ++++- .../src/plugin/src/form.cpp | 71 ++++++++++++++++++- 9 files changed, 130 insertions(+), 13 deletions(-) diff --git a/dltmessageanalyzerplugin/src/common/Definitions.hpp b/dltmessageanalyzerplugin/src/common/Definitions.hpp index d4225f8e..d7db9264 100644 --- a/dltmessageanalyzerplugin/src/common/Definitions.hpp +++ b/dltmessageanalyzerplugin/src/common/Definitions.hpp @@ -86,8 +86,6 @@ typedef std::shared_ptr tPatternsModelPtr; extern const QString sDefaultStatusText; extern const QString sDefaultRegexFileName; - - typedef int tMsgId; extern const tMsgId INVALID_MSG_ID; diff --git a/dltmessageanalyzerplugin/src/components/analyzer/api/IDLTMessageAnalyzerControllerConsumer.hpp b/dltmessageanalyzerplugin/src/components/analyzer/api/IDLTMessageAnalyzerControllerConsumer.hpp index d91ee4e8..faaa9f5c 100644 --- a/dltmessageanalyzerplugin/src/components/analyzer/api/IDLTMessageAnalyzerControllerConsumer.hpp +++ b/dltmessageanalyzerplugin/src/components/analyzer/api/IDLTMessageAnalyzerControllerConsumer.hpp @@ -35,12 +35,16 @@ public slots: IDLTMessageAnalyzerControllerConsumer( const std::weak_ptr& pController ); tRequestId requestAnalyze( const tRequestParameters& requestParameters, bool bUMLFeatureActive, - bool bPlotViewFeatureActive ); + bool bPlotViewFeatureActive, + bool bGroupedViewFeatureActive ); void cancelRequest( const tRequestId& requestId ); + bool isGroupedViewFeatureActiveForCurrentAnalysis() const; protected: // fields std::weak_ptr mpController; +private: // fields + bool mbGroupedViewFeatureActiveForCurrentAnalysis; }; typedef std::shared_ptr tDLTMessageAnalyzerControllerConsumerPtr; diff --git a/dltmessageanalyzerplugin/src/components/analyzer/src/IDLTMessageAnalyzerControllerConsumer.cpp b/dltmessageanalyzerplugin/src/components/analyzer/src/IDLTMessageAnalyzerControllerConsumer.cpp index 3f4c6be0..4bbd5e9d 100644 --- a/dltmessageanalyzerplugin/src/components/analyzer/src/IDLTMessageAnalyzerControllerConsumer.cpp +++ b/dltmessageanalyzerplugin/src/components/analyzer/src/IDLTMessageAnalyzerControllerConsumer.cpp @@ -20,14 +20,16 @@ IDLTMessageAnalyzerControllerConsumer::~IDLTMessageAnalyzerControllerConsumer() IDLTMessageAnalyzerControllerConsumer::IDLTMessageAnalyzerControllerConsumer( const std::weak_ptr& pController ): std::enable_shared_from_this(), - mpController(pController) + mpController(pController), + mbGroupedViewFeatureActiveForCurrentAnalysis(false) { } tRequestId IDLTMessageAnalyzerControllerConsumer::requestAnalyze( const tRequestParameters& requestParameters, bool bUMLFeatureActive, - bool bPlotViewFeatureActive ) + bool bPlotViewFeatureActive, + bool bGroupedViewFeatureActive ) { tRequestId requestId = INVALID_REQUEST_ID; @@ -35,7 +37,9 @@ tRequestId IDLTMessageAnalyzerControllerConsumer::requestAnalyze( const tRequest { tRegexScriptingMetadata regexMetadata; - bool bParseResult = regexMetadata.parse(requestParameters.regex, bUMLFeatureActive, bPlotViewFeatureActive); + bool bParseResult = regexMetadata.parse(requestParameters.regex, + bUMLFeatureActive, + bPlotViewFeatureActive); if(false == bParseResult) { @@ -71,11 +75,17 @@ tRequestId IDLTMessageAnalyzerControllerConsumer::requestAnalyze( const tRequest } requestId = mpController.lock()->requestAnalyze(shared_from_this(), requestParameters, regexMetadata); + mbGroupedViewFeatureActiveForCurrentAnalysis = bGroupedViewFeatureActive; } return requestId; } +bool IDLTMessageAnalyzerControllerConsumer::isGroupedViewFeatureActiveForCurrentAnalysis() const +{ + return mbGroupedViewFeatureActiveForCurrentAnalysis; +} + void IDLTMessageAnalyzerControllerConsumer::cancelRequest( const tRequestId& requestId ) { if(false == mpController.expired()) diff --git a/dltmessageanalyzerplugin/src/components/searchView/src/CSearchResultView.cpp b/dltmessageanalyzerplugin/src/components/searchView/src/CSearchResultView.cpp index 7491bcb1..400eb4c6 100644 --- a/dltmessageanalyzerplugin/src/components/searchView/src/CSearchResultView.cpp +++ b/dltmessageanalyzerplugin/src/components/searchView/src/CSearchResultView.cpp @@ -1791,6 +1791,11 @@ void CSearchResultView::handleSettingsManagerChange() forceUpdateWidthAndResetContentMap(); }); + connect( getSettingsManager().get(), &ISettingsManager::groupedViewFeatureActiveChanged, this, [this]() + { + restartSearch(); + }); + connect( getSettingsManager().get(), &ISettingsManager::UML_FeatureActiveChanged, this, [this]() { restartSearch(); diff --git a/dltmessageanalyzerplugin/src/components/settings/api/ISettingsManager.hpp b/dltmessageanalyzerplugin/src/components/settings/api/ISettingsManager.hpp index a488281d..4c8cce85 100644 --- a/dltmessageanalyzerplugin/src/components/settings/api/ISettingsManager.hpp +++ b/dltmessageanalyzerplugin/src/components/settings/api/ISettingsManager.hpp @@ -131,6 +131,7 @@ class ISettingsManager : public QObject virtual void setJavaPathMode(const int& val) = 0; virtual void setJavaPathEnvVar(const QString& val) = 0; virtual void setJavaCustomPath(const QString& val) = 0; + virtual void setGroupedViewFeatureActive(bool val) = 0; /** * @brief setSelectedRegexFile - updates selected regex file @@ -195,6 +196,7 @@ class ISettingsManager : public QObject virtual const int& getJavaPathMode() const = 0; virtual const QString& getJavaPathEnvVar() const = 0; virtual const QString& getJavaCustomPath() const = 0; + virtual const bool& getGroupedViewFeatureActive() const = 0; // allowed ranges virtual const TOptional>& getSetting_NumberOfThreads_AllowedRange() const = 0; @@ -259,4 +261,5 @@ class ISettingsManager : public QObject void javaPathModeChanged(const int& plantumlPathMode); void javaPathEnvVarChanged(const QString& plantumlPathEnvVar); void javaCustomPathChanged(const QString& plantumlPathEnvVar); + void groupedViewFeatureActiveChanged(const bool& groupedViewFeatureActive); }; diff --git a/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.cpp b/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.cpp index 823c6954..c2063850 100644 --- a/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.cpp +++ b/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.cpp @@ -84,6 +84,8 @@ static const QString sJavaPathMode = "JavaPathMode"; static const QString sJavaPathEnvVar = "JavaPathEnvVar"; static const QString sJavaCustomPath = "JavaCustomPath"; +static const QString sGroupedViewFeatureActive = "GroupedViewFeatureActive"; + static const tSettingsManagerVersion sDefaultSettingsManagerVersion = static_cast(-1); static const tSettingsManagerVersion sCurrentSettingsManagerVersion = 1u; // current version of settings manager used by SW. @@ -460,6 +462,10 @@ CSettingsManager::CSettingsManager(): [this](const QString& data){javaCustomPathChanged(data);}, [this](){tryStoreSettingsConfig();}, "")), + mSetting_GroupedViewFeatureActive(createBooleanSettingsItem(sGroupedViewFeatureActive, + [this](const bool& data){groupedViewFeatureActiveChanged(data);}, + [this](){tryStoreSettingsConfig();}, + true)), mRootSettingItemPtrVec(), mUserSettingItemPtrVec(), mPatternsSettingItemPtrVec(), @@ -484,7 +490,7 @@ CSettingsManager::CSettingsManager(): mUserSettingItemPtrVec.push_back(&mSetting_SearchResultHighlightingGradient); mUserSettingItemPtrVec.push_back(&mSetting_SearchResultColumnsVisibilityMap); mUserSettingItemPtrVec.push_back(&mSetting_SearchResultColumnsCopyPasteMap); - mUserSettingItemPtrVec.push_back(&mSetting_SearchResultColumnsSearchMap); + mUserSettingItemPtrVec.push_back(&mSetting_SearchResultColumnsSearchMap); mUserSettingItemPtrVec.push_back(&mSetting_MarkTimeStampWithBold); mUserSettingItemPtrVec.push_back(&mSetting_PatternsColumnsVisibilityMap); mUserSettingItemPtrVec.push_back(&mSetting_PatternsColumnsCopyPasteMap); @@ -514,6 +520,7 @@ CSettingsManager::CSettingsManager(): mUserSettingItemPtrVec.push_back(&mSetting_JavaPathMode); mUserSettingItemPtrVec.push_back(&mSetting_JavaPathEnvVar); mUserSettingItemPtrVec.push_back(&mSetting_JavaCustomPath); + mUserSettingItemPtrVec.push_back(&mSetting_GroupedViewFeatureActive); /////////////// PATTERNS SETTINGS /////////////// mPatternsSettingItemPtrVec.push_back(&mSetting_Aliases); @@ -1674,6 +1681,11 @@ void CSettingsManager::setJavaCustomPath(const QString& val) mSetting_JavaCustomPath.setData(val); } +void CSettingsManager::setGroupedViewFeatureActive(bool val) +{ + mSetting_GroupedViewFeatureActive.setData(val); +} + void CSettingsManager::setSelectedRegexFile(const QString& val) { mSetting_SelectedRegexFile.setData(val); @@ -1917,6 +1929,11 @@ const QString& CSettingsManager::getJavaCustomPath() const return mSetting_JavaCustomPath.getData(); } +const bool& CSettingsManager::getGroupedViewFeatureActive() const +{ + return mSetting_GroupedViewFeatureActive.getData(); +} + QString CSettingsManager::getRegexDirectory() const { return sSettingsManager_Directory + QDir::separator() + diff --git a/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.hpp b/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.hpp index 4bcc0441..24535752 100644 --- a/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.hpp +++ b/dltmessageanalyzerplugin/src/components/settings/src/CSettingsManager.hpp @@ -101,6 +101,7 @@ class CSettingsManager : public ISettingsManager void setJavaPathMode(const int& val) override; void setJavaPathEnvVar(const QString& val) override; void setJavaCustomPath(const QString& val) override; + void setGroupedViewFeatureActive(bool val) override; void setSelectedRegexFile(const QString& val) override; @@ -160,6 +161,7 @@ class CSettingsManager : public ISettingsManager const int& getJavaPathMode() const override; const QString& getJavaPathEnvVar() const override; const QString& getJavaCustomPath() const override; + const bool& getGroupedViewFeatureActive() const override; // allowed ranges const TRangedSettingItem::tOptionalAllowedRange& getSetting_NumberOfThreads_AllowedRange() const override; @@ -454,6 +456,9 @@ class CSettingsManager : public ISettingsManager TSettingItem mSetting_JavaPathEnvVar; TSettingItem mSetting_JavaCustomPath; + // Grouped view settings + TSettingItem mSetting_GroupedViewFeatureActive; + typedef ISettingItem* tSettingItemPtr; typedef std::vector tSettingItemsPtrVec; diff --git a/dltmessageanalyzerplugin/src/plugin/src/CDLTMessageAnalyzer.cpp b/dltmessageanalyzerplugin/src/plugin/src/CDLTMessageAnalyzer.cpp index 906926d3..50e5501c 100644 --- a/dltmessageanalyzerplugin/src/plugin/src/CDLTMessageAnalyzer.cpp +++ b/dltmessageanalyzerplugin/src/plugin/src/CDLTMessageAnalyzer.cpp @@ -940,7 +940,8 @@ bool CDLTMessageAnalyzer::analyze() auto requestId = requestAnalyze( requestParameters, getSettingsManager()->getUML_FeatureActive(), - getSettingsManager()->getPlotViewFeatureActive() ); + getSettingsManager()->getPlotViewFeatureActive(), + getSettingsManager()->getGroupedViewFeatureActive()); setReuqestId(requestId); @@ -1137,7 +1138,11 @@ void CDLTMessageAnalyzer::progressNotification(const tProgressNotificationData& progressNotificationData.processedMatches.matchedItemVec.end(); ++foundMatchesIt) { auto endIt = progressNotificationData.processedMatches.matchedItemVec.end(); - mpGroupedViewModel->addMatches(foundMatchesIt->getFoundMatches(), foundMatchesIt == --(endIt)); + if(true == isGroupedViewFeatureActiveForCurrentAnalysis()) + { + mpGroupedViewModel->addMatches(foundMatchesIt->getFoundMatches(), foundMatchesIt == --(endIt)); + } + mpFiltersModel->addCompletionData(foundMatchesIt->getFoundMatches()); } @@ -1179,7 +1184,12 @@ void CDLTMessageAnalyzer::progressNotification(const tProgressNotificationData& ++foundMatchesIt) { auto endIt = progressNotificationData.processedMatches.matchedItemVec.end(); - mpGroupedViewModel->addMatches(foundMatchesIt->getFoundMatches(), foundMatchesIt == --(endIt)); + + if(true == isGroupedViewFeatureActiveForCurrentAnalysis()) + { + mpGroupedViewModel->addMatches(foundMatchesIt->getFoundMatches(), foundMatchesIt == --(endIt)); + } + mpFiltersModel->addCompletionData(foundMatchesIt->getFoundMatches()); } diff --git a/dltmessageanalyzerplugin/src/plugin/src/form.cpp b/dltmessageanalyzerplugin/src/plugin/src/form.cpp index d3783c63..a2cb5492 100644 --- a/dltmessageanalyzerplugin/src/plugin/src/form.cpp +++ b/dltmessageanalyzerplugin/src/plugin/src/form.cpp @@ -211,6 +211,19 @@ Form::Form(DLTMessageAnalyzerPlugin* pDLTMessageAnalyzerPlugin, contextMenu.addSeparator(); + { + QAction* pAction = new QAction("Grouped view", this); + connect(pAction, &QAction::triggered, this, [this](bool checked) + { + getSettingsManager()->setGroupedViewFeatureActive(checked); + }); + pAction->setCheckable(true); + pAction->setChecked(getSettingsManager()->getGroupedViewFeatureActive()); + contextMenu.addAction(pAction); + } + + contextMenu.addSeparator(); + { QAction* pAction = new QAction("PlantUML", this); connect(pAction, &QAction::triggered, this, [this](bool checked) @@ -224,7 +237,6 @@ Form::Form(DLTMessageAnalyzerPlugin* pDLTMessageAnalyzerPlugin, contextMenu.addSeparator(); - { QAction* pAction = new QAction("Plot view", this); connect(pAction, &QAction::triggered, this, [this](bool checked) @@ -295,6 +307,38 @@ Form::Form(DLTMessageAnalyzerPlugin* pDLTMessageAnalyzerPlugin, mpUI->createSequenceDiagram->setText("Create sequence diagram"); }); + { + auto pGroupedViewWidget = mpUI->tabWidget->findChild(QString("groupedViewTab")); + + if(nullptr != pGroupedViewWidget) + { + auto enableGroupedViewWidget = [this, pGroupedViewWidget](bool val) + { + if(nullptr != mpUI && nullptr != mpUI->tabWidget) + { + if(mpUI->tabWidget->count() > 0) + { + if(true != val) + { + mpUI->tabWidget->removeTab(mpUI->tabWidget->indexOf(pGroupedViewWidget)); + } + else + { + mpUI->tabWidget->insertTab(2, pGroupedViewWidget, "Grouped view"); + } + } + } + }; + + enableGroupedViewWidget(getSettingsManager()->getGroupedViewFeatureActive()); + + connect(getSettingsManager().get(), &ISettingsManager::groupedViewFeatureActiveChanged, [enableGroupedViewWidget](bool val) + { + enableGroupedViewWidget(val); + }); + } + } + { auto pUMLWidget = mpUI->tabWidget->findChild(QString("UMLView")); @@ -312,7 +356,7 @@ Form::Form(DLTMessageAnalyzerPlugin* pDLTMessageAnalyzerPlugin, } else { - mpUI->tabWidget->insertTab(3, pUMLWidget, "UML View"); + mpUI->tabWidget->insertTab(true == getSettingsManager()->getGroupedViewFeatureActive() ? 3 : 2, pUMLWidget, "UML View"); } } } @@ -344,7 +388,28 @@ Form::Form(DLTMessageAnalyzerPlugin* pDLTMessageAnalyzerPlugin, } else { - mpUI->tabWidget->insertTab(true == getSettingsManager()->getUML_FeatureActive() ? 4 : 3, pPlotViewWidget, "Plot view"); + auto bGroupedViewFeatureActive = getSettingsManager()->getGroupedViewFeatureActive(); + auto bUML_FeatureActive = getSettingsManager()->getUML_FeatureActive(); + int tabIndex = 0; + + if(true == bGroupedViewFeatureActive && + true == bUML_FeatureActive) + { + tabIndex = 4; + } + else if((true == bGroupedViewFeatureActive && + false == bUML_FeatureActive) || + (false == bGroupedViewFeatureActive && + true == bUML_FeatureActive)) + { + tabIndex = 3; + } + else + { + tabIndex = 2; + } + + mpUI->tabWidget->insertTab(tabIndex, pPlotViewWidget, "Plot view"); } } }