From 32ce9bfea918c26b8cda79fac3f5ccba2c140be4 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 12 Mar 2018 22:32:56 +0100 Subject: [PATCH] LP-567 don't create a QSpinBox each time BrowserItemDelegate::sizeHint() is called --- .../src/plugins/uavobjectbrowser/browseritemdelegate.cpp | 6 ++++-- .../gcs/src/plugins/uavobjectbrowser/browseritemdelegate.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.cpp b/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.cpp index 017dd8b40..7af9b2f46 100644 --- a/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.cpp +++ b/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.cpp @@ -31,7 +31,9 @@ BrowserItemDelegate::BrowserItemDelegate(QObject *parent) : QStyledItemDelegate(parent) -{} +{ + _sizeHint = QSpinBox().sizeHint(); +} QWidget *BrowserItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & option, @@ -75,5 +77,5 @@ QSize BrowserItemDelegate::sizeHint(const QStyleOptionViewItem & option, const Q { Q_UNUSED(option); Q_UNUSED(index); - return QSpinBox().sizeHint(); + return _sizeHint; } diff --git a/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.h b/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.h index b9d12af04..3a9a1c3d7 100644 --- a/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.h +++ b/ground/gcs/src/plugins/uavobjectbrowser/browseritemdelegate.h @@ -47,6 +47,9 @@ public: const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex &index) const; + +private: + QSize _sizeHint; }; #endif // BROWSERITEMDELEGATE_H