Skip to content

Commit 54cd01a

Browse files
committed
use blue font for highlighted tree items
1 parent 6be8249 commit 54cd01a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/gui/qgsoptionsdialogbase.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,13 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
468468
{
469469
QList<QTreeWidgetItem *> items = treeWidget->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 0 );
470470
mChangedStyle = items.count() ? true : false;
471-
mTreeInitialBackground.clear();
471+
mTreeInitialStyle.clear();
472472
mTreeInitialExpand.clear();
473473
for ( QTreeWidgetItem *item : items )
474474
{
475-
mTreeInitialBackground.insert( item, item->background( 0 ) );
475+
mTreeInitialStyle.insert( item, qMakePair( item->background( 0 ), item->foreground( 0 ) ) );
476476
item->setBackground( 0, QBrush( QColor( Qt::yellow ) ) );
477+
item->setForeground( 0, QBrush( QColor( Qt::blue ) ) );
477478

478479
QTreeWidgetItem *parent = item;
479480
while ( ( parent = parent->parent() ) )
@@ -484,7 +485,6 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
484485
parent->setExpanded( true );
485486
}
486487
}
487-
488488
}
489489
};
490490

@@ -497,14 +497,15 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
497497
item->setExpanded( mTreeInitialExpand.value( item ) );
498498
}
499499
}
500-
for ( QTreeWidgetItem *item : mTreeInitialBackground.keys() )
500+
for ( QTreeWidgetItem *item : mTreeInitialStyle.keys() )
501501
{
502502
if ( item )
503503
{
504-
item->setBackground( 0, mTreeInitialBackground.value( item ) );
504+
item->setBackground( 0, mTreeInitialStyle.value( item ).first );
505+
item->setForeground( 0, mTreeInitialStyle.value( item ).second );
505506
}
506507
}
507-
mTreeInitialBackground.clear();
508+
mTreeInitialStyle.clear();
508509
mTreeInitialExpand.clear();
509510
};
510511
}

src/gui/qgsoptionsdialogbase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
9090
private:
9191
QPointer< QWidget > mWidget;
9292
QString mSearchText = QString();
93-
// a map to save the tree state (backouground, expanded) before highlighting items
94-
QMap<QTreeWidgetItem *, QBrush> mTreeInitialBackground = QMap<QTreeWidgetItem *, QBrush>();
93+
// a map to save the tree state (backouground, font, expanded) before highlighting items
94+
QMap<QTreeWidgetItem *, QPair<QBrush, QBrush>> mTreeInitialStyle = QMap<QTreeWidgetItem *, QPair<QBrush, QBrush>>();
9595
QMap<QTreeWidgetItem *, bool> mTreeInitialExpand = QMap<QTreeWidgetItem *, bool>();
9696
bool mValid = true;
9797
bool mChangedStyle = false;

0 commit comments

Comments
 (0)