summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-04 18:51:27 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-04 18:51:27 -0300
commit48dda4192f5e82fcaa7a04577a8a0b9aea1a00c8 (patch)
tree3eba70644f9b644fb37641926f9bb95f82c7ca4d /qt-ui
parentb38e2ab485756e33d4d8bbab8baf1969405a1d90 (diff)
downloadsubsurface-48dda4192f5e82fcaa7a04577a8a0b9aea1a00c8.tar.gz
Added a new widget 'MinMaxAvgWidget'
Added a new widget, MinMaxAvgWidget, a simple widget that displays values in 'min, max, avg' fashion. it has a setMaximum, setAverage and setMinimum methods, that is userful for setting the minimum, maximum and average of stuff. Ah, it also shows the minimum, maximum and average of things. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp56
-rw-r--r--qt-ui/maintab.ui230
-rw-r--r--qt-ui/simplewidgets.cpp92
-rw-r--r--qt-ui/simplewidgets.h28
4 files changed, 167 insertions, 239 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 55f11789f..07e1d9749 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -137,20 +137,12 @@ void MainTab::clearInfo()
void MainTab::clearStats()
{
- ui->maximumDepthAllText->clear();
- ui->minimumDepthAllText->clear();
- ui->averageDepthAllText->clear();
- ui->maximumSacAllText->clear();
- ui->minimumSacAllText->clear();
- ui->averageSacAllText->clear();
+ ui->depthLimits->clear();
+ ui->sacLimits->clear();
ui->divesAllText->clear();
- ui->maximumTemperatureAllText->clear();
- ui->minimumTemperatureAllText->clear();
- ui->averageTemperatureAllText->clear();
+ ui->tempLimits->clear();
ui->totalTimeAllText->clear();
- ui->averageTimeAllText->clear();
- ui->longestAllText->clear();
- ui->shortestAllText->clear();
+ ui->timeLimits->clear();
}
#define UPDATE_TEXT(d, field) \
@@ -217,29 +209,29 @@ void MainTab::updateDiveInfo(int dive)
else
ui->airPressureText->clear();
ui->visibility->setCurrentStars(d->visibility);
- ui->maximumDepthAllText->setText(get_depth_string(stats_selection.max_depth, TRUE));
- ui->minimumDepthAllText->setText(get_depth_string(stats_selection.min_depth, TRUE));
- ui->averageDepthAllText->setText(get_depth_string(stats_selection.avg_depth, TRUE));
- ui->maximumSacAllText->setText(get_volume_string(stats_selection.max_sac, TRUE).append(tr("/min")));
- ui->minimumSacAllText->setText(get_volume_string(stats_selection.min_sac, TRUE).append(tr("/min")));
- ui->averageSacAllText->setText(get_volume_string(stats_selection.avg_sac, TRUE).append(tr("/min")));
+ ui->depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, TRUE));
+ ui->depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, TRUE));
+ ui->depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, TRUE));
+ ui->sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, TRUE).append(tr("/min")));
+ ui->sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, TRUE).append(tr("/min")));
+ ui->sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, TRUE).append(tr("/min")));
ui->divesAllText->setText(QString::number(stats_selection.selection_size));
temp.mkelvin = stats_selection.max_temp;
- ui->maximumTemperatureAllText->setText(get_temperature_string(temp, TRUE));
+ ui->tempLimits->setMaximum(get_temperature_string(temp, TRUE));
temp.mkelvin = stats_selection.min_temp;
- ui->minimumTemperatureAllText->setText(get_temperature_string(temp, TRUE));
+ ui->tempLimits->setMinimum(get_temperature_string(temp, TRUE));
if (stats_selection.combined_temp && stats_selection.combined_count) {
const char *unit;
get_temp_units(0, &unit);
- ui->averageTemperatureAllText->setText(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit));
+ ui->tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit));
}
ui->totalTimeAllText->setText(get_time_string(stats_selection.total_time.seconds, 0));
int seconds = stats_selection.total_time.seconds;
if (stats_selection.selection_size)
seconds /= stats_selection.selection_size;
- ui->averageTimeAllText->setText(get_time_string(seconds, 0));
- ui->longestAllText->setText(get_time_string(stats_selection.longest_time.seconds, 0));
- ui->shortestAllText->setText(get_time_string(stats_selection.shortest_time.seconds, 0));
+ ui->timeLimits->setAverage(get_time_string(seconds, 0));
+ ui->timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0));
+ ui->timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
cylindersModel->setDive(d);
weightModel->setDive(d);
addCylinder->setEnabled(true);
@@ -272,20 +264,12 @@ void MainTab::updateDiveInfo(int dive)
weightModel->clear();
addCylinder->setEnabled(false);
addWeight->setEnabled(false);
- ui->maximumDepthAllText->clear();
- ui->minimumDepthAllText->clear();
- ui->averageDepthAllText->clear();
- ui->maximumSacAllText->clear();
- ui->minimumSacAllText->clear();
- ui->averageSacAllText->clear();
+ ui->depthLimits->clear();
+ ui->sacLimits->clear();
ui->divesAllText->clear();
- ui->maximumTemperatureAllText->clear();
- ui->minimumTemperatureAllText->clear();
- ui->averageTemperatureAllText->clear();
+ ui->tempLimits->clear();
ui->totalTimeAllText->clear();
- ui->averageTimeAllText->clear();
- ui->longestAllText->clear();
- ui->shortestAllText->clear();
+ ui->timeLimits->clear();
}
/* statisticsTab*/
/* we can access the stats_selection struct, but how do we ensure the relevant dives are selected
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index 854e67940..55d4f3a54 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -14,7 +14,7 @@
<string>TabWidget</string>
</property>
<property name="currentIndex">
- <number>2</number>
+ <number>3</number>
</property>
<property name="documentMode">
<bool>true</bool>
@@ -453,40 +453,26 @@
<string>Stats</string>
</attribute>
<layout class="QGridLayout" name="gridLayout1">
- <item row="2" column="0">
- <widget class="QGroupBox" name="groupBox_8b">
+ <item row="0" column="2">
+ <widget class="QGroupBox" name="groupBox_4b">
<property name="title">
- <string>Max. Temp.</string>
+ <string>SAC</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout_5b">
+ <layout class="QHBoxLayout" name="horizontalLayout_10b">
<item>
- <widget class="QLabel" name="maximumTemperatureAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
+ <widget class="MinMaxAvgWidget" name="sacLimits" native="true"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
- <widget class="QGroupBox" name="groupBox_2b">
+ <widget class="QGroupBox" name="groupBox_8b">
<property name="title">
- <string>Min Depth</string>
+ <string>Temperature</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout_3b">
+ <layout class="QHBoxLayout" name="horizontalLayout_5b">
<item>
- <widget class="QLabel" name="minimumDepthAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
+ <widget class="MinMaxAvgWidget" name="tempLimits" native="true"/>
</item>
</layout>
</widget>
@@ -494,196 +480,28 @@
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxb">
<property name="title">
- <string>Max. Depth</string>
+ <string>Depth</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2b">
<item>
- <widget class="QLabel" name="maximumDepthAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- <zorder>maximumDepthAllText</zorder>
- <zorder>minimumDepthAllText</zorder>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QGroupBox" name="groupBox_10b">
- <property name="title">
- <string>Ave. Temp.</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_7b">
- <item>
- <widget class="QLabel" name="averageTemperatureAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QGroupBox" name="groupBox_12b">
- <property name="title">
- <string>Ave. Time</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_13b">
- <item>
- <widget class="QLabel" name="averageTimeAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QGroupBox" name="groupBox_9b">
- <property name="title">
- <string>Min. Temp.</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_6b">
- <item>
- <widget class="QLabel" name="minimumTemperatureAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QGroupBox" name="groupBox_3b">
- <property name="title">
- <string>Ave. Depth</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_4b">
- <item>
- <widget class="QLabel" name="averageDepthAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QGroupBox" name="groupBox_4b">
- <property name="title">
- <string>Max. SAC</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_10b">
- <item>
- <widget class="QLabel" name="maximumSacAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QGroupBox" name="groupBox_5b">
- <property name="title">
- <string>Min. SAC</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_9b">
- <item>
- <widget class="QLabel" name="minimumSacAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
+ <widget class="MinMaxAvgWidget" name="depthLimits" native="true"/>
</item>
</layout>
</widget>
</item>
- <item row="3" column="2">
- <widget class="QGroupBox" name="groupBox_6b">
- <property name="title">
- <string>Ave. SAC</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_8b">
- <item>
- <widget class="QLabel" name="averageSacAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="7" column="0">
- <widget class="QGroupBox" name="groupBox_7b">
- <property name="title">
- <string>Dives</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_15">
- <item>
- <widget class="QLabel" name="divesAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="1">
+ <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_13">
<property name="title">
- <string>Longest</string>
+ <string>Duration</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12b">
<item>
- <widget class="QLabel" name="longestAllText">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
+ <widget class="MinMaxAvgWidget" name="timeLimits" native="true"/>
</item>
</layout>
</widget>
</item>
- <item row="4" column="0">
+ <item row="1" column="1">
<widget class="QGroupBox" name="groupBox_11b">
<property name="title">
<string>Total Time</string>
@@ -702,14 +520,14 @@
</layout>
</widget>
</item>
- <item row="7" column="1">
- <widget class="QGroupBox" name="groupBox_14">
+ <item row="1" column="2">
+ <widget class="QGroupBox" name="groupBox_7b">
<property name="title">
- <string>Shortest</string>
+ <string>Dives</string>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout_14">
+ <layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
- <widget class="QLabel" name="shortestAllText">
+ <widget class="QLabel" name="divesAllText">
<property name="text">
<string>TextLabel</string>
</property>
@@ -737,6 +555,12 @@
<header>starwidget.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>MinMaxAvgWidget</class>
+ <extends>QWidget</extends>
+ <header>simplewidgets.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
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);
+}
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
new file mode 100644
index 000000000..b05dd8f0e
--- /dev/null
+++ b/qt-ui/simplewidgets.h
@@ -0,0 +1,28 @@
+#ifndef SIMPLEWIDGETS_H
+#define SIMPLEWIDGETS_H
+
+class MinMaxAvgWidgetPrivate;
+#include <QWidget>
+
+class MinMaxAvgWidget : public QWidget{
+ Q_OBJECT
+ Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
+ Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
+ Q_PROPERTY(double average READ average WRITE setAverage)
+public:
+ MinMaxAvgWidget(QWidget *parent);
+ double minimum() const;
+ double maximum() const;
+ double average() const;
+ void setMinimum(double minimum);
+ void setMaximum(double maximum);
+ void setAverage(double average);
+ void setMinimum(const QString& minimum);
+ void setMaximum(const QString& maximum);
+ void setAverage(const QString& average);
+ void clear();
+private:
+ MinMaxAvgWidgetPrivate *d;
+};
+
+#endif \ No newline at end of file