Skip to content
Snippets Groups Projects
Commit adb186a4 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

ListItemDelegate: + assert; simplify

parent 563c52dc
No related branches found
No related tags found
1 merge request!2362rename fcts, ..., to prepare for simplification of InstrumentsSet
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// ************************************************************************************************ // ************************************************************************************************
#include "GUI/View/Widget/ListItemDelegate.h" #include "GUI/View/Widget/ListItemDelegate.h"
#include "Base/Util/Assert.h"
#include <QPainter> #include <QPainter>
#include <QTextDocument> #include <QTextDocument>
...@@ -52,19 +53,15 @@ void ListItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti ...@@ -52,19 +53,15 @@ void ListItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti
QSize ListItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const QSize ListItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{ {
QSize s = QStyledItemDelegate::sizeHint(option, index); ASSERT(index.isValid());
int h = QStyledItemDelegate::sizeHint(option, index).height();
// get size of parent; this is the minimum size
const int h = QStyledItemDelegate::sizeHint(option, index).height();
s.setHeight(std::max(s.height(), h));
QStyleOptionViewItem options = option; QStyleOptionViewItem options = option;
initStyleOption(&options, index); initStyleOption(&options, index);
auto s2 = mySizeHint(options.text); auto s2 = mySizeHint(options.text);
s.setHeight(std::max(s.height(), s2.height() + 10));
s.setHeight(std::max(s.height(), 32));
s.setWidth(s2.width() + h); // +h: icon
return s; h = std::max(h, 32);
h = std::max(h, s2.height() + 10);
return {s2.width() + h, h};
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment