Skip to content

Commit

Permalink
Merge branch 'feature/searchBar' of github.com:emsec/hal into feature…
Browse files Browse the repository at this point in the history
…/searchBar
  • Loading branch information
neoneela committed Oct 21, 2023
2 parents 2435b51 + b14c131 commit 72a2388
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions plugins/gui/src/searchbar/searchcolumndialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace hal {
SearchColumnDialog::SearchColumnDialog(const QStringList& colNames, const QList<int> &selected)
: mDisableHandler(false)
{
//TODO FIX check logic
setWindowTitle("Search in:");
QVBoxLayout* layout = new QVBoxLayout(this);
mCheckAllColumns = new QCheckBox("All columns", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace hal

mSearchbar = new Searchbar(treeViewContainer);
mSearchbar->hide();
mSearchbar->setColumnNames(mSelectionTreeProxyModel->getColumnNames());

containerLayout->addWidget(mSelectionTreeView);
containerLayout->addWidget(mSearchbar);
Expand Down Expand Up @@ -328,7 +329,7 @@ namespace hal
{
return;
}

SelectionTreeProxyModel* proxy = static_cast<SelectionTreeProxyModel*>(mSelectionTreeView->model());
mSelectionTreeView->setModel(mSelectionTreeProxyModel);
if (proxy->isGraphicsBusy()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,27 @@ namespace hal

bool SelectionTreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
//index to element in source mdoel
const QModelIndex& itemIndex = sourceModel()->index(source_row, 0, source_parent);

const SelectionTreeItem* sti = static_cast<SelectionTreeItem*>(itemIndex.internalPointer());
return sti->match(mFilterExpression);
QList<int> columns = mSearchOptions.getColumns();
if(columns.empty()){
//iterate over each column
for(int index = 0; index < 3; index++){
QString entry = sourceModel()->index(source_row, index, source_parent).data().toString();
if(isMatching(mSearchString, entry))
{
return true;
}
}
return false;
}else
{
for(int index : columns)
{
QString entry = sourceModel()->index(source_row, index, source_parent).data().toString();
if(isMatching(mSearchString, entry))
return true;
}
return false;
}
}

bool SelectionTreeProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
Expand Down

0 comments on commit 72a2388

Please sign in to comment.