mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Make mouse dragging work as it should.
This patch makes mouse dragging work as it should, a tiny bit different than the old version, but I think it's a better way. What's missing: Keyboard actions. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8a1e4b04db
commit
f67693b2e0
2 changed files with 20 additions and 2 deletions
|
@ -1009,12 +1009,29 @@ void ProfileWidget2::repositionDiveHandlers()
|
|||
}
|
||||
}
|
||||
|
||||
int ProfileWidget2::fixHandlerIndex(DiveHandler *activeHandler)
|
||||
{
|
||||
int index = handles.indexOf(activeHandler);
|
||||
if (index > 0 && index < handles.count() - 1) {
|
||||
DiveHandler *before = handles[index - 1];
|
||||
if (before->pos().x() > activeHandler->pos().x()) {
|
||||
handles.swap(index, index-1);
|
||||
return index - 1;
|
||||
}
|
||||
DiveHandler *after = handles[index + 1];
|
||||
if (after->pos().x() < activeHandler->pos().x()) {
|
||||
handles.swap(index, index+1);
|
||||
return index + 1;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void ProfileWidget2::recreatePlannedDive()
|
||||
{
|
||||
DiveHandler *activeHandler = qobject_cast<DiveHandler*>(sender());
|
||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||
int index = handles.indexOf(activeHandler);
|
||||
|
||||
int index = fixHandlerIndex(activeHandler);
|
||||
int mintime = 0, maxtime = (timeAxis->maximum() + 10) * 60;
|
||||
if (index > 0)
|
||||
mintime = plannerModel->at(index - 1).time;
|
||||
|
|
|
@ -149,6 +149,7 @@ private:
|
|||
QList<DiveHandler *> handles;
|
||||
QList<QGraphicsSimpleTextItem *> gases;
|
||||
void repositionDiveHandlers();
|
||||
int fixHandlerIndex(DiveHandler *activeHandler);
|
||||
};
|
||||
|
||||
#endif // PROFILEWIDGET2_H
|
||||
|
|
Loading…
Reference in a new issue