Skip to content
Permalink
Browse files

use blue font for highlighted tree items

  • Loading branch information
3nids committed Jan 27, 2018
1 parent 6be8249 commit 54cd01ac7dbab03fad96bc6c294192d183283780
Showing with 9 additions and 8 deletions.
  1. +7 −6 src/gui/qgsoptionsdialogbase.cpp
  2. +2 −2 src/gui/qgsoptionsdialogbase.h
@@ -468,12 +468,13 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
{
QList<QTreeWidgetItem *> items = treeWidget->findItems( searchText, Qt::MatchContains | Qt::MatchRecursive, 0 );
mChangedStyle = items.count() ? true : false;
mTreeInitialBackground.clear();
mTreeInitialStyle.clear();
mTreeInitialExpand.clear();
for ( QTreeWidgetItem *item : items )
{
mTreeInitialBackground.insert( item, item->background( 0 ) );
mTreeInitialStyle.insert( item, qMakePair( item->background( 0 ), item->foreground( 0 ) ) );
item->setBackground( 0, QBrush( QColor( Qt::yellow ) ) );
item->setForeground( 0, QBrush( QColor( Qt::blue ) ) );

QTreeWidgetItem *parent = item;
while ( ( parent = parent->parent() ) )
@@ -484,7 +485,6 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
parent->setExpanded( true );
}
}

}
};

@@ -497,14 +497,15 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
item->setExpanded( mTreeInitialExpand.value( item ) );
}
}
for ( QTreeWidgetItem *item : mTreeInitialBackground.keys() )
for ( QTreeWidgetItem *item : mTreeInitialStyle.keys() )
{
if ( item )
{
item->setBackground( 0, mTreeInitialBackground.value( item ) );
item->setBackground( 0, mTreeInitialStyle.value( item ).first );
item->setForeground( 0, mTreeInitialStyle.value( item ).second );
}
}
mTreeInitialBackground.clear();
mTreeInitialStyle.clear();
mTreeInitialExpand.clear();
};
}
@@ -90,8 +90,8 @@ class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
private:
QPointer< QWidget > mWidget;
QString mSearchText = QString();
// a map to save the tree state (backouground, expanded) before highlighting items
QMap<QTreeWidgetItem *, QBrush> mTreeInitialBackground = QMap<QTreeWidgetItem *, QBrush>();
// a map to save the tree state (backouground, font, expanded) before highlighting items
QMap<QTreeWidgetItem *, QPair<QBrush, QBrush>> mTreeInitialStyle = QMap<QTreeWidgetItem *, QPair<QBrush, QBrush>>();
QMap<QTreeWidgetItem *, bool> mTreeInitialExpand = QMap<QTreeWidgetItem *, bool>();
bool mValid = true;
bool mChangedStyle = false;

0 comments on commit 54cd01a

Please sign in to comment.
You can’t perform that action at this time.