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:

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.
- They can be emptied or cleared out by calling the empty() method.
- You can determine is the model has any data at all by calling the isEmpty() method.
- A model's data can be "validated", in other words you can call validate() to determine if the data in the model is in a correct state, or has meaningful values. Again, the exact implementation is up to the programmer, but if the model is not considered "valid" then the validate() method must throw an exception.
- A model can notify interested parties that it's state or data has changed through it's ModelChanged delegate. Any time the data for the model is modified some sort of ModelEvent should be passed to the ModelChanged delegate to notify any of the associated callbacks.
- a generic method for retrieving data is provided (it may not be the best or most effient way to retreive data) via the getValue() method
- a generic method for setting/modifying data is provided (it may not be the best or most effient way to retreive data) via the setValue() method
- Event Delegates for this class:
- Model::ModelChanged
- Model::ModelValidate
Member Enumeration Documentation
|
|
|
Constructor & Destructor Documentation
|
|
|
|
|
|
Member Function Documentation
|
|
adds a new view to the model
|
|
|
|
|
|
A virtual method that deletes the object stored by the model. You may choose to override this with an alternate implementation. |
|
|
clears out the model's data
Reimplemented in VCF::DefaultTableModel, VCF::DefaultTextModel, VCF::DefaultTreeModel, VCF::SimpleListModel, VCF::TabModel, and VCF::TreeListModel. |
|
|
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. |
|
|
Returns the data for the model as a string.
Reimplemented in VCF::ListModel, and VCF::TextModel. |
|
|
|
|
|
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. |
|
|
removes a view from the model
|
|
||||||||||||
|
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.
Reimplemented in VCF::ListModel, and VCF::TextModel. |
|
||||||||||||
|
Sets the value of the model using a string to specify the data.
Reimplemented in VCF::ListModel, and VCF::TextModel. |
|
|
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. |
|
|
notifies all the views the model has changed calls View::updateView( ), passing itself in as the updated Model
|
|
|
Validate the model.
Reimplemented in VCF::DefaultTableModel. |
Member Data Documentation
|
|
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.
|
|
|
|
|
|
|
|
|
|
The documentation for this class was generated from the following file:
- vcf/ApplicationKit/Model.h
