aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-17 22:01:41 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-17 22:01:41 -0700
commitf3f7bf51fa1dbe9cdb859e1a45b20c108613275b (patch)
treea28814b4d3d59ff26b41ecfe71670c03fe2ce71d /qt-ui/maintab.cpp
parent082ec43eeabe92c7d65d3ab0f189e8fb43016f35 (diff)
parent56dbb7c2ff697a393f5051e2b5363bd4c0f2bb6e (diff)
downloadsubsurface-f3f7bf51fa1dbe9cdb859e1a45b20c108613275b.tar.gz
Merge branch 'Qt'
After the 3.1 release it is time to shift the focus on the Qt effort - and the best way to do this is to merge the changes in the Qt branch into master. Linus was extremely nice and did a merge for me. I decided to do my own merge instead (which by accident actually based on a different version of the Qt branch) and then used his merge to double check what I was doing. I resolved a few things differently but overall what we did was very much the same (and I say this with pride since Linus is a professional git merger) Here's his merge commit message: This is a rough and tumble merge of the Qt branch into 'master', trying to sort out the conflicts as best as I could. There were two major kinds of conflicts: - the Makefile changes, in particular the split of the single Makefile into Rules.mk and Configure.mk, along with the obvious Qt build changes themselves. Those changes conflicted with some of the updates done in mainline wrt "release" targets and some helper macros ($(NAME) etc). Resolved by largely taking the Qt branch versions, and then editing in the most obvious parts of the Makefile updates from mainline. NOTE! The script/get_version shell script was made to just fail silently on not finding a git repository, which avoided having to take some particularly ugly Makefile changes. - Various random updates in mainline to support things like dive tags. The conflicts were mainly to the gtk GUI parts, which obviously looked different afterwards. I fixed things up to look like the newer code, but since the gtk files themselves are actually dead in the Qt branch, this is largely irrelevant. NOTE! This does *NOT* introduce the equivalent Qt functionality. The fields are there in the code now, but there's no Qt UI for the whole dive tag stuff etc. This seems to compile for me (although I have to force "QMAKE=qmake-qt4" on f19), and results in a Linux binary that seems to work, but it is otherwise largely untested. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp204
1 files changed, 204 insertions, 0 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
new file mode 100644
index 000000000..70cb3caea
--- /dev/null
+++ b/qt-ui/maintab.cpp
@@ -0,0 +1,204 @@
+/*
+ * maintab.cpp
+ *
+ * classes for the "notebook" area of the main window of Subsurface
+ *
+ */
+#include "maintab.h"
+#include "ui_maintab.h"
+#include "addcylinderdialog.h"
+#include "addweightsystemdialog.h"
+#include "../helpers.h"
+#include "../statistics.h"
+
+#include <QLabel>
+
+MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
+ ui(new Ui::MainTab()),
+ weightModel(new WeightModel()),
+ cylindersModel(new CylindersModel())
+{
+ ui->setupUi(this);
+ ui->cylinders->setModel(cylindersModel);
+ ui->weights->setModel(weightModel);
+
+ /* example of where code is more concise than Qt designer */
+ QList<QObject *> infoTabWidgets = ui->infoTab->children();
+ Q_FOREACH( QObject* obj, infoTabWidgets ){
+ QLabel* label = qobject_cast<QLabel *>(obj);
+ if (label)
+ label->setAlignment(Qt::AlignHCenter);
+ }
+ QList<QObject *> statisticsTabWidgets = ui->statisticsTab->children();
+ Q_FOREACH( QObject* obj, statisticsTabWidgets ){
+ QLabel* label = qobject_cast<QLabel *>(obj);
+ if (label)
+ label->setAlignment(Qt::AlignHCenter);
+ }
+}
+
+void MainTab::clearEquipment()
+{
+}
+
+void MainTab::clearInfo()
+{
+ ui->sacText->clear();
+ ui->otuText->clear();
+ ui->oxygenHeliumText->clear();
+ ui->gasUsedText->clear();
+ ui->dateText->clear();
+ ui->diveTimeText->clear();
+ ui->surfaceIntervalText->clear();
+ ui->maximumDepthText->clear();
+ ui->averageDepthText->clear();
+ ui->visibilityText->clear();
+ ui->waterTemperatureText->clear();
+ ui->airTemperatureText->clear();
+ ui->airPressureText->clear();
+}
+
+void MainTab::clearStats()
+{
+ ui->maximumDepthAllText->clear();
+ ui->minimumDepthAllText->clear();
+ ui->averageDepthAllText->clear();
+ ui->maximumSacAllText->clear();
+ ui->minimumSacAllText->clear();
+ ui->averageSacAllText->clear();
+ ui->divesAllText->clear();
+ ui->maximumTemperatureAllText->clear();
+ ui->minimumTemperatureAllText->clear();
+ ui->averageTemperatureAllText->clear();
+ ui->totalTimeAllText->clear();
+ ui->averageTimeAllText->clear();
+ ui->longestAllText->clear();
+ ui->shortestAllText->clear();
+}
+
+#define UPDATE_TEXT(d, field) \
+ if (!d || !d->field) \
+ ui->field->setText(""); \
+ else \
+ ui->field->setText(d->field)
+
+
+void MainTab::updateDiveInfo(int dive)
+{
+ // So, this is what happens now:
+ // Every tab should be populated from this method,
+ // it will be called whenever a new dive is selected
+ // I'm already populating the 'notes' box
+ // to show how it can be done.
+ // If you are unsure about the name of something,
+ // open the file maintab.ui on the designer
+ // click on the item and check its objectName,
+ // the access is ui->objectName from here on.
+ volume_t sacVal;
+ struct dive *d = get_dive(dive);
+ UPDATE_TEXT(d, notes);
+ UPDATE_TEXT(d, location);
+ UPDATE_TEXT(d, suit);
+ UPDATE_TEXT(d, divemaster);
+ UPDATE_TEXT(d, buddy);
+ /* infoTab */
+ if (d) {
+ ui->rating->setCurrentStars(d->rating);
+ ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
+ ui->averageDepthText->setText(get_depth_string(d->meandepth, TRUE));
+ ui->otuText->setText(QString("%1").arg(d->otu));
+ ui->waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE));
+ ui->airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE));
+ ui->gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE));
+ if ((sacVal.mliter = d->sac) > 0)
+ ui->sacText->setText(get_volume_string(sacVal, TRUE).append("/min"));
+ else
+ ui->sacText->clear();
+ if (d->surface_pressure.mbar)
+ /* this is ALWAYS displayed in mbar */
+ ui->airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
+ else
+ ui->airPressureText->clear();
+ } else {
+ ui->rating->setCurrentStars(0);
+ ui->sacText->clear();
+ ui->otuText->clear();
+ ui->oxygenHeliumText->clear();
+ ui->dateText->clear();
+ ui->diveTimeText->clear();
+ ui->surfaceIntervalText->clear();
+ ui->maximumDepthText->clear();
+ ui->averageDepthText->clear();
+ ui->visibilityText->clear();
+ ui->waterTemperatureText->clear();
+ ui->airTemperatureText->clear();
+ ui->gasUsedText->clear();
+ ui->airPressureText->clear();
+ }
+ /* statisticsTab*/
+ /* we can access the stats_selection struct, but how do we ensure the relevant dives are selected
+ * if we don't use the gtk widget to drive this?
+ * Maybe call process_selected_dives? Or re-write to query our Qt list view.
+ */
+// qDebug("max temp %u",stats_selection.max_temp);
+// qDebug("min temp %u",stats_selection.min_temp);
+}
+
+void MainTab::on_addCylinder_clicked()
+{
+ if (cylindersModel->rowCount() >= MAX_CYLINDERS)
+ return;
+
+ AddCylinderDialog dialog(this);
+ cylinder_t *newCylinder = (cylinder_t*) malloc(sizeof(cylinder_t));
+ newCylinder->type.description = "";
+
+ dialog.setCylinder(newCylinder);
+ int result = dialog.exec();
+ if (result == QDialog::Rejected){
+ return;
+ }
+
+ dialog.updateCylinder();
+ cylindersModel->add(newCylinder);
+}
+
+void MainTab::on_editCylinder_clicked()
+{
+}
+
+void MainTab::on_delCylinder_clicked()
+{
+}
+
+void MainTab::on_addWeight_clicked()
+{
+ if (weightModel->rowCount() >= MAX_WEIGHTSYSTEMS)
+ return;
+
+ AddWeightsystemDialog dialog(this);
+ weightsystem_t newWeightsystem;
+ newWeightsystem.description = "";
+ newWeightsystem.weight.grams = 0;
+
+ dialog.setWeightsystem(&newWeightsystem);
+ int result = dialog.exec();
+ if (result == QDialog::Rejected)
+ return;
+
+ dialog.updateWeightsystem();
+ weightModel->add(&newWeightsystem);
+}
+
+void MainTab::on_editWeight_clicked()
+{
+}
+
+void MainTab::on_delWeight_clicked()
+{
+}
+
+void MainTab::reload()
+{
+ cylindersModel->update();
+}