LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / plugins / config / dblspindelegate.cpp
blob8c7eda9b13b987bc710f7115f74eabf2ab8a1d5a
1 /**
2 ******************************************************************************
4 * @file doublespindelegate.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup ConfigPlugin Config Plugin
9 * @{
10 * @brief A double spinbox delegate
11 *****************************************************************************/
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.
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.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "dblspindelegate.h"
30 /**
31 Helper delegate for the custom mixer editor table.
33 DoubleSpinDelegate::DoubleSpinDelegate(QObject *parent)
34 : QItemDelegate(parent)
36 m_min = 0.0;
37 m_max = 1.0;
38 m_decimals = 2;
39 m_step = 0.01;
42 QWidget *DoubleSpinDelegate::createEditor(QWidget *parent,
43 const QStyleOptionViewItem & /* option */,
44 const QModelIndex & /* index */) const
46 QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
48 editor->setMinimum(m_min);
49 editor->setMaximum(m_max);
50 editor->setDecimals(m_decimals);
51 editor->setSingleStep(m_step);
53 connect(editor, SIGNAL(valueChanged(double)), this, SLOT(valueChanged()));
55 return editor;
58 void DoubleSpinDelegate::setEditorData(QWidget *editor,
59 const QModelIndex &index) const
61 double value = index.model()->data(index, Qt::EditRole).toDouble();
63 QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox *>(editor);
65 spinBox->setValue(value);
68 void DoubleSpinDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
69 const QModelIndex &index) const
71 QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox *>(editor);
73 spinBox->interpretText();
74 double value = spinBox->value();
76 model->setData(index, value, Qt::EditRole);
79 void DoubleSpinDelegate::updateEditorGeometry(QWidget *editor,
80 const QStyleOptionViewItem &option, const QModelIndex & /* index */) const
82 editor->setGeometry(option.rect);
85 void DoubleSpinDelegate::valueChanged()
87 emit ValueChanged();