| 4966 | } |
| 4967 | |
| 4968 | void EventBrowser::filter_apply() |
| 4969 | { |
| 4970 | if(!m_Ctx.IsCaptureLoaded()) |
| 4971 | return; |
| 4972 | |
| 4973 | if(ui->filterExpression->completionInProgress()) |
| 4974 | return; |
| 4975 | |
| 4976 | if(m_FilterTimeout->isActive()) |
| 4977 | m_FilterTimeout->stop(); |
| 4978 | |
| 4979 | m_Breadcrumbs->ForceRefresh(); |
| 4980 | |
| 4981 | // unselect everything while applying the filter, to avoid updating the source model while the |
| 4982 | // filter is processing if the current event is no longer selected |
| 4983 | uint32_t curSelEvent = m_Ctx.CurSelectedEvent(); |
| 4984 | ui->events->clearSelection(); |
| 4985 | ui->events->setCurrentIndex(QModelIndex()); |
| 4986 | |
| 4987 | ExpansionKeyGen keygen = [](QModelIndex idx, uint) { return idx.data(ROLE_SELECTED_EID).toUInt(); }; |
| 4988 | |
| 4989 | // update the expansion with the current state. Any rows that were hidden won't have their |
| 4990 | // collapsed/expanded state lost by this. We use the EID as a key because it will be the same even |
| 4991 | // if the model index changes (e.g. if some events are shown or hidden) |
| 4992 | ui->events->updateExpansion(m_EventsExpansion, keygen); |
| 4993 | |
| 4994 | QString expression = ui->filterExpression->toPlainText(); |
| 4995 | persistantStorage.CurrentFilter = expression; |
| 4996 | |
| 4997 | rdcarray<EventFilter> filters; |
| 4998 | *m_ParseTrace = m_FilterModel->ParseExpressionToFilters(expression, filters); |
| 4999 | |
| 5000 | if(m_ParseTrace->hasErrors()) |
| 5001 | filters.clear(); |
| 5002 | |
| 5003 | m_FilterModel->SetFilters(filters); |
| 5004 | |
| 5005 | QList<QTextEdit::ExtraSelection> sels; |
| 5006 | |
| 5007 | if(m_ParseTrace->errorText.isEmpty()) |
| 5008 | m_ParseError->setText(QString()); |
| 5009 | else |
| 5010 | m_ParseError->setText(m_ParseTrace->errorText + |
| 5011 | tr("\n\nOpen filter settings window for syntax help & explanation")); |
| 5012 | m_ParseError->hide(); |
| 5013 | |
| 5014 | if(m_ParseTrace->hasErrors()) |
| 5015 | { |
| 5016 | QTextEdit::ExtraSelection sel; |
| 5017 | |
| 5018 | m_ParseTrace->exprs.clear(); |
| 5019 | |
| 5020 | sel.cursor = ui->filterExpression->textCursor(); |
| 5021 | sel.cursor.setPosition(m_ParseTrace->position, QTextCursor::MoveAnchor); |
| 5022 | |
| 5023 | m_ParseErrorPos = ui->filterExpression->cursorRect(sel.cursor).bottomLeft(); |
| 5024 | |
| 5025 | sel.cursor.setPosition(m_ParseTrace->position + m_ParseTrace->length, QTextCursor::KeepAnchor); |
nothing calls this directly
no test coverage detected