dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
dblspindelegate.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 #ifndef DOUBLESPINDELEGATE_H
27 #define DOUBLESPINDELEGATE_H
28 
29 #include <QDoubleSpinBox>
30 #include <QItemDelegate>
31 
32 namespace Ui {
33 class DoubleSpinDelegate;
34 }
35 
36 class DoubleSpinDelegate : public QItemDelegate
37 {
38  Q_OBJECT
39 
40 public:
41  DoubleSpinDelegate(QObject *parent = nullptr);
42 
43  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
44  const QModelIndex &index) const;
45 
46  void setEditorData(QWidget *editor, const QModelIndex &index) const;
47  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
48 
49  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
50  const QModelIndex &index) const;
51 
52  void setMin(double min) { m_min = min; }
53  void setMax(double max) { m_max = max; }
54  void setRange(double min, double max)
55  {
56  m_min = min;
57  m_max = max;
58  }
59  void setStep(double step) { m_step = step; }
60  void setDecimals(int decimals) { m_decimals = decimals; }
61 
62 private:
63  double m_min;
64  double m_max;
65  double m_step;
66  int m_decimals;
67 
68 signals:
69  void ValueChanged();
70 
71 private slots:
72  void valueChanged();
73 };
74 
75 #endif // DOUBLESPINDELEGATE_H
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setStep(double step)
void setMax(double max)
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
void setDecimals(int decimals)
void setMin(double min)
void setEditorData(QWidget *editor, const QModelIndex &index) const
DoubleSpinDelegate(QObject *parent=nullptr)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setRange(double min, double max)