diff options
-rw-r--r-- | Configure.mk | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | Rules.mk | 11 | ||||
-rw-r--r-- | deco.c | 5 | ||||
-rw-r--r-- | deco.h | 12 | ||||
-rw-r--r-- | helpers.h | 1 | ||||
-rw-r--r-- | pref.h | 1 | ||||
-rw-r--r-- | profile.c | 15 | ||||
-rw-r--r-- | profile.h | 1 | ||||
-rw-r--r-- | qt-gui.cpp | 26 | ||||
-rw-r--r-- | qt-ui/divelistview.cpp | 39 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 3 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 30 | ||||
-rw-r--r-- | qt-ui/downloadfromdivecomputer.h | 7 | ||||
-rw-r--r-- | qt-ui/globe.cpp | 20 | ||||
-rw-r--r-- | qt-ui/globe.h | 1 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 5 | ||||
-rw-r--r-- | qt-ui/maintab.ui | 517 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 36 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 4 | ||||
-rw-r--r-- | qt-ui/mainwindow.ui | 3 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 3 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 134 | ||||
-rw-r--r-- | qt-ui/profilegraphics.cpp | 24 |
24 files changed, 533 insertions, 367 deletions
diff --git a/Configure.mk b/Configure.mk index ff003fd75..a09fcbbf1 100644 --- a/Configure.mk +++ b/Configure.mk @@ -8,6 +8,7 @@ XSLCONFIG=xslt-config QMAKE=qmake MOC=moc UIC=uic +TAR=tar CONFIGFILE = config.cache ifeq ($(CONFIGURING),1) @@ -21,6 +21,7 @@ ICONPATH = $(DATADIR)/icons/hicolor ICONDIR = $(ICONPATH)/scalable/apps MANDIR = $(DATADIR)/man/man1 XSLTDIR = $(DATADIR)/$(NAME)/xslt +MARBLEDIR = marbledata/maps/earth/googlesat gtk_update_icon_cache = gtk-update-icon-cache -f -t $(ICONPATH) ICONFILE = $(NAME)-icon.svg @@ -70,6 +70,10 @@ install: all $(INSTALL) -d -m 755 $(XSLTDIR); \ $(INSTALL) -m 644 $(XSLTFILES) $(XSLTDIR); \ fi + @-if test ! -z "$(MARBLEDIR)"; then \ + $(INSTALL) -d -m 755 $(DATADIR)/$(NAME)/$(MARBLEDIR); \ + $(TAR) cf - $(MARBLEDIR) | ( cd $(DATADIR)/$(NAME); $(TAR) xf - ); \ + fi for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ $(INSTALL) -d $(prefix)/$$LOC; \ $(INSTALL) -m 644 $$LOC/$(NAME).mo $(prefix)/$$LOC/$(NAME).mo; \ @@ -85,6 +89,10 @@ install-macosx: all $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/ $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/ $(INSTALL) $(MACOSXFILES)/$(CAPITALIZED_NAME).icns $(MACOSXINSTALL)/Contents/Resources/ + @-if test ! -z "$(MARBLEDIR)"; then \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/share/$(MARBLEDIR); \ + $(TAR) cf - $(MARBLEDIR) | ( cd $(MACOSXINSTALL)/Contents/Resources/share; $(TAR) xf - ); \ + fi for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ $(INSTALL) $$LOC/$(NAME).mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/$(NAME).mo; \ @@ -233,7 +241,8 @@ release: .PHONY: creator-files creator-files: $(CREATOR_FILES) $(NAME).files: Makefile $(CONFIGFILE) - echo $(wildcard *.h) $(HEADERS) $(SOURCES) | tr ' ' '\n' | sort | uniq > $(NAME).files + echo $(wildcard *.h qt-ui/*.h qt-ui/*.ui) $(HEADERS) $(SOURCES) | tr ' ' '\n' | sort | uniq > $(NAME).files + { echo Makefile; echo Rules.mk; echo Configure.mk; } >> $(NAME).files $(NAME).config: Makefile $(CONFIGFILE) echo $(patsubst -D%,%,$(filter -D%, $(CXXFLAGS) $(CFLAGS) $(EXTRA_FLAGS))) | tr ' ' '\n' | sort | uniq > $(NAME).config $(NAME).includes: Makefile $(CONFIGFILE) @@ -83,6 +83,9 @@ int ci_pointing_to_guiding_tissue; double gf_low_pressure_this_dive; #define TISSUE_ARRAY_SZ sizeof(tissue_n2_sat) +double tolerated_by_tissue[16]; + + static double tissue_tolerance_calc(const struct dive *dive) { int ci = -1; @@ -117,6 +120,8 @@ static double tissue_tolerance_calc(const struct dive *dive) (1.0 - buehlmann_inertgas_b)*(gf_low * gf_low_pressure_this_dive - gf_high * surface) + buehlmann_inertgas_b * (gf_low_pressure_this_dive - surface)); + tolerated_by_tissue[ci] = tolerated; + if (tolerated > ret_tolerance_limit_ambient_pressure) { ci_pointing_to_guiding_tissue = ci; @@ -0,0 +1,12 @@ +#ifndef DECO_H +#define DECO_H + +#ifdef __cplusplus +extern "C" { +#endif + + extern double tolerated_by_tissue[]; + + extern double buehlmann_N2_t_halflife[]; + +#endif @@ -17,5 +17,6 @@ QString get_volume_string(volume_t volume, bool showunit); QString get_pressure_string(pressure_t pressure, bool showunit); void set_default_dive_computer(const char *vendor, const char *product); void set_default_dive_computer_device(const char *name); +QString getSubsurfaceDataPath(QString folderToFind); #endif /* HELPER_H */ @@ -39,6 +39,7 @@ struct preferences { short profile_red_ceiling; short profile_calc_ceiling; short calc_ceiling_3m_incr; + short calc_all_tissues; short gflow; short gfhigh; int map_provider; @@ -12,6 +12,7 @@ #include "divelist.h" #include "profile.h" +#include "deco.h" #include "libdivecomputer/parser.h" #include "libdivecomputer/version.h" @@ -971,7 +972,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, TRUE)) / 1000.0; for (i = 1; i < pi->nr; i++) { - int fo2, fhe, j, t0, t1; + int fo2, fhe, j, k, t0, t1; double tissue_tolerance; struct plot_data *entry = pi->entry + i; int cylinderindex = entry->cylinderindex; @@ -1038,6 +1039,8 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d entry->ceiling = (entry - 1)->ceiling; else entry->ceiling = deco_allowed_depth(tissue_tolerance, surface_pressure, dive, !prefs.calc_ceiling_3m_incr); + for (k=0; k<16; k++) + entry->ceilings[k] = deco_allowed_depth(tolerated_by_tissue[k], surface_pressure, dive, 1); } #if DECO_CALC_DEBUG & 1 @@ -1137,6 +1140,16 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize, depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit); memcpy(buf2, buf, bufsize); snprintf(buf, bufsize, _("%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit); + if (prefs.calc_all_tissues){ + int k; + for (k=0; k<16; k++){ + if (entry->ceilings[k]){ + depthvalue = get_depth_units(entry->ceilings[k], NULL, &depth_unit); + memcpy(buf2, buf, bufsize); + snprintf(buf, bufsize, _("%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit); + } + } + } } if (entry->stopdepth) { depthvalue = get_depth_units(entry->stopdepth, NULL, &depth_unit); @@ -23,6 +23,7 @@ struct plot_data { /* Depth info */ int depth; int ceiling; + int ceilings[16]; int ndl; int stoptime; int stopdepth; diff --git a/qt-gui.cpp b/qt-gui.cpp index 2d5e409b3..1d9f9cad3 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -263,4 +263,30 @@ void set_default_dive_computer_device(const char *name) s.endGroup(); } +QString getSubsurfaceDataPath(QString folderToFind) +{ + QString execdir; + QDir folder; + + // first check if we are running in the build dir, so this + // is just subdirectory of the current directory + execdir = QCoreApplication::applicationDirPath(); + folder = QDir(execdir.append(QDir::separator()).append(folderToFind)); + if (folder.exists()) + return folder.absolutePath(); + + // next check for the Linux typical $(prefix)/share/subsurface + execdir = QCoreApplication::applicationDirPath(); + folder = QDir(execdir.replace("bin", "share/subsurface/").append(folderToFind)); + if (folder.exists()) + return folder.absolutePath(); + + // then look for the usual location on a Mac + execdir = QCoreApplication::applicationDirPath(); + folder = QDir(execdir.append("/../Resources/share/").append(folderToFind)); + if (folder.exists()) + return folder.absolutePath(); + return QString(""); +} + #include "qt-gui.moc" diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index eb19be904..c384d4872 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -14,17 +14,52 @@ #include <QKeyEvent> #include <QSortFilterProxyModel> #include <QAction> +#include <QLineEdit> +#include <QKeyEvent> - -DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), currentHeaderClicked(-1) +DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), + currentHeaderClicked(-1), searchBox(new QLineEdit(this)) { setUniformRowHeights(true); setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate()); QSortFilterProxyModel *model = new QSortFilterProxyModel(this); model->setSortRole(TreeItemDT::SORT_ROLE); + model->setFilterKeyColumn(-1); // filter all columns setModel(model); setSortingEnabled(false); header()->setContextMenuPolicy(Qt::ActionsContextMenu); + QAction *showSearchBox = new QAction(tr("Show Search Box"), this); + showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F); + showSearchBox->setShortcutContext(Qt::ApplicationShortcut); + addAction(showSearchBox); + + searchBox->installEventFilter(this); + searchBox->hide(); + connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); + connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); +} + +void DiveListView::showSearchEdit() +{ + searchBox->show(); + searchBox->setFocus(); +} + +bool DiveListView::eventFilter(QObject* , QEvent* event) +{ + if(event->type() != QEvent::KeyPress){ + return false; + } + QKeyEvent *keyEv = static_cast<QKeyEvent*>(event); + if (keyEv->key() != Qt::Key_Escape){ + return false; + } + + searchBox->clear(); + searchBox->hide(); + QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model()); + m->setFilterFixedString(QString()); + return true; } void DiveListView::headerClicked(int i) diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index 6f22597f6..2f3838c00 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -25,11 +25,13 @@ public: void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); void currentChanged(const QModelIndex& current, const QModelIndex& previous); void reload(DiveTripModel::Layout layout = DiveTripModel::TREE, bool forceSort = true); + bool eventFilter(QObject* , QEvent* ); public slots: void toggleColumnVisibilityByIndex(); void reloadHeaderActions(); void headerClicked(int); + void showSearchEdit(); Q_SIGNALS: void currentDiveChanged(int divenr); @@ -37,6 +39,7 @@ private: bool mouseClickSelection; int currentHeaderClicked; DiveTripModel::Layout currentLayout; + QLineEdit *searchBox; }; #endif // DIVELISTVIEW_H diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 9411ddd88..b0bdea739 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -4,6 +4,8 @@ #include "../libdivecomputer.h" #include "../helpers.h" #include "../display.h" +#include "../divelist.h" +#include "mainwindow.h" #include <cstdlib> #include <QThread> #include <QDebug> @@ -32,6 +34,12 @@ namespace DownloadFromDcGlobal{ const char *err_string; }; +DownloadFromDCWidget *DownloadFromDCWidget::instance() +{ + static DownloadFromDCWidget *dialog = new DownloadFromDCWidget(); + return dialog; +} + DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f), ui(new Ui::DownloadFromDiveComputer), thread(0), downloading(false) { @@ -54,6 +62,17 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : ui->device->setText(default_dive_computer_device); } +void DownloadFromDCWidget::runDialog() +{ + ui->progressBar->hide(); + show(); +} + +void DownloadFromDCWidget::stoppedDownloading() +{ + downloading = false; +} + void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor) { QAbstractItemModel *currentModel = ui->product->model(); @@ -151,13 +170,21 @@ void DownloadFromDCWidget::on_ok_clicked() downloading = true; } +bool DownloadFromDCWidget::preferDownloaded() +{ + return ui->preferDownloaded->isChecked(); +} + DownloadThread::DownloadThread(device_data_t* data): data(data) { } void DownloadThread::run() { + DownloadFromDCWidget *dfdcw = DownloadFromDCWidget::instance(); do_libdivecomputer_import(data); + process_dives(TRUE, dfdcw->preferDownloaded()); + dfdcw->stoppedDownloading(); } InterfaceThread::InterfaceThread(QObject* parent, device_data_t* data): QThread(parent), data(data) @@ -167,7 +194,8 @@ InterfaceThread::InterfaceThread(QObject* parent, device_data_t* data): QThread( void InterfaceThread::run() { DownloadThread *download = new DownloadThread(data); - + MainWindow *w = mainWindow(); + connect(download, SIGNAL(finished()), w, SLOT(refreshDisplay())); download->start(); while (download->isRunning()) { msleep(200); diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h index fdc730753..de80c4028 100644 --- a/qt-ui/downloadfromdivecomputer.h +++ b/qt-ui/downloadfromdivecomputer.h @@ -38,11 +38,12 @@ class DownloadFromDCWidget : public QDialog{ Q_OBJECT public: explicit DownloadFromDCWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - + static DownloadFromDCWidget *instance(); public slots: void on_ok_clicked(); void on_cancel_clicked(); - + void runDialog(); + void stoppedDownloading(); void on_vendor_currentIndexChanged(const QString& vendor); private: Ui::DownloadFromDiveComputer *ui; @@ -57,6 +58,8 @@ private: QStringListModel *vendorModel; QStringListModel *productModel; void fill_computer_list(); +public: + bool preferDownloaded(); }; #endif diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index c1abd082f..bf2369862 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -1,6 +1,7 @@ #include "globe.h" #include "kmessagewidget.h" #include "../dive.h" +#include "../helpers.h" #include <QDebug> @@ -9,6 +10,7 @@ #include <marble/GeoDataDocument.h> #include <marble/MarbleModel.h> #include <marble/MarbleDirs.h> +#include <marble/MapThemeManager.h> #if INCOMPLETE_MARBLE #include "marble/GeoDataTreeModel.h" #else @@ -19,9 +21,21 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0) { - // this will find the Google maps when running from your build directory - // TODO: all the magic to find the install path (and actually install/bundle these files) - MarbleDirs::setMarbleDataPath(QDir("./marbledata").absolutePath()); + // check if Google Sat Maps are installed + // if not, check if they are in a known location + MapThemeManager mtm; + QStringList list = mtm.mapThemeIds(); + QString theme, subsurfaceDataPath; + QDir marble; + bool foundGoogleMap = false; + Q_FOREACH(theme, list) + if (theme == "earth/googlesat/googlesat.dgml") + foundGoogleMap = true; + if (!foundGoogleMap) { + subsurfaceDataPath = getSubsurfaceDataPath("marbledata"); + if (subsurfaceDataPath != "") + MarbleDirs::setMarbleDataPath(subsurfaceDataPath); + } messageWidget = new KMessageWidget(this); messageWidget->setCloseButtonVisible(false); messageWidget->setHidden(true); diff --git a/qt-ui/globe.h b/qt-ui/globe.h index 0d42ab90a..167cdf292 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -3,6 +3,7 @@ #include <marble/MarbleWidget.h> #include <marble/GeoDataCoordinates.h> +#include <marble/GeoDataDocument.h> #include <QHash> diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 57f0d1da5..1de80271e 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -48,9 +48,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui->rating->installEventFilter(this); ui->visibility->installEventFilter(this); - /* example of where code is more concise than Qt designer */ - QList<QObject *> infoTabWidgets = ui->infoTab->children(); - Q_FOREACH(QObject* obj, infoTabWidgets) { + QList<QObject *> statisticsTabWidgets = ui->statisticsTab->children(); + Q_FOREACH(QObject* obj, statisticsTabWidgets) { QLabel* label = qobject_cast<QLabel *>(obj); if (label) label->setAlignment(Qt::AlignHCenter); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 2b9f74b30..e7fcfed0a 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -6,15 +6,18 @@ <rect> <x>0</x> <y>0</y> - <width>692</width> - <height>513</height> + <width>409</width> + <height>368</height> </rect> </property> <property name="windowTitle"> <string>TabWidget</string> </property> <property name="currentIndex"> - <number>3</number> + <number>2</number> + </property> + <property name="documentMode"> + <bool>true</bool> </property> <widget class="QWidget" name="notesTab"> <attribute name="title"> @@ -214,308 +217,234 @@ <attribute name="title"> <string>Dive Info</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <spacer name="verticalSpacer_4"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>SAC</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="sacText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>O²/HE</string> </property> - </spacer> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLabel" name="oxygenHeliumText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> </item> - <item> - <layout class="QGridLayout" name="diveInfoUpperGridLayout"> - <property name="horizontalSpacing"> - <number>10</number> + <item row="1" column="0"> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>OTU</string> </property> - <property name="verticalSpacing"> - <number>15</number> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="otuText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="4" column="0"> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string>Date</string> </property> - <property name="margin"> - <number>10</number> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLabel" name="dateText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="5" column="0"> + <widget class="QGroupBox" name="groupBox_10"> + <property name="title"> + <string>Air Pressure</string> </property> - <item row="0" column="0"> - <widget class="QLabel" name="sacLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>SAC</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="outLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>OTU</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="oxygenHeliumLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>0²/He</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="gasUsedLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Gas Used</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QLabel" name="gasUsedText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="sacText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="otuText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="oxygenHeliumText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - </layout> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QLabel" name="airPressureText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> </item> - <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <item row="4" column="1"> + <widget class="QGroupBox" name="groupBox_9"> + <property name="title"> + <string>Air Temperature</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QGridLayout" name="diveInfoLowerGridLayout"> - <property name="margin"> - <number>10</number> - </property> - <property name="spacing"> - <number>15</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="dateLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Date</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="maximumDepthText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="waterTempertureLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Water Temp.</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLabel" name="airTemperatureText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="diveTimeText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="surfaceIntervalText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QLabel" name="airPressureLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Air Pressure</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="averageDepthLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Ave. Depth</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="maximumDepthLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Max. Depth</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLabel" name="airTempertatureLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Air Temp.</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="averageDepthText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="5" column="2"> - <widget class="QLabel" name="airPressureText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="waterTemperatureText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="dateText"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="surfaceIntervalLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Interval</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="diveTimeLabel"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Dive Time</string> - </property> - </widget> - </item> - </layout> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <item> + <widget class="QLabel" name="airTemperatureText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <item row="0" column="2"> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>Gas Used</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QLabel" name="gasUsedText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="groupBox_6"> + <property name="title"> + <string>Max. Depth</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="QLabel" name="maximumDepthText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="2"> + <widget class="QGroupBox" name="groupBox_7"> + <property name="title"> + <string>Ave. Depth</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <item> + <widget class="QLabel" name="averageDepthText"> + <property name="text"> + <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_8"> + <property name="title"> + <string>Water Temperature</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <item> + <widget class="QLabel" name="waterTemperatureText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="5" column="1"> + <widget class="QGroupBox" name="groupBox_12"> + <property name="title"> + <string>Interval</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> + <layout class="QHBoxLayout" name="horizontalLayout_13"> + <item> + <widget class="QLabel" name="surfaceIntervalText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="5" column="2"> + <widget class="QGroupBox" name="groupBox_11"> + <property name="title"> + <string>Dive Time</string> </property> - </spacer> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QLabel" name="diveTimeText"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> </item> </layout> </widget> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 8c600ea19..d3cd951d8 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -15,7 +15,7 @@ #include <QCloseEvent> #include <QApplication> #include <QFontMetrics> - +#include <QTextBrowser> #include "divelistview.h" #include "starwidget.h" @@ -23,6 +23,7 @@ #include "../dive.h" #include "../divelist.h" #include "../pref.h" +#include "../helpers.h" #include "modeldelegates.h" #include "models.h" #include "downloadfromdivecomputer.h" @@ -35,7 +36,7 @@ MainWindow* mainWindow() return instance; } -MainWindow::MainWindow() : ui(new Ui::MainWindow()) +MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0) { ui->setupUi(this); setWindowIcon(QIcon(":subsurface-icon")); @@ -52,6 +53,14 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()) instance = this; } +// this gets called after we download dives from a divecomputer +void MainWindow::refreshDisplay() +{ + if (!selected_dive) + current_dive_changed(dive_table.nr - 1); + ui->ListWidget->reload(); +} + void MainWindow::current_dive_changed(int divenr) { select_dive(divenr); @@ -162,8 +171,8 @@ void MainWindow::on_actionQuit_triggered() void MainWindow::on_actionDownloadDC_triggered() { - DownloadFromDCWidget* downloadWidget = new DownloadFromDCWidget(); - downloadWidget->show(); + DownloadFromDCWidget* downloadWidget = DownloadFromDCWidget::instance(); + downloadWidget->runDialog(); } void MainWindow::on_actionDownloadWeb_triggered() @@ -256,7 +265,17 @@ void MainWindow::on_actionAboutSubsurface_triggered() void MainWindow::on_actionUserManual_triggered() { - qDebug("actionUserManual"); + if(!helpView){ + helpView = new QTextBrowser(); + } + QString searchPath = getSubsurfaceDataPath("Documentation"); + if (searchPath != "") { + QUrl url(searchPath.append("/user-manual.html")); + helpView->setSource(url); + } else { + helpView->setText(tr("Cannot find the Subsurface manual")); + } + helpView->show(); } QString MainWindow::filter() @@ -395,6 +414,7 @@ void MainWindow::readSettings() GET_BOOL(v, "dcceiling", prefs.profile_dc_ceiling); GET_BOOL(v, "calcceiling", prefs.profile_calc_ceiling); GET_BOOL(v, "calcceiling3m", prefs.calc_ceiling_3m_incr); + GET_BOOL(v, "calcalltissues", prefs.calc_all_tissues); v = settings.value(QString("gflow")); if (v.isValid()) prefs.gflow = v.toInt(); @@ -471,6 +491,7 @@ void MainWindow::writeSettings() SAVE_VALUE("redceiling", profile_red_ceiling); SAVE_VALUE("calcceiling", profile_calc_ceiling); SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr); + SAVE_VALUE("calcalltissues", calc_all_tissues); SAVE_VALUE("dcceiling", profile_dc_ceiling); SAVE_VALUE("gflow", gflow); SAVE_VALUE("gfhigh", gfhigh); @@ -482,6 +503,11 @@ void MainWindow::writeSettings() void MainWindow::closeEvent(QCloseEvent *event) { + if (helpView && helpView->isVisible()){ + helpView->close(); + helpView->deleteLater(); + } + if (unsaved_changes() && (askSaveChanges() == FALSE)) { event->ignore(); return; diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 2366617c6..f3e728176 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -29,6 +29,7 @@ class DiveListView; class GlobeGPS; class MainTab; class ProfileGraphicsView; +class QTextBrowser; class MainWindow : public QMainWindow { @@ -87,12 +88,13 @@ protected: public Q_SLOTS: void readSettings(); + void refreshDisplay(); private: Ui::MainWindow *ui; QAction *actionNextDive; QAction *actionPreviousDive; - + QTextBrowser *helpView; QString filter(); bool askSaveChanges(); void writeSettings(); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index c72e36eb4..fbf10cdf8 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -361,6 +361,9 @@ <property name="text"> <string>User Manual</string> </property> + <property name="shortcut"> + <string>F1</string> + </property> </action> </widget> <customwidgets> diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 453f20c34..dd484b6e8 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -41,6 +41,8 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial ui->calculated_ceiling->setChecked(B(calcceiling, profile_calc_ceiling)); ui->increment_3m->setEnabled(ui->calculated_ceiling->isChecked()); ui->increment_3m->setChecked(B(calcceiling3m, calc_ceiling_3m_incr)); + ui->all_tissues->setEnabled(ui->calculated_ceiling->isChecked()); + ui->all_tissues->setChecked(B(calcalltissues, calc_all_tissues)); ui->gflow->setValue((int)(I(gflow, gflow))); ui->gfhigh->setValue((int)(I(gfhigh, gfhigh))); @@ -112,6 +114,7 @@ void PreferencesDialog::syncSettings() SB("redceiling", ui->red_ceiling); SB("calcceiling", ui->calculated_ceiling); SB("calcceiling3m", ui->increment_3m); + SB("calcalltissues", ui->all_tissues); s.setValue("gflow", ui->gflow->value()); s.setValue("gfhigh", ui->gfhigh->value()); s.endGroup(); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 348e62ecd..3cef8785a 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>444</width> - <height>386</height> + <width>698</width> + <height>521</height> </rect> </property> <property name="windowTitle"> @@ -116,7 +116,7 @@ </sizepolicy> </property> <property name="currentIndex"> - <number>1</number> + <number>2</number> </property> <widget class="QWidget" name="page_2"> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -624,8 +624,8 @@ </property> </widget> </item> - </layout> - </item> + </layout> + </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_10"> <item> @@ -649,6 +649,16 @@ </spacer> </item> <item> + <widget class="QCheckBox" name="all_tissues"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>show all tissues</string> + </property> + </widget> + </item> + <item> <widget class="QCheckBox" name="increment_3m"> <property name="enabled"> <bool>false</bool> @@ -721,8 +731,8 @@ <slot>accept()</slot> <hints> <hint type="sourcelabel"> - <x>226</x> - <y>522</y> + <x>235</x> + <y>511</y> </hint> <hint type="destinationlabel"> <x>157</x> @@ -737,8 +747,8 @@ <slot>reject()</slot> <hints> <hint type="sourcelabel"> - <x>294</x> - <y>522</y> + <x>303</x> + <y>511</y> </hint> <hint type="destinationlabel"> <x>286</x> @@ -757,8 +767,8 @@ <y>97</y> </hint> <hint type="destinationlabel"> - <x>186</x> - <y>8</y> + <x>282</x> + <y>18</y> </hint> </hints> </connection> @@ -769,12 +779,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>288</x> - <y>179</y> + <x>187</x> + <y>77</y> </hint> <hint type="destinationlabel"> - <x>681</x> - <y>194</y> + <x>581</x> + <y>80</y> </hint> </hints> </connection> @@ -785,12 +795,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>301</x> - <y>179</y> + <x>187</x> + <y>77</y> </hint> <hint type="destinationlabel"> - <x>742</x> - <y>184</y> + <x>668</x> + <y>80</y> </hint> </hints> </connection> @@ -801,12 +811,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>295</x> - <y>208</y> + <x>186</x> + <y>121</y> </hint> <hint type="destinationlabel"> - <x>673</x> - <y>216</y> + <x>581</x> + <y>124</y> </hint> </hints> </connection> @@ -817,12 +827,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>301</x> - <y>206</y> + <x>186</x> + <y>121</y> </hint> <hint type="destinationlabel"> - <x>740</x> - <y>216</y> + <x>668</x> + <y>124</y> </hint> </hints> </connection> @@ -833,12 +843,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>296</x> - <y>240</y> + <x>184</x> + <y>165</y> </hint> <hint type="destinationlabel"> - <x>683</x> - <y>242</y> + <x>581</x> + <y>168</y> </hint> </hints> </connection> @@ -849,12 +859,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>304</x> - <y>232</y> + <x>184</x> + <y>165</y> </hint> <hint type="destinationlabel"> - <x>760</x> - <y>236</y> + <x>668</x> + <y>168</y> </hint> </hints> </connection> @@ -865,12 +875,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>294</x> - <y>267</y> + <x>195</x> + <y>209</y> </hint> <hint type="destinationlabel"> - <x>692</x> - <y>271</y> + <x>591</x> + <y>212</y> </hint> </hints> </connection> @@ -881,28 +891,28 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>286</x> - <y>261</y> + <x>195</x> + <y>209</y> </hint> <hint type="destinationlabel"> - <x>760</x> - <y>269</y> + <x>668</x> + <y>212</y> </hint> </hints> </connection> <connection> - <sender>dc_ceiling</sender> + <sender>calculated_ceiling</sender> <signal>clicked(bool)</signal> - <receiver>red_ceiling</receiver> + <receiver>all_tissues</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>288</x> - <y>364</y> + <x>298</x> + <y>327</y> </hint> <hint type="destinationlabel"> - <x>555</x> - <y>371</y> + <x>512</x> + <y>327</y> </hint> </hints> </connection> @@ -913,21 +923,37 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>288</x> - <y>344</y> + <x>298</x> + <y>327</y> + </hint> + <hint type="destinationlabel"> + <x>668</x> + <y>327</y> + </hint> + </hints> + </connection> + <connection> + <sender>dc_reported_ceiling</sender> + <signal>clicked(bool)</signal> + <receiver>red_ceiling</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>362</x> + <y>275</y> </hint> <hint type="destinationlabel"> - <x>555</x> - <y>351</y> + <x>586</x> + <y>270</y> </hint> </hints> </connection> </connections> <buttongroups> - <buttongroup name="buttonGroup"/> <buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_3"/> <buttongroup name="buttonGroup_4"/> <buttongroup name="buttonGroup_5"/> + <buttongroup name="buttonGroup"/> </buttongroups> </ui> diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 663aefe25..fb336da72 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -1072,6 +1072,30 @@ void ProfileGraphicsView::plot_depth_profile() neatFill->setBrush(pat); scene()->addItem(neatFill); } + + /* plot the calculated ceiling for all tissues */ + if (prefs.profile_calc_ceiling && prefs.calc_all_tissues){ + int k; + for (k=0; k<16; k++){ + pat.setColorAt(0, profile_color[CALC_CEILING_SHALLOW].first()); + pat.setColorAt(1, QColor(100, 100, 100, 50)); + + entry = gc.pi.entry; + p.clear(); + p.append(QPointF(SCALEGC(0, 0))); + for (i = 0; i < gc.pi.nr; i++, entry++) { + if ((entry->ceilings)[k]) + p.append(QPointF(SCALEGC(entry->sec, (entry->ceilings)[k]))); + else + p.append(QPointF(SCALEGC(entry->sec, 0))); + } + p.append(QPointF(SCALEGC((entry-1)->sec, 0))); + neatFill = new QGraphicsPolygonItem(); + neatFill->setPolygon(p); + neatFill->setBrush(pat); + scene()->addItem(neatFill); + } + } /* next show where we have been bad and crossed the dc's ceiling */ if (prefs.profile_dc_ceiling) { pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); |