@@ -468,12 +468,13 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
468
468
{
469
469
QList<QTreeWidgetItem *> items = treeWidget->findItems ( searchText, Qt::MatchContains | Qt::MatchRecursive, 0 );
470
470
mChangedStyle = items.count () ? true : false ;
471
- mTreeInitialBackground .clear ();
471
+ mTreeInitialStyle .clear ();
472
472
mTreeInitialExpand .clear ();
473
473
for ( QTreeWidgetItem *item : items )
474
474
{
475
- mTreeInitialBackground .insert ( item, item->background ( 0 ) );
475
+ mTreeInitialStyle .insert ( item, qMakePair ( item->background ( 0 ), item-> foreground ( 0 ) ) );
476
476
item->setBackground ( 0 , QBrush ( QColor ( Qt::yellow ) ) );
477
+ item->setForeground ( 0 , QBrush ( QColor ( Qt::blue ) ) );
477
478
478
479
QTreeWidgetItem *parent = item;
479
480
while ( ( parent = parent->parent () ) )
@@ -484,7 +485,6 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
484
485
parent->setExpanded ( true );
485
486
}
486
487
}
487
-
488
488
}
489
489
};
490
490
@@ -497,14 +497,15 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
497
497
item->setExpanded ( mTreeInitialExpand .value ( item ) );
498
498
}
499
499
}
500
- for ( QTreeWidgetItem *item : mTreeInitialBackground .keys () )
500
+ for ( QTreeWidgetItem *item : mTreeInitialStyle .keys () )
501
501
{
502
502
if ( item )
503
503
{
504
- item->setBackground ( 0 , mTreeInitialBackground .value ( item ) );
504
+ item->setBackground ( 0 , mTreeInitialStyle .value ( item ).first );
505
+ item->setForeground ( 0 , mTreeInitialStyle .value ( item ).second );
505
506
}
506
507
}
507
- mTreeInitialBackground .clear ();
508
+ mTreeInitialStyle .clear ();
508
509
mTreeInitialExpand .clear ();
509
510
};
510
511
}
0 commit comments