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
|
This class is an implementation of an N+1 dimensional data store suitable for use as a generic QAbstractItemModel data container. More...
#include <ZblDataModel.h>
Public Types | |
typedef QHash< int, QByteArray > | zRoleNames |
Public Member Functions | |
ZblDataModel () | |
~ZblDataModel () | |
void | setColumnCount (int count, ZblTableCell *cell=NULL) |
Sets the number of columns in the data table. This method fails if the data table contains rows. More... | |
int | columnCount (const ZblTableCell *cell=NULL) const |
int | rowCount (const ZblTableCell *cell=NULL) const |
QVariant | data (int role, int row, int col, const ZblTableCell *cell=NULL) const |
void | setData (int role, int row, int col, const QVariant &value, ZblTableCell *cell=NULL) |
QVariant | getTableColumnRows (QList< int > roles, int startRow, int col, int rowCount, ZblTableCell *cell=NULL) const |
void | putTableColumnRows (QVariant rows, int startRow, int col, ZblTableCell *cell=NULL) |
void | appendRow (QMap< int, QList< QVariant > > data, ZblTableCell *cell=NULL) |
void | appendRows (QList< QMap< int, QList< QVariant > > > data, ZblTableCell *cell=NULL) |
void | prependRow (QMap< int, QList< QVariant > > data, ZblTableCell *cell=NULL) |
void | prependRows (QList< QMap< int, QList< QVariant > > > data, ZblTableCell *cell=NULL) |
void | removeRows (int row, int count, ZblTableCell *cell=NULL) |
Removes the specified data rows from the model. More... | |
bool | addRole (int roleNumber, ZblTableCell *cell=NULL) |
Adds the specified role to the data table. More... | |
bool | addRole (int roleNumber, const QByteArray &roleName, ZblTableCell *cell=NULL) |
Adds the specified role to the data table. More... | |
bool | hasRole (int role, const ZblTableCell *cell=NULL) const |
Determines if a specified role already exists in the data table. More... | |
QList< int > | roles (const ZblTableCell *cell=NULL) const |
Determines which roles are in the data set. More... | |
zRoleNames | roleNames () const |
Obtains a hash that maps role numbers to role names. More... | |
int | roleCount (const ZblTableCell *cell=NULL) const |
Obtains the number of roles contained by the specified cell. More... | |
void | clearData (ZblTableCell *cell=NULL) |
Removes all data rows from the specified table cell. More... | |
void | clearRoles () |
Removes all information from the model and returns the model to it's uninitialized state. More... | |
void | dumpModelData (const ZblTableCell *cell=NULL) 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 ZblTableCell *cell=NULL) const |
Searches for the specified text from startIndex. More... | |
bool | copyColumn (int fromColumn, int toColumn, ZblTableCell *cell=NULL) |
Copies data between data model columns for all rows and roles in the model. More... | |
Protected Member Functions | |
ZblTableHeaders & | headers () |
ZblTableCell & | colNamesCell () |
ZblTableCell & | rootCell () |
const ZblTableCell & | constRootCell () const |
Private Attributes | |
ZblTableHeaders * | m_headers |
This object contains row and column header values for the model. More... | |
ZblTableCell * | m_columnNames |
The cell containing column names if column names have been set. TBD: do we need column names? roles have subsumed this? More... | |
zRoleNames * | m_roleNames |
A hash of role value/name pairs. More... | |
ZblTableCell * | m_rootCell |
The model's root cell contains the top level items. The root cell has no parent. More... | |
This class is an implementation of an N+1 dimensional data store suitable for use as a generic QAbstractItemModel data container.
It can be internally configured to store any data structure the item data model can represent. Optimizations are possible for typical configurations such as list, table and tree.
The data model is composed of cell data, role name, model header and column name components. Lazy allocation is employed for these subcomponents.
Internally the data store uses the composite design pattern to define a table cell which contains the role data for it's child cells. If a table cell's child cells have children the table cell contains a table of child cell objects to contain their data.
This class is reentrant but not thread safe.
Definition at line 62 of file ZblDataModel.h.
typedef QHash<int, QByteArray> Zbl::ZblDataModel::zRoleNames |
Definition at line 66 of file ZblDataModel.h.
Zbl::ZblDataModel::ZblDataModel | ( | ) |
Definition at line 32 of file ZblDataModel.cpp.
Zbl::ZblDataModel::~ZblDataModel | ( | ) |
Definition at line 41 of file ZblDataModel.cpp.
bool Zbl::ZblDataModel::addRole | ( | int | roleNumber, |
ZblTableCell * | cell = NULL |
||
) |
Adds the specified role to the data table.
roleNumber | id number for the role to be added |
cell | the table cell object to which the role will be added, NULL selects the table root cell |
Definition at line 229 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::addRole(), and Zbl::ZTableModel::putJsonData().
bool Zbl::ZblDataModel::addRole | ( | int | roleNumber, |
const QByteArray & | roleName, | ||
ZblTableCell * | cell = NULL |
||
) |
Adds the specified role to the data table.
roleNumber | id number for the role to be added |
roleName | name for the role (must be unique) |
cell | the table cell object to which the role will be added, NULL selects the table root cell |
Definition at line 237 of file ZblDataModel.cpp.
void Zbl::ZblDataModel::appendRow | ( | QMap< int, QList< QVariant > > | data, |
ZblTableCell * | cell = NULL |
||
) |
Definition at line 162 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::appendRow(), and Zbl::ZTableModel::appendRowIndex().
void Zbl::ZblDataModel::appendRows | ( | QList< QMap< int, QList< QVariant > > > | data, |
ZblTableCell * | cell = NULL |
||
) |
Definition at line 181 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::appendRows().
void Zbl::ZblDataModel::clearData | ( | ZblTableCell * | cell = NULL | ) |
Removes all data rows from the specified table cell.
cell | the table cell object for which rows will be removed, NULL selects the table root cell |
Definition at line 321 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::clearData().
void Zbl::ZblDataModel::clearRoles | ( | ) |
Removes all information from the model and returns the model to it's uninitialized state.
This includes roles, data rows, row headers, column headers and column names for the root cell and all descendants.
cell | the table cell object for which roles and rows will be removed, NULL selects the table root cell |
Definition at line 329 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::clearRoles().
|
protected |
Definition at line 305 of file ZblDataModel.cpp.
int Zbl::ZblDataModel::columnCount | ( | const ZblTableCell * | cell = NULL | ) | const |
Definition at line 65 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::columnCount(), Zbl::ZTableModel::mergeCells(), and Zbl::ZTableModel::modelColumnCount().
|
protected |
Definition at line 374 of file ZblDataModel.cpp.
Referenced by columnCount(), data(), dumpModelData(), findNextItemRow(), getTableColumnRows(), hasRole(), roleCount(), roles(), and rowCount().
bool Zbl::ZblDataModel::copyColumn | ( | int | fromColumn, |
int | toColumn, | ||
ZblTableCell * | cell = NULL |
||
) |
Copies data between data model columns for all rows and roles in the model.
fromColumn | Column from which data will be copied |
toColumn | Column to which data will be copied |
cell | the table cell to act on |
Definition at line 288 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::copyColumn().
QVariant Zbl::ZblDataModel::data | ( | int | role, |
int | row, | ||
int | col, | ||
const ZblTableCell * | cell = NULL |
||
) | const |
Definition at line 81 of file ZblDataModel.cpp.
Referenced by appendRow(), appendRows(), Zbl::ZTableModel::data(), Zbl::ZTableModel::getJsonData(), Zbl::ZTableModel::getValue(), prependRow(), and prependRows().
void Zbl::ZblDataModel::dumpModelData | ( | const ZblTableCell * | cell = NULL | ) | const |
Prints diagnostic information about the state of the contained data to debug output.
Definition at line 280 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::dumpModelData().
int Zbl::ZblDataModel::findNextItemRow | ( | int | startRow, |
const QString & | text, | ||
int | column = 0 , |
||
bool | caseSensitive = true , |
||
bool | forwardDirection = true , |
||
bool | keySearch = false , |
||
const ZblTableCell * | cell = NULL |
||
) | const |
Searches for the specified text from startIndex.
Definition at line 379 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::appendMissingRow(), and Zbl::ZTableModel::findNextItemRow().
QVariant Zbl::ZblDataModel::getTableColumnRows | ( | QList< int > | roles, |
int | startRow, | ||
int | col, | ||
int | rowCount, | ||
ZblTableCell * | cell = NULL |
||
) | const |
Definition at line 116 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::getTableColumnRows().
bool Zbl::ZblDataModel::hasRole | ( | int | role, |
const ZblTableCell * | cell = NULL |
||
) | const |
Determines if a specified role already exists in the data table.
Definition at line 256 of file ZblDataModel.cpp.
|
protected |
Definition at line 297 of file ZblDataModel.cpp.
void Zbl::ZblDataModel::prependRow | ( | QMap< int, QList< QVariant > > | data, |
ZblTableCell * | cell = NULL |
||
) |
Definition at line 191 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::prependRow().
void Zbl::ZblDataModel::prependRows | ( | QList< QMap< int, QList< QVariant > > > | data, |
ZblTableCell * | cell = NULL |
||
) |
Definition at line 210 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::prependRows().
void Zbl::ZblDataModel::putTableColumnRows | ( | QVariant | rows, |
int | startRow, | ||
int | col, | ||
ZblTableCell * | cell = NULL |
||
) |
Definition at line 137 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::insertTableColumnRows().
void Zbl::ZblDataModel::removeRows | ( | int | row, |
int | count, | ||
ZblTableCell * | cell = NULL |
||
) |
Removes the specified data rows from the model.
row | row number of the first row to remove |
count | number of rows to remove |
cell | table cell to remove rows from, NULL to use root cell |
Definition at line 220 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::removeRows().
int Zbl::ZblDataModel::roleCount | ( | const ZblTableCell * | cell = NULL | ) | const |
Obtains the number of roles contained by the specified cell.
cell | the table cell object for which role numbers wll be returned, NULL selects the table root cell |
Definition at line 272 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::getRoleCount(), and Zbl::ZTableModel::mergeCells().
ZblDataModel::zRoleNames Zbl::ZblDataModel::roleNames | ( | ) | const |
Obtains a hash that maps role numbers to role names.
cell | the table cell object for which role numbers wll be returned, NULL selects the table root cell |
Definition at line 313 of file ZblDataModel.cpp.
Referenced by clearRoles(), and Zbl::ZTableModel::roleNames().
QList< int > Zbl::ZblDataModel::roles | ( | const ZblTableCell * | cell = NULL | ) | const |
Determines which roles are in the data set.
Definition at line 264 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::mergeCells(), and Zbl::ZTableModel::roles().
|
protected |
Definition at line 369 of file ZblDataModel.cpp.
Referenced by addRole(), appendRow(), appendRows(), clearData(), colNamesCell(), copyColumn(), prependRow(), prependRows(), putTableColumnRows(), removeRows(), setColumnCount(), and setData().
int Zbl::ZblDataModel::rowCount | ( | const ZblTableCell * | cell = NULL | ) | const |
Definition at line 73 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::appendRow(), Zbl::ZTableModel::appendRowIndex(), Zbl::ZTableModel::appendRows(), Zbl::ZTableModel::mergeCells(), Zbl::ZTableModel::modelRowCount(), Zbl::ZTableModel::rowCount(), and Zbl::ZTableModel::truncate().
void Zbl::ZblDataModel::setColumnCount | ( | int | count, |
ZblTableCell * | cell = NULL |
||
) |
Sets the number of columns in the data table. This method fails if the data table contains rows.
Definition at line 57 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::setColumnCount().
void Zbl::ZblDataModel::setData | ( | int | role, |
int | row, | ||
int | col, | ||
const QVariant & | value, | ||
ZblTableCell * | cell = NULL |
||
) |
Definition at line 93 of file ZblDataModel.cpp.
Referenced by Zbl::ZTableModel::putValue().
|
private |
The cell containing column names if column names have been set. TBD: do we need column names? roles have subsumed this?
Definition at line 268 of file ZblDataModel.h.
Referenced by clearRoles(), colNamesCell(), and ~ZblDataModel().
|
private |
This object contains row and column header values for the model.
Definition at line 260 of file ZblDataModel.h.
Referenced by clearRoles(), headers(), and ~ZblDataModel().
|
private |
A hash of role value/name pairs.
Definition at line 274 of file ZblDataModel.h.
Referenced by addRole(), clearRoles(), roleNames(), and ~ZblDataModel().
|
private |
The model's root cell contains the top level items. The root cell has no parent.
Definition at line 281 of file ZblDataModel.h.
Referenced by clearRoles(), constRootCell(), rootCell(), and ~ZblDataModel().
Zuble documentation copyright © 2019 Bob Dinitto. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Zuble is a derivative work of Qt version 5. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.