diff options
-rw-r--r-- | qt-ui/diveplanner.cpp | 8 | ||||
-rw-r--r-- | qt-ui/modeldelegates.cpp | 12 | ||||
-rw-r--r-- | qt-ui/modeldelegates.h | 6 |
3 files changed, 16 insertions, 10 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index a24f1487e..d98ac5992 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -290,10 +290,10 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan())); // This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth. - ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, this)); - ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, this)); - ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, this)); - ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0.2, 2, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, 1, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, 1, this)); + ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0.2, 2, 0.1, this)); /* set defaults. */ ui.ATMPressure->setValue(1013); diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index b339e7f4a..a3796e0aa 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -365,10 +365,11 @@ void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem & QStyledItemDelegate::paint(painter, option, index); } -SpinBoxDelegate::SpinBoxDelegate(int min, int max, QObject *parent): +SpinBoxDelegate::SpinBoxDelegate(int min, int max, int step, QObject *parent): QStyledItemDelegate(parent), min(min), - max(max) + max(max), + step(step) { } @@ -376,13 +377,15 @@ QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt { QSpinBox *w = qobject_cast<QSpinBox*>(QStyledItemDelegate::createEditor(parent, option, index)); w->setRange(min,max); + w->setSingleStep(step); return w; } -DoubleSpinBoxDelegate::DoubleSpinBoxDelegate(double min, double max, QObject *parent): +DoubleSpinBoxDelegate::DoubleSpinBoxDelegate(double min, double max, double step, QObject *parent): QStyledItemDelegate(parent), min(min), - max(max) + max(max), + step(step) { } @@ -390,5 +393,6 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption { QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox*>(QStyledItemDelegate::createEditor(parent, option, index)); w->setRange(min,max); + w->setSingleStep(step); return w; } diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h index bb948d32d..bb9854eb5 100644 --- a/qt-ui/modeldelegates.h +++ b/qt-ui/modeldelegates.h @@ -91,21 +91,23 @@ public: class SpinBoxDelegate : public QStyledItemDelegate { Q_OBJECT public: - SpinBoxDelegate(int min, int max, QObject *parent = 0); + SpinBoxDelegate(int min, int max, int step, QObject *parent = 0); virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; private: int min; int max; + int step; }; class DoubleSpinBoxDelegate : public QStyledItemDelegate { Q_OBJECT public: - DoubleSpinBoxDelegate(double min, double max, QObject *parent = 0); + DoubleSpinBoxDelegate(double min, double max, double step, QObject *parent = 0); virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; private: double min; double max; + double step; }; #endif // MODELDELEGATES_H |