diff options
Diffstat (limited to 'qt-ui/profile/profilewidget2.cpp')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index f04d16b3f..a426ceef2 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> @@ -644,7 +650,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) // so if we are calculation TTS / NDL then let's force that off. if (measureDuration.elapsed() > 1000 && prefs.calcndltts) { MainWindow::instance()->turnOffNdlTts(); - MainWindow::instance()->showError(tr("Show NDL / TTS was disabled because of excessive processing time")); + MainWindow::instance()->getNotificationWidget()->showNotification(tr("Show NDL / TTS was disabled because of excessive processing time"), KMessageWidget::Error); } } @@ -727,6 +733,8 @@ void ProfileWidget2::resizeEvent(QResizeEvent *event) void ProfileWidget2::mousePressEvent(QMouseEvent *event) { + if (zoomLevel) + return; QGraphicsView::mousePressEvent(event); if (currentState == PLAN) shouldCalculateMaxTime = false; @@ -734,18 +742,24 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event) void ProfileWidget2::divePlannerHandlerClicked() { + if (zoomLevel) + return; shouldCalculateMaxDepth = false; replot(); } void ProfileWidget2::divePlannerHandlerReleased() { + if (zoomLevel) + return; shouldCalculateMaxDepth = true; replot(); } void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) { + if (zoomLevel) + return; QGraphicsView::mouseReleaseEvent(event); if (currentState == PLAN) { shouldCalculateMaxTime = true; @@ -1039,6 +1053,7 @@ void ProfileWidget2::clearHandlers() if (handles.count()) { foreach (DiveHandler *handle, handles) { scene()->removeItem(handle); + delete handle; } handles.clear(); } @@ -1054,6 +1069,7 @@ void ProfileWidget2::setAddState() if (currentState == ADD) return; + clearHandlers(); setProfileState(); mouseFollowerHorizontal->setVisible(true); mouseFollowerVertical->setVisible(true); @@ -1206,6 +1222,10 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) setpointAction->setData(event->globalPos()); QAction *action = m.addAction(tr("Add bookmark"), this, SLOT(addBookmark())); action->setData(event->globalPos()); + + if (same_string(current_dc->model, "manually added dive")) + QAction *editProfileAction = m.addAction(tr("Edit the profile"), MainWindow::instance(), SLOT(editCurrentDive())); + if (DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem)) { action = new QAction(&m); action->setText(tr("Remove event")); @@ -1375,8 +1395,21 @@ void ProfileWidget2::changeGas() // backup the things on the dataModel, since we will clear that out. struct gasmix gasmix; - int seconds = timeAxis->valueAt(scenePos); + qreal sec_val = timeAxis->valueAt(scenePos); + + // no gas changes before the dive starts + unsigned int seconds = (sec_val < 0.0) ? 0 : (unsigned int)sec_val; + // if there is a gas change at this time stamp, remove it before adding the new one + struct event *gasChangeEvent = current_dc->events; + while ((gasChangeEvent = get_next_event(gasChangeEvent, "gaschange")) != NULL) { + if (gasChangeEvent->time.seconds == seconds) { + remove_event(gasChangeEvent); + gasChangeEvent = current_dc->events; + } else { + gasChangeEvent = gasChangeEvent->next; + } + } validate_gas(gas.toUtf8().constData(), &gasmix); QRegExp rx("\\(\\D*(\\d+)"); int tank; @@ -1504,6 +1537,7 @@ void ProfileWidget2::repositionDiveHandlers() { DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); // Re-position the user generated dive handlers + struct gasmix mix, lastmix; for (int i = 0; i < plannerModel->rowCount(); i++) { struct divedatapoint datapoint = plannerModel->at(i); if (datapoint.time == 0) // those are the magic entries for tanks @@ -1528,8 +1562,9 @@ void ProfileWidget2::repositionDiveHandlers() QLineF line(p1, p2); QPointF pos = line.pointAt(0.5); gases[i]->setPos(pos); - gases[i]->setVisible(datapoint.entered); - gases[i]->setText(dpGasToStr(plannerModel->at(i))); + gases[i]->setText(dpGasToStr(datapoint)); + gases[i]->setVisible(datapoint.entered && + (i == 0 || gases[i]->text() != gases[i-1]->text())); } } |