From 02e302133358687b7f50127a053ae9e315bbeba5 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 15 Jan 2014 12:34:42 -0200 Subject: Started the work on the States for the Profile. This is a start of the work on the States for the Profile. All setup is done, all connections are done. Maybe there's something missing because I never worked with QStateMachine before, but it seems to work correctly. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 2b9296d25..21caef50b 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -5,7 +5,9 @@ #include "divecartesianaxis.h" #include "diveprofileitem.h" #include "helpers.h" + #include +#include ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), @@ -61,6 +63,51 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : } background->setFlag(QGraphicsItem::ItemIgnoresTransformations); + + //enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID }; + stateMachine = new QStateMachine(this); + + // TopLevel States + QState *emptyState = new QState(); + QState *profileState = new QState(); + QState *editState = new QState(); + QState *addState = new QState(); + QState *planState = new QState(); + + // Conections: + stateMachine->addState(emptyState); + stateMachine->addState(profileState); + stateMachine->addState(editState); + stateMachine->addState(addState); + stateMachine->addState(planState); + stateMachine->setInitialState(emptyState); + + // All Empty State Connections. + QSignalTransition *tEmptyToProfile = emptyState->addTransition(this, SIGNAL(startProfileState()), profileState); + QSignalTransition *tEmptyToAdd = emptyState->addTransition(this, SIGNAL(startAddState()), addState); + QSignalTransition *tEmptyToPlan = emptyState->addTransition(this, SIGNAL(startPlanState()), planState); + + // All Plan Connections + QSignalTransition *tPlanToEmpty = planState->addTransition(this, SIGNAL(startEmptyState()), emptyState); + QSignalTransition *tPlanToProfile = planState->addTransition(this, SIGNAL(startProfileState()), profileState); + QSignalTransition *tPlanToAdd = planState->addTransition(this, SIGNAL(startAddState()), addState); + + // All Add Dive Connections + QSignalTransition *tAddToEmpty = addState->addTransition(this, SIGNAL(startEmptyState()), emptyState); + QSignalTransition *tAddToPlan = addState->addTransition(this, SIGNAL(startPlanState()), planState); + QSignalTransition *tAddToProfile = addState->addTransition(this, SIGNAL(startProfileState()), profileState); + + // All Profile State Connections + QSignalTransition *tProfileToEdit = profileState->addTransition(this, SIGNAL(startEditState()), editState); + QSignalTransition *tProfileToEmpty = profileState->addTransition(this, SIGNAL(startEmptyState()), emptyState); + QSignalTransition *tProfileToPlan = profileState->addTransition(this, SIGNAL(startPlanState()), planState); + QSignalTransition *tProfileToAdd = profileState->addTransition(this, SIGNAL(startAddState()), addState); + + // All "Edit" state connections + QSignalTransition *tEditToEmpty = editState->addTransition(this, SIGNAL(startEmptyState()), emptyState); + QSignalTransition *tEditToPlan = editState->addTransition(this, SIGNAL(startPlanState()), planState); + QSignalTransition *tEditToProfile = editState->addTransition(this, SIGNAL(startProfileState()), profileState); + QSignalTransition *tEditToAdd = editState->addTransition(this, SIGNAL(startAddState()), addState); } // Currently just one dive, but the plan is to enable All of the selected dives. -- cgit v1.2.3-70-g09d2