1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

Added option (#define USE_SCIENTIFIC_NOTATION) to use scientific notation (or not as the case maybe)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2872 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-02-24 10:31:23 +00:00 committed by pip
parent 223b3089ed
commit 3883a561e4

View File

@ -32,6 +32,7 @@
#include <QtCore/QStringList>
#include <QtGui/QWidget>
#include <QtGui/QSpinBox>
#include <QtGui/QDoubleSpinBox>
#include <qscispinbox/QScienceSpinBox.h>
#include <QtGui/QComboBox>
#include <limits>
@ -47,6 +48,8 @@
#define QINT32MAX std::numeric_limits<qint32>::max()
#define QUINT32MAX std::numeric_limits<qint32>::max()
#define USE_SCIENTIFIC_NOTATION
class FieldTreeItem : public TreeItem
{
Q_OBJECT
@ -231,21 +234,34 @@ public:
}
}
QWidget *createEditor(QWidget *parent) {
#idef USE_SCIENTIFIC_NOTATION
QScienceSpinBox *editor = new QScienceSpinBox(parent);
editor->setDecimals(6);
#else
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
editor->setDecimals(8);
#endif
editor->setMinimum(-std::numeric_limits<float>::max());
editor->setMaximum(std::numeric_limits<float>::max());
return editor;
}
QVariant getEditorValue(QWidget *editor) {
#idef USE_SCIENTIFIC_NOTATION
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
#else
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
#endif
spinBox->interpretText();
return spinBox->value();
}
void setEditorValue(QWidget *editor, QVariant value) {
#idef USE_SCIENTIFIC_NOTATION
QScienceSpinBox *spinBox = static_cast<QScienceSpinBox*>(editor);
#else
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
#endif
spinBox->setValue(value.toDouble());
}
private: