Cleanup: Improve Connection Handling in Profile.

- improve naming;
- remove unneeded disconnects.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
=Michael Keller 2024-05-25 00:33:44 +12:00 committed by bstoeger
parent 8c14fb971c
commit ecc6f64d10
2 changed files with 14 additions and 16 deletions

View file

@ -404,7 +404,7 @@ void ProfileWidget2::clear()
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
clearPictures(); clearPictures();
#endif #endif
disconnectTemporaryConnections(); disconnectPlannerModel();
profileScene->clear(); profileScene->clear();
handles.clear(); handles.clear();
gases.clear(); gases.clear();
@ -426,7 +426,7 @@ void ProfileWidget2::setProfileState()
if (currentState == PROFILE) if (currentState == PROFILE)
return; return;
disconnectTemporaryConnections(); disconnectPlannerModel();
currentState = PROFILE; currentState = PROFILE;
setBackgroundBrush(getColor(::BACKGROUND, profileScene->isGrayscale)); setBackgroundBrush(getColor(::BACKGROUND, profileScene->isGrayscale));
@ -444,16 +444,6 @@ void ProfileWidget2::setProfileState()
} }
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
void ProfileWidget2::connectPlannerModel()
{
connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot);
connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot);
connect(plannerModel, &DivePlannerPointsModel::modelReset, this, &ProfileWidget2::pointsReset);
connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted);
connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved);
connect(plannerModel, &DivePlannerPointsModel::rowsMoved, this, &ProfileWidget2::pointsMoved);
}
void ProfileWidget2::setEditState(const dive *d, int dc) void ProfileWidget2::setEditState(const dive *d, int dc)
{ {
if (currentState == EDIT) if (currentState == EDIT)
@ -462,7 +452,6 @@ void ProfileWidget2::setEditState(const dive *d, int dc)
setProfileState(d, dc); setProfileState(d, dc);
mouseFollowerHorizontal->setVisible(true); mouseFollowerHorizontal->setVisible(true);
mouseFollowerVertical->setVisible(true); mouseFollowerVertical->setVisible(true);
disconnectTemporaryConnections();
connectPlannerModel(); connectPlannerModel();
@ -480,7 +469,6 @@ void ProfileWidget2::setPlanState(const dive *d, int dc)
setProfileState(d, dc); setProfileState(d, dc);
mouseFollowerHorizontal->setVisible(true); mouseFollowerHorizontal->setVisible(true);
mouseFollowerVertical->setVisible(true); mouseFollowerVertical->setVisible(true);
disconnectTemporaryConnections();
connectPlannerModel(); connectPlannerModel();
@ -800,9 +788,19 @@ void ProfileWidget2::editName(DiveEventItem *item)
Command::renameEvent(mutable_dive(), dc, event, qPrintable(newName)); Command::renameEvent(mutable_dive(), dc, event, qPrintable(newName));
} }
} }
void ProfileWidget2::connectPlannerModel()
{
connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot);
connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot);
connect(plannerModel, &DivePlannerPointsModel::modelReset, this, &ProfileWidget2::pointsReset);
connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted);
connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved);
connect(plannerModel, &DivePlannerPointsModel::rowsMoved, this, &ProfileWidget2::pointsMoved);
}
#endif #endif
void ProfileWidget2::disconnectTemporaryConnections() void ProfileWidget2::disconnectPlannerModel()
{ {
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
if (plannerModel) { if (plannerModel) {

View file

@ -115,7 +115,6 @@ private:
void setupSceneAndFlags(); void setupSceneAndFlags();
void addItemsToScene(); void addItemsToScene();
void setupItemOnScene(); void setupItemOnScene();
void disconnectTemporaryConnections();
struct plot_data *getEntryFromPos(QPointF pos); struct plot_data *getEntryFromPos(QPointF pos);
void clearPictures(); void clearPictures();
void plotPicturesInternal(const struct dive *d, bool synchronous); void plotPicturesInternal(const struct dive *d, bool synchronous);
@ -184,6 +183,7 @@ private:
std::vector<std::unique_ptr<DiveHandler>> handles; std::vector<std::unique_ptr<DiveHandler>> handles;
int handleIndex(const DiveHandler *h) const; int handleIndex(const DiveHandler *h) const;
void disconnectPlannerModel();
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
void connectPlannerModel(); void connectPlannerModel();
void repositionDiveHandlers(); void repositionDiveHandlers();