PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFOTableModel
Concrete table model class which is used by the the SFZTableView class.
#include <SFOTableModel.h.hpp>
class SFOTableModel : public SFOTableModelBase;
SFMTYPEDEFREFOBJECT(SFOTableModel)
        

Inheritance diagram

 Inheritance diagram of SFOTableModelClass

Collaboration diagram

 Collaboration diagram of SFOTableModelClass

Description

This class is an concrete table model class which is used by the SFZTableView class.

This class implements various interfaces to access the table model.

Table data is implemented as an array (SFXArray) of table items [rows] (SFXTableItemBase).

Reference

SFOTableModelBase | SFZTableView

Member

Constructor/Destructor
SFOTableModel( Void )
Constructor of the SFOTableModel class.
~SFOTableModel( Void )
Destructor of the SFOTableModel class.
Public Functions
SFXAnyPtr GetColumnRow( SInt32 col , SInt32 row )
Get the pointer to the cell object specified by row-column indices.
SInt32 GetRowLength( Void )
Get the length of the table row.
SFCError InsertLast( SFXTableItemBaseConstRef item )
Insert the table item [row] at the tail.
static
SFOTableModelSmp
NewInstance( SFCErrorPtr exception = null )
Create a new instance of this class.
Protected Functions
static
SFORefObjectSmp
Factory( SFORefObjectPtr object , SFCErrorPtr exception ) (inherits from SFORefObject)
This function is used to implement the NewInstance function.
SFCError Initialize( Void ) (inherits from SFORefObject)
Make the initialization which may raise an error.

SFOTableModel::SFOTableModel
Constructor of the SFOTableModel class.
[ protected, explicit ]
SFOTableModel(Void);

SFOTableModel::~SFOTableModel
Destructor of the SFOTableModel class.
[ protected, virtual ]
~SFOTableModel(Void);

Description

Release the heap of the all table items.


SFOTableModel::GetColumnRow
Get the pointer to the cell object specified by row-column indices.
[ public, virtual ]
SFXAnyPtr GetColumnRow(
    SInt32 col   // column index
    SInt32 row   // row index
);

Return value

Pointer to the cell object

Description

If a row index or a column index out of range is specified, a null pointer will be returned.

Reference

SFXAny


SFOTableModel::GetRowLength
Get the length of the table row.
[ public, virtual, const ]
SInt32 GetRowLength(Void);

Return value

Length of table row


SFOTableModel::InsertLast
Insert the table item [row] at the tail.
[ public, virtual ]
SFCError InsertLast(
    SFXTableItemBaseConstRef item   // table item [row]
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

When the item is inserted, the item will be copied to heap.

Example

SFOTableModelSmp model;
SFXTableItem<2> item;
SFCError error;

model = SFOTableModel::NewInstance(&error);

if (model != null) {
    for (SInt32 row = 0; row < 10; row++) {
        item.data[0] = static_cast<Bool>((row % 2));
        item.data[1] = SFXAnsiString::Format("item_%d", row);

        // Insert the item [row] to the model.
        error = model->InsertLast(item);

        if (error != SFERR_NO_ERROR) {
            break;
        }
    }
}

Reference

SFOTableModel::NewInstance | SFXTableItemBase | SFXTableItem


SFOTableModel::NewInstance
Create a new instance of this class.
[ public, static ]
SFOTableModelSmp NewInstance(
    SFCErrorPtr exception = null   // error value
);

Argument

exception

Return the error value generated inside the function

Return value

  • If succeeds: not null pointer
  • Otherwise: null pointer

Description

This function creates a new instance of the SFOTableModel class.

If succeeds, a not null pointer will be returned, and the "exception" argument is SFERR_NO_ERROR. If fails such as insufficient memory, a null pointer will be returned, and the "exception" argument holds the error value

Example

The following is a code to create a new instance of the table model.

SFOTableModelSmp model;
SFCError error;

if ((model = SFOTableModel::NewInstance(&error)) != null) {
    // .. (omitted) ..
}