mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Enable 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 <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d73fdbc84b
commit
3661f291a4
3 changed files with 49 additions and 1 deletions
|
@ -408,11 +408,11 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
ui.InfoWidget->setCurrentIndex(0);
|
ui.InfoWidget->setCurrentIndex(0);
|
||||||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
ui.InfoWidget->updateDiveInfo(selected_dive);
|
||||||
ui.InfoWidget->addDiveStarted();
|
ui.InfoWidget->addDiveStarted();
|
||||||
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
|
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
ui.infoPane->setCurrentIndex(MAINTAB);
|
||||||
DivePlannerPointsModel::instance()->clear();
|
DivePlannerPointsModel::instance()->clear();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||||
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
||||||
|
ui.newProfile->setAddState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionRenumber_triggered()
|
void MainWindow::on_actionRenumber_triggered()
|
||||||
|
|
|
@ -540,6 +540,30 @@ void ProfileWidget2::wheelEvent(QWheelEvent *event)
|
||||||
toolTipItem->setPos(mapToScene(toolTipPos));
|
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)
|
void ProfileWidget2::scrollViewTo(const QPoint &pos)
|
||||||
{
|
{
|
||||||
/* since we cannot use translate() directly on the scene we hack on
|
/* since we cannot use translate() directly on the scene we hack on
|
||||||
|
@ -672,6 +696,26 @@ void ProfileWidget2::setProfileState()
|
||||||
rulerItem->setVisible(prefs.rulergraph);
|
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 struct ev_select *ev_namelist;
|
||||||
extern int evn_allocated;
|
extern int evn_allocated;
|
||||||
extern int evn_used;
|
extern int evn_used;
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
virtual bool eventFilter(QObject *, QEvent *);
|
virtual bool eventFilter(QObject *, QEvent *);
|
||||||
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
|
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
|
||||||
void setPrintMode(bool mode, bool grayscale = false);
|
void setPrintMode(bool mode, bool grayscale = false);
|
||||||
|
bool isPointOutOfBoundaries(const QPointF& point) const;
|
||||||
State currentState;
|
State currentState;
|
||||||
|
|
||||||
public
|
public
|
||||||
|
@ -75,6 +76,8 @@ slots: // Necessary to call from QAction's signals.
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void setEmptyState();
|
void setEmptyState();
|
||||||
void setProfileState();
|
void setProfileState();
|
||||||
|
void setPlanState();
|
||||||
|
void setAddState();
|
||||||
void changeGas();
|
void changeGas();
|
||||||
void addBookmark();
|
void addBookmark();
|
||||||
void hideEvents();
|
void hideEvents();
|
||||||
|
@ -88,6 +91,7 @@ protected:
|
||||||
virtual void wheelEvent(QWheelEvent *event);
|
virtual void wheelEvent(QWheelEvent *event);
|
||||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
|
||||||
private: /*methods*/
|
private: /*methods*/
|
||||||
void fixBackgroundPos();
|
void fixBackgroundPos();
|
||||||
|
|
Loading…
Add table
Reference in a new issue