From 53120cf27028a3ec6ca8ed6672d828611e108da1 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 6 Jun 2016 15:40:46 +0200 Subject: [PATCH] ui: fixed autocompletion list highlights wrong for large indices --- .../qt/element/QtAutocompletionList.cpp | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib_gui/qt/element/QtAutocompletionList.cpp b/src/lib_gui/qt/element/QtAutocompletionList.cpp index 31e8c45d..b85f024b 100644 --- a/src/lib_gui/qt/element/QtAutocompletionList.cpp +++ b/src/lib_gui/qt/element/QtAutocompletionList.cpp @@ -99,7 +99,7 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt } QString name = index.data().toString(); - float charWidth = option.fontMetrics.width("FontWidth") / 9.0f; + QString type = index.sibling(index.row(), index.column() + 1).data().toString(); QColor color("#FFFFFF"); @@ -114,23 +114,17 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt color = QColor(scheme->getSearchTypeColor(SearchMatch::getSearchTypeName(SearchMatch::SEARCH_COMMAND)).c_str()); } - + float charWidth = option.fontMetrics.width( + "----------------------------------------------------------------------------------------------------" + ) / 100.0f; QList indices = index.sibling(index.row(), index.column() + 2).data().toList(); if (indices.size()) { - int idx = 0; - float x = charWidth + 2; - for (int i = 0; i < name.size(); i++) + for (int i = 0; i < indices.size(); i++) { - if (idx < indices.size() && i == indices[idx]) - { - QRect rect = option.rect.adjusted(x, 2, 0, -1); - rect.setWidth(charWidth + 1); - painter->fillRect(rect, color); - idx++; - } - - x += charWidth; + QRect rect = option.rect.adjusted(charWidth * (indices[i].toInt() + 1) + 1, 2, 0, -1); + rect.setWidth(charWidth + 2); + painter->fillRect(rect, color); } } else