BPS C++ API  2.24.4
BpsTableItem Class Reference

Items used by BpsTableModel. More...

#include <bpstableitem.h>

Public Types

enum  CacheIndex { CacheDisplayColumnStart = 1000000 }
 Reserved cache indexes. More...
 
enum  Status { StatusSaved = 0 , StatusEdited = 1 , StatusAdded = 2 , StatusDeleted = 3 }
 Current status of the item. More...
 

Public Member Functions

void addFields (const QSqlRecord &aRecord)
 Add more fields to the record. More...
 
QVariant cache (const QString &aField) const
 Get the named cache value. More...
 
QVariant cache (int aIndex) const
 Get the indexed cache value. More...
 
QVariantMap changedValues () const
 
QVariant data (int aIndex=0) const
 Get application data. More...
 
bool hasField (const QString &aField)
 Check if the field is present. More...
 
bool hasOptions (const QString &aTable)
 Check if the options are present. More...
 
bool isEditable () const
 
QVariant key () const
 The record key (value of c_key field), only valid when status in not StatusAdded.
 
BpsTableOptions options (const QString &aMappingTable) const
 Get the named option key set. More...
 
void setCache (const QString &aField, const QVariant &aValue)
 Set the cache value of the named field. More...
 
void setCache (int aIndex, const QVariant &aValue)
 Set the indexed cache value. More...
 
void setData (const QVariant &aValue, int aIndex=0)
 Set application data. More...
 
void setIsEditable (bool aIsEditable)
 Enable / disable editing of a field. More...
 
bool setOptions (const QString &aMappingTable, const BpsTableOptions &aOptions)
 Set the options of the named set. More...
 
void setSaved ()
 Set the item status to saved.
 
bool setValue (const QString &aField, const QVariant &aValue)
 Set the value of the named field. More...
 
BpsTableModelslaveModel (const QString &aTable)
 Get the named slave table model. More...
 
Status status () const
 
QVariant value (const QString &aField) const
 Get the named value. More...
 
QVariantMap values () const
 

Friends

class BpsTableModel
 
class BpsTableModelPrivate
 

Detailed Description

Items used by BpsTableModel.

Member Enumeration Documentation

◆ CacheIndex

Reserved cache indexes.

Enumerator
CacheDisplayColumnStart 

This plus field count subsequent values are for display caching.

◆ Status

Current status of the item.

Enumerator
StatusSaved 

Item, options and slaves are saved and unchanged in the model.

StatusEdited 

Item, options or slave table models have unsaved changes.

StatusAdded 

A new, yet unsaved item.

StatusDeleted 

Item marked to get deleted from database.

Member Function Documentation

◆ addFields()

void BpsTableItem::addFields ( const QSqlRecord aRecord)

Add more fields to the record.

Parameters
aRecordThe record containing the additional fields.

◆ cache() [1/2]

QVariant BpsTableItem::cache ( const QString aField) const

Get the named cache value.

The cached value is used to store cache values, for example a thumbnail pixmap of an image stored as byte array (JPG, PNG) in the record value. The cache value gets cleared when the value is modified by setValue().

Parameters
aFieldName of the field (column name).
Returns
The current cache value, or QVariant() in case there is no such cached value.

◆ cache() [2/2]

QVariant BpsTableItem::cache ( int  aIndex) const

Get the indexed cache value.

The indexes 0+numberOfFields-1 refers to the custom cache value which may also be accessed by cache(const QString& aField).

The indexes CacheDisplayColumnStart+numberOfFields-1 is reserved for internal display column caching.

Parameters
aIndexIndex of the cached value.
Returns
The current cache value, or QVariant() in case there is no such cached value.

◆ changedValues()

QVariantMap BpsTableItem::changedValues ( ) const
Returns
List of all changed values.

◆ data()

QVariant BpsTableItem::data ( int  aIndex = 0) const

Get application data.

The application data is not used by QTableModel but available for the applications use. It is not necessary related to distinct column values and may be used to store any additional information not saved in the database.

Parameters
aIndexThe data index.
Returns
The data, or an invalid QVariant if not set.

◆ hasField()

bool BpsTableItem::hasField ( const QString aField)

Check if the field is present.

Parameters
aFieldThe field (column) name.
Returns
True if field is in record, false otherwise.

◆ hasOptions()

bool BpsTableItem::hasOptions ( const QString aTable)

Check if the options are present.

Parameters
aTableName of the options table.
Returns
True if options are present, false otherwise.

◆ isEditable()

bool BpsTableItem::isEditable ( ) const
Returns
True if the field can be edited.

◆ options()

BpsTableOptions BpsTableItem::options ( const QString aMappingTable) const

Get the named option key set.

Parameters
aMappingTableThe name of the mapping table with the options.
Returns
The option set, or an empty set in case of invalid table name.

◆ setCache() [1/2]

void BpsTableItem::setCache ( const QString aField,
const QVariant aValue 
)

Set the cache value of the named field.

Parameters
aFieldName of the field (column name).
aValueThe new cache value to set. Set QVariant() to clear the cache.

◆ setCache() [2/2]

void BpsTableItem::setCache ( int  aIndex,
const QVariant aValue 
)

Set the indexed cache value.

The indexes 0+numberOfFields-1 refers to the custom cache value which may also be accessed by setCache(const QString& aField).

The indexes CacheDisplayColumnStart+numberOfFields-1 is reserved for internal display column caching.

Parameters
aIndexIndex of the cached value.
aValueThe cached value. Set QVariant() to clear the cache.

◆ setData()

void BpsTableItem::setData ( const QVariant aValue,
int  aIndex = 0 
)

Set application data.

Parameters
aValueThe value to set. A invalid QVariant clears the data.
aIndexThe data index.

◆ setIsEditable()

void BpsTableItem::setIsEditable ( bool  aIsEditable)

Enable / disable editing of a field.

Initially items are enabled for editing.

Parameters
aIsEditableThe new editable status.

◆ setOptions()

bool BpsTableItem::setOptions ( const QString aMappingTable,
const BpsTableOptions aOptions 
)

Set the options of the named set.

Parameters
aMappingTableThe name of the mapping table with the options.
aOptionsThe new options to set
Returns
True if the options was changed, false if invalid table or options were already same.

◆ setValue()

bool BpsTableItem::setValue ( const QString aField,
const QVariant aValue 
)

Set the value of the named field.

Parameters
aFieldName of the field (column name).
aValueThe new value to set
Returns
True if the value was changed, false if invalid field name or value was already same.

◆ slaveModel()

BpsTableModel* BpsTableItem::slaveModel ( const QString aTable)

Get the named slave table model.

Parameters
aTableTable name of the desired slave model.
Returns
Model pointer, or 0 if no such slave model.

◆ status()

Status BpsTableItem::status ( ) const
Returns
The current status.

◆ value()

QVariant BpsTableItem::value ( const QString aField) const

Get the named value.

Parameters
aFieldName of the field (column name).
Returns
The current value, or QVariant() in case there is no such field.

◆ values()

QVariantMap BpsTableItem::values ( ) const
Returns
List of all values.

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