From ae19f0a2c94c08586208c78cb3f63979f2bf96a0 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 21 May 2014 13:50:26 -0300 Subject: [PATCH 06/11] PreferencesChanged -> settingsChanged.
We used both preferencesChanged and settingsChanged in different methods and classes to mean the same thing, this adds consistency. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divecartesianaxis.cpp | 8 ++++---- qt-ui/profile/divecartesianaxis.h | 2 +- qt-ui/profile/diveprofileitem.cpp | 20 ++++++++++---------- qt-ui/profile/diveprofileitem.h | 14 +++++++------- qt-ui/profile/profilewidget2.cpp | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index c1e93fa..f5feea5 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -411,17 +411,17 @@ QString TemperatureAxis::textForValue(double value) PartialGasPressureAxis::PartialGasPressureAxis() { - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); } void PartialGasPressureAxis::setModel(DivePlotDataModel *m) { model = m; - connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(preferencesChanged())); - preferencesChanged(); + connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(settingsChanged())); + settingsChanged(); } -void PartialGasPressureAxis::preferencesChanged() +void PartialGasPressureAxis::settingsChanged() { bool showPhe = prefs.pp_graphs.phe; bool showPn2 = prefs.pp_graphs.pn2; diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h index e5b9b7b..34089e6 100644 --- a/qt-ui/profile/divecartesianaxis.h +++ b/qt-ui/profile/divecartesianaxis.h @@ -110,7 +110,7 @@ public: void setModel(DivePlotDataModel *model); public slots: - void preferencesChanged(); + void settingsChanged(); private: DivePlotDataModel *model; diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 58c4a86..954eb60 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -18,10 +18,10 @@ AbstractProfilePolygonItem::AbstractProfilePolygonItem() : QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1) { - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged())); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); } -void AbstractProfilePolygonItem::preferencesChanged() +void AbstractProfilePolygonItem::settingsChanged() { } @@ -192,7 +192,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI } } -void DiveProfileItem::preferencesChanged() +void DiveProfileItem::settingsChanged() { //TODO: Only modelDataChanged() here if we need to rebuild the graph ( for instance, // if the prefs.dcceiling are enabled, but prefs.redceiling is disabled @@ -296,7 +296,7 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->drawPolyline(polygon()); } -void DiveHeartrateItem::preferencesChanged() +void DiveHeartrateItem::settingsChanged() { QSettings s; s.beginGroup("TecDetails"); @@ -503,7 +503,7 @@ DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false), gradientF gradientFactor->setY(0); gradientFactor->setBrush(getColor(PRESSURE_TEXT)); gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); - preferencesChanged(); + settingsChanged(); } void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) @@ -542,10 +542,10 @@ void DiveCalculatedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsI DiveCalculatedTissue::DiveCalculatedTissue() { - preferencesChanged(); + settingsChanged(); } -void DiveCalculatedTissue::preferencesChanged() +void DiveCalculatedTissue::settingsChanged() { setVisible(prefs.calcalltissues && prefs.calcceiling); } @@ -579,7 +579,7 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QMo setBrush(pat); } -void DiveCalculatedCeiling::preferencesChanged() +void DiveCalculatedCeiling::settingsChanged() { if (dataModel && is3mIncrement != prefs.calcceiling3m) { // recalculate that part. @@ -589,7 +589,7 @@ void DiveCalculatedCeiling::preferencesChanged() setVisible(prefs.calcceiling); } -void DiveReportedCeiling::preferencesChanged() +void DiveReportedCeiling::settingsChanged() { setVisible(prefs.dcceiling); } @@ -696,7 +696,7 @@ PartialPressureGasItem::PartialPressureGasItem() { } -void PartialPressureGasItem::preferencesChanged() +void PartialPressureGasItem::settingsChanged() { QSettings s; s.beginGroup("TecDetails"); diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index c7fa598..de0c6f0 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -46,7 +46,7 @@ public: } public slots: - virtual void preferencesChanged(); + virtual void settingsChanged(); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void modelDataRemoved(const QModelIndex &parent, int from, int to); @@ -75,7 +75,7 @@ public: DiveProfileItem(); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); - virtual void preferencesChanged(); + virtual void settingsChanged(); void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color); private: @@ -100,7 +100,7 @@ public: DiveHeartrateItem(); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - virtual void preferencesChanged(); + virtual void settingsChanged(); void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey); bool isVisible(); @@ -130,7 +130,7 @@ public: DiveCalculatedCeiling(); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - virtual void preferencesChanged(); + virtual void settingsChanged(); private: bool is3mIncrement; @@ -143,14 +143,14 @@ class DiveReportedCeiling : public AbstractProfilePolygonItem { public: virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - virtual void preferencesChanged(); + virtual void settingsChanged(); }; class DiveCalculatedTissue : public DiveCalculatedCeiling { Q_OBJECT public: DiveCalculatedTissue(); - virtual void preferencesChanged(); + virtual void settingsChanged(); }; class MeanDepthLine : public DiveLineItem { @@ -176,7 +176,7 @@ public: PartialPressureGasItem(); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); - virtual void preferencesChanged(); + virtual void settingsChanged(); void setThreshouldSettingsKey(const QString &threshouldSettingsKey); void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey); void setColors(const QColor &normalColor, const QColor &alertColor); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index fbbf3df..3104406 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -203,7 +203,7 @@ void ProfileWidget2::setupItemOnScene() setupItem(temperatureItem, timeAxis, temperatureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1); setupItem(heartBeatItem, timeAxis, heartBeatAxis, dataModel, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1); heartBeatItem->setVisibilitySettingsKey("hrgraph"); - heartBeatItem->preferencesChanged(); + heartBeatItem->settingsChanged(); setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0); #define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \ @@ -211,7 +211,7 @@ void ProfileWidget2::setupItemOnScene() ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \ ITEM->setVisibilitySettingsKey(VISIBILITY_SETTINGS); \ ITEM->setColors(getColor(COLOR, isGrayscale), getColor(COLOR_ALERT, isGrayscale)); \ - ITEM->preferencesChanged(); \ + ITEM->settingsChanged(); \ ITEM->setZValue(99); CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, "pn2threshold", "pn2graph"); -- 1.9.3
From 698c6d7f15d6958a2c76b61a86256b43f1078604 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 21 May 2014 14:24:19 -0300 Subject: [PATCH 07/11] Move settings of the Ruler to the Ruler. As with any other graphics object, the settings for the ruler should be managed by the ruler, clearing up the Profile logic and making the code easier to read. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/profilewidget2.cpp | 6 +----- qt-ui/profile/profilewidget2.h | 2 +- qt-ui/profile/ruleritem.cpp | 11 +++++++++++ qt-ui/profile/ruleritem.h | 7 ++++++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 3104406..336042c 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -499,11 +499,6 @@ void ProfileWidget2::settingsChanged() needReplot = true; } - if (currentState == PROFILE) { - rulerItem->setVisible(prefs.rulergraph); - } else { - rulerItem->setVisible(false); - } if (needReplot) replot(); } @@ -874,3 +869,4 @@ void ProfileWidget2::editName() } replot(); } + diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 4517cc1..a5d9eed 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -68,6 +68,7 @@ public: virtual bool eventFilter(QObject *, QEvent *); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); void setPrintMode(bool mode, bool grayscale = false); + State currentState; public slots: // Necessary to call from QAction's signals. @@ -98,7 +99,6 @@ private: /*methods*/ private: DivePlotDataModel *dataModel; - State currentState; int zoomLevel; qreal zoomFactor; DivePixmapItem *background; diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index 1c52c6e..f168da9 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -1,5 +1,7 @@ #include "ruleritem.h" #include "divetextitem.h" +#include "profilewidget2.h" +#include "../preferences.h" #include <QFont> #include <QFontMetrics> @@ -79,6 +81,15 @@ RulerItem2::RulerItem2() : source(new RulerNodeItem2()), textItemBack->setPen(QColor(Qt::white)); textItemBack->setFlag(QGraphicsItem::ItemIgnoresTransformations); setPen(QPen(QColor(Qt::black), 0.0)); + connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); +} + +void RulerItem2::settingsChanged() +{ + ProfileWidget2 *profWidget = NULL; + if(scene() && scene()->views().count()) + profWidget = qobject_cast<ProfileWidget2*>(scene()->views().first()); + setVisible(profWidget->currentState == ProfileWidget2::PROFILE ? prefs.rulergraph : false); } void RulerItem2::recalculate() diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h index d00e345..2ee1703 100644 --- a/qt-ui/profile/ruleritem.h +++ b/qt-ui/profile/ruleritem.h @@ -31,7 +31,8 @@ private: DiveCartesianAxis *depthAxis; }; -class RulerItem2 : public QGraphicsLineItem { +class RulerItem2 :public QObject, public QGraphicsLineItem { + Q_OBJECT public: explicit RulerItem2(); void recalculate(); @@ -41,6 +42,10 @@ public: RulerNodeItem2 *destNode() const; void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth); void setVisible(bool visible); + +public slots: + void settingsChanged(); + private: struct plot_info pInfo; QPointF startPoint, endPoint; -- 1.9.3
From 6a6f8ec8b4dc576a7ff07d9169ce7197de3c521b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 21 May 2014 14:26:00 -0300 Subject: [PATCH 08/11] Source and dest are created on the constructor, no need to check for them. The code checked if dest and source existed before trying to call an method on them, but dest and source are created on the constructor, and thus, the if is dummy. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/ruleritem.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp index f168da9..92e8f12 100644 --- a/qt-ui/profile/ruleritem.cpp +++ b/qt-ui/profile/ruleritem.cpp @@ -172,8 +172,6 @@ void RulerItem2::setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth) void RulerItem2::setVisible(bool visible) { QGraphicsLineItem::setVisible(visible); - if (source) - source->setVisible(visible); - if (dest) - dest->setVisible(visible); + source->setVisible(visible); + dest->setVisible(visible); } -- 1.9.3
From b3efc10de77cffbd65cee8bbe7bc2548cf01986e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 21 May 2014 15:05:55 -0300 Subject: [PATCH 09/11] Temporary Tab Widget for the planner and the Profile View. This is a temporary measure to help me port the planner to the new profile. it will be removed when I finish the port, but it makes the software still usable, so there's no worris. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.ui | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 8ae8b24..5885baf 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -85,11 +85,14 @@ </layout> </widget> </widget> - <widget class="QStackedWidget" name="stackedWidget"> + <widget class="QTabWidget" name="stackedWidget"> <property name="currentIndex"> <number>0</number> </property> <widget class="QWidget" name="page_5"> + <attribute name="title"> + <string>Profile Visualization</string> + </attribute> <layout class="QGridLayout" name="gridLayout"> <property name="leftMargin"> <number>0</number> @@ -495,6 +498,9 @@ </layout> </widget> <widget class="QWidget" name="page_6"> + <attribute name="title"> + <string>Old Planner Visualization</string> + </attribute> <layout class="QHBoxLayout" name="horizontalLayout_2"> <property name="spacing"> <number>0</number> @@ -563,7 +569,7 @@ <x>0</x> <y>0</y> <width>1418</width> - <height>29</height> + <height>20</height> </rect> </property> <widget class="QMenu" name="menuFile"> -- 1.9.3
From 0a3f90e4f4c18101a8efef2e18988314a768d71b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 21 May 2014 15:52:24 -0300 Subject: [PATCH 10/11] Enables Editing the 'Add dive' from the new profile. This is highly broken in many ways - but it's the right first step. I ported two of the most important methods from the old profile and now if you are in add dive mode, double clicking on the new profile will correctly add a handler on the planned dive. to see and move the handler around, however, you need to activate the old planner. next step: add the handlers on the new profile. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.cpp | 2 +- qt-ui/profile/profilewidget2.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ qt-ui/profile/profilewidget2.h | 4 ++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index b00d5e8..c56d02e 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -408,11 +408,11 @@ 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); DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->createSimpleDive(); ui.ListWidget->reload(DiveTripModel::CURRENT); + ui.newProfile->setAddState(); } void MainWindow::on_actionRenumber_triggered() diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 336042c..5975c53 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -540,6 +540,30 @@ void ProfileWidget2::wheelEvent(QWheelEvent *event) toolTipItem->setPos(mapToScene(toolTipPos)); } +void ProfileWidget2::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (currentState == PLAN || currentState == ADD){ + DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); + QPointF mappedPos = mapToScene(event->pos()); + if (isPointOutOfBoundaries(mappedPos)) + return; + + int minutes = rint(timeAxis->valueAt(mappedPos) / 60); + int milimeters = rint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); + plannerModel->addStop(milimeters, minutes * 60, -1, 0, 0, true); + } +} + +bool ProfileWidget2::isPointOutOfBoundaries(const QPointF &point) const +{ + double xpos = timeAxis->valueAt(point); + double ypos = profileYAxis->valueAt(point); + return (xpos > timeAxis->maximum() || + xpos < timeAxis->minimum() || + ypos > profileYAxis->maximum() || + ypos < profileYAxis->minimum()); +} + void ProfileWidget2::scrollViewTo(const QPoint &pos) { /* since we cannot use translate() directly on the scene we hack on @@ -672,6 +696,26 @@ void ProfileWidget2::setProfileState() rulerItem->setVisible(prefs.rulergraph); } +void ProfileWidget2::setAddState() +{ + if (currentState == ADD) + return; + + /* show the same stuff that the profile shows. */ + currentState = ADD; /* enable the add state. */ + setBackgroundBrush(QColor(Qt::blue).light()); +} + +void ProfileWidget2::setPlanState() +{ + if (currentState == PLAN) + return; + + /* show the same stuff that the profile shows. */ + currentState = PLAN; /* enable the add state. */ + setBackgroundBrush(QColor(Qt::green).light()); +} + 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 a5d9eed..1ba6e57 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -68,6 +68,7 @@ public: virtual bool eventFilter(QObject *, QEvent *); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); void setPrintMode(bool mode, bool grayscale = false); + bool isPointOutOfBoundaries(const QPointF& point) const; State currentState; public @@ -75,6 +76,8 @@ slots: // Necessary to call from QAction's signals. void settingsChanged(); void setEmptyState(); void setProfileState(); + void setPlanState(); + void setAddState(); void changeGas(); void addBookmark(); void hideEvents(); @@ -88,6 +91,7 @@ protected: virtual void wheelEvent(QWheelEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event); + virtual void mouseDoubleClickEvent(QMouseEvent *event); private: /*methods*/ void fixBackgroundPos(); -- 1.9.3
From 392195917da780a2b0601d856b5cbe2bfa7ad240 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 21 May 2014 20:34:06 -0300 Subject: [PATCH 11/11] Back to profile or empty state when finishing addition. This patch adds a signal to MainTab, that should be removed from there when dirk finishes the rework on the edit part, to go to the edit classes, but in the meantime, let's keep it there. The signal is connected to the ProfileWidget in a way that the end of the edit will also trigger the profile to go back to ProfileState ( show the dive, if there's any ) or empty Profile ( if there's none. ) Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/maintab.cpp | 2 ++ qt-ui/maintab.h | 3 +++ qt-ui/mainwindow.cpp | 1 + qt-ui/profile/profilewidget2.cpp | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 96e2efc..2fd0787 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -761,6 +761,7 @@ void MainTab::acceptChanges() editMode = NONE; MainWindow::instance()->refreshDisplay(); MainWindow::instance()->graphics()->replot(); + emit addDiveFinished(); } else { editMode = NONE; MainWindow::instance()->dive_list()->rememberSelection(); @@ -861,6 +862,7 @@ void MainTab::rejectChanges() delete_single_dive(selected_dive); MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT); MainWindow::instance()->dive_list()->restoreSelection(); + emit addDiveFinished(); } if (selected_dive >= 0) { multiEditEquipmentPlaceholder = *get_dive(selected_dive); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 241f4c7..939e387 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -67,6 +67,9 @@ public: bool isEditing(); void updateCoordinatesText(qreal lat, qreal lon); void nextInputField(QKeyEvent *event); +signals: + void addDiveFinished(); + public slots: void addCylinder_clicked(); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index c56d02e..33946f3 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -75,6 +75,7 @@ MainWindow::MainWindow() : QMainWindow(), 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())); ui.mainErrorMessage->hide(); initialUiSetup(); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 5975c53..45df8b1 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -606,6 +606,7 @@ void ProfileWidget2::setEmptyState() if (currentState == EMPTY) return; + setBackgroundBrush(getColor(::BACKGROUND, isGrayscale)); dataModel->clear(); currentState = EMPTY; MainWindow::instance()->setToolButtonsEnabled(false); @@ -642,6 +643,11 @@ void ProfileWidget2::setProfileState() if (currentState == PROFILE) return; + if (dive_table.nr == 0) { // oops, called to plot something with zero dives. bail out. + setEmptyState(); + return; + } + currentState = PROFILE; MainWindow::instance()->setToolButtonsEnabled(true); toolTipItem->readPos(); -- 1.9.3
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
