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 <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-07-11 17:42:43 -03:00 committed by Dirk Hohndel
parent 3dbc5bfeaa
commit af9d62bac3
3 changed files with 55 additions and 1 deletions

View file

@ -88,4 +88,24 @@ public:
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
class SpinBoxDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
SpinBoxDelegate(int min, int max, QObject *parent = 0);
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
int min;
int max;
};
class DoubleSpinBoxDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
DoubleSpinBoxDelegate(qreal min, qreal max, QObject *parent = 0);
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
int min;
int max;
};
#endif // MODELDELEGATES_H