18#include <QDialogButtonBox>
24#include <QAbstractItemModel>
26#include <QTextDocumentFragment>
46 , mStyleSheet( QStringLiteral(
"QLabel { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6 );}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
59 const QString labelText = QTextDocumentFragment::fromHtml(
mLabel->text() ).toPlainText();
60 return labelText.contains( text, Qt::CaseInsensitive );
76 QString ss =
mWidget->styleSheet();
85 , mCheckBox( checkBox )
86 , mStyleSheet( QStringLiteral(
"/*!search!*/QCheckBox { background-color: rgb(%1, %2, %3); color: rgb( %4, %5, %6);}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
100 return mCheckBox->text().contains( text, Qt::CaseInsensitive );
117 QString ss =
mWidget->styleSheet();
127 , mStyleSheet( QStringLiteral(
"/*!search!*/QAbstractButton { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6);}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
141 return mButton->text().contains( text, Qt::CaseInsensitive );
158 QString ss =
mWidget->styleSheet();
167 , mGroupBox( groupBox )
168 , mStyleSheet( QStringLiteral(
"/*!search!*/QGroupBox::title { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6);}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
182 return mGroupBox->title().contains( text, Qt::CaseInsensitive );
199 QString ss =
mWidget->styleSheet();
208 , mTreeView( treeView )
218 for (
int col = 0; col <
mTreeView->model()->columnCount(); ++col )
220 const QString headerText =
mTreeView->model()->headerData( col, Qt::Horizontal ).toString();
221 if ( headerText.contains( text, Qt::CaseInsensitive ) )
225 const QModelIndexList hits =
mTreeView->model()->match(
mTreeView->model()->index( 0, 0 ), Qt::DisplayRole, text, 1, Qt::MatchContains | Qt::MatchRecursive );
226 return !hits.isEmpty();
231 bool success =
false;
232 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
237 std::function< void( QTreeWidgetItem *,
bool ) > setChildrenVisible;
238 setChildrenVisible = [
this, &setChildrenVisible]( QTreeWidgetItem * item,
bool visible )
240 for (
int i = 0; i < item->childCount(); ++i )
241 setChildrenVisible( item->child( i ), visible );
243 item->setHidden( !visible );
245 setChildrenVisible( treeWidget->invisibleRootItem(),
false );
247 const QList<QTreeWidgetItem *> items = treeWidget->findItems( text, Qt::MatchContains | Qt::MatchRecursive, 0 );
248 success = !items.empty();
250 for ( QTreeWidgetItem *item : items )
252 setChildrenVisible( item,
true );
254 QTreeWidgetItem *parent = item;
260 parent->setExpanded(
true );
261 parent->setHidden(
false );
262 parent = parent->parent();
275 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
279 std::function< void( QTreeWidgetItem * ) > showChildren;
280 showChildren = [
this, &showChildren]( QTreeWidgetItem * item )
282 for (
int i = 0; i < item->childCount(); ++i )
283 showChildren( item->child( i ) );
286 showChildren( treeWidget->invisibleRootItem() );
289 QTreeWidgetItem *item = it.key();
292 item->setExpanded( it.value() );
304 , mTableView( tableView )
314 for (
int col = 0; col <
mTableView->model()->columnCount(); ++col )
316 const QString headerText =
mTableView->model()->headerData( col, Qt::Horizontal ).toString();
317 if ( headerText.contains( text, Qt::CaseInsensitive ) )
321 const QModelIndexList hits =
mTableView->model()->match(
mTableView->model()->index( 0, 0 ), Qt::DisplayRole, text, 1, Qt::MatchContains | Qt::MatchRecursive );
322 return !hits.isEmpty();
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.
QgsOptionsDialogHighlightCheckBox(QCheckBox *checkBox)
constructs a highlight widget for a checkbox
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
QPointer< QCheckBox > mCheckBox
QgsOptionsDialogHighlightGroupBox(QGroupBox *groupBox)
constructs a highlight widget for a group box.
void reset() override
reset the style of the widgets to its original state
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
bool highlightText(const QString &text) override
Highlight the text in the widget.
QPointer< QGroupBox > mGroupBox
QPointer< QLabel > mLabel
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
bool highlightText(const QString &text) override
Highlight the text in the widget.
QgsOptionsDialogHighlightLabel(QLabel *label)
constructs a highlight widget for a label
void reset() override
reset the style of the widgets to its original state
QPointer< QTableView > mTableView
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
bool highlightText(const QString &text) override
Highlight the text in the widget.
QgsOptionsDialogHighlightTable(QTableView *tableView)
constructs a highlight widget for a table view or widget.
void reset() override
reset the style of the widgets to its original state
QgsOptionsDialogHighlightTree(QTreeView *treeView)
constructs a highlight widget for a tree view or widget.
bool highlightText(const QString &text) override
Highlight the text in the widget.
QMap< QTreeWidgetItem *, bool > mTreeInitialVisible
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
QMap< QTreeWidgetItem *, bool > mTreeInitialExpand
QPointer< QTreeView > mTreeView