Navigation Menu

Skip to content

Commit

Permalink
use blue font for highlighted tree items
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 27, 2018
1 parent 6be8249 commit 54cd01a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/gui/qgsoptionsdialogbase.cpp
Expand Up @@ -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() ) )
Expand All @@ -484,7 +485,6 @@ QgsSearchHighlightOptionWidget::QgsSearchHighlightOptionWidget( QWidget *widget
parent->setExpanded( true );
}
}

}
};

Expand All @@ -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();
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsoptionsdialogbase.h
Expand Up @@ -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;
Expand Down

0 comments on commit 54cd01a

Please sign in to comment.