18 #include <QDialogButtonBox> 23 #include <QTreeWidget> 24 #include <QAbstractItemModel> 46 , mStyleSheet( QStringLiteral(
"QLabel { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6 );}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
59 return mLabel->text().contains( text, Qt::CaseInsensitive );
75 QString ss =
mWidget->styleSheet();
84 , mCheckBox( checkBox )
99 return mCheckBox->text().contains( text, Qt::CaseInsensitive );
116 QString ss =
mWidget->styleSheet();
140 return mButton->text().contains( text, Qt::CaseInsensitive );
157 QString ss =
mWidget->styleSheet();
166 , mGroupBox( groupBox )
181 return mGroupBox->title().contains( text, Qt::CaseInsensitive );
198 QString ss =
mWidget->styleSheet();
207 , mTreeView( treeView )
215 QModelIndexList hits =
mTreeView->model()->match(
mTreeView->model()->index( 0, 0 ), Qt::DisplayRole, text, 1, Qt::MatchContains | Qt::MatchRecursive );
216 return !hits.isEmpty();
221 bool success =
false;
222 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
227 std::function< void( QTreeWidgetItem *, bool ) > setChildrenVisible;
228 setChildrenVisible = [
this, &setChildrenVisible]( QTreeWidgetItem * item,
bool visible )
230 for (
int i = 0; i < item->childCount(); ++i )
231 setChildrenVisible( item->child( i ), visible );
233 item->setHidden( !visible );
235 setChildrenVisible( treeWidget->invisibleRootItem(), false );
237 QList<QTreeWidgetItem *> items = treeWidget->findItems( text, Qt::MatchContains | Qt::MatchRecursive, 0 );
238 success = !items.empty();
242 for ( QTreeWidgetItem *item : items )
244 setChildrenVisible( item,
true );
246 QTreeWidgetItem *parent = item;
252 parent->setExpanded(
true );
253 parent->setHidden(
false );
254 parent = parent->parent();
267 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
271 std::function< void( QTreeWidgetItem * ) > showChildren;
272 showChildren = [
this, &showChildren]( QTreeWidgetItem * item )
274 for (
int i = 0; i < item->childCount(); ++i )
275 showChildren( item->child( i ) );
278 showChildren( treeWidget->invisibleRootItem() );
bool highlightText(const QString &text) override
Highlight the text in the widget.
QPointer< QTreeView > mTreeView
QgsOptionsDialogHighlightTree(QTreeView *treeView)
constructs a highlight widget for a tree view or widget.
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
QgsOptionsDialogHighlightCheckBox(QCheckBox *checkBox)
constructs a highlight widget for a checkbox
void reset() override
reset the style of the widgets to its original state
QMap< QTreeWidgetItem *, bool > mTreeInitialExpand
QPointer< QGroupBox > mGroupBox
QMap< QTreeWidgetItem *, bool > mTreeInitialVisible
QgsOptionsDialogHighlightLabel(QLabel *label)
constructs a highlight widget for a label
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
QgsOptionsDialogHighlightGroupBox(QGroupBox *groupBox)
constructs a highlight widget for a group box.
bool highlightText(const QString &text) override
Highlight the text in the widget.
QPointer< QCheckBox > mCheckBox
bool highlightText(const QString &text) override
Highlight the text in the widget.
void reset() override
reset the style of the widgets to its original state
bool highlightText(const QString &text) override
Highlight the text in the widget.
QPointer< QLabel > mLabel
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
void reset() override
reset the style of the widgets to its original state
void reset() override
reset the style of the widgets to its original state