18 #include <QDialogButtonBox> 23 #include <QTreeWidget> 24 #include <QAbstractItemModel> 45 , mStyleSheet( QStringLiteral(
"QLabel { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6 );}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
58 return mLabel->text().contains( text, Qt::CaseInsensitive );
74 QString ss =
mWidget->styleSheet();
83 , mCheckBox( checkBox )
98 return mCheckBox->text().contains( text, Qt::CaseInsensitive );
115 QString ss =
mWidget->styleSheet();
139 return mButton->text().contains( text, Qt::CaseInsensitive );
156 QString ss =
mWidget->styleSheet();
165 , mGroupBox( groupBox )
180 return mGroupBox->title().contains( text, Qt::CaseInsensitive );
197 QString ss =
mWidget->styleSheet();
206 , mTreeView( treeView )
214 QModelIndexList hits =
mTreeView->model()->match(
mTreeView->model()->index( 0, 0 ), Qt::DisplayRole, text, 1, Qt::MatchContains | Qt::MatchRecursive );
215 return !hits.isEmpty();
220 bool success =
false;
221 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
226 std::function< void( QTreeWidgetItem *, bool ) > setChildrenVisible;
227 setChildrenVisible = [
this, &setChildrenVisible]( QTreeWidgetItem * item,
bool visible )
229 for (
int i = 0; i < item->childCount(); ++i )
230 setChildrenVisible( item->child( i ), visible );
232 item->setHidden( !visible );
234 setChildrenVisible( treeWidget->invisibleRootItem(), false );
236 QList<QTreeWidgetItem *> items = treeWidget->findItems( text, Qt::MatchContains | Qt::MatchRecursive, 0 );
237 success = !items.empty();
240 for ( QTreeWidgetItem *item : items )
242 mTreeInitialStyle.insert( item, qMakePair( item->background( 0 ), item->foreground( 0 ) ) );
245 setChildrenVisible( item,
true );
247 QTreeWidgetItem *parent = item;
253 parent->setExpanded(
true );
254 parent->setHidden(
false );
255 parent = parent->parent();
268 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
272 std::function< void( QTreeWidgetItem * ) > showChildren;
273 showChildren = [
this, &showChildren]( QTreeWidgetItem * item )
275 for (
int i = 0; i < item->childCount(); ++i )
276 showChildren( item->child( i ) );
279 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.
QMap< QTreeWidgetItem *, QPair< QBrush, QBrush > > mTreeInitialStyle
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