So, I was looking at the profile today to port stuff the planner to the new profile, but I couldn't, I was just fixing stuff that I looked at there ( while I was thinking how to port the planner to the new profile ), so no work was lost. :)
The 0002 and 0011 patches disables / reenables the planner ( as I tougth at the beginning that I was just going to port it and not fix anything... silly me. ) I think tomorrow I'll start really porting the planner as those other patches kept me busy. Dirk, please take a good look at the patches, as I don't program for subsurface for quite a while, see if I didn't messed anything. ;)
From 984ec4a9b11883e994f1623a93cb084c8be4507c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 12 May 2014 20:51:39 -0300 Subject: [PATCH 01/11] Removed silly macro to pretend that we were doing things the right way. That macro was useless, I sould have been drunk when I wrote it, and I don't drink. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/diveplanner.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index b45b4e0..aabd331 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1624,17 +1624,10 @@ ExpanderGraphics::ExpanderGraphics(QGraphicsItem *parent) : QGraphicsRectItem(pa leftWing(new QGraphicsPixmapItem(this)), rightWing(new QGraphicsPixmapItem(this)) { - QPixmap p; -#define CREATE(item, pixmap) \ - p = QPixmap(QString(pixmap)); \ - item->setPixmap(p); - - CREATE(icon, ":icon_time"); - CREATE(bg, ":round_base"); - CREATE(leftWing, ":left_wing"); - CREATE(rightWing, ":right_wing"); -#undef CREATE - + icon->setPixmap(QPixmap(":icon_time")); + bg->setPixmap(QPixmap(":round_base")); + leftWing->setPixmap(QPixmap(":left_wing")); + rightWing->setPixmap(QPixmap(":right_wing")); decreaseBtn->setPixmap(QPixmap(":arrow_down")); increaseBtn->setPixmap(QPixmap(":arrow_up")); -- 1.9.2
From 1dcdef471f2e373977f2f924696e6ede2a509129 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 12 May 2014 21:20:50 -0300 Subject: [PATCH 02/11] Started to port the Planner to the new profile code. This is a start of the code to port the planner to the new profile. Nothing works yet and the planner is severely damaged by this. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.cpp | 3 +-- qt-ui/profile/profilewidget2.cpp | 12 ++++++++++++ qt-ui/profile/profilewidget2.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 709693c..ccd6b5b 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -420,7 +420,6 @@ void MainWindow::on_actionAddDive_triggered() struct dive *dive = alloc_dive(); dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset(); dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file - dive->latitude.udeg = 0; dive->longitude.udeg = 0; record_dive(dive); @@ -430,8 +429,8 @@ void MainWindow::on_actionAddDive_triggered() ui.InfoWidget->setCurrentIndex(0); ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->addDiveStarted(); - ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. ui.infoPane->setCurrentIndex(MAINTAB); + ui.newProfile->setAddState(); DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->createSimpleDive(); ui.ListWidget->reload(DiveTripModel::CURRENT); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index d2d01a3..0a14ec7 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -682,6 +682,18 @@ void ProfileWidget2::setProfileState() rulerItem->sourceNode()->setVisible(rulerVisible); } + +void ProfileWidget2::setAddState() +{ + // This takes care of positioning everything related to the profile graph. + setProfileState(); + // Then we add down here what is missing to the *add* part. + if (currentState == ADD) + return; + + currentState = ADD; +} + extern struct ev_select *ev_namelist; extern int evn_allocated; extern int evn_used; diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index d00cb26..c79e97c 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -74,6 +74,7 @@ slots: // Necessary to call from QAction's signals. void settingsChanged(); void setEmptyState(); void setProfileState(); + void setAddState(); void changeGas(); void addBookmark(); void hideEvents(); -- 1.9.2
From 5c8e5dad6463b9f9de62aebe2e22fddef7ec30bf Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 12 May 2014 21:26:12 -0300 Subject: [PATCH 03/11] Only set the state to profile if it's empty, not if iits Add or Plan. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 0a14ec7..3c9a54e 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -368,7 +368,8 @@ void ProfileWidget2::plotDives(QList<dive *> dives) if (d->id == dataModel->id() && dc_number == dataModel->dcShown()) return; - setProfileState(); + if(currentState == EMPTY) + setProfileState(); // next get the dive computer structure - if there are no samples // let's create a fake profile that's somewhat reasonable for the -- 1.9.2
From 5fe0af8fc208712b78eeaaf56da300a371d0de52 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 12 May 2014 22:37:24 -0300 Subject: [PATCH 04/11] Changed the event-handlers to point-methods. This way we can override the event handlers by passing a pointer to a new method and things should work. The Profile2 class is fairly monolithyc ( I don't like that ) and doesn't works in a plugin-like way, and I would need probably to change a lot of stuff for that, so I'll just keep like what it is today. I needed a way to change the behavior of the mouse press / move when on different types of views, this way seemed the best cost / benefit: we can add more different states of the profile ( view dive, view multiple dives, plan, add dive, edit ) creating the events that should override the original ones, and set them. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 65 ++++++++++++++++++++++++++++++---------- qt-ui/profile/profilewidget2.h | 12 ++++++++ 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 3c9a54e..f795610 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -336,6 +336,18 @@ void ProfileWidget2::plotDives(QList<dive *> dives) if (!d) return; + // No need to do this again if we are already showing the same dive + // computer of the same dive, so we check the unique id of the dive + // and the selected dive computer number against the ones we are + // showing (can't compare the dive pointers as those might change). + // I'm unclear what the semantics are supposed to be if we actually + // use more than one 'dives' as argument - so ignoring that right now :-) + if (d->id == dataModel->id() && dc_number == dataModel->dcShown()) + return; + + if(currentState == EMPTY) + setProfileState(); + int animSpeedBackup = -1; if (firstCall && MainWindow::instance()->filesFromCommandLine()) { animSpeedBackup = prefs.animation; @@ -359,17 +371,6 @@ void ProfileWidget2::plotDives(QList<dive *> dives) rulerItem->sourceNode()->setVisible(rulerVisible); rulerItem->destNode()->setVisible(rulerVisible); - // No need to do this again if we are already showing the same dive - // computer of the same dive, so we check the unique id of the dive - // and the selected dive computer number against the ones we are - // showing (can't compare the dive pointers as those might change). - // I'm unclear what the semantics are supposed to be if we actually - // use more than one 'dives' as argument - so ignoring that right now :-) - if (d->id == dataModel->id() && dc_number == dataModel->dcShown()) - return; - - if(currentState == EMPTY) - setProfileState(); // next get the dive computer structure - if there are no samples // let's create a fake profile that's somewhat reasonable for the @@ -506,8 +507,31 @@ void ProfileWidget2::settingsChanged() if (needReplot) replot(); } +void ProfileWidget2::contextMenuEvent(QContextMenuEvent* event) +{ + if (currContextMenuEvent) + (this->*currContextMenuEvent)(event); +} + +void ProfileWidget2::mouseMoveEvent(QMouseEvent* event) +{ + if(currMouseMoveEvent) + (this->*currMouseMoveEvent)(event); +} -void ProfileWidget2::resizeEvent(QResizeEvent *event) +void ProfileWidget2::resizeEvent(QResizeEvent* event) +{ + if(currResizeEvent) + (this->*currResizeEvent)(event); +} + +void ProfileWidget2::wheelEvent(QWheelEvent* event) +{ + if(currWheelEvent) + (this->*currWheelEvent)(event); +} + +void ProfileWidget2::profile_resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); fitInView(sceneRect(), Qt::IgnoreAspectRatio); @@ -527,7 +551,7 @@ void ProfileWidget2::fixBackgroundPos() background->setY(mapToScene(y, 20).y()); } -void ProfileWidget2::wheelEvent(QWheelEvent *event) +void ProfileWidget2::profile_wheelEvent(QWheelEvent *event) { if (currentState == EMPTY) return; @@ -558,7 +582,7 @@ void ProfileWidget2::scrollViewTo(const QPoint &pos) hs->setValue(xRat * hs->maximum()); } -void ProfileWidget2::mouseMoveEvent(QMouseEvent *event) +void ProfileWidget2::profile_mouseMoveEvent(QMouseEvent *event) { toolTipItem->refresh(mapToScene(event->pos())); QPoint toolTipPos = mapFromScene(toolTipItem->pos()); @@ -586,6 +610,11 @@ void ProfileWidget2::setEmptyState() if (currentState == EMPTY) return; + currContextMenuEvent = &ProfileWidget2::profile_contextMenuEvent; + currMouseMoveEvent = &ProfileWidget2::profile_mouseMoveEvent; + currResizeEvent = &ProfileWidget2::profile_resizeEvent; + currWheelEvent = &ProfileWidget2::profile_wheelEvent; + dataModel->clear(); currentState = EMPTY; MainWindow::instance()->setToolButtonsEnabled(false); @@ -624,6 +653,11 @@ void ProfileWidget2::setProfileState() if (currentState == PROFILE) return; + currContextMenuEvent = &ProfileWidget2::profile_contextMenuEvent; + currMouseMoveEvent = &ProfileWidget2::profile_mouseMoveEvent; + currResizeEvent = &ProfileWidget2::profile_resizeEvent; + currWheelEvent = &ProfileWidget2::profile_wheelEvent; + currentState = PROFILE; MainWindow::instance()->setToolButtonsEnabled(true); toolTipItem->readPos(); @@ -692,6 +726,7 @@ void ProfileWidget2::setAddState() if (currentState == ADD) return; + setBackgroundBrush(QColor(Qt::darkCyan)); currentState = ADD; } @@ -699,7 +734,7 @@ extern struct ev_select *ev_namelist; extern int evn_allocated; extern int evn_used; -void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) +void ProfileWidget2::profile_contextMenuEvent(QContextMenuEvent *event) { if (selected_dive == -1) return; diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index c79e97c..577e84d 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -88,6 +88,11 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event); + void profile_resizeEvent(QResizeEvent *event); + void profile_wheelEvent(QWheelEvent *event); + void profile_mouseMoveEvent(QMouseEvent *event); + void profile_contextMenuEvent(QContextMenuEvent *event); + private: /*methods*/ void fixBackgroundPos(); void scrollViewTo(const QPoint &pos); @@ -105,6 +110,13 @@ private: QString backgroundFile; ToolTipItem *toolTipItem; bool isPlotZoomed; + + // Pointer to methods. uglyer than pointer to functions, but works beautifully. + void (ProfileWidget2::*currResizeEvent)(QResizeEvent *event); + void (ProfileWidget2::*currWheelEvent)(QWheelEvent *event); + void (ProfileWidget2::*currMouseMoveEvent)(QMouseEvent *event); + void (ProfileWidget2::*currContextMenuEvent)(QContextMenuEvent *event); + // All those here should probably be merged into one structure, // So it's esyer to replicate for more dives later. // In the meantime, keep it here. -- 1.9.2
From de53ce5549d941624ae65e85fd77b993ba7b41a3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 21:32:54 -0300 Subject: [PATCH 05/11] Created a 'remove event' function that removes an event And call that function on the UI code instead of creating the algorithm of that function there. :) Signed-off-by: Tomaz Canabrava <[email protected]> --- dive.c | 12 ++++++++++++ dive.h | 2 ++ qt-ui/profile/profilewidget2.cpp | 10 ++-------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/dive.c b/dive.c index 68f619b..5036965 100644 --- a/dive.c +++ b/dive.c @@ -7,6 +7,7 @@ #include "gettext.h" #include "dive.h" +extern unsigned int dc_number; struct tag_entry *g_tag_list = NULL; static const char *default_tags[] = { @@ -2236,3 +2237,14 @@ int average_depth(struct diveplan *dive) return integral / last_time; } + +void remove_event(struct event* event) +{ + struct event **ep = ¤t_dc->events; + while (ep && *ep != event) + ep = &(*ep)->next; + if (ep) { + *ep = event->next; + free(event); + } +} diff --git a/dive.h b/dive.h index b27eff2..4ba944e 100644 --- a/dive.h +++ b/dive.h @@ -485,6 +485,8 @@ extern int save_dives_logic(const char *filename, bool select_only); extern int save_dive(FILE *f, struct dive *dive); extern int export_dives_xslt(const char *filename, const bool selected, const char *export_xslt); +extern void remove_event(struct event* event); + struct git_oid; struct git_repository; #define dummy_git_repository ((git_repository *) 3ul) /* Random bogus pointer, not NULL */ diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index f795610..a189e16 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -585,10 +585,10 @@ void ProfileWidget2::scrollViewTo(const QPoint &pos) void ProfileWidget2::profile_mouseMoveEvent(QMouseEvent *event) { toolTipItem->refresh(mapToScene(event->pos())); - QPoint toolTipPos = mapFromScene(toolTipItem->pos()); if (zoomLevel == 0) { QGraphicsView::mouseMoveEvent(event); } else { + QPoint toolTipPos = mapFromScene(toolTipItem->pos()); scrollViewTo(event->pos()); toolTipItem->setPos(mapToScene(toolTipPos)); } @@ -826,13 +826,7 @@ void ProfileWidget2::removeEvent() tr("Remove the selected event?"), tr("%1 @ %2:%3").arg(event->name).arg(event->time.seconds / 60).arg(event->time.seconds % 60, 2, 10, QChar('0'))), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { - struct event **ep = ¤t_dc->events; - while (ep && *ep != event) - ep = &(*ep)->next; - if (ep) { - *ep = event->next; - free(event); - } + remove_event(event); mark_divelist_changed(true); replot(); } -- 1.9.2
From 0c821770d191239b3f6f7deb231af4b699378c06 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 21:45:39 -0300 Subject: [PATCH 06/11] Speed Improv: hide events, instead of replotting everythign. The 'Hide Similar Events' function asked the Profile to replot eveything, only because some events were hidden from the interface . Instead of that we can only hide the events since the graph will be the same. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index a189e16..e100ad6 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -797,14 +797,18 @@ void ProfileWidget2::hideEvents() QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { if (event->name) { for (int i = 0; i < evn_used; i++) { - if (!strcmp(event->name, ev_namelist[i].ev_name)) { + if (same_string(event->name, ev_namelist[i].ev_name)) { ev_namelist[i].plot_ev = false; break; } } + Q_FOREACH(DiveEventItem *evItem, eventItems){ + if(same_string(evItem->getEvent()->name, event->name)) + evItem->hide(); + } + }else{ + item->hide(); } - item->hide(); - replot(); } } -- 1.9.2
From e7eb251b686d469b5d917d9c7c1454b155d17bab Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 21:51:45 -0300 Subject: [PATCH 07/11] Speed Improv: Unhide all events by calling event->show() instead of replot. The old code replotted the whole dive, while what we really wanted was to show the events. so just ->show() them. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index e100ad6..902d2fc 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -817,7 +817,8 @@ void ProfileWidget2::unhideEvents() for (int i = 0; i < evn_used; i++) { ev_namelist[i].plot_ev = true; } - replot(); + Q_FOREACH(DiveEventItem *item, eventItems) + item->show(); } void ProfileWidget2::removeEvent() -- 1.9.2
From 465b8304c5fa8cb1cb51ac7032435d0399c14d9e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 22:06:11 -0300 Subject: [PATCH 08/11] Code Cleanup: use the internal method to hide / show ruler. The old way se called show() on the ruler and internal handlers, this shouldn't be necessary as they are internal to the ruler. I created a setVisible() method on the ruler that should take care of that. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 21 ++------------------- qt-ui/profile/ruleritem.cpp | 9 +++++++++ qt-ui/profile/ruleritem.h | 1 + 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 902d2fc..b65da50 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -364,13 +364,7 @@ void ProfileWidget2::plotDives(QList<dive *> dives) // reset some item visibility on printMode changes toolTipItem->setVisible(!printMode); - QSettings s; - s.beginGroup("TecDetails"); - const bool rulerVisible = s.value("rulergraph", false).toBool() && !printMode; - rulerItem->setVisible(rulerVisible); - rulerItem->sourceNode()->setVisible(rulerVisible); - rulerItem->destNode()->setVisible(rulerVisible); - + rulerItem->setVisible(prefs.rulergraph && !printMode); // next get the dive computer structure - if there are no samples // let's create a fake profile that's somewhat reasonable for the @@ -496,13 +490,9 @@ void ProfileWidget2::settingsChanged() if (currentState == PROFILE) { rulerItem->setVisible(prefs.rulergraph); - rulerItem->destNode()->setVisible(prefs.rulergraph); - rulerItem->sourceNode()->setVisible(prefs.rulergraph); needReplot = true; } else { rulerItem->setVisible(false); - rulerItem->destNode()->setVisible(false); - rulerItem->sourceNode()->setVisible(false); } if (needReplot) replot(); @@ -634,8 +624,6 @@ void ProfileWidget2::setEmptyState() diveCeiling->setVisible(false); reportedCeiling->setVisible(false); rulerItem->setVisible(false); - rulerItem->destNode()->setVisible(false); - rulerItem->sourceNode()->setVisible(false); pn2GasItem->setVisible(false); po2GasItem->setVisible(false); pheGasItem->setVisible(false); @@ -709,12 +697,7 @@ void ProfileWidget2::setProfileState() tissue->setVisible(true); } } - QSettings s; - s.beginGroup("TecDetails"); - bool rulerVisible = s.value("rulergraph", false).toBool(); - rulerItem->setVisible(rulerVisible); - rulerItem->destNode()->setVisible(rulerVisible); - rulerItem->sourceNode()->setVisible(rulerVisible); + rulerItem->setVisible(prefs.rulergraph); } diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 768d912..148d1f4 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -137,6 +137,15 @@ RulerNodeItem2 *RulerItem2::destNode() const return dest; } +void RulerItem2::setVisible(bool visible) +{ + QGraphicsLineItem::setVisible(visible); + if(source) + source->setVisible(visible); + if(dest) + dest->setVisible(visible); +} + void RulerItem2::setPlotInfo(plot_info info) { pInfo = info; diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h index 7bfc63e..ee6203a 100644 --- a/qt-ui/profile/ruleritem.h +++ b/qt-ui/profile/ruleritem.h @@ -39,6 +39,7 @@ public: void setPlotInfo(struct plot_info pInfo); RulerNodeItem2 *sourceNode() const; RulerNodeItem2 *destNode() const; + void setVisible(bool visible); void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth); private: -- 1.9.2
From aeab42cd30db966ce0d248d04e376ffd2535a9d2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 22:21:03 -0300 Subject: [PATCH 09/11] Speedup: Do not replot the profile if on profile mode on settings changed. The profile should be replotted completely only on last case, a change of visibility of a single item should plot only the are of that single item that was changed. We need to keep track of what items should trigger a whole repaint or not. for now, I don't think that the old result was correct ( if we hided the ruler, everything got repainted. ) Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index b65da50..4e826f2 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -474,6 +474,9 @@ void ProfileWidget2::settingsChanged() // if we are showing calculated ceilings then we have to replot() // because the GF could have changed; otherwise we try to avoid replot() bool needReplot = prefs.calcceiling; + // DIRK OR ANYONE ELSE THAT KNOWS BETTER THAN ME WHAT SHOULD RECALCULATE THE DIVE: + // SET THIS VARIABLE CORRECTLY PLEASE :D + if (PP_GRAPHS_ENABLED) { profileYAxis->animateChangeLine(itemPos.depth.shrinked); temperatureAxis->animateChangeLine(itemPos.temperature.shrinked); @@ -483,6 +486,13 @@ void ProfileWidget2::settingsChanged() temperatureAxis->animateChangeLine(itemPos.temperature.expanded); cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded); } + // TODO: + // bad, bad naming. 'zoom' here doesn't means that it's in zoom, + // but it means that the dive is a small one and the user wants it + // scaled to the whole screen. Maybe a change of name is needed? + // Anyhow, the code below is correct and we should replot everything. + // ----- or not, we just need to adjust the sizes of the rulers, so + // a function named 'get_max_time()' to fix that will work already. if (prefs.zoomed_plot != isPlotZoomed) { isPlotZoomed = prefs.zoomed_plot; needReplot = true; @@ -490,7 +500,6 @@ void ProfileWidget2::settingsChanged() if (currentState == PROFILE) { rulerItem->setVisible(prefs.rulergraph); - needReplot = true; } else { rulerItem->setVisible(false); } -- 1.9.2
From 7c172b26eedb806a153ba97f6ba5140c27d78175 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 22:27:26 -0300 Subject: [PATCH 10/11] Code Cleanup: use qMin instad of if( min ) setMin else setMax. silly code cleanup. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/diveprofileitem.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 1615be8..76eb32e 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -156,10 +156,8 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI if (!entry->in_deco) { /* not in deco implies this is a safety stop, no ceiling */ p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0))); - } else if (entry->stopdepth < entry->depth) { - p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->stopdepth))); - } else { - p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth))); + } else{ + p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(qMin(entry->stopdepth, entry->depth)))); } } setPolygon(p); @@ -562,11 +560,7 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QMo plot_data *entry = dataModel->data().entry; for (int i = 0, count = dataModel->rowCount(); i < count; i++, entry++) { if (entry->in_deco && entry->stopdepth) { - if (entry->stopdepth < entry->depth) { - p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->stopdepth))); - } else { - p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth))); - } + p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(qMin(entry->stopdepth, entry->depth)))); } else { p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0))); } -- 1.9.2
From a662b302353091d3d18d990cecb2807413dbc254 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 May 2014 22:36:46 -0300 Subject: [PATCH 11/11] Revert "Started to port the Planner to the new profile code." This reverts commit 1dcdef471f2e373977f2f924696e6ede2a509129. Conflicts: qt-ui/profile/profilewidget2.cpp --- qt-ui/mainwindow.cpp | 3 ++- qt-ui/profile/profilewidget2.cpp | 13 ------------- qt-ui/profile/profilewidget2.h | 1 - 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index ccd6b5b..709693c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -420,6 +420,7 @@ void MainWindow::on_actionAddDive_triggered() struct dive *dive = alloc_dive(); dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset(); dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file + dive->latitude.udeg = 0; dive->longitude.udeg = 0; record_dive(dive); @@ -429,8 +430,8 @@ void MainWindow::on_actionAddDive_triggered() ui.InfoWidget->setCurrentIndex(0); ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->addDiveStarted(); + ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. ui.infoPane->setCurrentIndex(MAINTAB); - ui.newProfile->setAddState(); DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->createSimpleDive(); ui.ListWidget->reload(DiveTripModel::CURRENT); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 4e826f2..173c8a6 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -709,19 +709,6 @@ void ProfileWidget2::setProfileState() rulerItem->setVisible(prefs.rulergraph); } - -void ProfileWidget2::setAddState() -{ - // This takes care of positioning everything related to the profile graph. - setProfileState(); - // Then we add down here what is missing to the *add* part. - if (currentState == ADD) - return; - - setBackgroundBrush(QColor(Qt::darkCyan)); - currentState = ADD; -} - extern struct ev_select *ev_namelist; extern int evn_allocated; extern int evn_used; diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 577e84d..38e125d 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -74,7 +74,6 @@ slots: // Necessary to call from QAction's signals. void settingsChanged(); void setEmptyState(); void setProfileState(); - void setAddState(); void changeGas(); void addBookmark(); void hideEvents(); -- 1.9.2
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
