Commit 3cd7f49e authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Fixed search results handling of font height

This patch makes sure that the rows that show the file and the rows that
show the results are the same height, to satisfy the uniform row heights
setting.

Also, a layout changed signal is now emitted when the font is changed.
This makes active search results update correctly when the text editor
font is changed.

Reviewed-by: con
parent 6a9e7ab0
......@@ -109,7 +109,7 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle
painter->setPen(isSelected ?
option.palette.color(cg, QPalette::HighlightedText) : Qt::darkGray);
painter->drawText(lineNumberAreaRect.adjusted(0, 0, -lineNumberAreaHorizontalPadding, 0),
Qt::AlignRight, QString::number(lineNumber));
Qt::AlignRight | Qt::AlignVCenter, QString::number(lineNumber));
return lineNumberAreaWidth;
}
......
......@@ -33,6 +33,7 @@
#include <QtGui/QApplication>
#include <QtGui/QFont>
#include <QtGui/QFontMetrics>
#include <QtGui/QColor>
#include <QtGui/QPalette>
#include <QtCore/QDir>
......@@ -45,7 +46,7 @@ SearchResultTreeModel::SearchResultTreeModel(QObject *parent)
, m_lastAppendedResultFile(0)
, m_showReplaceUI(false)
{
m_rootItem = new SearchResultTreeItem();
m_rootItem = new SearchResultTreeItem;
m_textEditorFont = QFont("Courier");
}
......@@ -61,7 +62,9 @@ void SearchResultTreeModel::setShowReplaceUI(bool show)
void SearchResultTreeModel::setTextEditorFont(const QFont &font)
{
layoutAboutToBeChanged();
m_textEditorFont = font;
layoutChanged();
}
Qt::ItemFlags SearchResultTreeModel::flags(const QModelIndex &index) const
......@@ -143,7 +146,13 @@ QVariant SearchResultTreeModel::data(const QModelIndex &index, int role) const
QVariant result;
if (item->itemType() == SearchResultTreeItem::ResultRow)
if (role == Qt::SizeHintRole)
{
const int appFontHeight = QApplication::fontMetrics().height();
const int editorFontHeight = QFontMetrics(m_textEditorFont).height();
result = QSize(0, qMax(appFontHeight, editorFontHeight));
}
else if (item->itemType() == SearchResultTreeItem::ResultRow)
{
const SearchResultTextRow *row = static_cast<const SearchResultTextRow *>(item);
result = data(row, role);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment