Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::Model Class Reference

A model is the base class for storing data that can then be presented to the user by controls and/or views. More...

#include <vcf/ApplicationKit/Model.h>

Inheritance diagram for VCF::Model:

VCF::Component VCF::ObjectWithCallbacks VCF::Object VCF::ListModel VCF::TableModel VCF::TextModel VCF::ToolbarModel VCF::TreeModel VCF::SimpleListModel VCF::DefaultTableModel VCF::DefaultTextModel VCF::DefaultTreeModel VCF::ColumnModel VCF::DefaultListModel VCF::TabModel VCF::TreeListModel List of all members.

Public Types

enum  ModelEvents { MODEL_CHANGED = 2000, MODEL_VALIDATED, MODEL_EMPTIED, MODEL_LAST_EVENT }

Public Member Functions

 Model ()
virtual ~Model ()
virtual ModelValidate void validate ()
 Validate the model.
virtual bool isEmpty ()
 Returns whether or not the model has an data.
virtual void empty ()
 clears out the model's data
virtual void addView (View *view)
 adds a new view to the model
virtual void removeView (View *view)
 removes a view from the model
virtual void updateAllViews ()
 notifies all the views the model has changed calls View::updateView( ), passing itself in as the updated Model
Enumerator< View * > * getViews ()
void changed (ModelEvent *event)
virtual VariantData getValue (const VariantData &key=VariantData::null())
 Returns the value for the model.
virtual String getValueAsString (const VariantData &key=VariantData::null())
 Returns the data for the model as a string.
virtual void setValue (const VariantData &value, const VariantData &key=VariantData::null())
 Sets the value of the model.
virtual void setValueAsString (const String &value, const VariantData &key=VariantData::null())
 Sets the value of the model using a string to specify the data.
bool shouldDeleteVarObjects ()
 Indicates whether or not the model will be responsible for deleting objects that may be held in a collection of VariantData instances.

Public Attributes

VCF::Delegate ModelDelegate
ModelChanged VCF::Delegate ValidationDelegate

Protected Member Functions

virtual void deleteVariantObject (Object *obj)
 A virtual method that deletes the object stored by the model.

Protected Attributes

bool deleteVariantObjects_
 Indicates whether the model deletes the variant objects.
Array< View * > views_

Detailed Description

A model is the base class for storing data that can then be presented to the user by controls and/or views.

The model maintains zero or more views. It can update the views in one shot by the updateAllViews().

The exact kind of data store in the model is up to the implementor but all models has some basic common characteristics.

Event Delegates for this class:
  • Model::ModelChanged
  • Model::ModelValidate


Member Enumeration Documentation

enum VCF::Model::ModelEvents
 

Enumerator:
MODEL_CHANGED 
MODEL_VALIDATED 
MODEL_EMPTIED 
MODEL_LAST_EVENT 


Constructor & Destructor Documentation

VCF::Model::Model  ) 
 

virtual VCF::Model::~Model  )  [virtual]
 


Member Function Documentation

virtual void VCF::Model::addView View view  )  [virtual]
 

adds a new view to the model

void VCF::Model::changed ModelEvent event  )  [inline]
 

virtual void VCF::Model::deleteVariantObject Object obj  )  [inline, protected, virtual]
 

A virtual method that deletes the object stored by the model.

You may choose to override this with an alternate implementation.

virtual void VCF::Model::empty  )  [inline, virtual]
 

clears out the model's data

Reimplemented in VCF::DefaultTableModel, VCF::DefaultTextModel, VCF::DefaultTreeModel, VCF::SimpleListModel, VCF::TabModel, and VCF::TreeListModel.

virtual VariantData VCF::Model::getValue const VariantData key = VariantData::null()  )  [inline, virtual]
 

Returns the value for the model.

A key may be specified with a VariantData object. The exact meaning of the key is up to the specific implementation Model based sub class. For example, a ListModel would expect a key that represents an integer based index. Another kind of model might use a string that represent's coordinates, or perhaps even an object instance that has relevant data for the key. Some models might ignore the key altogether, for example a TextModel might ignore the key and simply return the text of the model.

Reimplemented in VCF::ListModel, and VCF::TextModel.

virtual String VCF::Model::getValueAsString const VariantData key = VariantData::null()  )  [inline, virtual]
 

Returns the data for the model as a string.

See also:
getValue

Reimplemented in VCF::ListModel, and VCF::TextModel.

Enumerator<View*>* VCF::Model::getViews  )  [inline]
 

virtual bool VCF::Model::isEmpty  )  [inline, virtual]
 

Returns whether or not the model has an data.

The default is true, since in it's abstract form the model doesn't (yet) have any data associated it. It is up to implementers to return something meaningful here.

Reimplemented in VCF::DefaultTextModel, VCF::ListModel, VCF::TableModel, and VCF::TreeModel.

virtual void VCF::Model::removeView View view  )  [virtual]
 

removes a view from the model

virtual void VCF::Model::setValue const VariantData value,
const VariantData key = VariantData::null()
[inline, virtual]
 

Sets the value of the model.

The data is stored in a VariantData object. The key may be used if it's relevant to the specific kind of model. See the getValue documentation for more information about the key parameter.

See also:
getValue

Reimplemented in VCF::ListModel, and VCF::TextModel.

virtual void VCF::Model::setValueAsString const String value,
const VariantData key = VariantData::null()
[inline, virtual]
 

Sets the value of the model using a string to specify the data.

See also:
setValue()

Reimplemented in VCF::ListModel, and VCF::TextModel.

bool VCF::Model::shouldDeleteVarObjects  )  [inline]
 

Indicates whether or not the model will be responsible for deleting objects that may be held in a collection of VariantData instances.

For example, if the model stored it's data using an array of VariantData objects, and each item in the array was a pointer to some Object based instance, then if the method returns true, the model will be responsible for freeing all the object instances stored in the array. If it returns false then the programmer would be responsible for freeing up the instances.

virtual void VCF::Model::updateAllViews  )  [virtual]
 

notifies all the views the model has changed calls View::updateView( ), passing itself in as the updated Model

virtual ModelValidate void VCF::Model::validate  )  [inline, virtual]
 

Validate the model.

Reimplemented in VCF::DefaultTableModel.


Member Data Documentation

bool VCF::Model::deleteVariantObjects_ [protected]
 

Indicates whether the model deletes the variant objects.

If you need to set this, you should do so in your models constructor by accessing this variable directly. If you set it to true, the model should delete any object's it stores.

See also:
shouldDeleteVarObjects

VCF::Delegate VCF::Model::ModelDelegate
 

Event Delegate:
ModelChanged fired when the model's empty() method is called. Should also be fired for any change to the model's content.
event class: ModelEvent
event type: Model::MODEL_EMPTIED
See also:
empty()

ModelChanged VCF::Delegate VCF::Model::ValidationDelegate
 

Event Delegate:
ModelValidate fired when the model's validate() method is called
event class: ValidationEvent
See also:
validate()

Array<View*> VCF::Model::views_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information