summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/diveplanner.cpp12
-rw-r--r--qt-ui/diveplanner.h4
-rw-r--r--qt-ui/profile/profilewidget2.cpp32
-rw-r--r--qt-ui/profile/profilewidget2.h5
4 files changed, 50 insertions, 3 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index e6c1889d5..44449a52a 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -258,6 +258,18 @@ void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
emit moved();
}
+void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ QGraphicsItem::mousePressEvent(event);
+ emit clicked();
+}
+
+void DiveHandler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ QGraphicsItem::mouseReleaseEvent(event);
+ emit released();
+}
+
DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
ui.setupUi(this);
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 4911a5628..02c401822 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -118,8 +118,12 @@ public:
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
signals:
void moved();
+ void clicked();
+ void released();
private:
int parentIndex();
public
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 0aa2a4a2e..f9186daf5 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -90,7 +90,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
rulerItem(new RulerItem2()),
isGrayscale(false),
printMode(false),
- shouldCalculateMaxTime(true)
+ shouldCalculateMaxTime(true),
+ shouldCalculateMaxDepth(true)
{
memset(&plotInfo, 0, sizeof(plotInfo));
@@ -430,7 +431,19 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
create_plot_info_new(d, currentdc, &pInfo);
if(shouldCalculateMaxTime)
maxtime = get_maxtime(&pInfo);
- int maxdepth = get_maxdepth(&pInfo);
+
+ /* Only update the max depth if it's bigger than the current ones
+ * when we are dragging the handler to plan / add dive.
+ * otherwhise, update normally.
+ */
+ int newMaxDepth = get_maxdepth(&pInfo);
+ if(!shouldCalculateMaxDepth) {
+ if (maxdepth < newMaxDepth) {
+ maxdepth = newMaxDepth;
+ }
+ } else {
+ maxdepth = newMaxDepth;
+ }
dataModel->setDive(d, pInfo);
toolTipItem->setPlotInfo(pInfo);
@@ -506,7 +519,6 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
// Only set visible the events that should be visible
Q_FOREACH (DiveEventItem *event, eventItems) {
event->setVisible(!event->shouldBeHidden());
- // qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds << "is hidden:" << event->isHidden();
}
QString dcText = get_dc_nickname(currentdc->model, currentdc->deviceid);
int nr;
@@ -567,6 +579,18 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event)
shouldCalculateMaxTime = false;
}
+void ProfileWidget2::divePlannerHandlerClicked()
+{
+ shouldCalculateMaxDepth = false;
+ replot();
+}
+
+void ProfileWidget2::divePlannerHandlerReleased()
+{
+ shouldCalculateMaxDepth = true;
+ replot();
+}
+
void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
{
QGraphicsView::mouseReleaseEvent(event);
@@ -1090,6 +1114,8 @@ void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end
handles << item;
connect(item, SIGNAL(moved()), this, SLOT(recreatePlannedDive()));
+ connect(item, SIGNAL(clicked()), this, SLOT(divePlannerHandlerClicked()));
+ connect(item, SIGNAL(released()), this, SLOT(divePlannerHandlerReleased()));
QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem();
scene()->addItem(gasChooseBtn);
gasChooseBtn->setZValue(10);
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 47e9a51b3..42d5abbcb 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -107,6 +107,8 @@ slots: // Necessary to call from QAction's signals.
void keyLeftAction();
void keyRightAction();
+ void divePlannerHandlerClicked();
+ void divePlannerHandlerReleased();
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void wheelEvent(QWheelEvent *event);
@@ -115,6 +117,7 @@ protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
+
private: /*methods*/
void fixBackgroundPos();
void scrollViewTo(const QPoint &pos);
@@ -169,7 +172,9 @@ private:
friend class DiveHandler;
QHash<Qt::Key, QAction *> actionsForKeys;
bool shouldCalculateMaxTime;
+ bool shouldCalculateMaxDepth;
int maxtime;
+ int maxdepth;
};
#endif // PROFILEWIDGET2_H