WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Zbl::ZblTableData Class Reference

A table data object contains the role data and model item flags for a 2 dimensional array of model data cells. More...

#include <ZblTableData.h>

Public Types

typedef QList< QString > zColumnNames
 
typedef QList< QList< int > > zFlagsTable
 
typedef QMap< int, QVariant > zCellValue
 
typedef QList< QVariant > zDataRow
 
typedef QList< zDataRowzDataTable
 
typedef QMap< int, zDataRowzRoleRow
 
typedef QList< zRoleRowzRoleRowList
 
typedef QMap< int, QVariant > zTableRow
 
typedef QList< zTableRowzTableRowList
 
typedef QMap< int, zDataTablezRoleTable
 

Public Member Functions

 ZblTableData ()
 
void putValue (int role, int row, int col, const QVariant value)
 Replaces the current value of a cell's role. This is a blocking call. with the specified value. More...
 
QVariant getValue (int role, int row, int col) const
 Obtains the value of the specified cell and role. This is a blocking call. More...
 
void putTableColumnRows (QVariant rows, int startRow, int col)
 Replaces the current value for a set of rows for a single model column. More...
 
QVariant getTableColumnRows (QList< int > roles, int startRow, int col, int rowCount) const
 Obtain data values for a set of rows from a single model column. More...
 
bool hasCell (int role, int row, int col) const
 Determines if the specified cell and role combination exists in the data table. More...
 
bool hasCell (int row, int col) const
 Determines if the specified cell exists in the data table. More...
 
void appendRow (zRoleRow data)
 Appends a row of role values to the table data. More...
 
void appendRows (zRoleRowList data)
 Appends a list of rows of role values to the table data. More...
 
void prependRow (zRoleRow data)
 Prepends a row of role values to the table data. More...
 
void prependRows (zRoleRowList data)
 Prepends a list of rows of role values to the table data. More...
 
void removeRows (int row, int count)
 Removes one or more rows from the table. More...
 
void clearData ()
 Removes all rows from the data table. More...
 
bool addRole (int role)
 Adds the specified role to the data table. The table must not contain data rows when calling this method. More...
 
bool hasRole (int role) const
 Determines if a specified role already exists in the data table. More...
 
QList< int > roles () const
 Determines which roles are in the data set. More...
 
int roleCount () const
 Determines the current number of roles in the data table. More...
 
void clearRoles ()
 Removes all roles and data rows from the data table. More...
 
int columnCount () const
 Determines the number of columns in the data table. More...
 
void setColumnCount (int count)
 Sets the number of columns in the data table. This method fails if the data table contains rows. More...
 
int rowCount () const
 Determines the number of rows in the data table. More...
 
void dumpData () const
 Prints diagnostic information about the state of the contained data to debug output. More...
 
int findNextItemRow (int startRow, const QString &text, int column=0, bool caseSensitive=true, bool forwardDirection=true, bool keySearch=false) const
 
bool copyColumn (int fromColumn, int toColumn)
 

Private Member Functions

void pushRow (zRoleRow data, bool front=false)
 

Private Attributes

zFlagsTable m_childFlags
 A two dimensional array of child cell flags. Dimensions of the array are row and column. TBD: Sorry, not yet implemented! More...
 
zRoleTable m_roles
 A three dimensional array of child cell data. Dimensions of the array are role, row and column. More...
 
int m_columnCount
 The number of columns in the child data table. More...
 
int m_rowCount
 The number of rows in the child data table. More...
 

Detailed Description

A table data object contains the role data and model item flags for a 2 dimensional array of model data cells.

A separate table is stored for each role in the data set. Before adding rows you should call addRole() to add roles to the data set and setColumnCount() to set the table size.

TBD: this should be refactored into separate abstract and implementation classes to support selectable cell engines OR the cell engine should be optimized for 2 dimensions.

See also
addRole() setColumnCount()

Definition at line 51 of file ZblTableData.h.

Member Typedef Documentation

◆ zCellValue

typedef QMap<int,QVariant> Zbl::ZblTableData::zCellValue

Definition at line 59 of file ZblTableData.h.

◆ zColumnNames

typedef QList<QString> Zbl::ZblTableData::zColumnNames

Definition at line 55 of file ZblTableData.h.

◆ zDataRow

typedef QList<QVariant> Zbl::ZblTableData::zDataRow

Definition at line 61 of file ZblTableData.h.

◆ zDataTable

Definition at line 63 of file ZblTableData.h.

◆ zFlagsTable

typedef QList<QList<int> > Zbl::ZblTableData::zFlagsTable

Definition at line 57 of file ZblTableData.h.

◆ zRoleRow

Definition at line 65 of file ZblTableData.h.

◆ zRoleRowList

Definition at line 67 of file ZblTableData.h.

◆ zRoleTable

Definition at line 73 of file ZblTableData.h.

◆ zTableRow

typedef QMap<int, QVariant> Zbl::ZblTableData::zTableRow

Definition at line 69 of file ZblTableData.h.

◆ zTableRowList

Definition at line 71 of file ZblTableData.h.

Constructor & Destructor Documentation

◆ ZblTableData()

Zbl::ZblTableData::ZblTableData ( )

Definition at line 32 of file ZblTableData.cpp.

Member Function Documentation

◆ addRole()

bool Zbl::ZblTableData::addRole ( int  role)

Adds the specified role to the data table. The table must not contain data rows when calling this method.

If the data table is already populated with rows an exception is thrown.

Parameters
rolethe role to be added
Returns
true if specified role was added, false if specified role already existed

Definition at line 293 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::addRole().

◆ appendRow()

void Zbl::ZblTableData::appendRow ( zRoleRow  data)

Appends a row of role values to the table data.

Only roles that currently exist in the data table will be appended. Roles that don't exist will be silently ignored. Call the ZblDataTable::addRole() method to add roles to the data table before calling this method.

Parameters
dataa QMap<int, QList<QVariant> >, which is a map containing a list of variants for each role/column
See also
addRole()

Definition at line 195 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::appendRow().

◆ appendRows()

void Zbl::ZblTableData::appendRows ( zRoleRowList  data)

Appends a list of rows of role values to the table data.

Only roles that currently exist in the data table will be appended. Roles that don't exist will be silently ignored. Call the ZblDataTable::addRole() method to add roles to the data table before calling this method.

Parameters
dataa QList<QMap<int, QList<QVariant> > >, which is a list of maps containing a list of variants for each role/row
See also
addRole()

Definition at line 200 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::appendRows().

◆ clearData()

void Zbl::ZblTableData::clearData ( )

Removes all rows from the data table.

Definition at line 262 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::clearData().

◆ clearRoles()

void Zbl::ZblTableData::clearRoles ( )

Removes all roles and data rows from the data table.

Definition at line 284 of file ZblTableData.cpp.

◆ columnCount()

int Zbl::ZblTableData::columnCount ( ) const

Determines the number of columns in the data table.

Returns
current column count

Definition at line 474 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::columnCount().

◆ copyColumn()

bool Zbl::ZblTableData::copyColumn ( int  fromColumn,
int  toColumn 
)

Definition at line 375 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::copyColumn().

◆ dumpData()

void Zbl::ZblTableData::dumpData ( ) const

Prints diagnostic information about the state of the contained data to debug output.

Definition at line 36 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::dumpModelData().

◆ findNextItemRow()

int Zbl::ZblTableData::findNextItemRow ( int  startRow,
const QString &  text,
int  column = 0,
bool  caseSensitive = true,
bool  forwardDirection = true,
bool  keySearch = false 
) const

Definition at line 310 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::findNextItemRow().

◆ getTableColumnRows()

QVariant Zbl::ZblTableData::getTableColumnRows ( QList< int >  roles,
int  startRow,
int  col,
int  rowCount 
) const

Obtain data values for a set of rows from a single model column.

Only data for the model roles specified in the roles parameter will be returned. Data is returned in a zTableRowList structure, which is a list of maps, each of which contains a data value for each role that was requested to be returned.

Parameters
rolesA list of model role values determines which model roles will be returned
startRowThe first model row to return
colThe model column to return
rowCountThe number of rows to return
Returns
A QVariant containing a zTableRowList object containing the requested data

Definition at line 135 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::getTableColumnRows().

◆ getValue()

QVariant Zbl::ZblTableData::getValue ( int  role,
int  row,
int  col 
) const

Obtains the value of the specified cell and role. This is a blocking call.

Parameters
role
row
col
Returns

Definition at line 100 of file ZblTableData.cpp.

Referenced by copyColumn(), Zbl::ZblDataModel::data(), dumpData(), and getTableColumnRows().

◆ hasCell() [1/2]

bool Zbl::ZblTableData::hasCell ( int  role,
int  row,
int  col 
) const

Determines if the specified cell and role combination exists in the data table.

Parameters
role
row
col
Returns
true if the specified role/row/column value exists, false otherwise

Definition at line 182 of file ZblTableData.cpp.

Referenced by getValue(), Zbl::ZblTableCell::hasCell(), and putValue().

◆ hasCell() [2/2]

bool Zbl::ZblTableData::hasCell ( int  row,
int  col 
) const

Determines if the specified cell exists in the data table.

Parameters
row
col
Returns
true if the specified row/column value exists, false otherwise

Definition at line 190 of file ZblTableData.cpp.

◆ hasRole()

bool Zbl::ZblTableData::hasRole ( int  role) const

Determines if a specified role already exists in the data table.

Returns
true if specified role exists, false otherwise

Definition at line 458 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::hasRole().

◆ prependRow()

void Zbl::ZblTableData::prependRow ( zRoleRow  data)

Prepends a row of role values to the table data.

Only roles that currently exist in the data table will be prepended. Roles that don't exist will be silently ignored. Call the ZblDataTable::addRole() method to add roles to the data table before calling this method.

Parameters
dataa QMap<int, QList<QVariant> >, which is a map containing a list of variants for each role/row
See also
addRole()

Definition at line 215 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::prependRow().

◆ prependRows()

void Zbl::ZblTableData::prependRows ( zRoleRowList  data)

Prepends a list of rows of role values to the table data.

Only roles that currently exist in the data table will be prepended. Roles that don't exist will be silently ignored. Call the ZblDataTable::addRole() method to add roles to the data table before calling this method.

Parameters
dataa QList<QMap<int, QList<QVariant> > >, which is a list of maps containing a list of variants for each role/row
See also
addRole()

Definition at line 220 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::prependRows().

◆ pushRow()

void Zbl::ZblTableData::pushRow ( zRoleRow  data,
bool  front = false 
)
private

Definition at line 392 of file ZblTableData.cpp.

Referenced by appendRow(), appendRows(), prependRow(), and prependRows().

◆ putTableColumnRows()

void Zbl::ZblTableData::putTableColumnRows ( QVariant  rows,
int  startRow,
int  col 
)

Replaces the current value for a set of rows for a single model column.

Only data for the model roles specified contained in the rows parameter is replaced. Values for roles not contained in the rows parameter are not modified by this method.

Parameters
rowsA QVaraint containing a zTableRowList structure containing the row data to be replaced
startRowThe row number of the first row to be replaced
colThe column number of the row to be replaced

Definition at line 109 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::putTableColumnRows().

◆ putValue()

void Zbl::ZblTableData::putValue ( int  role,
int  row,
int  col,
const QVariant  value 
)

Replaces the current value of a cell's role. This is a blocking call. with the specified value.

Parameters
role
row
col
value
Exceptions
ZblExceptionif specified role or cell doesn't exist

Definition at line 84 of file ZblTableData.cpp.

Referenced by copyColumn(), putTableColumnRows(), and Zbl::ZblDataModel::setData().

◆ removeRows()

void Zbl::ZblTableData::removeRows ( int  row,
int  count 
)

Removes one or more rows from the table.

Parameters
rowRow number of the first row to remove. Row numbers start at zero.
countThe number of rows to remove.

Definition at line 234 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::removeRows().

◆ roleCount()

int Zbl::ZblTableData::roleCount ( ) const

Determines the current number of roles in the data table.

Returns
current number of roles

Definition at line 468 of file ZblTableData.cpp.

Referenced by copyColumn(), dumpData(), findNextItemRow(), getTableColumnRows(), pushRow(), and Zbl::ZblDataModel::roleCount().

◆ roles()

QList< int > Zbl::ZblTableData::roles ( ) const

Determines which roles are in the data set.

Returns
A list of integers representing the roles currently in the data set.

Definition at line 463 of file ZblTableData.cpp.

Referenced by copyColumn(), dumpData(), putTableColumnRows(), and Zbl::ZblDataModel::roles().

◆ rowCount()

int Zbl::ZblTableData::rowCount ( ) const

Determines the number of rows in the data table.

Returns
current row count

Definition at line 488 of file ZblTableData.cpp.

Referenced by appendRows(), prependRows(), and Zbl::ZblDataModel::rowCount().

◆ setColumnCount()

void Zbl::ZblTableData::setColumnCount ( int  count)

Sets the number of columns in the data table. This method fails if the data table contains rows.

Definition at line 479 of file ZblTableData.cpp.

Referenced by Zbl::ZblDataModel::setColumnCount().

Member Data Documentation

◆ m_childFlags

zFlagsTable Zbl::ZblTableData::m_childFlags
private

A two dimensional array of child cell flags. Dimensions of the array are row and column. TBD: Sorry, not yet implemented!

Definition at line 384 of file ZblTableData.h.

◆ m_columnCount

int Zbl::ZblTableData::m_columnCount
private

The number of columns in the child data table.

Definition at line 401 of file ZblTableData.h.

Referenced by columnCount(), dumpData(), findNextItemRow(), hasCell(), pushRow(), and setColumnCount().

◆ m_roles

zRoleTable Zbl::ZblTableData::m_roles
private

A three dimensional array of child cell data. Dimensions of the array are role, row and column.

Data is arranged as a map of roles, each role consisting of a two dimensional array of variants.

Definition at line 395 of file ZblTableData.h.

Referenced by addRole(), clearData(), clearRoles(), findNextItemRow(), getValue(), hasCell(), hasRole(), pushRow(), putValue(), removeRows(), roleCount(), and roles().

◆ m_rowCount

int Zbl::ZblTableData::m_rowCount
private

The number of rows in the child data table.

Definition at line 407 of file ZblTableData.h.

Referenced by addRole(), clearData(), clearRoles(), copyColumn(), dumpData(), findNextItemRow(), getTableColumnRows(), hasCell(), pushRow(), removeRows(), rowCount(), and setColumnCount().


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