diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2014-10-15 15:30:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-10-18 15:16:03 -0700 |
commit | f18bcd66072c115456d98a8aeb87500b2ca8e642 (patch) | |
tree | 6639ddf1c43a4499e020c4821657d24aa3d87e68 /qt-ui/modeldelegates.cpp | |
parent | 10351b34955a2a008269e489acde9bc084e3aa43 (diff) | |
download | subsurface-f18bcd66072c115456d98a8aeb87500b2ca8e642.tar.gz |
Dynamic dive trip list column widths
Compute the default widths for the columns in the dive trip list from
their header and (expected) content length rather than some fixed pixel
sizes.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r-- | qt-ui/modeldelegates.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 70cce7d68..507a5f197 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -32,6 +32,8 @@ static bool keyboardFinished = false; StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent), parentWidget(parent) { + const StarMetrics& metrics = StarWidget::metrics(); + minStarSize = QSize(metrics.size * TOTALSTARS + metrics.spacing * (TOTALSTARS - 1), metrics.size); } void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -61,8 +63,12 @@ void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - const StarMetrics& metrics = StarWidget::metrics(); - return QSize(metrics.size * TOTALSTARS + metrics.spacing * (TOTALSTARS - 1), metrics.size); + return minStarSize; +} + +const QSize& StarWidgetsDelegate::starSize() const +{ + return minStarSize; } ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject *parent) : QStyledItemDelegate(parent), model(model) |