18 #include <QDialogButtonBox>
23 #include <QTreeWidget>
24 #include <QAbstractItemModel>
26 #include <QTextDocumentFragment>
48 , mStyleSheet( QStringLiteral(
"QLabel { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6 );}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
61 const QString labelText = QTextDocumentFragment::fromHtml(
mLabel->text() ).toPlainText();
62 return labelText.contains( text, Qt::CaseInsensitive );
78 QString ss =
mWidget->styleSheet();
87 , mCheckBox( checkBox )
88 , mStyleSheet( QStringLiteral(
"/*!search!*/QCheckBox { background-color: rgb(%1, %2, %3); color: rgb( %4, %5, %6);}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
102 return mCheckBox->text().contains( text, Qt::CaseInsensitive );
119 QString ss =
mWidget->styleSheet();
129 , mStyleSheet( QStringLiteral(
"/*!search!*/QAbstractButton { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6);}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
143 return mButton->text().contains( text, Qt::CaseInsensitive );
160 QString ss =
mWidget->styleSheet();
169 , mGroupBox( groupBox )
170 , mStyleSheet( QStringLiteral(
"/*!search!*/QGroupBox::title { background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6);}/*!search!*/" ).arg(
HIGHLIGHT_BACKGROUND_RED )
184 return mGroupBox->title().contains( text, Qt::CaseInsensitive );
201 QString ss =
mWidget->styleSheet();
210 , mTreeView( treeView )
220 for (
int col = 0; col <
mTreeView->model()->columnCount(); ++col )
222 const QString headerText =
mTreeView->model()->headerData( col, Qt::Horizontal ).toString();
223 if ( headerText.contains( text, Qt::CaseInsensitive ) )
227 const QModelIndexList hits =
mTreeView->model()->match(
mTreeView->model()->index( 0, 0 ), Qt::DisplayRole, text, 1, Qt::MatchContains | Qt::MatchRecursive );
228 return !hits.isEmpty();
233 bool success =
false;
234 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
239 std::function< void( QTreeWidgetItem *,
bool ) > setChildrenVisible;
240 setChildrenVisible = [
this, &setChildrenVisible]( QTreeWidgetItem * item,
bool visible )
242 for (
int i = 0; i < item->childCount(); ++i )
243 setChildrenVisible( item->child( i ), visible );
245 item->setHidden( !visible );
247 setChildrenVisible( treeWidget->invisibleRootItem(),
false );
249 const QList<QTreeWidgetItem *> items = treeWidget->findItems( text, Qt::MatchContains | Qt::MatchRecursive, 0 );
250 success = !items.empty();
252 for ( QTreeWidgetItem *item : items )
254 setChildrenVisible( item,
true );
256 QTreeWidgetItem *parent = item;
262 parent->setExpanded(
true );
263 parent->setHidden(
false );
264 parent = parent->parent();
277 QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(
mTreeView );
281 std::function< void( QTreeWidgetItem * ) > showChildren;
282 showChildren = [
this, &showChildren]( QTreeWidgetItem * item )
284 for (
int i = 0; i < item->childCount(); ++i )
285 showChildren( item->child( i ) );
288 showChildren( treeWidget->invisibleRootItem() );
305 , mTableView( tableView )
315 for (
int col = 0; col <
mTableView->model()->columnCount(); ++col )
317 const QString headerText =
mTableView->model()->headerData( col, Qt::Horizontal ).toString();
318 if ( headerText.contains( text, Qt::CaseInsensitive ) )
322 const QModelIndexList hits =
mTableView->model()->match(
mTableView->model()->index( 0, 0 ), Qt::DisplayRole, text, 1, Qt::MatchContains | Qt::MatchRecursive );
323 return !hits.isEmpty();