summaryrefslogtreecommitdiffstats
path: root/qt-ui/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-05 10:01:27 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-05 10:01:27 +0900
commit3fa6d981b072f2a14aaf7dc96caa9da2a41bca1c (patch)
tree8a20425f22419c4537d0185d6cd3b426d6f996ec /qt-ui/simplewidgets.cpp
parentca1c112424d0ac7c6dda3ee80d3bf45348ead54a (diff)
parent48dda4192f5e82fcaa7a04577a8a0b9aea1a00c8 (diff)
downloadsubsurface-3fa6d981b072f2a14aaf7dc96caa9da2a41bca1c.tar.gz
Merge branch 'minMaxAvgWidget' of https://github.com/tcanabrava/subsurface
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r--qt-ui/simplewidgets.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
new file mode 100644
index 000000000..c389a34c3
--- /dev/null
+++ b/qt-ui/simplewidgets.cpp
@@ -0,0 +1,92 @@
+#include "simplewidgets.h"
+
+#include <QLabel>
+#include <QLabel>
+#include <QFormLayout>
+#include <QIcon>
+
+class MinMaxAvgWidgetPrivate{
+public:
+ QLabel *avgIco, *avgValue;
+ QLabel *minIco, *minValue;
+ QLabel *maxIco, *maxValue;
+
+ MinMaxAvgWidgetPrivate(MinMaxAvgWidget *owner){
+ avgIco = new QLabel(owner);
+ avgIco->setPixmap(QIcon(":/average").pixmap(16,16));
+ avgIco->setToolTip(QObject::tr("Average"));
+ minIco = new QLabel(owner);
+ minIco->setPixmap(QIcon(":/minimum").pixmap(16,16));
+ minIco->setToolTip(QObject::tr("Minimum"));
+ maxIco = new QLabel(owner);
+ maxIco->setPixmap(QIcon(":/maximum").pixmap(16,16));
+ maxIco->setToolTip(QObject::tr("Maximum"));
+ avgValue = new QLabel(owner);
+ minValue = new QLabel(owner);
+ maxValue = new QLabel(owner);
+
+ QGridLayout *formLayout = new QGridLayout();
+ formLayout->addWidget(maxIco, 0, 0);
+ formLayout->addWidget(maxValue, 0, 1);
+ formLayout->addWidget(avgIco, 1, 0);
+ formLayout->addWidget(avgValue, 1, 1);
+ formLayout->addWidget(minIco, 2, 0);
+ formLayout->addWidget(minValue, 2, 1);
+ owner->setLayout(formLayout);
+ }
+};
+
+double MinMaxAvgWidget::average() const
+{
+ return d->avgValue->text().toDouble();
+}
+
+double MinMaxAvgWidget::maximum() const
+{
+ return d->maxValue->text().toDouble();
+}
+double MinMaxAvgWidget::minimum() const
+{
+ return d->minValue->text().toDouble();
+}
+
+MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent)
+: d(new MinMaxAvgWidgetPrivate(this)){
+
+}
+
+void MinMaxAvgWidget::clear()
+{
+ d->avgValue->setText(QString());
+ d->maxValue->setText(QString());
+ d->minValue->setText(QString());
+}
+
+void MinMaxAvgWidget::setAverage(double average)
+{
+ d->avgValue->setText(QString::number(average));
+}
+
+void MinMaxAvgWidget::setMaximum(double maximum)
+{
+ d->maxValue->setText(QString::number(maximum));
+}
+void MinMaxAvgWidget::setMinimum(double minimum)
+{
+ d->minValue->setText(QString::number(minimum));
+}
+
+void MinMaxAvgWidget::setAverage(const QString& average)
+{
+ d->avgValue->setText(average);
+}
+
+void MinMaxAvgWidget::setMaximum(const QString& maximum)
+{
+ d->maxValue->setText(maximum);
+}
+
+void MinMaxAvgWidget::setMinimum(const QString& minimum)
+{
+ d->minValue->setText(minimum);
+}