MCPcopy Create free account
hub / github.com/KDE/kdevelop / outputFilter

Method outputFilter

plugins/standardoutputview/outputwidget.cpp:712–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710}
711
712void OutputWidget::outputFilter(const QString& filter)
713{
714 auto *view = qobject_cast<QAbstractItemView*>(currentWidget());
715 if( !view )
716 return;
717
718 auto fvIt = findFilteredView(view);
719 auto proxyModel = qobject_cast<QSortFilterProxyModel*>(view->model());
720 if( !proxyModel )
721 {
722 // create new proxy model and make view it's parent. This allows us destroy view and
723 // it's model with "one shot" (see removeOutput() method).
724 fvIt->proxyModel = proxyModel = new QSortFilterProxyModel(view);
725 proxyModel->setDynamicSortFilter(true);
726 proxyModel->setSourceModel(view->model());
727 view->setModel(proxyModel);
728 }
729
730 // Don't capture anything as the captures are not used anyway.
731 QRegularExpression regex(filter, QRegularExpression::CaseInsensitiveOption | QRegularExpression::DontCaptureOption);
732 fvIt->filter = regex; // store away the original regex to be restored when the current tab/widget changes
733
734 if (!regex.isValid()) {
735 // Setting an invalid regex as the model filter hides all output as expected, but also causes runtime warnings:
736 // "QString::contains: invalid QRegularExpression object".
737 // Set a valid regex that matches nothing to hide all output and avoid the warnings.
738 static const QRegularExpression matchNothing(QStringLiteral("$z"));
739 regex = matchNothing;
740 }
741 proxyModel->setFilterRegularExpression(regex);
742
743 updateFilterInputAppearance(constIterator(fvIt));
744}
745
746void OutputWidget::updateFilter(int index)
747{

Callers

nothing calls this directly

Calls 4

setSourceModelMethod · 0.80
modelMethod · 0.45
setModelMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected