27 #ifndef FIELDTREEITEM_H
28 #define FIELDTREEITEM_H
31 #include <QtCore/QStringList>
34 #include <QDoubleSpinBox>
35 #include <qscispinbox/QScienceSpinBox.h>
40 #define QINT8MIN std::numeric_limits<qint8>::min()
41 #define QINT8MAX std::numeric_limits<qint8>::max()
42 #define QUINTMIN std::numeric_limits<quint8>::min()
43 #define QUINT8MAX std::numeric_limits<quint8>::max()
44 #define QINT16MIN std::numeric_limits<qint16>::min()
45 #define QINT16MAX std::numeric_limits<qint16>::max()
46 #define QUINT16MAX std::numeric_limits<quint16>::max()
47 #define QINT32MIN std::numeric_limits<qint32>::min()
48 #define QINT32MAX std::numeric_limits<qint32>::max()
49 #define QUINT32MAX std::numeric_limits<quint32>::max()
67 inline virtual bool isEditable()
override {
return true; }
73 virtual void apply()
override {}
86 , m_enumOptions(field->getOptions())
92 , m_enumOptions(field->getOptions())
100 int tmpValIndex = options.indexOf(tmpValue.toString());
106 if ((index < 0) || (index >= m_enumOptions.length())) {
107 return QString(
"Invalid Value (") + QString().setNum(index) + QString(
")");
109 return m_enumOptions.at(index);
115 qDebug() <<
"Warning, UAVO browser field is outside range. This should never happen!";
127 int valIndex = options.indexOf(value.toString());
138 QComboBox *editor =
new QComboBox(parent);
139 editor->setFocusPolicy(Qt::ClickFocus);
140 foreach (QString option, m_enumOptions)
141 editor->addItem(option);
147 QComboBox *comboBox =
static_cast<QComboBox *
>(editor);
148 return comboBox->currentIndex();
153 QComboBox *comboBox =
static_cast<QComboBox *
>(editor);
154 comboBox->setCurrentIndex(value.toInt());
158 QStringList m_enumOptions;
184 m_minValue = QINT8MIN;
185 m_maxValue = QINT8MAX;
188 m_minValue = QINT16MIN;
189 m_maxValue = QINT16MAX;
192 m_minValue = QINT32MIN;
193 m_maxValue = QINT32MAX;
196 m_minValue = QUINTMIN;
197 m_maxValue = QUINT8MAX;
200 m_minValue = QUINTMIN;
201 m_maxValue = QUINT16MAX;
204 m_minValue = QUINTMIN;
205 m_maxValue = QUINT32MAX;
219 editor->
setRange(m_minValue, m_maxValue);
226 QSpinBox *editor =
new QSpinBox(parent);
227 editor->setRange(m_minValue, m_maxValue);
237 if (QSpinBox *spinBox = qobject_cast<QSpinBox *>(editor)) {
238 spinBox->interpretText();
239 return QVariant(spinBox->value());
240 }
else if (
LongLongSpinBox *spinBox = qobject_cast<LongLongSpinBox *>(editor)) {
241 spinBox->interpretText();
242 return QVariant(spinBox->value());
256 QSpinBox *spinBox =
static_cast<QSpinBox *
>(editor);
257 spinBox->setValue(value.toInt());
263 QSpinBox *spinBox =
static_cast<QSpinBox *
>(editor);
264 spinBox->setValue(value.toUInt());
364 , m_useScientificNotation(scientific)
371 , m_useScientificNotation(scientific)
398 if (m_useScientificNotation) {
399 QScienceSpinBox *editor =
new QScienceSpinBox(parent);
400 editor->setDecimals(6);
401 editor->setMinimum(-std::numeric_limits<float>::max());
402 editor->setMaximum(std::numeric_limits<float>::max());
405 QDoubleSpinBox *editor =
new QDoubleSpinBox(parent);
406 editor->setDecimals(8);
407 editor->setMinimum(-std::numeric_limits<float>::max());
408 editor->setMaximum(std::numeric_limits<float>::max());
415 if (m_useScientificNotation) {
416 QScienceSpinBox *spinBox =
static_cast<QScienceSpinBox *
>(editor);
417 spinBox->interpretText();
418 return spinBox->value();
420 QDoubleSpinBox *spinBox =
static_cast<QDoubleSpinBox *
>(editor);
421 spinBox->interpretText();
422 return spinBox->value();
429 if (m_useScientificNotation) {
430 QScienceSpinBox *spinBox =
static_cast<QScienceSpinBox *
>(editor);
431 spinBox->setValue(value.toDouble());
433 QDoubleSpinBox *spinBox =
static_cast<QDoubleSpinBox *
>(editor);
434 spinBox->setValue(value.toDouble());
440 bool m_useScientificNotation;
443 #endif // FIELDTREEITEM_H
void setPrefix(const QString &prefix)
bool isDefaultValue(int index=0)
Check if the element is set to default value.
void setDisplayIntegerBase(int base)
void setData(QVariant value, int column)
virtual QVariant getEditorValue(QWidget *editor)=0
UAVObject * getObject() const
void setRange(qint64 min, qint64 max)
void setData(QVariant value, int column)
virtual void setEditorValue(QWidget *editor, QVariant value)=0
QString getDisplayPrefix() const
Get the prefix for the preferred display format.
virtual QWidget * createEditor(QWidget *parent)=0
QVariant getValue(int index=0) const
void setData(QVariant value, int column)
void setEditorValue(QWidget *editor, QVariant value)
FloatFieldTreeItem(UAVObjectField *field, int index, const QList< QVariant > &data, bool scientific=false, TreeItem *parent=nullptr)
virtual bool isDefaultValue() const override
QStringList getOptions() const
FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, bool scientific=false, TreeItem *parent=nullptr)
void setValue(qint64 val)
void setEditorValue(QWidget *editor, QVariant value)
void setValue(const QVariant &data, int index=0)
virtual bool isEditable() override
EnumFieldTreeItem(UAVObjectField *field, int index, const QList< QVariant > &data, TreeItem *parent=nullptr)
FieldTreeItem(int index, const QList< QVariant > &data, TreeItem *parent=nullptr)
QWidget * createEditor(QWidget *parent)
FieldTreeItem(int index, const QVariant &data, TreeItem *parent=nullptr)
virtual void apply() override
IntFieldTreeItem(UAVObjectField *field, int index, const QList< QVariant > &data, TreeItem *parent=nullptr)
QWidget * createEditor(QWidget *parent)
virtual void setData(QVariant value, int column=1)
QVariant getEditorValue(QWidget *editor)
IntFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent=nullptr)
void setEditorValue(QWidget *editor, QVariant value)
QVariant data(int column=1) const
void setIsDefaultValue(bool isDefault)
int getDisplayIntegerBase() const
Get the preferred integer base for this field.
void setChanged(bool changed)
EnumFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent=nullptr)
QWidget * createEditor(QWidget *parent)
QString enumOptions(int index)
FieldType getType() const
QVariant getEditorValue(QWidget *editor)
static const int dataColumn
QVariant getEditorValue(QWidget *editor)