VPTissue Reference Manual
SimShell::Gui::HasUnsavedChanges Class Referenceabstract

Abstract class that represents the ability be in closed or opened state, and, if the latter, in clean or dirty state. More...

#include <HasUnsavedChanges.h>

Inheritance diagram for SimShell::Gui::HasUnsavedChanges:
Inheritance graph
Collaboration diagram for SimShell::Gui::HasUnsavedChanges:
Collaboration graph

Public Types

typedef std::vector< HasUnsavedChanges * > ChildrenType
 

Public Member Functions

 HasUnsavedChanges (std::string &&title)
 
virtual ~HasUnsavedChanges ()
 Virtual destructor.
 
ChildrenType::iterator begin ()
 Get iterator to first child.
 
ChildrenType::const_iterator begin () const
 Get iterator to first child.
 
ChildrenType::iterator end ()
 Get iterator to one position after last child.
 
ChildrenType::const_iterator end () const
 Get iterator to one position after last child.
 
void ForceClose ()
 Force this object and its children to go back to unopened state so it can be safely deleted.
 
const std::string & GetTitle ()
 Get title of this object.
 
bool IsClean () const
 
virtual bool IsOpened () const =0
 
bool Save ()
 Try to save this widget's (and its children's) changes. More...
 
bool SaveAndClose ()
 Try to save this object (and its children) and, if successful, close them all.
 

Protected Member Functions

void AddChild (ChildrenType::value_type &&v)
 Add child.
 
virtual void InternalForceClose ()=0
 Implementation should only close THIS widget, not its children.
 
virtual bool InternalIsClean () const =0
 The result should be true only if THIS widget is in clean state.
 
virtual void InternalPreForceClose ()
 Additional things to do before closing children of this widget.
 
virtual bool InternalSave ()=0
 Implementation should only save THIS widget. More...
 
void SetChildren (ChildrenType &&c)
 Set children.
 

Detailed Description

Abstract class that represents the ability be in closed or opened state, and, if the latter, in clean or dirty state.

There are methods for querying the state, and quietly saving or discarding (if in opened state).

Objects of this type can also have children of the same type, to represent a hierarchical tree of closed/opened/clean/dirty objects. Children of this object can only be in opened state if this object is in opened state. Therefore, this object can only be closed if all of its children are closed first. This has the consequence that if one of this object's children are in 'dirty' state, a user confirmation might be necessary before being able close this object.

See also
HasUnsavedChangesPrompt SaveChangesDialog

Definition at line 39 of file HasUnsavedChanges.h.

Constructor & Destructor Documentation

SimShell::Gui::HasUnsavedChanges::HasUnsavedChanges ( std::string &&  title)
Parameters
titleTitle for this window. Displayed in "Save Changes?" dialog.

Definition at line 27 of file HasUnsavedChanges.cpp.

Member Function Documentation

virtual bool SimShell::Gui::HasUnsavedChanges::InternalSave ( )
protectedpure virtual

Implementation should only save THIS widget.

The result should be true only if THIS widget is in clean state.

Implemented in SimPT_Shell::Gui::PTreeEditor, SimShell::Gui::PTreeEditorWindow, SimShell::Gui::HasUnsavedChangesDummy, SimShell::Gui::Controller::ProjectController, SimShell::Gui::Controller::WorkspaceController, SimShell::Gui::PTreeContainer, and SimShell::Gui::PTreeMenu.

Referenced by Save().

Here is the caller graph for this function:

bool SimShell::Gui::HasUnsavedChanges::IsClean ( ) const
Returns
Whether this widget and all of its children are in clean state.

Definition at line 73 of file HasUnsavedChanges.cpp.

References InternalIsClean().

Referenced by SimShell::Gui::PTreeContainerPreferencesObserver::Update().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool SimShell::Gui::HasUnsavedChanges::IsOpened ( ) const
pure virtual
bool SimShell::Gui::HasUnsavedChanges::Save ( )

Try to save this widget's (and its children's) changes.

Returns
whether we are in clean state.

Definition at line 85 of file HasUnsavedChanges.cpp.

References InternalSave(), and IsOpened().

Referenced by SaveAndClose().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: