From 1fc4fba69fed8607d9b961086a88bcf362a482a5 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 4 Apr 2017 19:21:30 +0200 Subject: [PATCH] Break down MainTab into smaller classes Maintab is one of our most complex classes, and it's something I'm not actually proud of. But it currently works and the idea of splitting it was in my head for quite a while. This is the third or fourth tentative of splitting it, and this time I let the most complex part of it untouched, the Notes and Equipment tab are way too complex to untangle right now on my limited time. A new class 'TabBase' should be used for any new tab that we may create, and added on the MainTab (see the new lines on the MainTab constructor). Also, Extra Info, Information, Photos and Statistics where ported to this new way helping reduce the number of lines and functions on the MainTab quite a bit. Overall this is a step in the right direction for the future. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- desktop-widgets/CMakeLists.txt | 13 +- desktop-widgets/globe.cpp | 2 +- desktop-widgets/mainwindow.cpp | 6 +- desktop-widgets/subsurfacewebservices.cpp | 2 +- desktop-widgets/tab-widgets/TabBase.cpp | 6 + desktop-widgets/tab-widgets/TabBase.h | 17 + .../tab-widgets/TabDiveExtraInfo.cpp | 29 + .../tab-widgets/TabDiveExtraInfo.h | 24 + .../tab-widgets/TabDiveExtraInfo.ui | 24 + .../tab-widgets/TabDiveInformation.cpp | 100 +++ .../tab-widgets/TabDiveInformation.h | 23 + .../tab-widgets/TabDiveInformation.ui | 340 ++++++++++ desktop-widgets/tab-widgets/TabDivePhotos.cpp | 98 +++ desktop-widgets/tab-widgets/TabDivePhotos.h | 33 + desktop-widgets/tab-widgets/TabDivePhotos.ui | 35 + .../tab-widgets/TabDiveStatistics.cpp | 125 ++++ .../tab-widgets/TabDiveStatistics.h | 22 + .../tab-widgets/TabDiveStatistics.ui | 222 ++++++ desktop-widgets/{ => tab-widgets}/maintab.cpp | 262 +------ desktop-widgets/{ => tab-widgets}/maintab.h | 13 +- desktop-widgets/{ => tab-widgets}/maintab.ui | 638 +----------------- desktop-widgets/tagwidget.cpp | 2 +- subsurface-desktop-main.cpp | 2 +- 23 files changed, 1152 insertions(+), 886 deletions(-) create mode 100644 desktop-widgets/tab-widgets/TabBase.cpp create mode 100644 desktop-widgets/tab-widgets/TabBase.h create mode 100644 desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp create mode 100644 desktop-widgets/tab-widgets/TabDiveExtraInfo.h create mode 100644 desktop-widgets/tab-widgets/TabDiveExtraInfo.ui create mode 100644 desktop-widgets/tab-widgets/TabDiveInformation.cpp create mode 100644 desktop-widgets/tab-widgets/TabDiveInformation.h create mode 100644 desktop-widgets/tab-widgets/TabDiveInformation.ui create mode 100644 desktop-widgets/tab-widgets/TabDivePhotos.cpp create mode 100644 desktop-widgets/tab-widgets/TabDivePhotos.h create mode 100644 desktop-widgets/tab-widgets/TabDivePhotos.ui create mode 100644 desktop-widgets/tab-widgets/TabDiveStatistics.cpp create mode 100644 desktop-widgets/tab-widgets/TabDiveStatistics.h create mode 100644 desktop-widgets/tab-widgets/TabDiveStatistics.ui rename desktop-widgets/{ => tab-widgets}/maintab.cpp (83%) rename desktop-widgets/{ => tab-widgets}/maintab.h (91%) rename desktop-widgets/{ => tab-widgets}/maintab.ui (51%) diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 0e7601196..2cf6382dd 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -36,7 +36,6 @@ set (SUBSURFACE_UI filterwidget.ui listfilter.ui locationInformation.ui - maintab.ui mainwindow.ui plannerDetails.ui plannerSettings.ui @@ -51,6 +50,11 @@ set (SUBSURFACE_UI urldialog.ui usersurvey.ui webservices.ui + tab-widgets/maintab.ui + tab-widgets/TabDiveStatistics.ui + tab-widgets/TabDiveInformation.ui + tab-widgets/TabDivePhotos.ui + tab-widgets/TabDiveExtraInfo.ui ) # the interface, in C++ @@ -64,7 +68,6 @@ set(SUBSURFACE_INTERFACE downloadfromdivecomputer.cpp globe.cpp kmessagewidget.cpp - maintab.cpp mainwindow.cpp modeldelegates.cpp notificationwidget.cpp @@ -82,6 +85,12 @@ set(SUBSURFACE_INTERFACE undocommands.cpp locationinformation.cpp qtwaitingspinner.cpp + tab-widgets/TabDiveStatistics.cpp + tab-widgets/TabDiveInformation.cpp + tab-widgets/TabDivePhotos.cpp + tab-widgets/TabDiveExtraInfo.cpp + tab-widgets/maintab.cpp + tab-widgets/TabBase.cpp ) if(NOT NO_USERMANUAL) diff --git a/desktop-widgets/globe.cpp b/desktop-widgets/globe.cpp index 2bab4e83f..2aef1438b 100644 --- a/desktop-widgets/globe.cpp +++ b/desktop-widgets/globe.cpp @@ -3,7 +3,7 @@ #include "desktop-widgets/mainwindow.h" #include "core/helpers.h" #include "desktop-widgets/divelistview.h" -#include "desktop-widgets/maintab.h" +#include "desktop-widgets/tab-widgets/maintab.h" #include "core/display.h" #include diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 28bc6cee6..5f70fa2e3 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -24,7 +24,7 @@ #include "profile-widget/profilewidget2.h" #include "desktop-widgets/globe.h" #include "core/divecomputer.h" -#include "desktop-widgets/maintab.h" +#include "desktop-widgets/tab-widgets/maintab.h" #include "desktop-widgets/diveplanner.h" #ifndef NO_PRINTING #include @@ -643,9 +643,7 @@ ProfileWidget2 *MainWindow::graphics() const void MainWindow::cleanUpEmpty() { - information()->clearStats(); - information()->clearInfo(); - information()->clearEquipment(); + information()->clearTabs(); information()->updateDiveInfo(true); graphics()->setEmptyState(); dive_list()->reload(DiveTripModel::TREE); diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index dd5d0943f..156f724e0 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -5,7 +5,7 @@ #include "desktop-widgets/usersurvey.h" #include "core/divelist.h" #include "desktop-widgets/globe.h" -#include "desktop-widgets/maintab.h" +#include "desktop-widgets/tab-widgets/maintab.h" #include "core/display.h" #include "core/membuffer.h" #include "core/subsurface-qt/SettingsObjectWrapper.h" diff --git a/desktop-widgets/tab-widgets/TabBase.cpp b/desktop-widgets/tab-widgets/TabBase.cpp new file mode 100644 index 000000000..127cce6e4 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabBase.cpp @@ -0,0 +1,6 @@ +#include "TabBase.h" + +TabBase::TabBase(QWidget *parent) : QWidget(parent) +{ +} + diff --git a/desktop-widgets/tab-widgets/TabBase.h b/desktop-widgets/tab-widgets/TabBase.h new file mode 100644 index 000000000..c5f3c4dcc --- /dev/null +++ b/desktop-widgets/tab-widgets/TabBase.h @@ -0,0 +1,17 @@ +#ifndef TAB_BASE_H +#define TAB_BASE_H + +#include + +struct dive; + +class TabBase : public QWidget { + Q_OBJECT + +public: + TabBase(QWidget *parent); + virtual void updateData() = 0; + virtual void clear() = 0; +}; + +#endif diff --git a/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp b/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp new file mode 100644 index 000000000..0560da7b3 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp @@ -0,0 +1,29 @@ +#include "TabDiveExtraInfo.h" +#include "ui_TabDiveExtraInfo.h" + +#include + +TabDiveExtraInfo::TabDiveExtraInfo(QWidget *parent) : + TabBase(parent), + ui(new Ui::TabDiveExtraInfo()), + extraDataModel(new ExtraDataModel()) +{ + ui->setupUi(this); + ui->extraData->setModel(extraDataModel); +} + +TabDiveExtraInfo::~TabDiveExtraInfo() +{ + delete ui; +} + +void TabDiveExtraInfo::updateData() +{ + extraDataModel->updateDive(); +} + +void TabDiveExtraInfo::clear() +{ + extraDataModel->updateDive(); +} + diff --git a/desktop-widgets/tab-widgets/TabDiveExtraInfo.h b/desktop-widgets/tab-widgets/TabDiveExtraInfo.h new file mode 100644 index 000000000..194e6cfd3 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveExtraInfo.h @@ -0,0 +1,24 @@ +#ifndef TAB_DIVE_EXTRA_INFO_H +#define TAB_DIVE_EXTRA_INFO_H + +#include "TabBase.h" + +namespace Ui { + class TabDiveExtraInfo; +}; + +class ExtraDataModel; + +class TabDiveExtraInfo : public TabBase { + Q_OBJECT +public: + TabDiveExtraInfo(QWidget *parent); + ~TabDiveExtraInfo(); + void updateData() override; + void clear() override; +private: + Ui::TabDiveExtraInfo *ui; + ExtraDataModel *extraDataModel; +}; + +#endif diff --git a/desktop-widgets/tab-widgets/TabDiveExtraInfo.ui b/desktop-widgets/tab-widgets/TabDiveExtraInfo.ui new file mode 100644 index 000000000..0e3008d1a --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveExtraInfo.ui @@ -0,0 +1,24 @@ + + + TabDiveExtraInfo + + + + 0 + 0 + 400 + 300 + + + + Extra Info + + + + + + + + + + diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp new file mode 100644 index 000000000..c9f9a4c44 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -0,0 +1,100 @@ +#include "TabDiveInformation.h" +#include "ui_TabDiveInformation.h" +#include "../tagwidget.h" + +#include +#include +#include + +TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation()) +{ + ui->setupUi(this); +} + +TabDiveInformation::~TabDiveInformation() +{ + delete ui; +} + +void TabDiveInformation::clear() +{ + ui->sacText->clear(); + ui->otuText->clear(); + ui->maxcnsText->clear(); + ui->oxygenHeliumText->clear(); + ui->gasUsedText->clear(); + ui->dateText->clear(); + ui->diveTimeText->clear(); + ui->surfaceIntervalText->clear(); + ui->maximumDepthText->clear(); + ui->averageDepthText->clear(); + ui->waterTemperatureText->clear(); + ui->airTemperatureText->clear(); + ui->airPressureText->clear(); + ui->salinityText->clear(); +} + +void TabDiveInformation::updateData() +{ + clear(); + + ui->maxcnsText->setText(QString("%1\%").arg(displayed_dive.maxcns)); + ui->otuText->setText(QString("%1").arg(displayed_dive.otu)); + ui->maximumDepthText->setText(get_depth_string(displayed_dive.maxdepth, true)); + ui->averageDepthText->setText(get_depth_string(displayed_dive.meandepth, true)); + ui->dateText->setText(get_short_dive_date_string(displayed_dive.when)); + ui->waterTemperatureText->setText(get_temperature_string(displayed_dive.watertemp, true)); + ui->airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, true)); + + volume_t gases[MAX_CYLINDERS] = {}; + get_gas_used(&displayed_dive, gases); + QString volumes; + int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS]; + per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration); + volume_t sac; + QString gaslist, SACs, separator; + + gaslist = ""; SACs = ""; volumes = ""; separator = ""; + for (int i = 0; i < MAX_CYLINDERS; i++) { + if (!is_cylinder_used(&displayed_dive, i)) + continue; + gaslist.append(separator); volumes.append(separator); SACs.append(separator); + separator = "\n"; + + gaslist.append(gasname(&displayed_dive.cylinder[i].gasmix)); + if (!gases[i].mliter) + continue; + volumes.append(get_volume_string(gases[i], true)); + if (duration[i]) { + sac.mliter = gases[i].mliter / (depth_to_atm(mean[i], &displayed_dive) * duration[i] / 60); + SACs.append(get_volume_string(sac, true).append(tr("/min"))); + } + } + ui->gasUsedText->setText(volumes); + ui->oxygenHeliumText->setText(gaslist); + + int sum = displayed_dive.dc.divemode != FREEDIVE ? 30 : 0; + ui->diveTimeText->setText(get_time_string_s(displayed_dive.duration.seconds + sum, 0, false)); + + struct dive *prevd; + process_all_dives(&displayed_dive, &prevd); + + if (prevd) + ui->surfaceIntervalText->setText(get_time_string_s(displayed_dive.when - (prevd->when + prevd->duration.seconds), 4, + (displayed_dive.dc.divemode == FREEDIVE))); + else + ui->surfaceIntervalText->clear(); + + ui->sacText->setText( mean[0] ? SACs : QString()); + + if (displayed_dive.surface_pressure.mbar) /* this is ALWAYS displayed in mbar */ + ui->airPressureText->setText(QString("%1mbar").arg(displayed_dive.surface_pressure.mbar)); + else + ui->airPressureText->clear(); + + if (displayed_dive.salinity) + ui->salinityText->setText(QString("%1g/l").arg(displayed_dive.salinity / 10.0)); + else + ui->salinityText->clear(); + +} diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h new file mode 100644 index 000000000..e67b981c9 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -0,0 +1,23 @@ +#ifndef TAB_DIVE_INFORMATION_H +#define TAB_DIVE_INFORMATION_H + +#include "TabBase.h" + +namespace Ui { + class TabDiveInformation; +}; + +class TabDiveInformation : public TabBase { + Q_OBJECT +public: + TabDiveInformation(QWidget *parent); + ~TabDiveInformation(); + void updateData() override; + void clear() override; + +private: + Ui::TabDiveInformation *ui; +}; + + +#endif diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.ui b/desktop-widgets/tab-widgets/TabDiveInformation.ui new file mode 100644 index 000000000..feb547334 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveInformation.ui @@ -0,0 +1,340 @@ + + + TabDiveInformation + + + + 0 + 0 + 400 + 421 + + + + Information + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 388 + 409 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 2 + + + + + Date + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Interval + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Gases used + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Gas consumed + + + + + + + + + Qt::AlignCenter + + + + + + + + + + SAC + + + + + + + + + Qt::AlignCenter + + + + + + + + + + CNS + + + + + + + + + Qt::AlignCenter + + + + + + + + + + OTU + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Max. depth + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Avg. depth + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Air pressure + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Air temp. + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Water temp. + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Dive time + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Salinity + + + + + + Qt::AlignCenter + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + + + + + diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.cpp b/desktop-widgets/tab-widgets/TabDivePhotos.cpp new file mode 100644 index 000000000..7f8b3a8b0 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDivePhotos.cpp @@ -0,0 +1,98 @@ +#include "TabDivePhotos.h" +#include "ui_TabDivePhotos.h" + +#include + +#include +#include +#include +#include +#include + +//TODO: Remove those in the future. +#include "../mainwindow.h" +#include "../divelistview.h" + +TabDivePhotos::TabDivePhotos(QWidget *parent) + : TabBase(parent), + ui(new Ui::TabDivePhotos()), + divePictureModel(DivePictureModel::instance()) +{ + ui->setupUi(this); + ui->photosView->setModel(divePictureModel); + ui->photosView->setSelectionMode(QAbstractItemView::MultiSelection); + + connect(ui->photosView, &DivePictureWidget::photoDoubleClicked, + [](const QString& path) { + QDesktopServices::openUrl(QUrl::fromLocalFile(path)); + } + ); +} + +TabDivePhotos::~TabDivePhotos() +{ + delete ui; +} + +void TabDivePhotos::clear() +{ + updateData(); +} + +void TabDivePhotos::contextMenuEvent(QContextMenuEvent *event) +{ + QMenu popup(this); + popup.addAction(tr("Load image(s) from file(s)"), this, &TabDivePhotos::addPhotosFromFile); + popup.addAction(tr("Load image(s) from web"), this, &TabDivePhotos::addPhotosFromURL); + popup.addSeparator(); + popup.addAction(tr("Delete selected images"), this, &TabDivePhotos::removeSelectedPhotos); + popup.addAction(tr("Delete all images"), this, &TabDivePhotos::removeAllPhotos); + popup.exec(event->globalPos()); + event->accept(); +} + +void TabDivePhotos::removeSelectedPhotos() +{ + bool last = false; + if (!ui->photosView->selectionModel()->hasSelection()) + return; + QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows(); + if (indexes.count() == 0) + indexes = ui->photosView->selectionModel()->selectedIndexes(); + QModelIndex photo = indexes.first(); + do { + photo = indexes.first(); + last = indexes.count() == 1; + if (photo.isValid()) { + QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString(); + if (fileUrl.length() > 0) + DivePictureModel::instance()->removePicture(fileUrl, last); + } + indexes.removeFirst(); + } while(!indexes.isEmpty()); +} + +//TODO: This looks overly wrong. We shouldn't call MainWindow to retrieve the DiveList to add Images. +void TabDivePhotos::addPhotosFromFile() +{ + MainWindow::instance()->dive_list()->loadImages(); +} + +void TabDivePhotos::addPhotosFromURL() +{ + MainWindow::instance()->dive_list()->loadWebImages(); +} + +void TabDivePhotos::removeAllPhotos() +{ + if (QMessageBox::warning(this, tr("Deleting Images"), tr("Are you sure you want to delete all images?"), QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Cancel ) { + ui->photosView->selectAll(); + removeSelectedPhotos(); + } +} + +void TabDivePhotos::updateData() +{ + divePictureModel->updateDivePictures(); +} + diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.h b/desktop-widgets/tab-widgets/TabDivePhotos.h new file mode 100644 index 000000000..f2c73b572 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDivePhotos.h @@ -0,0 +1,33 @@ +#ifndef TAB_DIVE_PHOTOS_H +#define TAB_DIVE_PHOTOS_H + +#include "TabBase.h" + +namespace Ui { + class TabDivePhotos; +}; + +class DivePictureModel; + +class TabDivePhotos : public TabBase { + Q_OBJECT +public: + TabDivePhotos(QWidget *parent); + ~TabDivePhotos(); + void updateData() override; + void clear() override; + +protected: + void contextMenuEvent(QContextMenuEvent *ev) override; + +private: + void addPhotosFromFile(); + void addPhotosFromURL(); + void removeAllPhotos(); + void removeSelectedPhotos(); + + Ui::TabDivePhotos *ui; + DivePictureModel *divePictureModel; +}; + +#endif diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.ui b/desktop-widgets/tab-widgets/TabDivePhotos.ui new file mode 100644 index 000000000..35cfd375a --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDivePhotos.ui @@ -0,0 +1,35 @@ + + + TabDivePhotos + + + + 0 + 0 + 400 + 300 + + + + Photos + + + + + + QListView::IconMode + + + + + + + + DivePictureWidget + QListView +
desktop-widgets/divepicturewidget.h
+
+
+ + +
diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp new file mode 100644 index 000000000..6f8c207b1 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp @@ -0,0 +1,125 @@ +#include "TabDiveStatistics.h" +#include "ui_TabDiveStatistics.h" + +#include +#include +#include + +TabDiveStatistics::TabDiveStatistics(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveStatistics()) +{ + ui->setupUi(this); + ui->sacLimits->overrideMaxToolTipText(tr("Highest total SAC of a dive")); + ui->sacLimits->overrideMinToolTipText(tr("Lowest total SAC of a dive")); + ui->sacLimits->overrideAvgToolTipText(tr("Average total SAC of all selected dives")); + ui->tempLimits->overrideMaxToolTipText(tr("Highest temperature")); + ui->tempLimits->overrideMinToolTipText(tr("Lowest temperature")); + ui->tempLimits->overrideAvgToolTipText(tr("Average temperature of all selected dives")); + ui->depthLimits->overrideMaxToolTipText(tr("Deepest dive")); + ui->depthLimits->overrideMinToolTipText(tr("Shallowest dive")); + ui->timeLimits->overrideMaxToolTipText(tr("Longest dive")); + ui->timeLimits->overrideMinToolTipText(tr("Shortest dive")); + ui->timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives")); + + Q_FOREACH (QObject *obj, children()) { + if (QLabel *label = qobject_cast(obj)) + label->setAlignment(Qt::AlignHCenter); + } +} + +TabDiveStatistics::~TabDiveStatistics() +{ + delete ui; +} + +void TabDiveStatistics::clear() +{ + ui->depthLimits->clear(); + ui->sacLimits->clear(); + ui->divesAllText->clear(); + ui->tempLimits->clear(); + ui->totalTimeAllText->clear(); + ui->timeLimits->clear(); +} + +void TabDiveStatistics::updateData() +{ + clear(); + ui->depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, true)); + ui->depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, true)); + // the overall average depth is really confusing when listed between the + // deepest and shallowest dive - let's just not set it + // ui->depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, true)); + + + if (amount_selected > 1 && stats_selection.max_sac.mliter) + ui->sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min"))); + else + ui->sacLimits->setMaximum(""); + if (amount_selected > 1 && stats_selection.min_sac.mliter) + ui->sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, true).append(tr("/min"))); + else + ui->sacLimits->setMinimum(""); + if (stats_selection.avg_sac.mliter) + ui->sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, true).append(tr("/min"))); + else + ui->sacLimits->setAverage(""); + + temperature_t temp; + temp.mkelvin = stats_selection.max_temp; + ui->tempLimits->setMaximum(get_temperature_string(temp, true)); + temp.mkelvin = stats_selection.min_temp; + 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->tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit)); + } + + + ui->divesAllText->setText(QString::number(stats_selection.selection_size)); + ui->totalTimeAllText->setText(get_time_string_s(stats_selection.total_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE))); + int seconds = stats_selection.total_time.seconds; + if (stats_selection.selection_size) + seconds /= stats_selection.selection_size; + ui->timeLimits->setAverage(get_time_string_s(seconds, 0,(displayed_dive.dc.divemode == FREEDIVE))); + if (amount_selected > 1) { + ui->timeLimits->setMaximum(get_time_string_s(stats_selection.longest_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE))); + ui->timeLimits->setMinimum(get_time_string_s(stats_selection.shortest_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE))); + } else { + ui->timeLimits->setMaximum(""); + ui->timeLimits->setMinimum(""); + } + + QVector > gasUsed; + QString gasUsedString; + volume_t vol; + selectedDivesGasUsed(gasUsed); + for (int j = 0; j < 20; j++) { + if (gasUsed.isEmpty()) + break; + QPair gasPair = gasUsed.last(); + gasUsed.pop_back(); + vol.mliter = gasPair.second; + gasUsedString.append(gasPair.first).append(": ").append(get_volume_string(vol, true)).append("\n"); + } + if (!gasUsed.isEmpty()) + gasUsedString.append("..."); + volume_t o2_tot = {}, he_tot = {}; + selected_dives_gas_parts(&o2_tot, &he_tot); + + /* No need to show the gas mixing information if diving + * with pure air, and only display the he / O2 part when + * it is used. + */ + if (he_tot.mliter || o2_tot.mliter) { + gasUsedString.append(tr("These gases could be\nmixed from Air and using:\n")); + if (he_tot.mliter) + gasUsedString.append(QString("He: %1").arg(get_volume_string(he_tot, true))); + if (he_tot.mliter && o2_tot.mliter) + gasUsedString.append(tr(" and ")); + if (o2_tot.mliter) + gasUsedString.append(QString("O2: %2\n").arg(get_volume_string(o2_tot, true))); + } + ui->gasConsumption->setText(gasUsedString); +} + diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.h b/desktop-widgets/tab-widgets/TabDiveStatistics.h new file mode 100644 index 000000000..fd0d4ec0d --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveStatistics.h @@ -0,0 +1,22 @@ +#ifndef TAB_DIVE_STATISTICS_H +#define TAB_DIVE_STATISTICS_H + +#include "TabBase.h" + +namespace Ui { + class TabDiveStatistics; +}; + +class TabDiveStatistics : public TabBase { + Q_OBJECT +public: + TabDiveStatistics(QWidget *parent); + ~TabDiveStatistics(); + void updateData() override; + void clear() override; + +private: + Ui::TabDiveStatistics *ui; +}; + +#endif diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.ui b/desktop-widgets/tab-widgets/TabDiveStatistics.ui new file mode 100644 index 000000000..251983611 --- /dev/null +++ b/desktop-widgets/tab-widgets/TabDiveStatistics.ui @@ -0,0 +1,222 @@ + + + TabDiveStatistics + + + + 0 + 0 + 400 + 300 + + + + Statistics + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 388 + 288 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + Depth + + + + + + + + + + + + Duration + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Temperature + + + + + + + + + + + + Total time + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Dives + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + SAC + + + + + + + + + + + + Gas consumption + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + MinMaxAvgWidget + QWidget +
desktop-widgets/simplewidgets.h
+ 1 +
+
+ + +
diff --git a/desktop-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp similarity index 83% rename from desktop-widgets/maintab.cpp rename to desktop-widgets/tab-widgets/maintab.cpp index d8ccafb0a..0b712c8fb 100644 --- a/desktop-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -4,7 +4,7 @@ * classes for the "notebook" area of the main window of Subsurface * */ -#include "desktop-widgets/maintab.h" +#include "desktop-widgets/tab-widgets/maintab.h" #include "desktop-widgets/mainwindow.h" #include "desktop-widgets/globe.h" #include "core/helpers.h" @@ -18,12 +18,16 @@ #include "core/divesitehelpers.h" #include "qt-models/cylindermodel.h" #include "qt-models/weightmodel.h" -#include "qt-models/divepicturemodel.h" #include "qt-models/divecomputerextradatamodel.h" #include "qt-models/divelocationmodel.h" #include "core/divesite.h" #include "desktop-widgets/locationinformation.h" +#include "TabDiveExtraInfo.h" +#include "TabDiveInformation.h" +#include "TabDivePhotos.h" +#include "TabDiveStatistics.h" + #include #include #include @@ -35,13 +39,21 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), weightModel(new WeightModel(this)), cylindersModel(new CylindersModel(this)), - extraDataModel(new ExtraDataModel(this)), editMode(NONE), - divePictureModel(DivePictureModel::instance()), copyPaste(false), currentTrip(0) { ui.setupUi(this); + + extraWidgets << new TabDiveExtraInfo(this); + addTab(extraWidgets.last(), "Extra Info"); + extraWidgets << new TabDiveInformation(this); + addTab(extraWidgets.last(), "Information"); + extraWidgets << new TabDiveStatistics(this); + addTab(extraWidgets.last(), "Statistics"); + extraWidgets << new TabDivePhotos(this); + addTab(extraWidgets.last(), "Photos"); + ui.dateEdit->setDisplayFormat(prefs.date_format); memset(&displayed_dive, 0, sizeof(displayed_dive)); @@ -49,9 +61,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.cylinders->setModel(cylindersModel); ui.weights->setModel(weightModel); - ui.photosView->setModel(divePictureModel); - connect(ui.photosView, SIGNAL(photoDoubleClicked(QString)), this, SLOT(photoDoubleClicked(QString))); - ui.extraData->setModel(extraDataModel); closeMessage(); connect(ui.editDiveSiteButton, SIGNAL(clicked()), MainWindow::instance(), SIGNAL(startDiveSiteEdit())); @@ -80,11 +89,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), // filled from a dive, they are made writeable setEnabled(false); - Q_FOREACH (QObject *obj, ui.statisticsTab->children()) { - QLabel *label = qobject_cast(obj); - if (label) - label->setAlignment(Qt::AlignHCenter); - } ui.cylinders->setTitle(tr("Cylinders")); ui.cylinders->setBtnToolTip(tr("Add cylinder")); connect(ui.cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked())); @@ -118,8 +122,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.tagWidget->setCompleter(completers.tags); ui.diveNotesMessage->hide(); ui.diveEquipmentMessage->hide(); - ui.diveInfoMessage->hide(); - ui.diveStatisticsMessage->hide(); ui.depth->hide(); ui.depthLabel->hide(); ui.duration->hide(); @@ -134,8 +136,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), p.setColor(QPalette::Window, QColor(Qt::white)); ui.scrollArea->viewport()->setPalette(p); ui.scrollArea_2->viewport()->setPalette(p); - ui.scrollArea_3->viewport()->setPalette(p); - ui.scrollArea_4->viewport()->setPalette(p); // GroupBoxes in Gnome3 looks like I'v drawn them... static const QString gnomeCss( @@ -204,7 +204,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), acceptingEdit = false; ui.diveTripLocation->hide(); - ui.photosView->setSelectionMode(QAbstractItemView::MultiSelection); + + } MainTab::~MainTab() @@ -262,16 +263,12 @@ void MainTab::addMessageAction(QAction *action) { ui.diveEquipmentMessage->addAction(action); ui.diveNotesMessage->addAction(action); - ui.diveInfoMessage->addAction(action); - ui.diveStatisticsMessage->addAction(action); } void MainTab::hideMessage() { ui.diveNotesMessage->animatedHide(); ui.diveEquipmentMessage->animatedHide(); - ui.diveInfoMessage->animatedHide(); - ui.diveStatisticsMessage->animatedHide(); updateTextLabels(false); } @@ -280,24 +277,16 @@ void MainTab::closeMessage() hideMessage(); ui.diveNotesMessage->setCloseButtonVisible(false); ui.diveEquipmentMessage->setCloseButtonVisible(false); - ui.diveInfoMessage->setCloseButtonVisible(false); - ui.diveStatisticsMessage->setCloseButtonVisible(false); } void MainTab::displayMessage(QString str) { ui.diveNotesMessage->setCloseButtonVisible(false); ui.diveEquipmentMessage->setCloseButtonVisible(false); - ui.diveInfoMessage->setCloseButtonVisible(false); - ui.diveStatisticsMessage->setCloseButtonVisible(false); ui.diveNotesMessage->setText(str); ui.diveNotesMessage->animatedShow(); ui.diveEquipmentMessage->setText(str); ui.diveEquipmentMessage->animatedShow(); - ui.diveInfoMessage->setText(str); - ui.diveInfoMessage->animatedShow(); - ui.diveStatisticsMessage->setText(str); - ui.diveStatisticsMessage->animatedShow(); updateTextLabels(); } @@ -370,35 +359,6 @@ void MainTab::nextInputField(QKeyEvent *event) keyPressEvent(event); } -void MainTab::clearInfo() -{ - ui.sacText->clear(); - ui.otuText->clear(); - ui.maxcnsText->clear(); - ui.oxygenHeliumText->clear(); - ui.gasUsedText->clear(); - ui.dateText->clear(); - ui.diveTimeText->clear(); - ui.surfaceIntervalText->clear(); - ui.maximumDepthText->clear(); - ui.averageDepthText->clear(); - ui.waterTemperatureText->clear(); - ui.airTemperatureText->clear(); - ui.airPressureText->clear(); - ui.salinityText->clear(); - ui.tagWidget->clear(); -} - -void MainTab::clearStats() -{ - ui.depthLimits->clear(); - ui.sacLimits->clear(); - ui.divesAllText->clear(); - ui.tempLimits->clear(); - ui.totalTimeAllText->clear(); - ui.timeLimits->clear(); -} - #define UPDATE_TEXT(d, field) \ if (clear || !d.field) \ ui.field->setText(QString()); \ @@ -459,14 +419,15 @@ void MainTab::updateDiveInfo(bool clear) // If exactly one trip has been selected, we show the location / notes // for the trip in the Info tab, otherwise we show the info of the // selected_dive - temperature_t temp; struct dive *prevd; char buf[1024]; process_selected_dives(); process_all_dives(&displayed_dive, &prevd); - divePictureModel->updateDivePictures(); + for (auto widget : extraWidgets) { + widget->updateData(); + } ui.notes->setText(QString()); if (!clear) { @@ -590,7 +551,6 @@ void MainTab::updateDiveInfo(bool clear) ui.equipmentTab->setEnabled(true); cylindersModel->updateDive(); weightModel->updateDive(); - extraDataModel->updateDive(); taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); ui.tagWidget->setText(QString(buf)); bool isManual = !current_dive || same_string(current_dive->dc.model, "manually added dive"); @@ -601,12 +561,6 @@ void MainTab::updateDiveInfo(bool clear) } ui.duration->setText(QDateTime::fromTime_t(displayed_dive.duration.seconds).toUTC().toString("h:mm")); ui.depth->setText(get_depth_string(displayed_dive.maxdepth, true)); - ui.maximumDepthText->setText(get_depth_string(displayed_dive.maxdepth, true)); - ui.averageDepthText->setText(get_depth_string(displayed_dive.meandepth, true)); - ui.maxcnsText->setText(QString("%1\%").arg(displayed_dive.maxcns)); - ui.otuText->setText(QString("%1").arg(displayed_dive.otu)); - ui.waterTemperatureText->setText(get_temperature_string(displayed_dive.watertemp, true)); - ui.airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, true)); ui.DiveType->setCurrentIndex(get_dive_dc(&displayed_dive, dc_number)->divemode); volume_t gases[MAX_CYLINDERS] = {}; @@ -614,100 +568,7 @@ void MainTab::updateDiveInfo(bool clear) QString volumes; int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS]; per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration); - volume_t sac; - QString gaslist, SACs, separator; - gaslist = ""; SACs = ""; volumes = ""; separator = ""; - for (int i = 0; i < MAX_CYLINDERS; i++) { - if (!is_cylinder_used(&displayed_dive, i)) - continue; - gaslist.append(separator); volumes.append(separator); SACs.append(separator); - separator = "\n"; - - gaslist.append(gasname(&displayed_dive.cylinder[i].gasmix)); - if (!gases[i].mliter) - continue; - volumes.append(get_volume_string(gases[i], true)); - if (duration[i]) { - sac.mliter = lrint(gases[i].mliter / (depth_to_atm(mean[i], &displayed_dive) * duration[i] / 60)); - SACs.append(get_volume_string(sac, true).append(tr("/min"))); - } - } - ui.gasUsedText->setText(volumes); - ui.oxygenHeliumText->setText(gaslist); - ui.dateText->setText(get_short_dive_date_string(displayed_dive.when)); - if (displayed_dive.dc.divemode != FREEDIVE) - ui.diveTimeText->setText(get_time_string_s(displayed_dive.duration.seconds + 30, 0, false)); - else - ui.diveTimeText->setText(get_time_string_s(displayed_dive.duration.seconds, 0, true)); - if (prevd) - ui.surfaceIntervalText->setText(get_time_string_s(displayed_dive.when - (prevd->when + prevd->duration.seconds), 4, - (displayed_dive.dc.divemode == FREEDIVE))); - else - ui.surfaceIntervalText->clear(); - if (mean[0]) - ui.sacText->setText(SACs); - else - ui.sacText->clear(); - if (displayed_dive.surface_pressure.mbar) - /* this is ALWAYS displayed in mbar */ - ui.airPressureText->setText(QString("%1mbar").arg(displayed_dive.surface_pressure.mbar)); - else - ui.airPressureText->clear(); - if (displayed_dive.salinity) - ui.salinityText->setText(QString("%1g/l").arg(displayed_dive.salinity / 10.0)); - else - ui.salinityText->clear(); - ui.depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, true)); - ui.depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, true)); - // the overall average depth is really confusing when listed between the - // deepest and shallowest dive - let's just not set it - // ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, true)); - ui.depthLimits->overrideMaxToolTipText(tr("Deepest dive")); - ui.depthLimits->overrideMinToolTipText(tr("Shallowest dive")); - if (amount_selected > 1 && stats_selection.max_sac.mliter) - ui.sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min"))); - else - ui.sacLimits->setMaximum(""); - if (amount_selected > 1 && stats_selection.min_sac.mliter) - ui.sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, true).append(tr("/min"))); - else - ui.sacLimits->setMinimum(""); - if (stats_selection.avg_sac.mliter) - ui.sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, true).append(tr("/min"))); - else - ui.sacLimits->setAverage(""); - ui.sacLimits->overrideMaxToolTipText(tr("Highest total SAC of a dive")); - ui.sacLimits->overrideMinToolTipText(tr("Lowest total SAC of a dive")); - ui.sacLimits->overrideAvgToolTipText(tr("Average total SAC of all selected dives")); - ui.divesAllText->setText(QString::number(stats_selection.selection_size)); - temp.mkelvin = stats_selection.max_temp; - ui.tempLimits->setMaximum(get_temperature_string(temp, true)); - temp.mkelvin = stats_selection.min_temp; - 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.tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit)); - } - ui.tempLimits->overrideMaxToolTipText(tr("Highest temperature")); - ui.tempLimits->overrideMinToolTipText(tr("Lowest temperature")); - ui.tempLimits->overrideAvgToolTipText(tr("Average temperature of all selected dives")); - ui.totalTimeAllText->setText(get_time_string_s(stats_selection.total_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE))); - int seconds = stats_selection.total_time.seconds; - if (stats_selection.selection_size) - seconds /= stats_selection.selection_size; - ui.timeLimits->setAverage(get_time_string_s(seconds, 0,(displayed_dive.dc.divemode == FREEDIVE))); - if (amount_selected > 1) { - ui.timeLimits->setMaximum(get_time_string_s(stats_selection.longest_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE))); - ui.timeLimits->setMinimum(get_time_string_s(stats_selection.shortest_time.seconds, 0, (displayed_dive.dc.divemode == FREEDIVE))); - } else { - ui.timeLimits->setMaximum(""); - ui.timeLimits->setMinimum(""); - } - ui.timeLimits->overrideMaxToolTipText(tr("Longest dive")); - ui.timeLimits->overrideMinToolTipText(tr("Shortest dive")); - ui.timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives")); // now let's get some gas use statistics QVector > gasUsed; QString gasUsedString; @@ -726,20 +587,6 @@ void MainTab::updateDiveInfo(bool clear) volume_t o2_tot = {}, he_tot = {}; selected_dives_gas_parts(&o2_tot, &he_tot); - /* No need to show the gas mixing information if diving - * with pure air, and only display the he / O2 part when - * it is used. - */ - if (he_tot.mliter || o2_tot.mliter) { - gasUsedString.append(tr("These gases could be\nmixed from Air and using:\n")); - if (he_tot.mliter) - gasUsedString.append(QString("He: %1").arg(get_volume_string(he_tot, true))); - if (he_tot.mliter && o2_tot.mliter) - gasUsedString.append(tr(" and ")); - if (o2_tot.mliter) - gasUsedString.append(QString("O₂: %2\n").arg(get_volume_string(o2_tot, true))); - } - ui.gasConsumption->setText(gasUsedString); if(ui.locationTags->text().isEmpty()) ui.locationTags->hide(); else @@ -750,9 +597,7 @@ void MainTab::updateDiveInfo(bool clear) } else { /* clear the fields */ - clearInfo(); - clearStats(); - clearEquipment(); + clearTabs(); ui.rating->setCurrentStars(0); ui.visibility->setCurrentStars(0); ui.location->clear(); @@ -1186,7 +1031,10 @@ void MainTab::rejectChanges() else clear_dive(&displayed_dive); updateDiveInfo(selected_dive < 0); - DivePictureModel::instance()->updateDivePictures(); + + for (auto widget : extraWidgets) { + widget->updateData(); + } // the user could have edited the location and then canceled the edit // let's get the correct location back in view #ifndef NO_MARBLE @@ -1199,7 +1047,6 @@ void MainTab::rejectChanges() weightModel->changed = false; cylindersModel->updateDive(); weightModel->updateDive(); - extraDataModel->updateDive(); ui.editDiveSiteButton->setEnabled(true); } #undef EDIT_TEXT2 @@ -1627,48 +1474,11 @@ void MainTab::escDetected() rejectChanges(); } -void MainTab::photoDoubleClicked(const QString filePath) -{ - QDesktopServices::openUrl(QUrl::fromLocalFile(filePath)); -} - -void MainTab::removeSelectedPhotos() -{ - bool last = false; - if (!ui.photosView->selectionModel()->hasSelection()) - return; - QModelIndexList indexes = ui.photosView->selectionModel()->selectedRows(); - if (indexes.count() == 0) - indexes = ui.photosView->selectionModel()->selectedIndexes(); - QModelIndex photo = indexes.first(); - do { - photo = indexes.first(); - last = indexes.count() == 1; - if (photo.isValid()) { - QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString(); - if (fileUrl.length() > 0) - DivePictureModel::instance()->removePicture(fileUrl, last); - } - indexes.removeFirst(); - } while(!indexes.isEmpty()); -} - -void MainTab::removeAllPhotos() -{ - if (QMessageBox::warning(this, tr("Deleting Images"), tr("Are you sure you want to delete all images?"), QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Cancel ) { - ui.photosView->selectAll(); - removeSelectedPhotos(); +void MainTab::clearTabs() { + for (auto widget : extraWidgets) { + widget->clear(); } -} - -void MainTab::addPhotosFromFile() -{ - MainWindow::instance()->dive_list()->loadImages(); -} - -void MainTab::addPhotosFromURL() -{ - MainWindow::instance()->dive_list()->loadWebImages(); + clearEquipment(); } #define SHOW_SELECTIVE(_component) \ @@ -1710,15 +1520,3 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) weightModel->changed = true; } } - -void MainTab::contextMenuEvent(QContextMenuEvent *event) -{ - QMenu popup(this); - popup.addAction(tr("Load image(s) from file(s)"), this, SLOT(addPhotosFromFile())); - popup.addAction(tr("Load image(s) from web"), this, SLOT(addPhotosFromURL())); - popup.addSeparator(); - popup.addAction(tr("Delete selected images"), this, SLOT(removeSelectedPhotos())); - popup.addAction(tr("Delete all images"), this, SLOT(removeAllPhotos())); - popup.exec(event->globalPos()); - event->accept(); -} diff --git a/desktop-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h similarity index 91% rename from desktop-widgets/maintab.h rename to desktop-widgets/tab-widgets/maintab.h index 25d078434..a33d6053b 100644 --- a/desktop-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -30,6 +30,7 @@ struct Completers { QCompleter *tags; }; +class TabBase; class MainTab : public QTabWidget { Q_OBJECT public: @@ -44,8 +45,7 @@ public: MainTab(QWidget *parent = 0); ~MainTab(); - void clearStats(); - void clearInfo(); + void clearTabs(); void clearEquipment(); void reload(); void initialUiSetup(); @@ -54,7 +54,6 @@ public: void refreshDisplayedDiveSite(); void nextInputField(QKeyEvent *event); void showAndTriggerEditSelective(struct dive_components what); - void contextMenuEvent(QContextMenuEvent *event); signals: void addDiveFinished(); @@ -98,11 +97,6 @@ slots: void toggleTriggeredColumn(); void updateTextLabels(bool showUnits = true); void escDetected(void); - void photoDoubleClicked(const QString filePath); - void removeSelectedPhotos(); - void removeAllPhotos(); - void addPhotosFromFile(); - void addPhotosFromURL(); void showLocation(); void enableGeoLookupEdition(); void disableGeoLookupEdition(); @@ -112,13 +106,11 @@ private: Ui::MainTab ui; WeightModel *weightModel; CylindersModel *cylindersModel; - ExtraDataModel *extraDataModel; EditMode editMode; BuddyCompletionModel buddyModel; DiveMasterCompletionModel diveMasterModel; SuitCompletionModel suitModel; TagCompletionModel tagModel; - DivePictureModel *divePictureModel; Completers completers; bool modified; bool copyPaste; @@ -131,6 +123,7 @@ private: dive_trip_t displayedTrip; bool acceptingEdit; uint32_t updateDiveSite(uint32_t pickedUuid, int divenr); + QList extraWidgets; }; #endif // MAINTAB_H diff --git a/desktop-widgets/maintab.ui b/desktop-widgets/tab-widgets/maintab.ui similarity index 51% rename from desktop-widgets/maintab.ui rename to desktop-widgets/tab-widgets/maintab.ui index 4a6ed9807..e1e29d052 100644 --- a/desktop-widgets/maintab.ui +++ b/desktop-widgets/tab-widgets/maintab.ui @@ -11,7 +11,7 @@ - 0 + 1 @@ -237,7 +237,7 @@ ... - + :/geocode:/geocode @@ -546,7 +546,7 @@ 0 0 445 - 754 + 720 @@ -601,625 +601,6 @@ - - - Info - - - Dive information - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - 0 - 0 - 287 - 320 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 2 - - - - - Date - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Interval - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Gases used - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Gas consumed - - - - - - - - - Qt::AlignCenter - - - - - - - - - - SAC - - - - - - - - - Qt::AlignCenter - - - - - - - - - - CNS - - - - - - - - - Qt::AlignCenter - - - - - - - - - - OTU - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Max. depth - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Avg. depth - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Air pressure - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Air temp. - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Water temp. - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Dive time - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Salinity - - - - - - Qt::AlignCenter - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - - - - - - Stats - - - Simple statistics about the selection - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - 0 - 0 - 297 - 187 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - Depth - - - - - - - - - - - - Duration - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Temperature - - - - - - - - - - - - Total time - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Dives - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - SAC - - - - - - - - - - - - Gas consumption - - - - - - - - - Qt::AlignCenter - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - - Photos - - - All photos from the current selection - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - QListView::IconMode - - - - - - - - Extra data - - - Adittional data from the dive computer - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - @@ -1234,12 +615,6 @@
desktop-widgets/starwidget.h
1
- - MinMaxAvgWidget - QWidget -
desktop-widgets/simplewidgets.h
- 1 -
TableView QWidget @@ -1251,11 +626,6 @@ QPlainTextEdit
desktop-widgets/tagwidget.h
- - DivePictureWidget - QListView -
desktop-widgets/divepicturewidget.h
-
QtWaitingSpinner QWidget @@ -1281,7 +651,7 @@ notes - + diff --git a/desktop-widgets/tagwidget.cpp b/desktop-widgets/tagwidget.cpp index 3b61b492a..754a8886f 100644 --- a/desktop-widgets/tagwidget.cpp +++ b/desktop-widgets/tagwidget.cpp @@ -1,6 +1,6 @@ #include "tagwidget.h" #include "mainwindow.h" -#include "maintab.h" +#include "tab-widgets/maintab.h" #include TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL), lastFinishedTag(false) diff --git a/subsurface-desktop-main.cpp b/subsurface-desktop-main.cpp index e30df687c..e38101302 100644 --- a/subsurface-desktop-main.cpp +++ b/subsurface-desktop-main.cpp @@ -9,7 +9,7 @@ #include "core/qt-gui.h" #include "core/subsurfacestartup.h" #include "desktop-widgets/mainwindow.h" -#include "desktop-widgets/maintab.h" +#include "desktop-widgets/tab-widgets/maintab.h" #include "profile-widget/profilewidget2.h" #include "desktop-widgets/preferences/preferencesdialog.h" #include "desktop-widgets/diveplanner.h"