summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-11-25 13:37:37 +0000
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-11-25 13:37:59 +0000
commitea4b99ff0dfe5933c8f7b50e1fd59ec3c077c876 (patch)
tree5d3edc615bf5155306a8ccf8da76c4a7c23b4f87 /gui
parentf72e593d5dd779efc3b9f3d2578917daf31d7968 (diff)
Fix GUI visualization of floating point values.
According to http://doc.qt.nokia.com/stable/qvariant.html#type , variant types are actually QMetaType::Type, which includes floats. So handle the QMetaType::Float case everywhere.
Diffstat (limited to 'gui')
-rw-r--r--gui/apitracecall.cpp5
-rw-r--r--gui/argumentseditor.cpp14
-rw-r--r--gui/argumentseditor.h4
3 files changed, 18 insertions, 5 deletions
diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp
index 4752cc0..d0eb542 100644
--- a/gui/apitracecall.cpp
+++ b/gui/apitracecall.cpp
@@ -105,9 +105,12 @@ apiVariantToString(const QVariant &variant, bool multiLine)
return QLatin1String("?");
}
- if (variant.userType() == QVariant::Double) {
+ if (variant.userType() == QMetaType::Float) {
return QString::number(variant.toFloat());
}
+ if (variant.userType() == QVariant::Double) {
+ return QString::number(variant.toDouble());
+ }
if (variant.userType() == QVariant::ByteArray) {
if (variant.toByteArray().size() < 1024) {
int bytes = variant.toByteArray().size();
diff --git a/gui/argumentseditor.cpp b/gui/argumentseditor.cpp
index 1ee519e..9ce0f84 100644
--- a/gui/argumentseditor.cpp
+++ b/gui/argumentseditor.cpp
@@ -28,6 +28,7 @@ isVariantEditable(const QVariant &var)
case QVariant::UInt:
case QVariant::LongLong:
case QVariant::ULongLong:
+ case QMetaType::Float:
case QVariant::Double:
return true;
default:
@@ -55,7 +56,7 @@ ArgumentsItemEditorFactory::ArgumentsItemEditorFactory()
{
}
-QWidget * ArgumentsItemEditorFactory::createEditor(QVariant::Type type,
+QWidget * ArgumentsItemEditorFactory::createEditor(QMetaType::Type type,
QWidget *parent) const
{
switch (type) {
@@ -90,6 +91,14 @@ QWidget * ArgumentsItemEditorFactory::createEditor(QVariant::Type type,
}
case QVariant::Pixmap:
return new QLabel(parent);
+ case QMetaType::Float: {
+ QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
+ sb->setFrame(false);
+ sb->setMinimum(-FLT_MAX);
+ sb->setMaximum(FLT_MAX);
+ sb->setDecimals(8);
+ return sb;
+ }
case QVariant::Double: {
QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
sb->setFrame(false);
@@ -105,7 +114,7 @@ QWidget * ArgumentsItemEditorFactory::createEditor(QVariant::Type type,
}
QByteArray
-ArgumentsItemEditorFactory::valuePropertyName(QVariant::Type type) const
+ArgumentsItemEditorFactory::valuePropertyName(QMetaType::Type type) const
{
switch (type) {
case QVariant::Bool:
@@ -114,6 +123,7 @@ ArgumentsItemEditorFactory::valuePropertyName(QVariant::Type type) const
case QVariant::Int:
case QVariant::LongLong:
case QVariant::ULongLong:
+ case QMetaType::Float:
case QVariant::Double:
return "value";
#if 0
diff --git a/gui/argumentseditor.h b/gui/argumentseditor.h
index 7671d71..68b7d1f 100644
--- a/gui/argumentseditor.h
+++ b/gui/argumentseditor.h
@@ -25,8 +25,8 @@ class ArgumentsItemEditorFactory : public QItemEditorFactory
{
public:
ArgumentsItemEditorFactory();
- QWidget *createEditor(QVariant::Type type, QWidget *parent) const;
- QByteArray valuePropertyName(QVariant::Type) const;
+ QWidget *createEditor(QMetaType::Type type, QWidget *parent) const;
+ QByteArray valuePropertyName(QMetaType::Type) const;
};
class ArgumentsEditor : public QDialog