From af9d62bac3add0de07744f3d8a42e3a058e32a41 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 11 Jul 2014 17:42:43 -0300 Subject: Fixed input in the DivePlanner table Based on Glance's idea on rewritting the Delegates, but we don't need to redo the wheel as Qt already gives us the correct Delegate, we just need to set some boundaries on it before returning. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/modeldelegates.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'qt-ui/modeldelegates.cpp') diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index dc6af5665..8dfc56789 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -364,3 +364,31 @@ void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem & } QStyledItemDelegate::paint(painter, option, index); } + +SpinBoxDelegate::SpinBoxDelegate(int min, int max, QObject *parent): + QStyledItemDelegate(parent), + min(min), + max(max) +{ +} + +QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QSpinBox *w = qobject_cast(QStyledItemDelegate::createEditor(parent, option, index)); + w->setRange(min,max); + return w; +} + +DoubleSpinBoxDelegate::DoubleSpinBoxDelegate(qreal min, qreal max, QObject *parent): + QStyledItemDelegate(parent), + min(min), + max(max) +{ +} + +QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QDoubleSpinBox *w = qobject_cast(QStyledItemDelegate::createEditor(parent, option, index)); + w->setRange(min,max); + return w; +} -- cgit v1.2.3-70-g09d2