Graphics Reference
In-Depth Information
If the user is currently editing the tracks and has made some changes, we ask the user
whether they want to save their changes, and either commit the changes or roll them back.
If no changes have been made, we roll back (to turn off the vector layer's editing mode)
and switch back to the panning mode.
There are a couple of instance variables that we use here to monitor the state of our track
editing: self.editing will be set to True if we're currently editing the tracks, and
self.modified is set to True if the user has changed anything in the track layer.
We'll have to add the following to our ForestTrailsWindow.__init__() method
to initialize these two instance variables:
self.editing = False
self.modified= False
There's another method that we haven't seen before: adjustActions() . This method
will enable/disable and check/uncheck the various actions: depending on the application's
current state. For example, when we enter the track editing mode, our adjustAc-
tions() method will enable the add, edit, and delete tools, and these tools will be dis-
abled again when the user leaves the track-editing mode.
We can't implement all of adjustActions() at the moment because we haven't yet
defined the various map tools that our application will use. For now, we'll write the first
half of this method:
def adjustActions(self):
if self.editing:
self.actionAddTrack.setEnabled(True)
self.actionEditTrack.setEnabled(True)
self.actionDeleteTrack.setEnabled(True)
self.actionGetInfo.setEnabled(True)
self.actionSetStartPoint.setEnabled(False)
self.actionSetEndPoint.setEnabled(False)
self.actionFindShortestPath.setEnabled(False)
else:
self.actionAddTrack.setEnabled(False)
self.actionEditTrack.setEnabled(False)
self.actionDeleteTrack.setEnabled(False)
self.actionGetInfo.setEnabled(False)
self.actionSetStartPoint.setEnabled(True)
Search WWH ::




Custom Search