diff options
Diffstat (limited to 'qt-ui')
40 files changed, 1153 insertions, 717 deletions
diff --git a/qt-ui/about.cpp b/qt-ui/about.cpp index 361031599..203357010 100644 --- a/qt-ui/about.cpp +++ b/qt-ui/about.cpp @@ -1,5 +1,5 @@ #include "about.h" -#include "ssrf-version.h" +#include "version.h" #include <QDesktopServices> #include <QUrl> #include <QShortcut> @@ -9,7 +9,7 @@ SubsurfaceAbout::SubsurfaceAbout(QWidget *parent, Qt::WindowFlags f) : QDialog(p ui.setupUi(this); setWindowModality(Qt::ApplicationModal); - QString versionString(GIT_VERSION_STRING); + QString versionString(subsurface_git_version()); QStringList readableVersions = QStringList() << "4.3.950" << "4.4 Beta 1" << "4.3.960" << "4.4 Beta 2" << "4.3.970" << "4.4 Beta 3"; diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp index fd3cc7504..f2e70afd1 100644 --- a/qt-ui/completionmodels.cpp +++ b/qt-ui/completionmodels.cpp @@ -40,9 +40,21 @@ CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy); CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster); -CREATE_UPDATE_METHOD(LocationCompletionModel, location); CREATE_UPDATE_METHOD(SuitCompletionModel, suit); +void LocationCompletionModel::updateModel() +{ + QStringList list; + struct dive_site *ds; + int i = 0; + for_each_dive_site(i, ds) { + if (!list.contains(ds->name)) + list.append(ds->name); + } + std::sort(list.begin(), list.end()); + setStringList(list); +} + void TagCompletionModel::updateModel() { if (g_tag_list == NULL) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 95bc0f882..172a1a480 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -2,6 +2,8 @@ #include "helpers.h" #include "mainwindow.h" +#include "display.h" + #include <QFileDialog> #include <QMessageBox> #include <QSettings> diff --git a/qt-ui/divecomponentselection.ui b/qt-ui/divecomponentselection.ui index dbd0839ba..7eade039b 100644 --- a/qt-ui/divecomponentselection.ui +++ b/qt-ui/divecomponentselection.ui @@ -9,8 +9,8 @@ <rect> <x>0</x> <y>0</y> - <width>308</width> - <height>263</height> + <width>401</width> + <height>317</height> </rect> </property> <property name="sizePolicy"> @@ -41,9 +41,9 @@ </property> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> - <widget class="QCheckBox" name="location"> + <widget class="QCheckBox" name="divesite"> <property name="text"> - <string>Location</string> + <string>Dive site</string> </property> </widget> </item> @@ -54,34 +54,6 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="gps"> - <property name="text"> - <string>GPS coordinates</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="divemaster"> - <property name="text"> - <string>Divemaster</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="buddy"> - <property name="text"> - <string>Buddy</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QCheckBox" name="rating"> - <property name="text"> - <string>Rating</string> - </property> - </widget> - </item> <item row="5" column="0"> <widget class="QCheckBox" name="visibility"> <property name="text"> @@ -117,6 +89,27 @@ </property> </widget> </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="divemaster"> + <property name="text"> + <string>Divemaster</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="buddy"> + <property name="text"> + <string>Buddy</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="rating"> + <property name="text"> + <string>Rating</string> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/qt-ui/divecomputermanagementdialog.cpp b/qt-ui/divecomputermanagementdialog.cpp index 742facdcb..552f6058f 100644 --- a/qt-ui/divecomputermanagementdialog.cpp +++ b/qt-ui/divecomputermanagementdialog.cpp @@ -1,6 +1,7 @@ #include "divecomputermanagementdialog.h" #include "mainwindow.h" #include "helpers.h" +#include "models.h" #include <QMessageBox> #include <QShortcut> diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index d4e744237..e4ccb7208 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -8,9 +8,13 @@ #include "filtermodels.h" #include "modeldelegates.h" #include "mainwindow.h" +#include "divepicturewidget.h" +#include "display.h" #include <QSettings> +#include <QKeyEvent> #include <QFileDialog> #include "qthelper.h" +#include "undocommands.h" // # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Loc static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 500}; @@ -30,6 +34,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec setSortingEnabled(false); setContextMenuPolicy(Qt::DefaultContextMenu); + setSelectionMode(ExtendedSelection); header()->setContextMenuPolicy(Qt::ActionsContextMenu); const QFontMetrics metrics(defaultModelFont()); @@ -84,6 +89,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec header()->setStretchLastSection(true); + + installEventFilter(this); } DiveListView::~DiveListView() @@ -343,6 +350,10 @@ bool DiveListView::eventFilter(QObject *, QEvent *event) if (event->type() != QEvent::KeyPress) return false; QKeyEvent *keyEv = static_cast<QKeyEvent *>(event); + if (keyEv->key() == Qt::Key_Delete) { + contextMenuIndex = currentIndex(); + deleteDive(); + } if (keyEv->key() != Qt::Key_Escape) return false; return true; @@ -721,13 +732,19 @@ void DiveListView::deleteDive() // so instead of using the for_each_dive macro I'm using an explicit for loop // to make this easier to understand int lastDiveNr = -1; + QList<struct dive*> deletedDives; //a list of all deleted dives to be stored in the undo command for_each_dive (i, d) { if (!d->selected) continue; + struct dive* undo_entry = alloc_dive(); + copy_dive(get_dive(i), undo_entry); + deletedDives.append(undo_entry); delete_single_dive(i); i--; // so the next dive isn't skipped... it's now #i lastDiveNr = i; } + UndoDeleteDive *undoEntry = new UndoDeleteDive(deletedDives); + MainWindow::instance()->undoStack->push(undoEntry); if (amount_selected == 0) { MainWindow::instance()->cleanUpEmpty(); } diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index bb4701ce3..ce12ef7ec 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -1,5 +1,6 @@ #include "divelogimportdialog.h" #include "mainwindow.h" +#include "color.h" #include "ui_divelogimportdialog.h" #include <QShortcut> #include <QDrag> diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 7831cc6d9..434da1fab 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -3,6 +3,8 @@ #include "mainwindow.h" #include "planner.h" #include "helpers.h" +#include "models.h" +#include "profile/profilewidget2.h" #include <QGraphicsSceneMouseEvent> #include <QMessageBox> @@ -1266,3 +1268,8 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) setPlanMode(NOTHING); planCreated(); } + +PlannerDetails::PlannerDetails(QWidget *parent) : QWidget(parent) +{ + ui.setupUi(this); +} diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 4093bacd1..196e17546 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -186,6 +186,20 @@ private: void updateUnitsUI(); }; +#include "ui_plannerDetails.h" + +class PlannerDetails : public QWidget { + Q_OBJECT +public: + explicit PlannerDetails(QWidget *parent = 0); + QPushButton *printPlan() const { return ui.printPlan; } + QTextEdit *divePlanOutput() const { return ui.divePlanOutput; } + +private: + Ui::plannerDetails ui; +}; + + QString dpGasToStr(const divedatapoint &p); #endif // DIVEPLANNER_H diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index cd3dd90d0..c57aa1ef2 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -1,6 +1,8 @@ #include "downloadfromdivecomputer.h" #include "helpers.h" #include "mainwindow.h" +#include "divelistview.h" +#include "display.h" #include <QTimer> #include <QFileDialog> @@ -536,8 +538,8 @@ void DownloadThread::run() } DiveImportedModel::DiveImportedModel(QObject *o) : QAbstractTableModel(o), - lastIndex(-1), firstIndex(0), + lastIndex(-1), checkStates(0) { } diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp index e2597a634..f44ab7cf8 100644 --- a/qt-ui/filtermodels.cpp +++ b/qt-ui/filtermodels.cpp @@ -1,5 +1,8 @@ #include "filtermodels.h" #include "mainwindow.h" +#include "models.h" +#include "divelistview.h" +#include "display.h" #define CREATE_INSTANCE_METHOD( CLASS ) \ CLASS *CLASS::instance() \ @@ -246,7 +249,7 @@ bool LocationFilterModel::doFilter(struct dive *d, QModelIndex &index0, QAbstrac return true; } // Checked means 'Show', Unchecked means 'Hide'. - QString location(d->location); + QString location(get_dive_location(d)); // only show empty location dives if the user checked that. if (location.isEmpty()) { if (rowCount() > 0) @@ -274,7 +277,7 @@ void LocationFilterModel::repopulate() struct dive *dive; int i = 0; for_each_dive (i, dive) { - QString location(dive->location); + QString location(get_dive_location(dive)); if (!location.isEmpty() && !list.contains(location)) { list.append(location); } diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 1e4639d5c..91bb4e858 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -2,7 +2,13 @@ #ifndef NO_MARBLE #include "mainwindow.h" #include "helpers.h" +#include "divelistview.h" +#include "maintab.h" +#include "display.h" + #include <QTimer> +#include <QContextMenuEvent> +#include <QMouseEvent> #include <marble/AbstractFloatItem.h> #include <marble/GeoDataPlacemark.h> @@ -158,10 +164,11 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) QList<int> selectedDiveIds; for_each_dive (idx, dive) { long lat_diff, lon_diff; - if (!dive_has_gps_location(dive)) + struct dive_site *ds = get_dive_site_for_dive(dive); + if (!dive_site_has_gps_location(ds)) continue; - lat_diff = labs(dive->latitude.udeg - lat_udeg); - lon_diff = labs(dive->longitude.udeg - lon_udeg); + lat_diff = labs(ds->latitude.udeg - lat_udeg); + lon_diff = labs(ds->longitude.udeg - lon_udeg); if (lat_diff > 180000000) lat_diff = 360000000 - lat_diff; if (lon_diff > 180000000) @@ -180,6 +187,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) void GlobeGPS::repopulateLabels() { + struct dive_site *ds; if (loadedDives) { model()->treeModel()->removeDocument(loadedDives); delete loadedDives; @@ -198,12 +206,16 @@ void GlobeGPS::repopulateLabels() // don't show that flag, it's either already shown as displayed_dive // or it's the one that we are moving right now... continue; - if (dive_has_gps_location(dive)) { - GeoDataPlacemark *place = new GeoDataPlacemark(dive->location); - place->setCoordinate(dive->longitude.udeg / 1000000.0, dive->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree); + if (idx == -1) + ds = &displayed_dive_site; + else + ds = get_dive_site_for_dive(dive); + if (dive_site_has_gps_location(ds)) { + GeoDataPlacemark *place = new GeoDataPlacemark(ds->name); + place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree); // don't add dive locations twice, unless they are at least 50m apart - if (locationMap[QString(dive->location)]) { - GeoDataCoordinates existingLocation = locationMap[QString(dive->location)]->coordinate(); + if (locationMap[QString(ds->name)]) { + GeoDataCoordinates existingLocation = locationMap[QString(ds->name)]->coordinate(); GeoDataLineString segment = GeoDataLineString(); segment.append(existingLocation); GeoDataCoordinates newLocation = place->coordinate(); @@ -214,7 +226,7 @@ void GlobeGPS::repopulateLabels() if (dist < 0.05) continue; } - locationMap[QString(dive->location)] = place; + locationMap[QString(ds->name)] = place; loadedDives->append(place); } } @@ -230,23 +242,23 @@ void GlobeGPS::reload() void GlobeGPS::centerOnCurrentDive() { - struct dive *dive = current_dive; + struct dive_site *ds = get_dive_site_for_dive(current_dive); // dive has changed, if we had the 'editingDive', hide it. - if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive) || amount_selected != 1)) + if (messageWidget->isVisible() && (!ds || dive_site_has_gps_location(ds) || amount_selected != 1)) messageWidget->hide(); editingDiveLocation = false; - if (!dive) + if (!ds) return; - qreal longitude = dive->longitude.udeg / 1000000.0; - qreal latitude = dive->latitude.udeg / 1000000.0; + qreal longitude = ds->longitude.udeg / 1000000.0; + qreal latitude = ds->latitude.udeg / 1000000.0; - if ((!dive_has_gps_location(dive) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) { + if ((!dive_site_has_gps_location(ds) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) { prepareForGetDiveCoordinates(); return; } - if (!dive_has_gps_location(dive)) { + if (!dive_site_has_gps_location(ds)) { zoomOutForNoGPS(); return; } @@ -303,8 +315,10 @@ void GlobeGPS::prepareForGetDiveCoordinates() } } +// This needs to update the dive site, not just this dive void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) { + struct dive_site *ds; messageWidget->hide(); if (MainWindow::instance()->dive_list()->selectionModel()->selection().isEmpty()) @@ -318,8 +332,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U centerOn(lon, lat, true); // change the location of the displayed_dive and put the UI in edit mode - displayed_dive.latitude.udeg = lrint(lat * 1000000.0); - displayed_dive.longitude.udeg = lrint(lon * 1000000.0); + displayed_dive_site.latitude.udeg = lrint(lat * 1000000.0); + displayed_dive_site.longitude.udeg = lrint(lon * 1000000.0); emit(coordinatesChanged()); repopulateLabels(); editingDiveLocation = false; @@ -335,7 +349,12 @@ void GlobeGPS::mousePressEvent(QMouseEvent *event) // there could be two scenarios that got us here; let's check if we are editing a dive if (MainWindow::instance()->information()->isEditing() && clickOnGlobe) { - MainWindow::instance()->information()->updateCoordinatesText(lat, lon); + // + // FIXME + // TODO + // + // this needs to do this on the dive site screen + // MainWindow::instance()->information()->updateCoordinatesText(lat, lon); repopulateLabels(); } else if (clickOnGlobe) { changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree); diff --git a/qt-ui/globe.h b/qt-ui/globe.h index b6a33bbbe..4f9d7c611 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -19,7 +19,7 @@ class GlobeGPS : public MarbleWidget { Q_OBJECT public: using MarbleWidget::centerOn; - GlobeGPS(QWidget *parent); + GlobeGPS(QWidget *parent = 0); void reload(); void repopulateLabels(); void centerOnCurrentDive(); diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui new file mode 100644 index 000000000..658395b35 --- /dev/null +++ b/qt-ui/locationInformation.ui @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LocationInformation</class> + <widget class="QGroupBox" name="LocationInformation"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>GroupBox</string> + </property> + <property name="title"> + <string>Dive Site</string> + </property> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0" colspan="2"> + <widget class="KMessageWidget" name="diveSiteMessage" native="true"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Name</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="diveSiteName"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Coordinates</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="diveSiteCoordinates"/> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Description</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="diveSiteDescription"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Notes</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QPlainTextEdit" name="diveSiteNotes"/> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>KMessageWidget</class> + <extends>QWidget</extends> + <header>kmessagewidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 88cfd8849..3f6345c18 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -6,9 +6,15 @@ */ #include "maintab.h" #include "mainwindow.h" +#include "globe.h" #include "helpers.h" #include "statistics.h" #include "modeldelegates.h" +#include "models.h" +#include "divelistview.h" +#include "display.h" +#include "profile/profilewidget2.h" +#include "diveplanner.h" #if defined(FBSUPPORT) #include "socialnetworks.h" @@ -43,18 +49,19 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.extraData->setModel(extraDataModel); closeMessage(); + connect(ui.manageDiveSite, SIGNAL(clicked()), this, SLOT(prepareDiveSiteEdit())); + QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); addMessageAction(action); action = new QAction(tr("Discard changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); + addMessageAction(action); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected())); - addMessageAction(action); - if (qApp->style()->objectName() == "oxygen") setDocumentMode(true); else @@ -65,7 +72,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), setEnabled(false); ui.location->installEventFilter(this); - ui.coordinates->installEventFilter(this); ui.divemaster->installEventFilter(this); ui.buddy->installEventFilter(this); ui.suit->installEventFilter(this); @@ -206,6 +212,10 @@ MainTab::~MainTab() } } +void MainTab::prepareDiveSiteEdit() { + emit requestDiveSiteEdit(displayed_dive.dive_site_uuid); +} + void MainTab::toggleTriggeredColumn() { QAction *action = qobject_cast<QAction *>(sender()); @@ -385,6 +395,11 @@ bool MainTab::isEditing() return editMode != NONE; } +void MainTab::showLocation() +{ + ui.location->setText(get_dive_location(&displayed_dive)); +} + void MainTab::updateDiveInfo(bool clear) { // don't execute this while adding / planning a dive @@ -418,9 +433,7 @@ void MainTab::updateDiveInfo(bool clear) else ui.notes->setPlainText(tmp); } - UPDATE_TEXT(displayed_dive, notes); - UPDATE_TEXT(displayed_dive, location); UPDATE_TEXT(displayed_dive, suit); UPDATE_TEXT(displayed_dive, divemaster); UPDATE_TEXT(displayed_dive, buddy); @@ -429,7 +442,11 @@ void MainTab::updateDiveInfo(bool clear) ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode); if (!clear) { - updateGpsCoordinates(); + struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + if (ds) + ui.location->setText(ds->name); + else + ui.location->clear(); // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); @@ -440,8 +457,6 @@ void MainTab::updateDiveInfo(bool clear) setTabText(0, tr("Trip notes")); currentTrip = *MainWindow::instance()->dive_list()->selectedTrips().begin(); // only use trip relevant fields - ui.coordinates->setVisible(false); - ui.CoordinatedLabel->setVisible(false); ui.divemaster->setVisible(false); ui.DivemasterLabel->setVisible(false); ui.buddy->setVisible(false); @@ -468,11 +483,9 @@ void MainTab::updateDiveInfo(bool clear) clearEquipment(); ui.equipmentTab->setEnabled(false); } else { - setTabText(0, tr("Dive notes")); + setTabText(0, tr("Notes")); currentTrip = NULL; // make all the fields visible writeable - ui.coordinates->setVisible(true); - ui.CoordinatedLabel->setVisible(true); ui.divemaster->setVisible(true); ui.buddy->setVisible(true); ui.suit->setVisible(true); @@ -641,8 +654,8 @@ void MainTab::updateDiveInfo(bool clear) clearStats(); clearEquipment(); ui.rating->setCurrentStars(0); - ui.coordinates->clear(); ui.visibility->setCurrentStars(0); + ui.location->clear(); } editMode = NONE; ui.cylinders->view()->hideColumn(CylindersModel::DEPTH); @@ -750,8 +763,6 @@ void MainTab::acceptChanges() copy_samples(&displayed_dive.dc, ¤t_dive->dc); } struct dive *cd = current_dive; - //Reset coordinates field, in case it contains garbage. - updateGpsCoordinates(); // now check if something has changed and if yes, edit the selected dives that // were identical with the master dive shown (and mark the divelist as changed) if (!same_string(displayed_dive.buddy, cd->buddy)) @@ -779,17 +790,6 @@ void MainTab::acceptChanges() time_t offset = cd->when - displayed_dive.when; MODIFY_SELECTED_DIVES(mydive->when -= offset;); } - if (displayed_dive.latitude.udeg != cd->latitude.udeg || - displayed_dive.longitude.udeg != cd->longitude.udeg) - MODIFY_SELECTED_DIVES( - if (copyPaste || - (same_string(mydive->location, cd->location) && - mydive->latitude.udeg == cd->latitude.udeg && - mydive->longitude.udeg == cd->longitude.udeg)) - gpsHasChanged(mydive, cd, ui.coordinates->text(), 0); - ); - if (!same_string(displayed_dive.location, cd->location)) - MODIFY_SELECTED_DIVES(EDIT_TEXT(location)); saveTags(); @@ -895,7 +895,6 @@ void MainTab::resetPallete() ui.buddy->setPalette(p); ui.notes->setPalette(p); ui.location->setPalette(p); - ui.coordinates->setPalette(p); ui.divemaster->setPalette(p); ui.suit->setPalette(p); ui.airtemp->setPalette(p); @@ -1133,8 +1132,17 @@ void MainTab::on_location_textChanged(const QString &text) free(displayedTrip.location); displayedTrip.location = strdup(ui.location->text().toUtf8().data()); } else { - free(displayed_dive.location); - displayed_dive.location = strdup(ui.location->text().toUtf8().data()); + // this means we switched dive sites... this requires a lot more thinking + // + // + // FIXME + // + // TODO + // + // + // + // free(displayed_dive.location); + // displayed_dive.location = strdup(ui.location->text().toUtf8().data()); } markChangedWidget(ui.location); } @@ -1142,25 +1150,12 @@ void MainTab::on_location_textChanged(const QString &text) // If we have GPS data for the location entered, add it. void MainTab::on_location_editingFinished() { - // if we have a location and no GPS data, look up the GPS data; - // but if the GPS data was intentionally cleared then don't - if (!currentTrip && - !same_string(displayed_dive.location, "") && - ui.coordinates->text().trimmed().isEmpty() && - !(editMode == DIVE && dive_has_gps_location(current_dive))) { - struct dive *dive; - int i = 0; - for_each_dive (i, dive) { - if (same_string(displayed_dive.location, dive->location) && - (dive->latitude.udeg || dive->longitude.udeg)) { - displayed_dive.latitude = dive->latitude; - displayed_dive.longitude = dive->longitude; - MainWindow::instance()->globe()->reload(); - updateGpsCoordinates(); - break; - } - } - } + // find the dive site or create it + const char *name = ui.location->text().toUtf8().data(); + uint32_t uuid = get_dive_site_uuid_by_name(name, NULL); + if (!uuid) + uuid = create_dive_site(name); + displayed_dive.dive_site_uuid = uuid; } void MainTab::on_suit_textChanged(const QString &text) @@ -1193,6 +1188,7 @@ void MainTab::on_notes_textChanged() markChangedWidget(ui.notes); } +#if 0 // we'll need something like this for the dive site management void MainTab::on_coordinates_textChanged(const QString &text) { if (editMode == IGNORE || acceptingEdit == true) @@ -1209,6 +1205,7 @@ void MainTab::on_coordinates_textChanged(const QString &text) ui.coordinates->setPalette(p); // marks things red } } +#endif void MainTab::on_rating_valueChanged(int value) { @@ -1260,6 +1257,7 @@ void MainTab::editWeightWidget(const QModelIndex &index) ui.weights->edit(index); } +#if 0 // we'll need this for dive sites void MainTab::updateCoordinatesText(qreal lat, qreal lon) { int ulat = rint(lat * 1000000); @@ -1272,9 +1270,16 @@ void MainTab::updateGpsCoordinates() if (editMode == NONE) enableEdition(); - ui.coordinates->setText(printGPSCoords(displayed_dive.latitude.udeg, displayed_dive.longitude.udeg)); - ui.coordinates->setModified(displayed_dive.latitude.udeg || displayed_dive.longitude.udeg); + struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + if (ds && dive_site_has_gps_location(ds)) { + ui.coordinates->setText(printGPSCoords(ds->latitude.udeg, ds->longitude.udeg)); + ui.coordinates->setModified(true); + } else if (!ui.coordinates->text().isEmpty()) { + ui.coordinates->setModified(true); + ui.coordinates->clear(); + } } +#endif void MainTab::escDetected() { @@ -1306,7 +1311,6 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) // take the data in our copyPasteDive and apply it to selected dives enableEdition(); copyPaste = true; - SHOW_SELECTIVE(location); SHOW_SELECTIVE(buddy); SHOW_SELECTIVE(divemaster); SHOW_SELECTIVE(suit); @@ -1321,8 +1325,8 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) ui.rating->setCurrentStars(displayed_dive.rating); if (what.visibility) ui.visibility->setCurrentStars(displayed_dive.visibility); - if (what.gps) - updateGpsCoordinates(); + if (what.divesite) + ui.location->setText(get_dive_location(&displayed_dive)); if (what.tags) { char buf[1024]; taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 71703e3f1..8869b068e 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -10,6 +10,7 @@ #include <QTabWidget> #include <QDialog> #include <QMap> +#include <QUuid> #include "ui_maintab.h" #include "completionmodels.h" @@ -40,7 +41,7 @@ public: IGNORE }; - MainTab(QWidget *parent); + MainTab(QWidget *parent = 0); ~MainTab(); void clearStats(); void clearInfo(); @@ -55,7 +56,7 @@ public: signals: void addDiveFinished(); void dateTimeChanged(); - + void requestDiveSiteEdit(uint32_t uuid); public slots: void addCylinder_clicked(); @@ -65,7 +66,6 @@ slots: void rejectChanges(); void on_location_textChanged(const QString &text); void on_location_editingFinished(); - void on_coordinates_textChanged(const QString &text); void on_divemaster_textChanged(); void on_buddy_textChanged(); void on_suit_textChanged(const QString &text); @@ -92,7 +92,8 @@ slots: void escDetected(void); void photoDoubleClicked(const QString filePath); void removeSelectedPhotos(); - void updateGpsCoordinates(); + void prepareDiveSiteEdit(); + void showLocation(); private: Ui::MainTab ui; diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index bffbac97a..3626548c3 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>443</width> + <width>463</width> <height>815</height> </rect> </property> @@ -15,14 +15,15 @@ </property> <widget class="QWidget" name="notesTab"> <attribute name="title"> - <string>Dive notes</string> + <string>Notes</string> </attribute> <layout class="QGridLayout" name="diveNotesLayout"> <property name="spacing"> <number>0</number> </property> <item row="2" column="1"> - <widget class="KMessageWidget" name="diveNotesMessage" native="true"/> + <widget class="KMessageWidget" name="diveNotesMessage" native="true"> + </widget> </item> <item row="3" column="1"> <widget class="QScrollArea" name="scrollArea"> @@ -40,112 +41,72 @@ <rect> <x>0</x> <y>0</y> - <width>397</width> - <height>744</height> + <width>441</width> + <height>753</height> </rect> </property> - <layout class="QGridLayout" name="diveNotesScrollAreaLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item row="4" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="sizeConstraint"> - <enum>QLayout::SetNoConstraint</enum> - </property> - <item> - <widget class="QLabel" name="CoordinatedLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> <property name="text"> - <string>Coordinates</string> + <string>Date</string> </property> </widget> </item> - <item> - <widget class="QLabel" name="TypeLabel"> + <item row="0" column="1"> + <widget class="QLabel" name="label"> <property name="text"> - <string>Dive mode</string> + <string>Time</string> </property> </widget> </item> - </layout> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Date</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Time</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <layout class="QHBoxLayout" name="temperatureLabels"> - <property name="spacing"> - <number>0</number> - </property> - <item> + <item row="0" column="2"> <widget class="QLabel" name="airTempLabel"> <property name="text"> <string>Air temp.</string> </property> </widget> </item> - <item> + <item row="0" column="3"> <widget class="QLabel" name="waterTempLabel"> <property name="text"> <string>Water temp.</string> </property> </widget> </item> - </layout> - </item> - <item row="1" column="1"> - <widget class="QTimeEdit" name="timeEdit"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="timeSpec"> - <enum>Qt::UTC</enum> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QDateEdit" name="dateEdit"> - <property name="calendarPopup"> - <bool>true</bool> - </property> - <property name="timeSpec"> - <enum>Qt::UTC</enum> - </property> - </widget> - </item> - <item row="1" column="2"> - <layout class="QHBoxLayout" name="airWaterTempLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> + <item row="1" column="0"> + <widget class="QDateEdit" name="dateEdit"> + <property name="calendarPopup"> + <bool>true</bool> + </property> + <property name="timeSpec"> + <enum>Qt::UTC</enum> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QTimeEdit" name="timeEdit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="timeSpec"> + <enum>Qt::UTC</enum> + </property> + </widget> + </item> + <item row="1" column="2"> <widget class="QLineEdit" name="airtemp"> <property name="readOnly"> <bool>false</bool> </property> </widget> </item> - <item> + <item row="1" column="3"> <widget class="QLineEdit" name="watertemp"> <property name="readOnly"> <bool>false</bool> @@ -154,47 +115,66 @@ </item> </layout> </item> - <item row="2" column="0"> + <item> <widget class="QLabel" name="LocationLabel"> <property name="text"> <string>Location</string> </property> </widget> </item> - <item row="10" column="0"> - <widget class="QLabel" name="DivemasterLabel"> - <property name="text"> - <string>Divemaster</string> - </property> - </widget> - </item> - <item row="10" column="2"> - <widget class="QLabel" name="BuddyLabel"> - <property name="text"> - <string>Buddy</string> - </property> - </widget> - </item> - <item row="11" column="0" colspan="2"> - <widget class="TagWidget" name="divemaster"> - <property name="readOnly"> - <bool>false</bool> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLineEdit" name="location"> + <property name="readOnly"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="manageDiveSite"> + <property name="text"> + <string>manage</string> + </property> + </widget> + </item> + </layout> </item> - <item row="11" column="2"> - <widget class="TagWidget" name="buddy"> - <property name="readOnly"> - <bool>false</bool> - </property> - </widget> + <item> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <widget class="QLabel" name="DivemasterLabel"> + <property name="text"> + <string>Divemaster</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="BuddyLabel"> + <property name="text"> + <string>Buddy</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="TagWidget" name="divemaster"> + <property name="readOnly"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="TagWidget" name="buddy"> + <property name="readOnly"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> </item> - <item row="12" column="0" colspan="2"> - <layout class="QHBoxLayout" name="ratingVisibilityLabels"> - <property name="spacing"> - <number>0</number> - </property> - <item> + <item> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> <widget class="QLabel" name="RatingLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -207,7 +187,7 @@ </property> </widget> </item> - <item> + <item row="0" column="1"> <widget class="QLabel" name="visibilityLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -220,28 +200,14 @@ </property> </widget> </item> - </layout> - </item> - <item row="12" column="2"> - <widget class="QLabel" name="SuitLabel"> - <property name="text"> - <string>Suit</string> - </property> - </widget> - </item> - <item row="13" column="2"> - <widget class="QLineEdit" name="suit"> - <property name="readOnly"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="13" column="0" colspan="2"> - <layout class="QHBoxLayout" name="ratingVisibilityWidgets"> - <property name="spacing"> - <number>0</number> - </property> - <item> + <item row="0" column="2"> + <widget class="QLabel" name="SuitLabel"> + <property name="text"> + <string>Suit</string> + </property> + </widget> + </item> + <item row="1" column="0"> <widget class="StarWidget" name="rating" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -254,7 +220,7 @@ </property> </widget> </item> - <item> + <item row="1" column="1"> <widget class="StarWidget" name="visibility" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -267,55 +233,69 @@ </property> </widget> </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="suit"> + <property name="readOnly"> + <bool>false</bool> + </property> + </widget> + </item> </layout> </item> - <item row="14" column="0"> - <widget class="QLabel" name="TagLabel"> - <property name="text"> - <string>Tags</string> - </property> - </widget> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="1" column="1"> + <widget class="QComboBox" name="DiveType"/> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="TagLabel"> + <property name="text"> + <string>Tags</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="TypeLabel"> + <property name="text"> + <string>Dive mode</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="TagWidget" name="tagWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="lineWrapMode"> + <enum>QPlainTextEdit::NoWrap</enum> + </property> + </widget> + </item> + </layout> </item> - <item row="16" column="0"> + <item> <widget class="QLabel" name="NotesLabel"> <property name="text"> <string>Notes</string> </property> </widget> </item> - <item row="15" column="0" colspan="3"> - <widget class="TagWidget" name="tagWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="lineWrapMode"> - <enum>QPlainTextEdit::NoWrap</enum> - </property> - </widget> - </item> - <item row="3" column="0" colspan="3"> - <widget class="QLineEdit" name="location"> - <property name="readOnly"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="17" column="0" colspan="3"> + <item> <layout class="QHBoxLayout" name="notesAndSocialNetworksLayout"> <property name="spacing"> <number>0</number> @@ -371,20 +351,6 @@ </item> </layout> </item> - <item row="7" column="0" colspan="3"> - <layout class="QHBoxLayout" name="coordinatesDiveTypeLayout"> - <item> - <widget class="QLineEdit" name="coordinates"> - <property name="readOnly"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="DiveType"/> - </item> - </layout> - </item> </layout> </widget> </widget> @@ -415,8 +381,8 @@ <rect> <x>0</x> <y>0</y> - <width>397</width> - <height>734</height> + <width>68</width> + <height>40</height> </rect> </property> <layout class="QGridLayout" name="equipmentTabScrollAreaLayout"> @@ -449,7 +415,7 @@ </widget> <widget class="QWidget" name="infoTab"> <attribute name="title"> - <string>Dive info</string> + <string>Info</string> </attribute> <layout class="QGridLayout" name="diveInfoLayout"> <item row="0" column="0"> @@ -471,8 +437,8 @@ <rect> <x>0</x> <y>0</y> - <width>397</width> - <height>734</height> + <width>441</width> + <height>363</height> </rect> </property> <layout class="QGridLayout" name="diveInfoScrollAreaLayout"> @@ -788,8 +754,8 @@ <rect> <x>0</x> <y>0</y> - <width>397</width> - <height>734</height> + <width>446</width> + <height>215</height> </rect> </property> <layout class="QGridLayout" name="statsScrollAreaLayout"> @@ -1051,7 +1017,6 @@ <tabstop>rating</tabstop> <tabstop>visibility</tabstop> <tabstop>suit</tabstop> - <tabstop>tagWidget</tabstop> <tabstop>notes</tabstop> </tabstops> <resources> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 82eaaac57..648ead174 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -11,7 +11,8 @@ #include <QSettings> #include <QShortcut> #include <QToolBar> -#include "ssrf-version.h" +#include "version.h" +#include "divelistview.h" #include "downloadfromdivecomputer.h" #include "preferences.h" #include "subsurfacewebservices.h" @@ -20,6 +21,10 @@ #include "updatemanager.h" #include "planner.h" #include "filtermodels.h" +#include "profile/profilewidget2.h" +#include "globe.h" +#include "maintab.h" +#include "diveplanner.h" #ifndef NO_PRINTING #include <QPrintDialog> #include "printdialog.h" @@ -31,6 +36,7 @@ #include "usermanual.h" #endif #include <QNetworkProxy> +#include <QUndoStack> MainWindow *MainWindow::m_Instance = NULL; @@ -44,7 +50,25 @@ MainWindow::MainWindow() : QMainWindow(), Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!"); m_Instance = this; ui.setupUi(this); - ui.multiFilter->hide(); + // Define the States of the Application Here, Currently the states are situations where the different + // widgets will change on the mainwindow. + + // for the "default" mode + MainTab *mainTab = new MainTab(); + DiveListView *diveListView = new DiveListView(); + ProfileWidget2 *profileWidget = new ProfileWidget2(); + +#ifndef NO_MARBLE + GlobeGPS *globeGps = new GlobeGPS(); +#else + QWidget *globeGps = NULL; +#endif + + PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget(); + DivePlannerWidget *plannerWidget = new DivePlannerWidget(); + PlannerDetails *plannerDetails = new PlannerDetails(); + LocationInformationWidget *locationInformation = new LocationInformationWidget(); + // what is a sane order for those icons? we should have the ones the user is // most likely to want towards the top so they are always visible // and the ones that someone likely sets and then never touches again towards the bottom @@ -57,69 +81,83 @@ MainWindow::MainWindow() : QMainWindow(), ui.profEad << ui.profSAC << ui.profHR << // very few dive computers support this ui.profTissues; // maybe less frequently used + + QToolBar *toolBar = new QToolBar(); + Q_FOREACH (QAction *a, profileToolbarActions) + toolBar->addAction(a); + toolBar->setOrientation(Qt::Vertical); + toolBar->setIconSize(QSize(24,24)); + + QWidget *profileContainer = new QWidget(); + QHBoxLayout *profLayout = new QHBoxLayout(); + profLayout->addWidget(toolBar); + profLayout->addWidget(profileWidget); + profileContainer->setLayout(profLayout); + + registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps ); + registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps ); + registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps ); + registerApplicationState("PlanDive", plannerWidget, profileContainer, plannerSettings, plannerDetails ); + registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps ); + registerApplicationState("EditDiveSite",locationInformation, profileContainer, diveListView, globeGps ); + + setApplicationState("Default"); + + ui.multiFilter->hide(); + setWindowIcon(QIcon(":subsurface-icon")); if (!QIcon::hasThemeIcon("window-close")) { QIcon::setThemeName("subsurface"); } - connect(ui.ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); + connect(dive_list(), SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(update())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.plannerSettingsWidget, SLOT(settingsChanged())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget(), SLOT(settingsChanged())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerSettingsWidget(), SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update())); connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent2, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent3, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent4, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); - connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState())); + connect(information(), SIGNAL(addDiveFinished()), graphics(), SLOT(setProfileState())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); - connect(ui.printPlan, SIGNAL(pressed()), ui.divePlannerWidget, SLOT(printDecoPlan())); + connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); + connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t))); + connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); + connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(refreshDisplay())); + connect(locationInformation, SIGNAL(informationManagementEnded()), information(), SLOT(showLocation())); + #ifdef NO_PRINTING ui.printPlan->hide(); + ui.menuFile->removeAction(ui.actionPrint); #endif ui.mainErrorMessage->hide(); - ui.newProfile->setEmptyState(); + graphics()->setEmptyState(); initialUiSetup(); readSettings(); - ui.ListWidget->reload(DiveTripModel::TREE); - ui.ListWidget->reloadHeaderActions(); - ui.ListWidget->setFocus(); - ui.globe->reload(); - ui.ListWidget->expand(ui.ListWidget->model()->index(0, 0)); - ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0, 0), QAbstractItemView::PositionAtCenter); - ui.divePlannerWidget->settingsChanged(); - ui.plannerSettingsWidget->settingsChanged(); + diveListView->reload(DiveTripModel::TREE); + diveListView->reloadHeaderActions(); + diveListView->setFocus(); + globe()->reload(); + diveListView->expand(dive_list()->model()->index(0, 0)); + diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter); + divePlannerWidget()->settingsChanged(); + divePlannerSettingsWidget()->settingsChanged(); #ifdef NO_MARBLE - ui.globePane->hide(); ui.menuView->removeAction(ui.actionViewGlobe); #else - connect(ui.globe, SIGNAL(coordinatesChanged()), ui.InfoWidget, SLOT(updateGpsCoordinates())); + connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates())); #endif #ifdef NO_USERMANUAL ui.menuHelp->removeAction(ui.actionUserManual); #endif -#ifdef NO_PRINTING - ui.menuFile->removeAction(ui.actionPrint); -#endif memset(©PasteDive, 0, sizeof(copyPasteDive)); memset(&what, 0, sizeof(what)); - QToolBar *toolBar = new QToolBar(); - Q_FOREACH (QAction *a, profileToolbarActions) - toolBar->addAction(a); - toolBar->setOrientation(Qt::Vertical); - toolBar->setIconSize(QSize(24,24)); - // since I'm adding the toolBar by hand, because designer - // has no concept of "toolbar" for a non-mainwindow widget (...) - // I need to take the current item that's in the toolbar Position - // and reposition it alongside the grid layout. - QLayoutItem *p = ui.profileInnerLayout->takeAt(0); - ui.profileInnerLayout->addWidget(toolBar, 0, 0); - ui.profileInnerLayout->addItem(p, 0, 1); // and now for some layout hackery // this gets us consistent margins everywhere and a much more balanced look @@ -146,12 +184,19 @@ MainWindow::MainWindow() : QMainWindow(), else layout->setContentsMargins(margins); } - margins = QMargins(0, 5, 5, 5); - ui.profileInnerLayout->setContentsMargins(margins); - ui.profileInnerLayout->setSpacing(0); toolBar->setContentsMargins(zeroMargins); updateManager = new UpdateManager(this); + + undoStack = new QUndoStack(this); + QAction *undoAction = undoStack->createUndoAction(this, tr("&Undo")); + QAction *redoAction = undoStack->createRedoAction(this, tr("&Redo")); + undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z)); + redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z)); + QList<QAction*>undoRedoActions; + undoRedoActions.append(undoAction); + undoRedoActions.append(redoAction); + ui.menu_Edit->addActions(undoRedoActions); } MainWindow::~MainWindow() @@ -159,6 +204,26 @@ MainWindow::~MainWindow() m_Instance = NULL; } +PlannerDetails *MainWindow::plannerDetails() const { + return qobject_cast<PlannerDetails*>(applicationState["PlanDive"].bottomRight); +} + +PlannerSettingsWidget *MainWindow::divePlannerSettingsWidget() { + return qobject_cast<PlannerSettingsWidget*>(applicationState["PlanDive"].bottomLeft); +} + +LocationInformationWidget *MainWindow::locationInformationWidget() { + return qobject_cast<LocationInformationWidget*>(applicationState["EditDiveSite"].topLeft); +} + +void MainWindow::enableDiveSiteEdit(uint32_t id) { + setApplicationState("EditDiveSite"); +} + +void MainWindow::setDefaultState() { + setApplicationState("Default"); +} + void MainWindow::setLoadedWithFiles(bool f) { filesAsArguments = f; @@ -178,18 +243,15 @@ MainWindow *MainWindow::instance() void MainWindow::refreshDisplay(bool doRecreateDiveList) { showError(get_error_string()); - ui.InfoWidget->reload(); + information()->reload(); TankInfoModel::instance()->update(); - ui.globe->reload(); + globe()->reload(); if (doRecreateDiveList) recreateDiveList(); - ui.diveListPane->setCurrentIndex(0); // switch to the dive list -#ifdef NO_MARBLE - ui.globePane->hide(); -#endif - ui.globePane->setCurrentIndex(0); - ui.ListWidget->setEnabled(true); - ui.ListWidget->setFocus(); + + setApplicationState("Default"); + dive_list()->setEnabled(true); + dive_list()->setFocus(); WSInfoModel::instance()->updateInfo(); if (amount_selected == 0) cleanUpEmpty(); @@ -197,7 +259,7 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList) void MainWindow::recreateDiveList() { - ui.ListWidget->reload(DiveTripModel::CURRENT); + dive_list()->reload(DiveTripModel::CURRENT); TagFilterModel::instance()->repopulate(); BuddyFilterModel::instance()->repopulate(); LocationFilterModel::instance()->repopulate(); @@ -208,10 +270,11 @@ void MainWindow::current_dive_changed(int divenr) { if (divenr >= 0) { select_dive(divenr); - ui.globe->centerOnCurrentDive(); + globe()->centerOnCurrentDive(); } - ui.newProfile->plotDive(); - ui.InfoWidget->updateDiveInfo(); + graphics()->plotDive(); + information()->updateDiveInfo(); + locationInformationWidget()->setLocationId(displayed_dive.dive_site_uuid); } void MainWindow::on_actionNew_triggered() @@ -254,18 +317,19 @@ void MainWindow::on_actionSaveAs_triggered() ProfileWidget2 *MainWindow::graphics() const { - return ui.newProfile; + return qobject_cast<ProfileWidget2*>(applicationState["Default"].topRight->layout()->itemAt(1)->widget()); } void MainWindow::cleanUpEmpty() { - ui.InfoWidget->clearStats(); - ui.InfoWidget->clearInfo(); - ui.InfoWidget->clearEquipment(); - ui.InfoWidget->updateDiveInfo(true); - ui.newProfile->setEmptyState(); - ui.ListWidget->reload(DiveTripModel::TREE); - ui.globe->reload(); + information()->clearStats(); + information()->clearInfo(); + information()->clearEquipment(); + information()->updateDiveInfo(true); + graphics()->setEmptyState(); + dive_list()->reload(DiveTripModel::TREE); + locationInformationWidget()->setLocationId(0); + globe()->reload(); if (!existing_filename) setTitle(MWTF_DEFAULT); disableShortcuts(); @@ -274,7 +338,8 @@ void MainWindow::cleanUpEmpty() bool MainWindow::okToClose(QString message) { if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + information()->isEditing() || + currentApplicationState == "EditDiveSite") { QMessageBox::warning(this, tr("Warning"), message); return false; } @@ -286,11 +351,13 @@ bool MainWindow::okToClose(QString message) void MainWindow::closeCurrentFile() { - ui.newProfile->setEmptyState(); + graphics()->setEmptyState(); /* free the dives and trips */ clear_git_id(); while (dive_table.nr) delete_single_dive(0); + while (dive_site_table.nr) + delete_dive_site(get_dive_site(0)->uuid); free((void *)existing_filename); existing_filename = NULL; @@ -362,8 +429,8 @@ void MainWindow::enableShortcuts() void MainWindow::showProfile() { enableShortcuts(); - ui.newProfile->setProfileState(); - ui.infoPane->setCurrentIndex(MAINTAB); + graphics()->setProfileState(); + setApplicationState("Default"); } void MainWindow::on_actionPreferences_triggered() @@ -373,9 +440,9 @@ void MainWindow::on_actionPreferences_triggered() void MainWindow::on_actionQuit_triggered() { - if (ui.InfoWidget->isEditing()) { - ui.InfoWidget->rejectChanges(); - if (ui.InfoWidget->isEditing()) + if (information()->isEditing()) { + information()->rejectChanges(); + if (information()->isEditing()) // didn't discard the edits return; } @@ -421,7 +488,7 @@ void MainWindow::on_actionEditDeviceNames_triggered() bool MainWindow::plannerStateClean() { if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + information()->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive.")); return false; } @@ -433,16 +500,16 @@ void MainWindow::planCanceled() // while planning we might have modified the displayed_dive // let's refresh what's shown on the profile showProfile(); - ui.newProfile->replot(); + graphics()->replot(); refreshDisplay(false); - ui.newProfile->plotDive(get_dive(selected_dive)); + graphics()->plotDive(get_dive(selected_dive)); DivePictureModel::instance()->updateDivePictures(); } void MainWindow::planCreated() { // get the new dive selected and assign a number if reasonable - ui.newProfile->setProfileState(); + graphics()->setProfileState(); if (displayed_dive.id == 0) { // we might have added a new dive (so displayed_dive was cleared out by clone_dive() dive_list()->unselectDives(); @@ -451,20 +518,20 @@ void MainWindow::planCreated() set_dive_nr_for_current_dive(); } // make sure our UI is in a consistent state - ui.InfoWidget->updateDiveInfo(); + information()->updateDiveInfo(); showProfile(); refreshDisplay(); } void MainWindow::setPlanNotes(const char *notes) { - ui.divePlanOutput->setHtml(notes); + plannerDetails()->divePlanOutput()->setHtml(notes); } void MainWindow::printPlan() { #ifndef NO_PRINTING - QString diveplan = ui.divePlanOutput->toHtml(); + QString diveplan = plannerDetails()->divePlanOutput()->toHtml(); QString withDisclaimer = QString("<img height=50 src=\":subsurface-icon\"> ") + diveplan + QString(disclaimer); QPrinter printer; @@ -473,9 +540,9 @@ void MainWindow::printPlan() if (dialog->exec() != QDialog::Accepted) return; - ui.divePlanOutput->setHtml(withDisclaimer); - ui.divePlanOutput->print(&printer); - ui.divePlanOutput->setHtml(diveplan); + plannerDetails()->divePlanOutput()->setHtml(withDisclaimer); + plannerDetails()->divePlanOutput()->print(&printer); + plannerDetails()->divePlanOutput()->setHtml(diveplan); #endif } @@ -489,6 +556,7 @@ void MainWindow::setupForAddAndPlan(const char *model) // setup the dive cylinders DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->setupCylinders(); + locationInformationWidget()->setLocationId(0); } void MainWindow::on_actionReplanDive_triggered() @@ -503,17 +571,12 @@ void MainWindow::on_actionReplanDive_triggered() DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); - ui.newProfile->setPlanState(); - ui.newProfile->clearHandlers(); - ui.infoPane->setCurrentIndex(PLANNERWIDGET); - ui.divePlannerWidget->setReplanButton(true); + graphics()->setPlanState(); + graphics()->clearHandlers(); + setApplicationState("PlanDive"); + divePlannerWidget()->setReplanButton(true); DivePlannerPointsModel::instance()->loadFromDive(current_dive); reset_cylinders(&displayed_dive, true); - ui.diveListPane->setCurrentIndex(1); // switch to the plan output - ui.globePane->setCurrentIndex(1); -#ifdef NO_MARBLE - ui.globePane->show(); -#endif } void MainWindow::on_actionDivePlanner_triggered() @@ -523,22 +586,20 @@ void MainWindow::on_actionDivePlanner_triggered() // put us in PLAN mode DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); + setApplicationState("PlanDive"); - ui.newProfile->setPlanState(); - ui.infoPane->setCurrentIndex(PLANNERWIDGET); + graphics()->setPlanState(); // create a simple starting dive, using the first gas from the just copied cylidners setupForAddAndPlan("planned dive"); // don't translate, stored in XML file DivePlannerPointsModel::instance()->setupStartTime(); DivePlannerPointsModel::instance()->createSimpleDive(); DivePictureModel::instance()->updateDivePictures(); - ui.divePlannerWidget->setReplanButton(false); + divePlannerWidget()->setReplanButton(false); +} - ui.diveListPane->setCurrentIndex(1); // switch to the plan output - ui.globePane->setCurrentIndex(1); -#ifdef NO_MARBLE - ui.globePane->show(); -#endif +DivePlannerWidget* MainWindow::divePlannerWidget() { + return qobject_cast<DivePlannerWidget*>(applicationState["PlanDive"].topLeft); } void MainWindow::on_actionAddDive_triggered() @@ -551,23 +612,23 @@ void MainWindow::on_actionAddDive_triggered() dive_list()->clearSelection(); } + setApplicationState("AddDive"); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); // setup things so we can later create our starting dive setupForAddAndPlan("manually added dive"); // don't translate, stored in the XML file // now show the mostly empty main tab - ui.InfoWidget->updateDiveInfo(); + information()->updateDiveInfo(); // show main tab - ui.InfoWidget->setCurrentIndex(0); + information()->setCurrentIndex(0); - ui.InfoWidget->addDiveStarted(); - ui.infoPane->setCurrentIndex(MAINTAB); + information()->addDiveStarted(); - ui.newProfile->setAddState(); + graphics()->setAddState(); DivePlannerPointsModel::instance()->createSimpleDive(); - ui.newProfile->plotDive(); + graphics()->plotDive(); } void MainWindow::on_actionRenumber_triggered() @@ -612,16 +673,16 @@ void MainWindow::on_actionYearlyStatistics_triggered() #define TOGGLE_COLLAPSABLE( X ) \ ui.mainSplitter->setCollapsible(0, X); \ ui.mainSplitter->setCollapsible(1, X); \ - ui.infoProfileSplitter->setCollapsible(0, X); \ - ui.infoProfileSplitter->setCollapsible(1, X); \ - ui.listGlobeSplitter->setCollapsible(0, X); \ - ui.listGlobeSplitter->setCollapsible(1, X); + ui.topSplitter->setCollapsible(0, X); \ + ui.topSplitter->setCollapsible(1, X); \ + ui.bottomSplitter->setCollapsible(0, X); \ + ui.bottomSplitter->setCollapsible(1, X); void MainWindow::on_actionViewList_triggered() { TOGGLE_COLLAPSABLE( true ); beginChangeState(LIST_MAXIMIZED); - ui.listGlobeSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); + ui.topSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); } @@ -629,7 +690,7 @@ void MainWindow::on_actionViewProfile_triggered() { TOGGLE_COLLAPSABLE( true ); beginChangeState(PROFILE_MAXIMIZED); - ui.infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui.topSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); } @@ -637,7 +698,7 @@ void MainWindow::on_actionViewInfo_triggered() { TOGGLE_COLLAPSABLE( true ); beginChangeState(INFO_MAXIMIZED); - ui.infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); + ui.topSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); } @@ -646,7 +707,7 @@ void MainWindow::on_actionViewGlobe_triggered() TOGGLE_COLLAPSABLE( true ); beginChangeState(GLOBE_MAXIMIZED); ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); - ui.listGlobeSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui.bottomSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); } #undef BEHAVIOR @@ -677,26 +738,26 @@ void MainWindow::on_actionViewAll_triggered() settings.beginGroup("MainWindow"); if (settings.value("mainSplitter").isValid()) { ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); - ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); - ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray()); + ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); + ui.bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0) ui.mainSplitter->setSizes(mainSizes); - if (ui.infoProfileSplitter->sizes().first() == 0 || ui.infoProfileSplitter->sizes().last() == 0) - ui.infoProfileSplitter->setSizes(infoProfileSizes); - if (ui.listGlobeSplitter->sizes().first() == 0 || ui.listGlobeSplitter->sizes().last() == 0) - ui.listGlobeSplitter->setSizes(listGlobeSizes); + if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) + ui.topSplitter->setSizes(infoProfileSizes); + if (ui.bottomSplitter->sizes().first() == 0 || ui.bottomSplitter->sizes().last() == 0) + ui.bottomSplitter->setSizes(listGlobeSizes); } else { ui.mainSplitter->setSizes(mainSizes); - ui.infoProfileSplitter->setSizes(infoProfileSizes); - ui.listGlobeSplitter->setSizes(listGlobeSizes); + ui.topSplitter->setSizes(infoProfileSizes); + ui.bottomSplitter->setSizes(listGlobeSizes); } ui.mainSplitter->setCollapsible(0, false); ui.mainSplitter->setCollapsible(1, false); - ui.infoProfileSplitter->setCollapsible(0, false); - ui.infoProfileSplitter->setCollapsible(1, false); - ui.listGlobeSplitter->setCollapsible(0,false); - ui.listGlobeSplitter->setCollapsible(1,false); + ui.topSplitter->setCollapsible(0, false); + ui.topSplitter->setCollapsible(1, false); + ui.bottomSplitter->setCollapsible(0,false); + ui.bottomSplitter->setCollapsible(1,false); } #undef TOGGLE_COLLAPSABLE @@ -714,24 +775,24 @@ void MainWindow::saveSplitterSizes() QSettings settings; settings.beginGroup("MainWindow"); settings.setValue("mainSplitter", ui.mainSplitter->saveState()); - settings.setValue("infoProfileSplitter", ui.infoProfileSplitter->saveState()); - settings.setValue("listGlobeSplitter", ui.listGlobeSplitter->saveState()); + settings.setValue("topSplitter", ui.topSplitter->saveState()); + settings.setValue("bottomSplitter", ui.bottomSplitter->saveState()); } void MainWindow::on_actionPreviousDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + nrdc - 1) % nrdc; - ui.newProfile->plotDive(); - ui.InfoWidget->updateDiveInfo(); + graphics()->plotDive(); + information()->updateDiveInfo(); } void MainWindow::on_actionNextDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + 1) % nrdc; - ui.newProfile->plotDive(); - ui.InfoWidget->updateDiveInfo(); + graphics()->plotDive(); + information()->updateDiveInfo(); } void MainWindow::on_actionFullScreen_triggered(bool checked) @@ -937,7 +998,7 @@ void MainWindow::checkSurvey(QSettings *s) s->setValue("FirstUse42", value); } // wait a week for production versions, but not at all for non-tagged builds - QString ver(VERSION_STRING); + QString ver(subsurface_version()); int waitTime = 7; QDate firstUse42 = s->value("FirstUse42").toDate(); if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s->contains("SurveyDone"))) { @@ -965,7 +1026,7 @@ void MainWindow::writeSettings() void MainWindow::closeEvent(QCloseEvent *event) { if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + information()->isEditing()) { on_actionQuit_triggered(); event->ignore(); return; @@ -994,17 +1055,17 @@ void MainWindow::closeEvent(QCloseEvent *event) DiveListView *MainWindow::dive_list() { - return ui.ListWidget; + return qobject_cast<DiveListView*>(applicationState["Default"].bottomLeft); } GlobeGPS *MainWindow::globe() { - return ui.globe; + return qobject_cast<GlobeGPS*>(applicationState["Default"].bottomRight); } MainTab *MainWindow::information() { - return ui.InfoWidget; + return qobject_cast<MainTab*>(applicationState["Default"].topLeft); } void MainWindow::loadRecentFiles(QSettings *s) @@ -1179,8 +1240,8 @@ int MainWindow::file_save_as(void) if (filename.isNull() || filename.isEmpty()) return report_error("No filename to save into"); - if (ui.InfoWidget->isEditing()) - ui.InfoWidget->acceptChanges(); + if (information()->isEditing()) + information()->acceptChanges(); if (save_dives(filename.toUtf8().data())) { showError(get_error_string()); @@ -1202,8 +1263,8 @@ int MainWindow::file_save(void) if (!existing_filename) return file_save_as(); - if (ui.InfoWidget->isEditing()) - ui.InfoWidget->acceptChanges(); + if (information()->isEditing()) + information()->acceptChanges(); current_default = prefs.default_filename; if (strcmp(existing_filename, current_default) == 0) { @@ -1368,20 +1429,16 @@ void MainWindow::editCurrentDive() if (defaultDC == "manually added dive") { disableShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); - ui.newProfile->setAddState(); - ui.infoPane->setCurrentIndex(MAINTAB); + graphics()->setAddState(); + setApplicationState("EditDive"); DivePlannerPointsModel::instance()->loadFromDive(d); - ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE); + information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE); } else if (defaultDC == "planned dive") { disableShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); - //TODO: I BROKE THIS BY COMMENTING THE LINE BELOW - // and I'm sleepy now, so I think I should not try to fix right away. - // we don't setCurrentIndex anymore, we ->setPlanState() or ->setAddState() on the ProfileView. - //ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. - ui.infoPane->setCurrentIndex(PLANNERWIDGET); + setApplicationState("EditPlannedDive"); DivePlannerPointsModel::instance()->loadFromDive(d); - ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE); + information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE); } } @@ -1456,7 +1513,7 @@ void MainWindow::on_paste_triggered() { // take the data in our copyPasteDive and apply it to selected dives selective_copy_dive(©PasteDive, &displayed_dive, what, false); - ui.InfoWidget->showAndTriggerEditSelective(what); + information()->showAndTriggerEditSelective(what); } void MainWindow::on_actionFilterTags_triggered() @@ -1466,3 +1523,43 @@ void MainWindow::on_actionFilterTags_triggered() else ui.multiFilter->setVisible(true); } + +void MainWindow::registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight) +{ + applicationState[state] = WidgetForQuadrant(topLeft, topRight, bottomLeft, bottomRight); + if (ui.topLeft->indexOf(topLeft) == -1 && topLeft) { + ui.topLeft->addWidget(topLeft); + } + if (ui.topRight->indexOf(topRight) == -1 && topRight) { + ui.topRight->addWidget(topRight); + } + if (ui.bottomLeft->indexOf(bottomLeft) == -1 && bottomLeft) { + ui.bottomLeft->addWidget(bottomLeft); + } + if(ui.bottomRight->indexOf(bottomRight) == -1 && bottomRight) { + ui.bottomRight->addWidget(bottomRight); + } +} + +void MainWindow::setApplicationState(const QByteArray& state) { + if (!applicationState.keys().contains(state)) + return; + + if (currentApplicationState == state) + return; + + currentApplicationState = state; +#define SET_CURRENT_INDEX( X ) \ + if (applicationState[state].X) { \ + ui.X->setCurrentWidget( applicationState[state].X); \ + ui.X->show(); \ + } else { \ + ui.X->hide(); \ + } + + SET_CURRENT_INDEX( topLeft ) + SET_CURRENT_INDEX( topRight ) + SET_CURRENT_INDEX( bottomLeft ) + SET_CURRENT_INDEX( bottomRight ) +#undef SET_CURRENT_INDEX +} diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 2364caadc..85a63123b 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -10,6 +10,7 @@ #include <QMainWindow> #include <QAction> #include <QUrl> +#include <QUuid> #include "ui_mainwindow.h" @@ -30,6 +31,11 @@ class QWebView; class QSettings; class UpdateManager; class UserManual; +class DivePlannerWidget; +class ProfileWidget2; +class PlannerDetails; +class PlannerSettingsWidget; +class QUndoStack; enum MainWindowTitleFormat { MWTF_DEFAULT, @@ -43,10 +49,7 @@ public: COLLAPSED, EXPANDED }; - enum InfoWidgetIndexes { - MAINTAB, - PLANNERWIDGET - }; + enum CurrentState { VIEWALL, GLOBE_MAXIMIZED, @@ -64,6 +67,9 @@ public: void removeRecentFile(QStringList failedFiles); DiveListView *dive_list(); GlobeGPS *globe(); + DivePlannerWidget *divePlannerWidget(); + PlannerSettingsWidget *divePlannerSettingsWidget(); + LocationInformationWidget *locationInformationWidget(); void showError(QString message); void setTitle(enum MainWindowTitleFormat format); @@ -77,11 +83,14 @@ public: void cleanUpEmpty(); void setToolButtonsEnabled(bool enabled); ProfileWidget2 *graphics() const; + PlannerDetails *plannerDetails() const; void setLoadedWithFiles(bool filesFromCommandLine); bool filesFromCommandLine() const; void setPlanNotes(const char *notes); void printPlan(); void checkSurvey(QSettings *s); + void setApplicationState(const QByteArray& state); + QUndoStack *undoStack; private slots: /* file menu action */ @@ -151,6 +160,8 @@ slots: void on_paste_triggered(); void on_actionFilterTags_triggered(); void on_actionConfigure_Dive_Computer_triggered(); + void enableDiveSiteEdit(uint32_t id); + void setDefaultState(); protected: void closeEvent(QCloseEvent *); @@ -185,6 +196,7 @@ private: void saveSplitterSizes(); QString lastUsedDir(); void updateLastUsedDir(const QString &s); + void registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight); bool filesAsArguments; UpdateManager *updateManager; @@ -194,6 +206,17 @@ private: struct dive copyPasteDive; struct dive_components what; QList<QAction *> profileToolbarActions; + + struct WidgetForQuadrant { + WidgetForQuadrant(QWidget *tl = 0, QWidget *tr = 0, QWidget *bl = 0, QWidget *br = 0) : + topLeft(tl), topRight(tr), bottomLeft(bl), bottomRight(br) {} + QWidget *topLeft; + QWidget *topRight; + QWidget *bottomLeft; + QWidget *bottomRight; + }; + QHash<QByteArray, WidgetForQuadrant> applicationState; + QByteArray currentApplicationState; }; #endif // MAINWINDOW_H diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 8ffb8bbd8..b6cd4a358 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>1682</width> - <height>1151</height> + <width>861</width> + <height>800</height> </rect> </property> <widget class="QWidget" name="centralwidget"> @@ -23,164 +23,19 @@ <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <widget class="QSplitter" name="infoProfileSplitter"> + <widget class="QSplitter" name="topSplitter"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <widget class="QStackedWidget" name="infoPane"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="page"> - <layout class="QHBoxLayout" name="mainTabOuterLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="MainTab" name="InfoWidget" native="true"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_2"> - <property name="enabled"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="divePlannerLayout"> - <item> - <widget class="DivePlannerWidget" name="divePlannerWidget" native="true"> - <property name="enabled"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - <widget class="QWidget" name="ProfileWidget"> - <layout class="QGridLayout" name="profileInnerLayout"> - <item row="0" column="0" rowspan="3"> - <widget class="ProfileWidget2" name="newProfile"/> - </item> - </layout> - </widget> + <widget class="QStackedWidget" name="topLeft"/> + <widget class="QStackedWidget" name="topRight"/> </widget> - <widget class="QSplitter" name="listGlobeSplitter"> + <widget class="QSplitter" name="bottomSplitter"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <widget class="QStackedWidget" name="diveListPane"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="page_3"> - <layout class="QVBoxLayout" name="diveListLayout"> - <item> - <widget class="DiveListView" name="ListWidget"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="PlannerSettingsWidget" name="plannerSettingsWidget"/> - </widget> - <widget class="QStackedWidget" name="globePane"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="stackedWidgetPage1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="globeLayout"> - <item> - <widget class="GlobeGPS" name="globe" native="true"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_5"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QHBoxLayout" name="divePlanLayout"> - <item> - <widget class="QLabel" name="divePlanOutputLabel"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>20</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Dive plan details</span></p></body></html></string> - </property> - <property name="textFormat"> - <enum>Qt::RichText</enum> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="printPlan"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Print</string> - </property> - <property name="autoDefault"> - <bool>false</bool> - </property> - <property name="default"> - <bool>false</bool> - </property> - <property name="flat"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QTextEdit" name="divePlanOutput"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string notr="true">font: 13pt "Courier";</string> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - <property name="html"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Courier'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Curier New';"><br /></p></body></html></string> - </property> - </widget> - </item> - </layout> - </widget> - </widget> + <widget class="QStackedWidget" name="bottomLeft"/> + <widget class="QStackedWidget" name="bottomRight"/> </widget> </widget> </item> @@ -194,8 +49,8 @@ p, li { white-space: pre-wrap; } <rect> <x>0</x> <y>0</y> - <width>1682</width> - <height>27</height> + <width>861</width> + <height>25</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -271,7 +126,13 @@ p, li { white-space: pre-wrap; } <addaction name="actionDownloadWeb"/> <addaction name="actionDivelogs_de"/> </widget> + <widget class="QMenu" name="menu_Edit"> + <property name="title"> + <string>&Edit</string> + </property> + </widget> <addaction name="menuFile"/> + <addaction name="menu_Edit"/> <addaction name="menuImport"/> <addaction name="menuLog"/> <addaction name="menuView"/> @@ -813,6 +674,22 @@ p, li { white-space: pre-wrap; } <string>User &survey</string> </property> </action> + <action name="action_Undo"> + <property name="text"> + <string>&Undo</string> + </property> + <property name="shortcut"> + <string>Ctrl+Z</string> + </property> + </action> + <action name="action_Redo"> + <property name="text"> + <string>&Redo</string> + </property> + <property name="shortcut"> + <string>Ctrl+Shift+Z</string> + </property> + </action> </widget> <customwidgets> <customwidget> @@ -822,40 +699,6 @@ p, li { white-space: pre-wrap; } <container>1</container> </customwidget> <customwidget> - <class>MainTab</class> - <extends>QWidget</extends> - <header>qt-ui/maintab.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>DiveListView</class> - <extends>QTreeView</extends> - <header>divelistview.h</header> - </customwidget> - <customwidget> - <class>GlobeGPS</class> - <extends>QWidget</extends> - <header>globe.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>DivePlannerWidget</class> - <extends>QWidget</extends> - <header>diveplanner.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>ProfileWidget2</class> - <extends>QGraphicsView</extends> - <header>qt-ui/profile/profilewidget2.h</header> - </customwidget> - <customwidget> - <class>PlannerSettingsWidget</class> - <extends>QWidget</extends> - <header>diveplanner.h</header> - <container>1</container> - </customwidget> - <customwidget> <class>MultiFilter</class> <extends>QWidget</extends> <header>simplewidgets.h</header> diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index ee7dc6cf5..c6c46aa46 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -2,8 +2,13 @@ #include "dive.h" #include "gettextfromc.h" #include "mainwindow.h" +#include "models.h" +#include "starwidget.h" +#include "profile/profilewidget2.h" #include <QCompleter> +#include <QKeyEvent> +#include <QTextDocument> QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index fec7d02ed..bac9b4df0 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -14,6 +14,7 @@ #include "qthelper.h" #include "gettextfromc.h" #include "display.h" +#include "color.h" #include <QCoreApplication> #include <QDebug> @@ -1191,7 +1192,7 @@ QVariant DiveItem::data(int column, int role) const retVal = dive->maxcns; break; case LOCATION: - retVal = QString(dive->location); + retVal = QString(get_dive_location(dive)); break; } break; @@ -1232,7 +1233,7 @@ QVariant DiveItem::data(int column, int role) const retVal = dive->maxcns; break; case LOCATION: - retVal = QString(dive->location); + retVal = QString(get_dive_location(dive)); break; case GAS: const char *gas_string = get_dive_gas_string(dive); @@ -2110,7 +2111,7 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const } if (row == 1) { if (col == 0) - return QString(dive->location); + return QString(get_dive_location(dive)); if (col == 3) return QString(tr("Duration: %1 min")).arg(di.displayDuration()); } diff --git a/qt-ui/plannerDetails.ui b/qt-ui/plannerDetails.ui new file mode 100644 index 000000000..349ec536a --- /dev/null +++ b/qt-ui/plannerDetails.ui @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>plannerDetails</class> + <widget class="QWidget" name="plannerDetails"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="divePlanOutputLabel"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string><html><head/><body><p><span style=" font-weight:600;">Dive plan details</span></p></body></html></string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="printPlan"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Print</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + <property name="default"> + <bool>false</bool> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTextEdit" name="divePlanOutput"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="styleSheet"> + <string notr="true">font: 13pt "Courier";</string> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Courier'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Curier New';"><br /></p></body></html></string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index af03fd1fb..440fb534a 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -475,7 +475,7 @@ <item> <widget class="QGroupBox" name="groupBox_6"> <property name="title"> - <string>Dive notes</string> + <string>Notes</string> </property> <layout class="QGridLayout" name="gridLayout_6"> <property name="leftMargin"> diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index ab241f358..e4f97002e 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -1,5 +1,7 @@ #include "preferences.h" #include "mainwindow.h" +#include "models.h" + #include <QSettings> #include <QFileDialog> #include <QMessageBox> diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index 6b88f0d29..4be5fef73 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -3,11 +3,14 @@ #include <QPicture> #include <QMessageBox> #include <QPointer> +#include <QTableView> #include "mainwindow.h" #include "printdialog.h" #include "printlayout.h" #include "modeldelegates.h" +#include "models.h" +#include "profile/profilewidget2.h" PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct print_options *optionsPtr) { @@ -459,7 +462,7 @@ void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct d model->setData(model->index(row, 3), di.displayDuration(), Qt::DisplayRole); model->setData(model->index(row, 4), dive->divemaster, Qt::DisplayRole); model->setData(model->index(row, 5), dive->buddy, Qt::DisplayRole); - model->setData(model->index(row, 6), dive->location, Qt::DisplayRole); + model->setData(model->index(row, 6), get_dive_location(dive), Qt::DisplayRole); } void PrintLayout::addTablePrintHeadingRow(TablePrintModel *model, int row) const diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 467a8b978..41d94a9a0 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -5,6 +5,8 @@ #include "diveplotdatamodel.h" #include "animationfunctions.h" #include "mainwindow.h" +#include "divelineitem.h" +#include "profilewidget2.h" static QPen gridPen() { diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 3bc79832e..4ad0ba3ca 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -9,6 +9,9 @@ #include "helpers.h" #include "libdivecomputer/parser.h" #include "mainwindow.h" +#include "maintab.h" +#include "profile/profilewidget2.h" +#include "diveplanner.h" #include <QSettings> @@ -682,8 +685,8 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo bool offsets_initialised = false; int o2cyl = -1, dilcyl = -1; - QFlags<Qt::AlignmentFlag> alignVar, align_dil = Qt::AlignBottom, align_o2 = Qt::AlignBottom; - double axisRange = (vAxis->maximum() - vAxis->minimum())/1000; + QFlags<Qt::AlignmentFlag> alignVar= Qt::AlignTop, align_dil = Qt::AlignBottom, align_o2 = Qt::AlignTop; + double axisRange = (vAxis->maximum() - vAxis->minimum())/1000; // Convert axis pressure range to bar double axisLog = log10(log10(axisRange)); for (int i = 0, count = dataModel->rowCount(); i < count; i++) { entry = dataModel->data().entry + i; @@ -691,23 +694,17 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo if (displayed_dive.dc.divemode == CCR && displayed_dive.oxygen_cylinder_index >= 0) o2mbar = GET_O2CYLINDER_PRESSURE(entry); - if (o2mbar) { + if (o2mbar) { // If there is an o2mbar value then this is a CCR dive. Then do: // The first time an o2 value is detected, see if the oxygen cyl pressure graph starts above or below the dil graph if (!offsets_initialised) { // Initialise the parameters for placing the text correctly near the graph line: o2cyl = displayed_dive.oxygen_cylinder_index; dilcyl = displayed_dive.diluent_cylinder_index; if ((o2mbar > mbar)) { // If above, write o2 start cyl pressure above graph and diluent pressure below graph: - print_y_offset[o2cyl][0] = -7 * axisLog; // y offset for oxygen gas lable (above) - print_y_offset[o2cyl][1] = -0.5; // y offset for oxygen start pressure value (above) + print_y_offset[o2cyl][0] = -7 * axisLog; // y offset for oxygen gas lable (above); pressure offsets=-0.5, already initialised print_y_offset[dilcyl][0] = 5 * axisLog; // y offset for diluent gas lable (below) - print_y_offset[dilcyl][1] = 0; // y offset for diluent start pressure value (below) - align_dil = Qt::AlignBottom; - align_o2 = Qt::AlignTop; - } else { // ... else write o2 start cyl pressure below graph: - print_y_offset[o2cyl][0] = 5 * axisLog; // o2 lable & pressure below graph, - print_y_offset[o2cyl][1] = 0; - print_y_offset[dilcyl][0] = -7 * axisLog; // and diluent lable above graph. - print_y_offset[dilcyl][1] = -0.5; // and diluent pressure above graph. + } else { // ... else write o2 start cyl pressure below graph: + print_y_offset[o2cyl][0] = 5 * axisLog; // o2 lable & pressure below graph; pressure offsets=-0.5, already initialised + print_y_offset[dilcyl][0] = -7.8 * axisLog; // and diluent lable above graph. align_dil = Qt::AlignTop; align_o2 = Qt::AlignBottom; } @@ -722,9 +719,6 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo last_pressure[displayed_dive.oxygen_cylinder_index] = o2mbar; last_time[displayed_dive.oxygen_cylinder_index] = entry->sec; alignVar = align_dil; - } else { - alignVar = Qt::AlignBottom; - align_dil = Qt::AlignTop; } if (!mbar) @@ -733,29 +727,19 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo if (cyl != entry->cylinderindex) { // Pressure value near the left hand edge of the profile - other cylinders: cyl = entry->cylinderindex; // For each other cylinder, write the gas lable and pressure if (!seen_cyl[cyl]) { - plotPressureValue(mbar, entry->sec, alignVar, print_y_offset[cyl][0]); - plotGasValue(mbar, entry->sec, displayed_dive.cylinder[cyl].gasmix, align_dil, print_y_offset[cyl][1]); + plotPressureValue(mbar, entry->sec, alignVar, print_y_offset[cyl][1]); + plotGasValue(mbar, entry->sec, displayed_dive.cylinder[cyl].gasmix, align_dil, print_y_offset[cyl][0]); seen_cyl[cyl] = true; } } last_pressure[cyl] = mbar; last_time[cyl] = entry->sec; } - // Now, for the cylinder pressure written near the right edge of the profile: - if ((o2cyl >= 0) && (dilcyl >= 0)) { // At first, skip uninitialised values of o2cyl and dilcyl - if (last_pressure[o2cyl] > last_pressure[dilcyl]) { // If oxygen cyl pressure graph ends above diluent graph: - align_dil = Qt::AlignTop; // initialise to write diluent cyl end pressure underneath the graph - align_o2 = Qt::AlignBottom; - } else { - align_dil = Qt::AlignBottom; // else initialise to write diluent cyl end pressure above the graph - align_o2 = Qt::AlignTop; - } - } for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { // For each cylinder, on right hand side of profile, write cylinder pressure alignVar = ((o2cyl >= 0) && (cyl == displayed_dive.oxygen_cylinder_index)) ? align_o2 : align_dil; if (last_time[cyl]) { - plotPressureValue(last_pressure[cyl], last_time[cyl], (alignVar | Qt::AlignLeft), print_y_offset[cyl][0]); + plotPressureValue(last_pressure[cyl], last_time[cyl], (alignVar | Qt::AlignLeft), print_y_offset[cyl][1]); } } } @@ -808,12 +792,14 @@ DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false), gradientF gradientFactor->setY(0); gradientFactor->setBrush(getColor(PRESSURE_TEXT)); gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); - connect(MainWindow::instance()->information(), SIGNAL(dateTimeChanged()), this, SLOT(recalc())); settingsChanged(); } void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + if (MainWindow::instance()->information()) + connect(MainWindow::instance()->information(), SIGNAL(dateTimeChanged()), this, SLOT(recalc()), Qt::UniqueConnection); + // We don't have enougth data to calculate things, quit. if (!shouldCalculateStuff(topLeft, bottomRight)) return; diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp index 85e046638..4c0137177 100644 --- a/qt-ui/profile/divetextitem.cpp +++ b/qt-ui/profile/divetextitem.cpp @@ -1,5 +1,6 @@ #include "divetextitem.h" #include "mainwindow.h" +#include "profilewidget2.h" DiveTextItem::DiveTextItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent), internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter), diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index f04d16b3f..1de45ff9f 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -10,12 +10,18 @@ #include "ruleritem.h" #include "tankitem.h" #include "pref.h" +#include "divepicturewidget.h" +#include "models.h" +#include "maintab.h" +#include "diveplanner.h" + #include <libdivecomputer/parser.h> #include <QScrollBar> #include <QtCore/qmath.h> #include <QMessageBox> #include <QInputDialog> #include <QDebug> +#include <QWheelEvent> #ifndef QT_NO_DEBUG #include <QTableView> diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index c88a3353d..ddd8f4620 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -1,6 +1,8 @@ #include "ruleritem.h" #include "preferences.h" #include "mainwindow.h" +#include "profilewidget2.h" +#include "display.h" #include <qgraphicssceneevent.h> diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index f8f4c2493..f7944c90c 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -5,12 +5,17 @@ #include <QFileDialog> #include <QShortcut> #include <QCalendarWidget> +#include <QKeyEvent> +#include <QAction> #include "file.h" #include "mainwindow.h" #include "helpers.h" #include "libdivecomputer/parser.h" - +#include "divelistview.h" +#include "display.h" +#include "profile/profilewidget2.h" +#include "undocommands.h" class MinMaxAvgWidgetPrivate { public: @@ -169,7 +174,6 @@ void SetpointDialog::buttonClicked(QAbstractButton *button) add_event(dc, time, SAMPLE_EVENT_PO2, 0, (int)(1000.0 * ui.spinbox->value()), "SP change"); mark_divelist_changed(true); MainWindow::instance()->graphics()->replot(); - } SetpointDialog::SetpointDialog(QWidget *parent) : QDialog(parent) @@ -198,7 +202,16 @@ void ShiftTimesDialog::buttonClicked(QAbstractButton *button) amount *= -1; if (amount != 0) { // DANGER, DANGER - this could get our dive_table unsorted... - shift_times(amount); + int i; + struct dive *dive; + QList<int> affectedDives; + for_each_dive (i, dive) { + if (!dive->selected) + continue; + + affectedDives.append(dive->id); + } + MainWindow::instance()->undoStack->push(new UndoShiftTime(affectedDives, amount)); sort_table(&dive_table); mark_divelist_changed(true); MainWindow::instance()->dive_list()->rememberSelection(); @@ -454,8 +467,7 @@ DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *tar { ui.setupUi(this); what = _what; - UI_FROM_COMPONENT(location); - UI_FROM_COMPONENT(gps); + UI_FROM_COMPONENT(divesite); UI_FROM_COMPONENT(divemaster); UI_FROM_COMPONENT(buddy); UI_FROM_COMPONENT(rating); @@ -475,8 +487,7 @@ DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *tar void DiveComponentSelection::buttonClicked(QAbstractButton *button) { if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { - COMPONENT_FROM_UI(location); - COMPONENT_FROM_UI(gps); + COMPONENT_FROM_UI(divesite); COMPONENT_FROM_UI(divemaster); COMPONENT_FROM_UI(buddy); COMPONENT_FROM_UI(rating); @@ -644,3 +655,93 @@ void MultiFilter::closeFilter() MultiFilterSortModel::instance()->clearFilter(); hide(); } +#include <QDebug> +#include <QShowEvent> + +LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent) +{ + ui.setupUi(this); + ui.diveSiteMessage->setText("You are editing the Dive Site"); + ui.diveSiteMessage->setCloseButtonVisible(false); + + QAction *action = new QAction(tr("Apply changes"), this); + connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); + ui.diveSiteMessage->addAction(action); + + action = new QAction(tr("Discard changes"), this); + connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); + ui.diveSiteMessage->addAction(action); +} + +void LocationInformationWidget::setLocationId(uint32_t uuid) +{ + currentDs = get_dive_site_by_uuid(uuid); + + if (!currentDs) { + currentDs = get_dive_site_by_uuid(create_dive_site("")); + displayed_dive.dive_site_uuid = currentDs->uuid; + ui.diveSiteName->clear(); + ui.diveSiteDescription->clear(); + ui.diveSiteNotes->clear(); + ui.diveSiteCoordinates->clear(); + } + displayed_dive_site = *currentDs; + ui.diveSiteName->setText(displayed_dive_site.name); + ui.diveSiteDescription->setText(displayed_dive_site.description); + ui.diveSiteNotes->setPlainText(displayed_dive_site.notes); + ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg)); +} + +void LocationInformationWidget::updateGpsCoordinates() +{ + ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg)); + MainWindow::instance()->setApplicationState("EditDiveSite"); +} + +void LocationInformationWidget::acceptChanges() +{ + char *uiString; + currentDs->latitude = displayed_dive_site.latitude; + currentDs->longitude = displayed_dive_site.longitude; + uiString = ui.diveSiteName->text().toUtf8().data(); + if (!same_string(uiString, currentDs->name)) { + free(currentDs->name); + currentDs->name = copy_string(uiString); + } + uiString = ui.diveSiteDescription->text().toUtf8().data(); + if (!same_string(uiString, currentDs->description)) { + free(currentDs->description); + currentDs->description = copy_string(uiString); + } + uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data(); + if (!same_string(uiString, currentDs->notes)) { + free(currentDs->notes); + currentDs->notes = copy_string(uiString); + } + if (dive_site_is_empty(currentDs)) { + delete_dive_site(currentDs->uuid); + displayed_dive.dive_site_uuid = 0; + setLocationId(0); + } else { + setLocationId(currentDs->uuid); + } + mark_divelist_changed(true); + emit informationManagementEnded(); +} + +void LocationInformationWidget::rejectChanges() +{ + Q_ASSERT(currentDs != NULL); + if (dive_site_is_empty(currentDs)) { + delete_dive_site(currentDs->uuid); + displayed_dive.dive_site_uuid = 0; + setLocationId(0); + } else { + setLocationId(currentDs->uuid); + } + emit informationManagementEnded(); +} + +void LocationInformationWidget::showEvent(QShowEvent *ev) { + ui.diveSiteMessage->setCloseButtonVisible(false); +} diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 8d5b4f73c..d0cb60508 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -6,6 +6,7 @@ class QAbstractButton; class QNetworkReply; #include <QWidget> +#include <QGroupBox> #include <QDialog> #include <stdint.h> @@ -214,6 +215,30 @@ private: Ui::FilterWidget ui; }; +#include "ui_locationInformation.h" + +class LocationInformationWidget : public QGroupBox { +Q_OBJECT +public: + LocationInformationWidget(QWidget *parent = 0); + +public slots: + void acceptChanges(); + void rejectChanges(); + + void showEvent(QShowEvent *); + + void setLocationId(uint32_t uuid); + void updateGpsCoordinates(void); + +signals: + void informationManagementEnded(); + +private: + struct dive_site *currentDs; + Ui::LocationInformation ui; +}; + bool isGnome3Session(); QImage grayImage(const QImage &coloredImg); diff --git a/qt-ui/socialnetworks.cpp b/qt-ui/socialnetworks.cpp index 21ccf9354..6a81d5db7 100644 --- a/qt-ui/socialnetworks.cpp +++ b/qt-ui/socialnetworks.cpp @@ -302,7 +302,7 @@ void SocialNetworkDialog::selectionChanged() tr("min", "abbreviation for minutes"))); } if (ui->Location->isChecked()) { - fullText += tr("Dive location: %1 \n").arg(d->location); + fullText += tr("Dive location: %1 \n").arg(get_dive_location(d)); } if (ui->Buddy->isChecked()) { fullText += tr("Buddy: %1 \n").arg(d->buddy); diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index fe7605ad7..0348d6b8f 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -2,6 +2,10 @@ #include "webservice.h" #include "mainwindow.h" #include "usersurvey.h" +#include "divelist.h" +#include "globe.h" +#include "maintab.h" +#include "display.h" #include <errno.h> #include <QDir> @@ -26,7 +30,25 @@ #endif struct dive_table gps_location_table; -static bool merge_locations_into_dives(void); + +// we don't overwrite any existing GPS info in the dive +// so get the dive site and if there is none or there is one without GPS fix, add it +static void copy_gps_location(struct dive *from, struct dive *to) +{ + struct dive_site *ds = get_dive_site_for_dive(to); + if (!ds || !dive_site_has_gps_location(ds)) { + struct dive_site *gds = get_dive_site_for_dive(from); + if (!ds) { + // simply link to the one created for the fake dive + to->dive_site_uuid = gds->uuid; + } else { + ds->latitude = gds->latitude; + ds->longitude = gds->longitude; + if (same_string(ds->name, "")) + ds->name = copy_string(gds->name); + } + } +} #define SAME_GROUP 6 * 3600 // six hours //TODO: C Code. static functions are not good if we plan to have a test for them. @@ -39,14 +61,14 @@ static bool merge_locations_into_dives(void) for_each_dive (i, dive) { if (!dive_has_gps_location(dive)) { - for (j = tracer; (gpsfix = get_gps_location(j, &gps_location_table)) !=NULL; j++) { + for (j = tracer; (gpsfix = get_dive_from_table(j, &gps_location_table)) !=NULL; j++) { if (dive_within_time_range (dive, gpsfix->when, SAME_GROUP)) { /* * If position is fixed during dive. This is the good one. * Asign and mark position, and end gps_location loop */ if ((dive->when <= gpsfix->when && gpsfix->when <= dive->when + dive->duration.seconds)) { - copy_gps_location(gpsfix,dive); + copy_gps_location(gpsfix, dive); changed++; tracer = j; break; @@ -54,7 +76,7 @@ static bool merge_locations_into_dives(void) /* * If it is not, check if there are more position fixes in SAME_GROUP range */ - if ((nextgpsfix = get_gps_location(j+1,&gps_location_table)) && + if ((nextgpsfix = get_dive_from_table(j+1,&gps_location_table)) && dive_within_time_range (dive, nextgpsfix->when, SAME_GROUP)) { /* * If distance from gpsfix to end of dive is shorter than distance between @@ -62,7 +84,7 @@ static bool merge_locations_into_dives(void) * If not, simply fail and nextgpsfix will be evaluated in next iteration. */ if ((dive->when + dive->duration.seconds - gpsfix->when) < (nextgpsfix->when - gpsfix->when)) { - copy_gps_location(gpsfix,dive); + copy_gps_location(gpsfix, dive); tracer = j; break; } @@ -70,7 +92,7 @@ static bool merge_locations_into_dives(void) * If no more positions in range, the actual is the one. Asign, mark and end loop. */ } else { - copy_gps_location(gpsfix,dive); + copy_gps_location(gpsfix, dive); changed++; tracer = j; break; @@ -326,10 +348,19 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); switch (ui.buttonBox->buttonRole(button)) { case QDialogButtonBox::ApplyRole: { + int i; + struct dive *d; + struct dive_site *ds; clear_table(&gps_location_table); QByteArray url = tr("Webservice").toLocal8Bit(); parse_xml_buffer(url.data(), downloadedData.data(), downloadedData.length(), &gps_location_table, NULL); - + // make sure we mark all the dive sites that were created + for (i = 0; i < gps_location_table.nr; i++) { + d = get_dive_from_table(i, &gps_location_table); + ds = get_dive_site_by_uuid(d->dive_site_uuid); + if (ds) + ds->notes = strdup("SubsurfaceWebservice"); + } /* now merge the data in the gps_location table into the dive_table */ if (merge_locations_into_dives()) { mark_divelist_changed(true); @@ -358,6 +389,16 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) hide(); close(); resetState(); + /* and now clean up and remove all the extra dive sites that were created */ + QSet<uint32_t> usedUuids; + for_each_dive(i, d) { + if (d->dive_site_uuid) + usedUuids.insert(d->dive_site_uuid); + } + for_each_dive_site(i, ds) { + if (!usedUuids.contains(ds->uuid) && same_string(ds->notes, "SubsurfaceWebservice")) + delete_dive_site(ds->uuid); + } } break; case QDialogButtonBox::RejectRole: if (reply != NULL && reply->isOpen()) { diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp index 8365a2ea7..3b61b492a 100644 --- a/qt-ui/tagwidget.cpp +++ b/qt-ui/tagwidget.cpp @@ -1,5 +1,6 @@ #include "tagwidget.h" #include "mainwindow.h" +#include "maintab.h" #include <QCompleter> TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL), lastFinishedTag(false) diff --git a/qt-ui/undocommands.cpp b/qt-ui/undocommands.cpp new file mode 100644 index 000000000..316def495 --- /dev/null +++ b/qt-ui/undocommands.cpp @@ -0,0 +1,64 @@ +#include "undocommands.h" +#include "mainwindow.h" +#include "divelist.h" + +UndoDeleteDive::UndoDeleteDive(QList<dive *> diveList) +{ + dives = diveList; + setText("delete dive"); + if (dives.count() > 1) + setText(QString("delete %1 dives").arg(QString::number(dives.count()))); +} + +void UndoDeleteDive::undo() +{ + for (int i = 0; i < dives.count(); i++) + record_dive(dives.at(i)); + mark_divelist_changed(true); + MainWindow::instance()->refreshDisplay(); +} + +void UndoDeleteDive::redo() +{ + QList<struct dive*> newList; + for (int i = 0; i < dives.count(); i++) { + //make a copy of the dive before deleting it + struct dive* d = alloc_dive(); + copy_dive(dives.at(i), d); + newList.append(d); + //delete the dive + delete_single_dive(get_divenr(dives.at(i))); + } + mark_divelist_changed(true); + MainWindow::instance()->refreshDisplay(); + dives.clear(); + dives = newList; +} + + +UndoShiftTime::UndoShiftTime(QList<int> diveList, int amount) +{ + setText("shift time"); + dives = diveList; + timeChanged = amount; +} + +void UndoShiftTime::undo() +{ + for (int i = 0; i < dives.count(); i++) { + struct dive* d = get_dive_by_uniq_id(dives.at(i)); + d->when -= timeChanged; + } + mark_divelist_changed(true); + MainWindow::instance()->refreshDisplay(); +} + +void UndoShiftTime::redo() +{ + for (int i = 0; i < dives.count(); i++) { + struct dive* d = get_dive_by_uniq_id(dives.at(i)); + d->when += timeChanged; + } + mark_divelist_changed(true); + MainWindow::instance()->refreshDisplay(); +} diff --git a/qt-ui/undocommands.h b/qt-ui/undocommands.h new file mode 100644 index 000000000..addef8138 --- /dev/null +++ b/qt-ui/undocommands.h @@ -0,0 +1,28 @@ +#ifndef UNDOCOMMANDS_H +#define UNDOCOMMANDS_H + +#include <QUndoCommand> +#include "dive.h" + +class UndoDeleteDive : public QUndoCommand { +public: + UndoDeleteDive(QList<struct dive*> diveList); + virtual void undo(); + virtual void redo(); + +private: + QList<struct dive*> dives; +}; + +class UndoShiftTime : public QUndoCommand { +public: + UndoShiftTime(QList<int> diveList, int amount); + virtual void undo(); + virtual void redo(); + +private: + QList<int> dives; + int timeChanged; +}; + +#endif // UNDOCOMMANDS_H diff --git a/qt-ui/updatemanager.cpp b/qt-ui/updatemanager.cpp index 3fff8b45d..fbaa6ba3c 100644 --- a/qt-ui/updatemanager.cpp +++ b/qt-ui/updatemanager.cpp @@ -4,7 +4,7 @@ #include <QMessageBox> #include <QUuid> #include "subsurfacewebservices.h" -#include "ssrf-version.h" +#include "version.h" #include "mainwindow.h" UpdateManager::UpdateManager(QObject *parent) : QObject(parent) @@ -16,9 +16,9 @@ UpdateManager::UpdateManager(QObject *parent) : QObject(parent) return; if (settings.contains("LastVersionUsed")) { // we have checked at least once before - if (settings.value("LastVersionUsed").toString() != GIT_VERSION_STRING) { + if (settings.value("LastVersionUsed").toString() != subsurface_git_version()) { // we have just updated - wait two weeks before you check again - settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING)); + settings.setValue("LastVersionUsed", QString(subsurface_git_version())); settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate)); } else { // is it time to check again? @@ -28,7 +28,7 @@ UpdateManager::UpdateManager(QObject *parent) : QObject(parent) return; } } - settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING)); + settings.setValue("LastVersionUsed", QString(subsurface_git_version())); settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate)); checkForUpdates(true); } @@ -47,7 +47,7 @@ void UpdateManager::checkForUpdates(bool automatic) os = "unknown"; #endif isAutomaticCheck = automatic; - QString version = CANONICAL_VERSION_STRING; + QString version = subsurface_canonical_version(); QString uuidString = getUUID(); QString url = QString("http://subsurface-divelog.org/updatecheck.html?os=%1&version=%2&uuid=%3").arg(os, version, uuidString); QNetworkRequest request; diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp index 4061d46df..a2b47e4d0 100644 --- a/qt-ui/usersurvey.cpp +++ b/qt-ui/usersurvey.cpp @@ -4,7 +4,7 @@ #include "usersurvey.h" #include "ui_usersurvey.h" -#include "ssrf-version.h" +#include "version.h" #include "subsurfacewebservices.h" #include "updatemanager.h" @@ -22,12 +22,12 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quitKey, SIGNAL(activated()), parent, SLOT(close())); - os = QString("ssrfVers=%1").arg(VERSION_STRING); + os = QString("ssrfVers=%1").arg(subsurface_version()); os.append(QString("&prettyOsName=%1").arg(SubsurfaceSysInfo::prettyOsName())); - QString arch = SubsurfaceSysInfo::cpuArchitecture(); + QString arch = SubsurfaceSysInfo::buildCpuArchitecture(); os.append(QString("&appCpuArch=%1").arg(arch)); if (arch == "i386") { - QString osArch = SubsurfaceSysInfo::osArch(); + QString osArch = SubsurfaceSysInfo::currentCpuArchitecture(); os.append(QString("&osCpuArch=%1").arg(osArch)); } os.append(QString("&uiLang=%1").arg(uiLanguage(NULL))); @@ -39,12 +39,12 @@ QString UserSurvey::getVersion() { QString arch; // fill in the system data - QString sysInfo = QString("Subsurface %1").arg(VERSION_STRING); + QString sysInfo = QString("Subsurface %1").arg(subsurface_version()); sysInfo.append(tr("\nOperating system: %1").arg(SubsurfaceSysInfo::prettyOsName())); - arch = SubsurfaceSysInfo::cpuArchitecture(); + arch = SubsurfaceSysInfo::buildCpuArchitecture(); sysInfo.append(tr("\nCPU architecture: %1").arg(arch)); if (arch == "i386") - sysInfo.append(tr("\nOS CPU architecture: %1").arg(SubsurfaceSysInfo::osArch())); + sysInfo.append(tr("\nOS CPU architecture: %1").arg(SubsurfaceSysInfo::currentCpuArchitecture())); sysInfo.append(tr("\nLanguage: %1").arg(uiLanguage(NULL))); return sysInfo; } @@ -54,12 +54,12 @@ QString UserSurvey::getUserAgent() QString arch; // fill in the system data - use ':' as separator // replace all other ':' with ' ' so that this is easy to parse - QString userAgent = QString("Subsurface:%1:").arg(VERSION_STRING); + QString userAgent = QString("Subsurface:%1:").arg(subsurface_version()); userAgent.append(SubsurfaceSysInfo::prettyOsName().replace(':', ' ') + ":"); - arch = SubsurfaceSysInfo::cpuArchitecture().replace(':', ' '); + arch = SubsurfaceSysInfo::buildCpuArchitecture().replace(':', ' '); userAgent.append(arch); if (arch == "i386") - userAgent.append("/" + SubsurfaceSysInfo::osArch()); + userAgent.append("/" + SubsurfaceSysInfo::currentCpuArchitecture()); userAgent.append(":" + uiLanguage(NULL)); return userAgent; |