diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-09-01 14:31:17 +0200 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2009-09-02 17:08:57 +0200 |
commit | aefa148585f93ec17626aefad2158e4089676c08 (patch) | |
tree | 4b4f25d100bc67ffe1d0afecfe09371aa1482df9 | |
parent | 2b233814061dc2ddbc8626a246a80f0806e7e0e4 (diff) |
Adapt a few hardcoded background colors in search results
Make the background of the files and line numbers adapt to the
background color. Making it darker only works nicely for non-dark
backgrounds, but it's better than hardcoding a light background.
The highlight of the search results still has to be fixed.
(cherry picked from commit 83974d89142dfb6235ebb76612fea80c12f6d4db)
-rw-r--r-- | src/plugins/find/searchresulttreeitemdelegate.cpp | 3 | ||||
-rw-r--r-- | src/plugins/find/searchresulttreemodel.cpp | 13 | ||||
-rw-r--r-- | src/plugins/find/searchresulttreeview.cpp | 4 | ||||
-rw-r--r-- | src/plugins/find/searchresultwindow.cpp | 1 |
4 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/find/searchresulttreeitemdelegate.cpp b/src/plugins/find/searchresulttreeitemdelegate.cpp index 10a04538ec..35eab26cad 100644 --- a/src/plugins/find/searchresulttreeitemdelegate.cpp +++ b/src/plugins/find/searchresulttreeitemdelegate.cpp @@ -91,7 +91,8 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle cg = QPalette::Disabled; painter->fillRect(lineNumberAreaRect, QBrush(isSelected ? - option.palette.brush(cg, QPalette::Highlight) : QBrush(qRgb(230, 230, 230)))); + option.palette.brush(cg, QPalette::Highlight) : + option.palette.color(cg, QPalette::Base).darker(111))); painter->setPen(isSelected ? option.palette.color(cg, QPalette::HighlightedText) : Qt::darkGray); painter->drawText(lineNumberAreaRect.adjusted(0, 0, -lineNumberAreaHorizontalPadding, 0), diff --git a/src/plugins/find/searchresulttreemodel.cpp b/src/plugins/find/searchresulttreemodel.cpp index 4be37a1c72..5bd8cbdab7 100644 --- a/src/plugins/find/searchresulttreemodel.cpp +++ b/src/plugins/find/searchresulttreemodel.cpp @@ -31,8 +31,10 @@ #include "searchresulttreeitems.h" #include "searchresulttreeitemroles.h" +#include <QtGui/QApplication> #include <QtGui/QFont> #include <QtGui/QColor> +#include <QtGui/QPalette> #include <QtCore/QDir> using namespace Find::Internal; @@ -184,9 +186,11 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con switch (role) { - case Qt::BackgroundRole: - result = QColor(qRgb(245, 245, 245)); + case Qt::BackgroundRole: { + const QColor baseColor = QApplication::palette().base().color(); + result = baseColor.darker(105); break; + } case Qt::DisplayRole: result = QString(QDir::toNativeSeparators(file->fileName()) + " (" + QString::number(file->childrenCount()) + ")"); @@ -210,7 +214,7 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con } QVariant SearchResultTreeModel::headerData(int section, Qt::Orientation orientation, - int role) const + int role) const { Q_UNUSED(section) Q_UNUSED(orientation) @@ -222,7 +226,8 @@ void SearchResultTreeModel::appendResultFile(const QString &fileName) { m_lastAppendedResultFile = new SearchResultFile(fileName, m_rootItem); - beginInsertRows(QModelIndex(), m_rootItem->childrenCount(), m_rootItem->childrenCount()); + const int childrenCount = m_rootItem->childrenCount(); + beginInsertRows(QModelIndex(), childrenCount, childrenCount); m_rootItem->appendChild(m_lastAppendedResultFile); endInsertRows(); } diff --git a/src/plugins/find/searchresulttreeview.cpp b/src/plugins/find/searchresulttreeview.cpp index 49181495a0..c5317c0fdb 100644 --- a/src/plugins/find/searchresulttreeview.cpp +++ b/src/plugins/find/searchresulttreeview.cpp @@ -38,13 +38,13 @@ using namespace Find::Internal; SearchResultTreeView::SearchResultTreeView(QWidget *parent) : QTreeView(parent) + , m_model(new SearchResultTreeModel(this)) , m_autoExpandResults(false) { - m_model = new SearchResultTreeModel(this); setModel(m_model); setItemDelegate(new SearchResultTreeItemDelegate(this)); - setIndentation(14); + setUniformRowHeights(true); header()->hide(); connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(emitJumpToSearchResult(QModelIndex))); diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp index cdae2e48c7..6e44c7c8a9 100644 --- a/src/plugins/find/searchresultwindow.cpp +++ b/src/plugins/find/searchresultwindow.cpp @@ -51,7 +51,6 @@ SearchResultWindow::SearchResultWindow() m_widget->setWindowTitle(name()); m_searchResultTreeView = new SearchResultTreeView(m_widget); - m_searchResultTreeView->setUniformRowHeights(true); m_searchResultTreeView->setFrameStyle(QFrame::NoFrame); m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false); m_widget->addWidget(m_searchResultTreeView); |