summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-15 12:34:42 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-16 10:12:30 +0700
commit02e302133358687b7f50127a053ae9e315bbeba5 (patch)
treeeb0a2a719c54c3026e50813ea61b30709fbc1cfc /qt-ui
parentcdb447434d6470a2fd619609eb3ee292c6e08b2a (diff)
downloadsubsurface-02e302133358687b7f50127a053ae9e315bbeba5.tar.gz
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 <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp47
1 files changed, 47 insertions, 0 deletions
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 <QStateMachine>
+#include <QSignalTransition>
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.