Skip to content

Commit

Permalink
[ISSUE-31] Grouped view highlighting
Browse files Browse the repository at this point in the history
- Introduce the 'grouped view highlighting' feature
- Update development documentation
- Update documentation
- Improve the CTreeItem::sort efficiency
- Rename CTreeItem::mSortedChildren to CTreeItem::mChildrenVec to
reflect the meaning of the field. The collection is not always sorted
- Remove the sorting of the grouped view during the search's execution.
Sorting is now done only at the end of the search.
- Extend CTreeItem::addData with the tAfterAppendHandleLeafFunc
parameter that is called at the end of the append operation
- Add signal IDLTMessageAnalyzerController::analysisFinished
- Move to call IDLTMessageAnalyzerController::analysisStarted inside
of the CContinuousAnalyzer
- Rename IFileWrapper::getMsgRealPos to
IFileWrapper::getMsgIdFromIndexInMainTable to reflect its real meaning.
- Add DMA Plant UML force link to IRegexHistoryProvider class
- Refactor the CSettingsManager to provide old and new data to the
setting data callback
- Fix the issue with regex history not changing on the regex patterns
file
selection
- Add reset of the generated plot during canceling the search
operation

Signed-off-by: Vladyslav Goncharuk <vladyslav_goncharuk@epam.com>
  • Loading branch information
Vladyslav Goncharuk committed Sep 19, 2024
1 parent ee04683 commit 05d2723
Show file tree
Hide file tree
Showing 62 changed files with 1,050 additions and 503 deletions.
63 changes: 40 additions & 23 deletions dltmessageanalyzerplugin/src/common/CTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "DMA_Plantuml.hpp"

const int sInvalidIdx = -1;

//CTreeItem
void CTreeItem::visit( const tVisitFunction& preVisitFunction,
const tVisitFunction& postVisitFunction,
Expand Down Expand Up @@ -178,7 +180,7 @@ bool CTreeItem::visitInternal( const tVisitFunction& preVisitFunction,

if(true == visitSorted)
{
for( auto pChild : mSortedChildren )
for( auto pChild : mChildrenVec )
{
if(nullptr != pChild)
{
Expand Down Expand Up @@ -262,20 +264,13 @@ void CTreeItem::sort(int column, Qt::SortOrder order, bool recursive)

if(false == mbFirstLevelSorted)
{
QVector<tTreeItemPtr> children;

for(const auto& pChild : mChildItems)
{
children.push_back(pChild);
}

if(mSortingFunction)
{
mSortedChildren = mSortingFunction(children, mSortingColumn, mSortOrder);
mSortingFunction(mChildrenVec, mSortingColumn, mSortOrder);

int counter = 0;

for(auto& sortedChild : mSortedChildren)
for(auto& sortedChild : mChildrenVec)
{
sortedChild->setIdx(counter++);
}
Expand All @@ -288,7 +283,7 @@ void CTreeItem::sort(int column, Qt::SortOrder order, bool recursive)
{
if( false == mbWholeSorted )
{
for( auto& child : mSortedChildren )
for( auto& child : mChildrenVec )
{
child->sort(mSortingColumn, mSortOrder, recursive);
}
Expand Down Expand Up @@ -361,10 +356,10 @@ bool CTreeItem::isFirstLevelSorted() const

tTreeItemPtr CTreeItem::child(int row)
{
if (row < 0 || row >= mSortedChildren.size())
if (row < 0 || row >= mChildrenVec.size())
return nullptr;

return mSortedChildren[row];
return mChildrenVec[row];
}


Expand Down Expand Up @@ -392,11 +387,11 @@ void CTreeItem::removeChild( const QString& key )
{
if(true == mbFirstLevelSorted)
{
mSortedChildren.erase(mSortedChildren.begin() + foundChild.value()->getIdx());
mChildrenVec.erase(mChildrenVec.begin() + foundChild.value()->getIdx());

auto counter = 0;

for( auto& pChild : mSortedChildren )
for( auto& pChild : mChildrenVec )
{
if(nullptr != pChild)
{
Expand All @@ -412,7 +407,7 @@ void CTreeItem::removeChild( const QString& key )

CTreeItem::~CTreeItem()
{
mSortedChildren.clear();
mChildrenVec.clear();
qDeleteAll(mChildItems);
}

Expand All @@ -428,10 +423,11 @@ CTreeItem::CTreeItem(CTreeItem *pParent,
mFindFunc(findFunc),
mHandleDuplicateFunc(handleDuplicateFunc),
mData(),
mSortedChildren(),
mChildrenVec(),
mpGuard(std::make_shared<int>(0)),
mpParentItem(pParent),
mSortOrder(Qt::SortOrder::DescendingOrder),
mIdx(sInvalidIdx),
mSortingColumn(defaultSortingColumn),
mbFirstLevelSorted(true),
mbWholeSorted(true)
Expand All @@ -445,7 +441,14 @@ tTreeItemPtr CTreeItem::appendChild(const tDataItem& key, const tData& additionI
mHandleDuplicateFunc,
mFindFunc);

mChildItems.insert(key, pTreeItem);
auto it = mChildItems.insert(key, pTreeItem);

if(it.value()->getIdx() == sInvalidIdx)
{
mChildrenVec.push_back(pTreeItem);
pTreeItem->setIdx(mChildItems.size());
}

mbFirstLevelSorted = false;
mbWholeSorted = false;

Expand Down Expand Up @@ -488,10 +491,12 @@ tDataItem& CTreeItem::getWriteableData( int column )

void CTreeItem::addDataInternal( const tDataVec& dataVec,
tTreeItemPtrVec& res,
int dataVecItemIdx )
int dataVecItemIdx,
tAfterAppendHandleLeafFunc afterAppendHandleLeafFunc )
{
if(false == dataVec.empty() )
{
tTreeItemPtr pLeafChild = nullptr;
const tData& additionItems = dataVec[static_cast<std::size_t>(dataVecItemIdx)];

if(false == additionItems.empty())
Expand All @@ -504,6 +509,8 @@ void CTreeItem::addDataInternal( const tDataVec& dataVec,
{
auto foundChild = findRes.pItem;

pLeafChild = foundChild;

if(mHandleDuplicateFunc)
{
mHandleDuplicateFunc( foundChild, *dataVec.begin() );
Expand All @@ -512,7 +519,7 @@ void CTreeItem::addDataInternal( const tDataVec& dataVec,
auto newDataVecItemIdx = ++dataVecItemIdx;
if(static_cast<std::size_t>(newDataVecItemIdx) < dataVec.size() )
{
foundChild->addDataInternal( dataVec, res, newDataVecItemIdx );
foundChild->addDataInternal( dataVec, res, newDataVecItemIdx, afterAppendHandleLeafFunc );
}
}
}
Expand All @@ -522,10 +529,12 @@ void CTreeItem::addDataInternal( const tDataVec& dataVec,

if(pChild)
{
pLeafChild = pChild;

auto newDataVecItemIdx = ++dataVecItemIdx;
if( static_cast<std::size_t>(newDataVecItemIdx) < dataVec.size() )
{
pChild->addDataInternal( dataVec, res, newDataVecItemIdx );
pChild->addDataInternal( dataVec, res, newDataVecItemIdx, afterAppendHandleLeafFunc );
}

res.push_back( pChild );
Expand All @@ -535,15 +544,23 @@ void CTreeItem::addDataInternal( const tDataVec& dataVec,
mbFirstLevelSorted = false;
mbWholeSorted = false;
}

if(nullptr != pLeafChild &&
0 == pLeafChild->childCount() &&
afterAppendHandleLeafFunc)
{
afterAppendHandleLeafFunc(pLeafChild);
}
}
}

tTreeItemPtrVec CTreeItem::addData( const tDataVec& dataVec )
tTreeItemPtrVec CTreeItem::addData( const tDataVec& dataVec,
tAfterAppendHandleLeafFunc afterAppendHandleLeafFunc )
{
tTreeItemPtrVec result;
result.reserve( static_cast<int>(dataVec.size()) );

addDataInternal(dataVec, result, 0);
addDataInternal(dataVec, result, 0, afterAppendHandleLeafFunc);

tTreeItemPtrVec reversedResult;
reversedResult.reserve(result.size());
Expand Down
16 changes: 12 additions & 4 deletions dltmessageanalyzerplugin/src/common/CTreeItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class CTreeItem
typedef std::function<void(CTreeItem* oldItem, const tData& newData)> tHandleDuplicateFunc;

typedef QVector<tTreeItemPtr> tChildrenVector;
typedef std::function< tChildrenVector(const tChildrenVector&, const int& /*sortingColumn*/, Qt::SortOrder) > tSortingFunction;
typedef std::function< void(tChildrenVector&, const int& /*sortingColumn*/, Qt::SortOrder) > tSortingFunction;

typedef std::function<void(CTreeItem*)> tAfterAppendHandleLeafFunc;

/**
* @brief tFindItemResult - result of search of the element.
Expand Down Expand Up @@ -202,10 +204,13 @@ class CTreeItem
/**
* @brief addData - adds data to the tree
* @param dataVec - data to ba added
* @param afterAppendHandleLeafFunc - optional functionl object. It will be called
* with the 'leaf' tree item of the append operation when it is over
* @return - returns tTreeItemPtrVec, which represents all added elements.
* Note! Elements are sorted from most bottom-level to most top-level
*/
tTreeItemPtrVec addData( const tDataVec& dataVec );
tTreeItemPtrVec addData( const tDataVec& dataVec,
tAfterAppendHandleLeafFunc afterAppendHandleLeafFunc = tAfterAppendHandleLeafFunc() );

/**
* @brief data - get's data of this node by specified column
Expand Down Expand Up @@ -236,7 +241,10 @@ class CTreeItem

private:

void addDataInternal( const tDataVec& dataVec, tTreeItemPtrVec& res, int dataVecItemIdx );
void addDataInternal( const tDataVec& dataVec,
tTreeItemPtrVec& res,
int dataVecItemIdx,
tAfterAppendHandleLeafFunc afterAppendHandleLeafFunc );

CTreeItem(const CTreeItem&) = delete;
CTreeItem& operator=(const CTreeItem&) = delete;
Expand All @@ -259,7 +267,7 @@ class CTreeItem
tFindItemFunc mFindFunc;
tHandleDuplicateFunc mHandleDuplicateFunc;
tData mData;
QVector<tTreeItemPtr> mSortedChildren;
QVector<tTreeItemPtr> mChildrenVec;
tGuarded mpGuard;
tTreeItemPtr mpParentItem;
Qt::SortOrder mSortOrder;
Expand Down
39 changes: 33 additions & 6 deletions dltmessageanalyzerplugin/src/common/Definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ fieldRanges(rhs.fieldRanges),
pUMLInfo(rhs.pUMLInfo == nullptr ? nullptr : std::make_unique<tUMLInfo>(*rhs.pUMLInfo)),
pPlotViewInfo(rhs.pPlotViewInfo == nullptr ? nullptr : std::make_unique<tPlotViewInfo>(*rhs.pPlotViewInfo)),
msgId(rhs.msgId),
msgIdFiltered(rhs.msgIdFiltered),
msgIdxInMainTable(rhs.msgIdxInMainTable),
strSize(rhs.strSize),
timeStamp(rhs.timeStamp),
msgSize(rhs.msgSize)
Expand All @@ -938,7 +938,7 @@ tItemMetadata& tItemMetadata::operator= (const tItemMetadata& rhs)
pUMLInfo = rhs.pUMLInfo == nullptr ? nullptr : std::make_unique<tUMLInfo>(*rhs.pUMLInfo);
pPlotViewInfo = rhs.pPlotViewInfo == nullptr ? nullptr : std::make_unique<tPlotViewInfo>(*rhs.pPlotViewInfo);
msgId = rhs.msgId;
msgIdFiltered = rhs.msgIdFiltered;
msgIdxInMainTable = rhs.msgIdxInMainTable;
strSize = rhs.strSize;
timeStamp = rhs.timeStamp;
msgSize = rhs.msgSize;
Expand All @@ -947,14 +947,14 @@ tItemMetadata& tItemMetadata::operator= (const tItemMetadata& rhs)
}

tItemMetadata::tItemMetadata( const tMsgId& msgId_,
const tMsgId& msgIdFiltered_,
const tMsgId& msgIdxInMainTable_,
const tFieldRanges& fieldRanges_,
const int& strSize_,
const std::uint32_t& msgSize_,
const unsigned int& timeStamp_):
fieldRanges(fieldRanges_),
msgId(msgId_),
msgIdFiltered(msgIdFiltered_),
msgIdxInMainTable(msgIdxInMainTable_),
strSize(strSize_),
timeStamp(timeStamp_),
msgSize(msgSize_)
Expand Down Expand Up @@ -1407,6 +1407,34 @@ matchedItemVec(matchedItemVec_)

}

int tFoundMatchesPack::findRowByMsgId(const tMsgId& msgIdToFind) const
{
int left = 0;
int right = static_cast<int>(matchedItemVec.size()) - 1;

while (left <= right)
{
int mid = left + (right - left) / 2;
tMsgId midMsgId = matchedItemVec[mid]->getItemMetadata().msgId;

if (midMsgId == msgIdToFind)
{
return mid;
}
else if (midMsgId < msgIdToFind)
{
left = mid + 1;
}
else
{
right = mid - 1;
}
}

// Item not found
return -1;
}

QString getName(eSearchResultColumn val)
{
QString result;
Expand Down Expand Up @@ -1579,8 +1607,7 @@ bool tGroupedViewMetadata::operator== (const tGroupedViewMetadata& rhs) const
tGroupedViewMetadata::tGroupedViewMetadata( const unsigned int timeStamp_, const tMsgId& msgId_ ):
timeStamp(timeStamp_),
msgId(msgId_)
{
}
{}

QString getName(eGroupedViewColumn val)
{
Expand Down
8 changes: 6 additions & 2 deletions dltmessageanalyzerplugin/src/common/Definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <set>

#include "QMap"
#include "QSet"
#include "QString"
#include "QVector"
#include "QMetaType"
Expand Down Expand Up @@ -88,6 +89,7 @@ extern const QString sDefaultRegexFileName;

typedef int tMsgId;
extern const tMsgId INVALID_MSG_ID;
typedef std::set<tMsgId> tMsgIdSet;

typedef std::int32_t tHighlightingRangeItem;

Expand Down Expand Up @@ -244,6 +246,7 @@ struct tGroupedViewMetadata
tGroupedViewMetadata( const unsigned int timeStamp_, const tMsgId& msgId_ );
tTimeStamp timeStamp;
tMsgId msgId;
nonstd::variant<int, tMsgIdSet> relatedMsgIds = 0;
};
Q_DECLARE_METATYPE(tGroupedViewMetadata)

Expand Down Expand Up @@ -573,7 +576,7 @@ struct tItemMetadata
tItemMetadata(const tItemMetadata& rhs);
tItemMetadata& operator= (const tItemMetadata& rhs);
tItemMetadata( const tMsgId& msgId_,
const tMsgId& msgIdFiltered_,
const tMsgId& msgIdxInMainTable_,
const tFieldRanges& fieldRanges_,
const int& strSize_,
const std::uint32_t& msgSize_,
Expand Down Expand Up @@ -607,7 +610,7 @@ struct tItemMetadata
std::unique_ptr<tUMLInfo> pUMLInfo = nullptr;
std::unique_ptr<tPlotViewInfo> pPlotViewInfo = nullptr;
tMsgId msgId;
tMsgId msgIdFiltered;
tMsgId msgIdxInMainTable;
int strSize;
unsigned int timeStamp;
std::uint32_t msgSize;
Expand Down Expand Up @@ -638,6 +641,7 @@ struct tFoundMatchesPack
{
tFoundMatchesPack();
tFoundMatchesPack( const tFoundMatchesPackItemVec& matchedItemVec_ );
int findRowByMsgId(const tMsgId& msgIdToFind) const;
tFoundMatchesPackItemVec matchedItemVec;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ class IDLTMessageAnalyzerController: public QObject
* @brief analysisStarted - signal, which notifies client about the start of the analysis.
* @param requestId - the request id of the search
* @param usedRegex - the regex with which the anlysis was started
* @oaram selectedAliases - the selected regex alises that were used to form the search query
* @param selectedAliases - the selected regex alises that were used to form the search query
*/
void analysisStarted( const tRequestId& requestId, const QString& usedRegex, const QStringList& selectedAliases );

/**
* @brief analysisFinished - signal, which notifies client about the finish of the analysis.
* @param requestId - the request id of the search
*/
void analysisFinished( const tRequestId& requestId );
};

typedef std::shared_ptr<IDLTMessageAnalyzerController> tDLTMessageAnalyzerControllerPtr;
Loading

0 comments on commit 05d2723

Please sign in to comment.