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 Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Properties | Friends | List of all members
Zbl::ZTableModel Class Reference

This two dimensional table model is used to store and manipulate data. More...

#include <ZTableModel.h>

Inheritance diagram for Zbl::ZTableModel:
Inheritance graph
[legend]
Collaboration diagram for Zbl::ZTableModel:
Collaboration graph
[legend]

Public Slots

void moveModelToThread (QThread *targetThread)
 
void invalidateModel ()
 Resets the model. More...
 

Signals

void tableModified (int dataRole, int rowNumber)
 Sent when a table cell has been modified. More...
 
void tableModelReset ()
 Sent when the table model has been reset. More...
 

Public Member Functions

 ZTableModel (QObject *parent=0)
 
int getUserRole ()
 Returns the value of Qt::UserRole. ie: the first role number available for user defined roles. More...
 
int getRoleCount () const
 Returns the number of roles defined for this model. More...
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 QAbstractTableModel override. More...
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 QAbstractTableModel override. More...
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 QAbstractTableModel override. More...
 
virtual QHash< int, QByteArray > roleNames () const
 QAbstractTableModel override. More...
 
Q_INVOKABLE void dumpModelData () const
 dumps diagnostic information about the model to the debug output. More...
 
Q_INVOKABLE void putValue (int role, int row, const QVariant &value)
 Sets the value of the specified cell in the data set. More...
 
Q_INVOKABLE void putValue (int role, int row, int column, const QVariant &value)
 Sets the value of the specified cell in the data set. More...
 
Q_INVOKABLE QVariant getValue (int role, int row)
 Obtains the value of the specified data cell. More...
 
Q_INVOKABLE QVariant getValue (int role, int row, int column)
 Obtains the value of the specified data cell. More...
 
Q_INVOKABLE QVariant getTableColumnRows (QList< int > roles, int startRow, int col, int rowCount)
 Obtain data values for a set of rows from a single model column. More...
 
Q_INVOKABLE void putTableColumnRows (QVariant rows, int startRow, int col)
 Replaces the current value for a set of rows for a single model column. More...
 
Q_INVOKABLE void sendTableColumnRows (QVariant rows, int startRow, int col)
 Asynchronously replaces the current value for a set of rows for a single model column. More...
 
Q_INVOKABLE void appendRow (QVariant data)
 
Q_INVOKABLE void appendRows (QVariant data)
 
Q_INVOKABLE void appendRow (ZRoleRow roleRow)
 
Q_INVOKABLE int appendRowIndex (ZRoleRow roleRow)
 
Q_INVOKABLE void appendRows (ZRoleRowList roleRowList)
 
Q_INVOKABLE void prependRow (QVariant data)
 
Q_INVOKABLE void prependRows (QVariant data)
 
Q_INVOKABLE void prependRow (ZRoleRow roleRow)
 
Q_INVOKABLE void prependRows (ZRoleRowList roleRowList)
 
Q_INVOKABLE void removeRow (int row)
 
Q_INVOKABLE void removeRows (int row, int count)
 
Q_INVOKABLE void truncate (int rowCount, bool removeFromFront=false)
 
Q_INVOKABLE bool copyColumn (int fromColumn, int toColumn)
 
Q_INVOKABLE void appendCells (QVariant data, bool truncateModel=false)
 Asynchronously converts an array of cell data into one or more rows of model data and appends it to the model. More...
 
Q_INVOKABLE void prependCells (QVariant data, bool truncateModel=false)
 Asynchronously converts an array of cell data into one or more rows of model data and prepends it to the model. More...
 
Q_INVOKABLE int modelRowCount () const
 Returns the number of rows in the data set. This method may block the current thread. More...
 
Q_INVOKABLE void setColumnCount (int count)
 Sets the number of columns the table will contain. This method may block the current thread. More...
 
Q_INVOKABLE int modelColumnCount () const
 Returns the number of columns in the data set. This method may block the current thread. More...
 
Q_INVOKABLE bool addRole (int roleNumber)
 Adds the specified role to the data model. This method may block the current thread. More...
 
Q_INVOKABLE bool addRole (int roleNumber, const QString &roleName)
 Adds the specified role to the data model. This method may block the current thread. More...
 
Q_INVOKABLE QList< int > roles () const
 Determines which roles are in the data set. This method may block the current thread. More...
 
Q_INVOKABLE QVariantMap roleMap () const
 Determines which roles are in the data set. This method may block the current thread. More...
 
Q_INVOKABLE void clearRoles ()
 Removes all roles, role names and data from the model. More...
 
Q_INVOKABLE void clearData ()
 Removes all data from the model. Roles and role names remain intact. More...
 
Q_INVOKABLE int findNextItemRow (int startRow, const QString &text, int column=0, bool caseSensitive=true, bool forwardDirection=true, bool keySearch=false) const
 Searches for the specified text from startIndex. More...
 
Q_INVOKABLE void appendMissingRow (ZRoleRow roleRow, const QString &keyText, int keyColumn=0)
 Appends the specified row if no rows contain the specified text in the specified column. Otherwise does nothing. More...
 
Q_INVOKABLE void appendMissingRow (QVariant roleRow, const QString &keyText, int keyColumn=0)
 Appends the specified row if no rows contain the specified text in the specified column. Otherwise does nothing. More...
 
Q_INVOKABLE bool writeData (QVariant jsonData)
 Writes data from the specified JSON object into the data table. Previous data in the table is discarded. More...
 
Q_INVOKABLE QVariant readData () const
 Returns a JSON object containing a copy of the table data. Data in the table is unaffected. Data is formatted as for ZTableModel::writeData(QVariant jsonData) More...
 
Q_INVOKABLE void putJsonData (QJsonObject data)
 Writes data from the specified JSON object into the data table. Previous contents of the data table are lost. More...
 
Q_INVOKABLE QJsonObject getJsonData () const
 Copies data from the table model into a newly created JSON object and returns it. More...
 
Q_INVOKABLE void sync ()
 Blocks thread until model's event queue has been processed. More...
 

Static Public Member Functions

static void registerType ()
 Registers ZTableModel as a QML type. More...
 

Protected Member Functions

void insertTableColumnRows (QVariant rows, int startRow, int col, bool asynchronous)
 
Q_INVOKABLE void mergeCells (QVariant data, bool front=true, bool truncateModel=true)
 Converts an array of cell data into one or more rows of model data and either appends or prepends it to the model. More...
 
ZRoleRow coalesceCellRow (const ZDataRow cells, int startIndex, int columnCount, const QList< int > roles, int &nextIndex)
 
ZRoleRowList coalesceCellRows (const ZDataRow cells, int columnCount, const QList< int > roles)
 

Static Protected Member Functions

static void registerLogCategory ()
 

Protected Attributes

ZblDataModel m_model
 
int m_defaultRole
 The role used for data access methods that don't specify a role. More...
 

Properties

int userRole
 Returns the value of Qt::UserRole to javascript client code. ie: the first role number available for user defined roles. More...
 
int roleCount
 Returns the number of roles defined for this model. More...
 

Friends

class ZblLogManager
 

Detailed Description

This two dimensional table model is used to store and manipulate data.

Data models provide a means of transferring data between Zuble threads and QML views. Data is typically transferred from background to foreground threads for display purposes, however the models can support transferring data between any thread.

When transferring data between threads create the data model in the data consumer thread and then pass a reference to the model to the data producer thread.

This table is backed by an N-dimensional data storage engine. Set the column count > 1 and use getValue(int role, int row, int column), appendCells(), and prependCells() to access third dimension.

Definition at line 96 of file ZTableModel.h.

Constructor & Destructor Documentation

◆ ZTableModel()

Zbl::ZTableModel::ZTableModel ( QObject *  parent = 0)
explicit

Definition at line 41 of file ZTableModel.cpp.

Member Function Documentation

◆ addRole() [1/2]

bool Zbl::ZTableModel::addRole ( int  roleNumber)

Adds the specified role to the data model. This method may block the current thread.

This method must be called before adding rows to the table. It will fail if called when the table contains data.

Parameters
roleNumberThe role number to add.

Definition at line 946 of file ZTableModel.cpp.

Referenced by addRole(), Zbl::ZblLogManager::createLogBufferModel(), Zbl::ZblLogReclinkData::createMapModel(), Zbl::ZblLogManager::createRuleModel(), Zbl::ZblLogManager::getLogRules(), Zbl::ZLogMap::getReader(), Zbl::ZblLogSearch::getSearchRolesName(), Zbl::ZsqlQuery::getTableModel(), Zbl::ZLogBookmark::logMapType(), and Zbl::ZLogViewport::ZLogViewport().

◆ addRole() [2/2]

bool Zbl::ZTableModel::addRole ( int  roleNumber,
const QString &  roleName 
)

Adds the specified role to the data model. This method may block the current thread.

This method must be called before adding rows to the table. It will fail if called when the table contains data.

Parameters
roleNumberThe role number to add.
roleNameName of the role to add.

Definition at line 968 of file ZTableModel.cpp.

◆ appendCells()

void Zbl::ZTableModel::appendCells ( QVariant  data,
bool  truncateModel = false 
)

Asynchronously converts an array of cell data into one or more rows of model data and appends it to the model.

Data cells are assigned to roles in ascending order from smallest to largest role number. The cell array must contain an integral number of cells such that no row is incomplete. (ie cell count must be modulo role count)

Parameters
dataA QVariant containing a ZDataRow object (QList<QVariant>). Javascript can pass an Array object. (ie. multiple roles/cell)
truncateModeltrue to remove an equal number of rows from the opposite side of the model, false to leave model intact

Definition at line 736 of file ZTableModel.cpp.

Referenced by Zbl::ZLogReader::appendSearchModel(), Zbl::ZLogMap::getReader(), Zbl::ZblLogReclinkData::onSearchRowMatched(), Zbl::ZblLogWorker::outputLogMessage(), Zbl::ZblLogAgent::outputLogMessage(), Zbl::ZblLogSearch::populateLinkModel(), and Zbl::ZblLogReader::storeViewportData().

◆ appendMissingRow() [1/2]

void Zbl::ZTableModel::appendMissingRow ( ZRoleRow  roleRow,
const QString &  keyText,
int  keyColumn = 0 
)

Appends the specified row if no rows contain the specified text in the specified column. Otherwise does nothing.

Parameters
roleRowdata row to append if text not found
keyTextthe text to search for
columnthe column to search (default = 0)

Definition at line 417 of file ZTableModel.cpp.

Referenced by appendMissingRow(), and Zbl::ZblLogManager::appendRuleModelCategory().

◆ appendMissingRow() [2/2]

void Zbl::ZTableModel::appendMissingRow ( QVariant  roleRow,
const QString &  keyText,
int  keyColumn = 0 
)

Appends the specified row if no rows contain the specified text in the specified column. Otherwise does nothing.

Parameters
roleRowdata row to append if text not found
keyTextthe text to search for
columnthe column to search (default = 0)

Definition at line 385 of file ZTableModel.cpp.

◆ appendRow() [1/2]

void Zbl::ZTableModel::appendRow ( QVariant  data)

Definition at line 251 of file ZTableModel.cpp.

Referenced by appendMissingRow(), appendRow(), mergeCells(), and putJsonData().

◆ appendRow() [2/2]

void Zbl::ZTableModel::appendRow ( ZRoleRow  roleRow)

Definition at line 307 of file ZTableModel.cpp.

◆ appendRowIndex()

int Zbl::ZTableModel::appendRowIndex ( ZRoleRow  roleRow)

Definition at line 332 of file ZTableModel.cpp.

◆ appendRows() [1/2]

void Zbl::ZTableModel::appendRows ( QVariant  data)

Definition at line 280 of file ZTableModel.cpp.

Referenced by appendRows(), Zbl::ZsqlQuery::getTableModel(), and mergeCells().

◆ appendRows() [2/2]

void Zbl::ZTableModel::appendRows ( ZRoleRowList  roleRowList)

Definition at line 360 of file ZTableModel.cpp.

◆ clearData()

void Zbl::ZTableModel::clearData ( )

Removes all data from the model. Roles and role names remain intact.

Definition at line 139 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogReader::loadViewport(), and Zbl::ZLogReader::purgeSearchModel().

◆ clearRoles()

void Zbl::ZTableModel::clearRoles ( )

Removes all roles, role names and data from the model.

Definition at line 128 of file ZTableModel.cpp.

Referenced by Zbl::ZLogMap::getReader(), putJsonData(), and Zbl::ZTableFile::readFile().

◆ coalesceCellRow()

ZRoleRow Zbl::ZTableModel::coalesceCellRow ( const ZDataRow  cells,
int  startIndex,
int  columnCount,
const QList< int >  roles,
int &  nextIndex 
)
protected

Definition at line 669 of file ZTableModel.cpp.

Referenced by coalesceCellRows(), and mergeCells().

◆ coalesceCellRows()

ZRoleRowList Zbl::ZTableModel::coalesceCellRows ( const ZDataRow  cells,
int  columnCount,
const QList< int >  roles 
)
protected

Definition at line 706 of file ZTableModel.cpp.

Referenced by mergeCells().

◆ columnCount()

int Zbl::ZTableModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

QAbstractTableModel override.

Definition at line 81 of file ZTableModel.cpp.

Referenced by coalesceCellRow(), coalesceCellRows(), and data().

◆ copyColumn()

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

Definition at line 642 of file ZTableModel.cpp.

◆ data()

QVariant Zbl::ZTableModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

QAbstractTableModel override.

Definition at line 93 of file ZTableModel.cpp.

◆ dumpModelData()

void Zbl::ZTableModel::dumpModelData ( ) const

dumps diagnostic information about the model to the debug output.

Definition at line 150 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::populateRegisteredRules().

◆ findNextItemRow()

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

Searches for the specified text from startIndex.

Parameters
startRowindex of the first row to search
textthe text to search for
caseSEnsitivetrue for case sensitive search, false for case insensitive (default = true)
forwardDirectiontrue to search forward, false to search backward (default = true)
columnthe column to search (default = 0)
keySearchwhen true column text must match exactly, when false any part of column can match (default = false)
Returns
Row number of the next row containing the search term or -1 if no row was found.

Definition at line 1204 of file ZTableModel.cpp.

◆ getJsonData()

QJsonObject Zbl::ZTableModel::getJsonData ( ) const

Copies data from the table model into a newly created JSON object and returns it.

Returns
A JSON object in the same format as for ZTableModel::putJsonData()
See also
putJsonData(QJsonObject jsonData)

Definition at line 1345 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::saveFilterRules(), and Zbl::ZTableFile::writeFile().

◆ getRoleCount()

int Zbl::ZTableModel::getRoleCount ( ) const

Returns the number of roles defined for this model.

Returns
role count

Definition at line 991 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::createLogBufferModel().

◆ getTableColumnRows()

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

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 1123 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogScanner::scanModelColumnRows().

◆ getUserRole()

int Zbl::ZTableModel::getUserRole ( )

Returns the value of Qt::UserRole. ie: the first role number available for user defined roles.

Definition at line 58 of file ZTableModel.cpp.

◆ getValue() [1/2]

QVariant Zbl::ZTableModel::getValue ( int  role,
int  row 
)

◆ getValue() [2/2]

QVariant Zbl::ZTableModel::getValue ( int  role,
int  row,
int  column 
)

Obtains the value of the specified data cell.

This method allows access to the third dimension of the data model that backs ZTableModel. Use ZTableModel::setColumnCount() to set the number of columns in the third dimension.

Parameters
rolethe role whose value to return
rowthe cell's zero-based row number
columnthe cell's zero-based column number
Returns
the value stored in the specified cell

Definition at line 1096 of file ZTableModel.cpp.

◆ insertTableColumnRows()

void Zbl::ZTableModel::insertTableColumnRows ( QVariant  rows,
int  startRow,
int  col,
bool  asynchronous 
)
protected

Definition at line 1180 of file ZTableModel.cpp.

Referenced by putTableColumnRows(), and sendTableColumnRows().

◆ invalidateModel

void Zbl::ZTableModel::invalidateModel ( )
slot

◆ mergeCells()

void Zbl::ZTableModel::mergeCells ( QVariant  data,
bool  front = true,
bool  truncateModel = true 
)
protected

Converts an array of cell data into one or more rows of model data and either appends or prepends it to the model.

Parameters
dataA QVariant containing a ZDataRow object (QList<QVariant>). Javascript can pass an Array object.
fronttrue to prepend rows, false to append rows
truncateModeltrue to remove an equal number of rows from the opposite side of the model, false to leave model intact

Definition at line 776 of file ZTableModel.cpp.

Referenced by appendCells(), and prependCells().

◆ modelColumnCount()

int Zbl::ZTableModel::modelColumnCount ( ) const

Returns the number of columns in the data set. This method may block the current thread.

Note that the QAbstractTableModel interface allows access to only column zero. Additional columns are accessed through ZTableModel's custom interface.

Definition at line 889 of file ZTableModel.cpp.

Referenced by Zbl::ZLogViewport::loadRecords(), and Zbl::ZLogViewport::move().

◆ modelRowCount()

int Zbl::ZTableModel::modelRowCount ( ) const

◆ moveModelToThread

void Zbl::ZTableModel::moveModelToThread ( QThread *  targetThread)
slot

Definition at line 1422 of file ZTableModel.cpp.

◆ prependCells()

void Zbl::ZTableModel::prependCells ( QVariant  data,
bool  truncateModel = false 
)

Asynchronously converts an array of cell data into one or more rows of model data and prepends it to the model.

Parameters
dataA QVariant containing a ZRoleRow object (QList<QVariant>). Javascript can pass an Array object. (ie. multiple roles/cell)
truncateModeltrue to remove an equal number of rows from the opposite side of the model, false to leave model intact

Definition at line 757 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogReader::parseAndStoreViewportData().

◆ prependRow() [1/2]

void Zbl::ZTableModel::prependRow ( QVariant  data)

Definition at line 456 of file ZTableModel.cpp.

Referenced by mergeCells(), and prependRow().

◆ prependRow() [2/2]

void Zbl::ZTableModel::prependRow ( ZRoleRow  roleRow)

Definition at line 512 of file ZTableModel.cpp.

◆ prependRows() [1/2]

void Zbl::ZTableModel::prependRows ( QVariant  data)

Definition at line 485 of file ZTableModel.cpp.

Referenced by mergeCells(), and prependRows().

◆ prependRows() [2/2]

void Zbl::ZTableModel::prependRows ( ZRoleRowList  roleRowList)

Definition at line 537 of file ZTableModel.cpp.

◆ putJsonData()

void Zbl::ZTableModel::putJsonData ( QJsonObject  data)

Writes data from the specified JSON object into the data table. Previous contents of the data table are lost.

The JSON object should be formatted to contain the following keys:

  • roles - a json object containing role number keys and role name values
  • data-rows - an array of arrays of row data values

Example:

{"roles": {
    "4":"col-0-role-name",
    "5":"col-1-role-name",
    "10":"col-2-role-name"
    }
 "data-rows": [
   ["row-0-col-0-value","row-0-col-1-value","row-0-col-2-value"]
   ["row-1-col-0-value","row-1-col-1-value","row-1-col-2-value"]
  ]}

The zero-based column number is the index into the roles array for that column. (ie: roles[0] locates the first column, roles[2] locates the last column)

Parameters
dataa JSON object with the specified format.
Exceptions
Zbl::ZblException

Definition at line 1240 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::loadFilterRules(), and Zbl::ZTableFile::readFile().

◆ putTableColumnRows()

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

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

This method will block if this object is not in the same thread as the caller. Only data for the model roles 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 1154 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogScanner::scanModelColumnRows().

◆ putValue() [1/2]

void Zbl::ZTableModel::putValue ( int  role,
int  row,
const QVariant &  value 
)

Sets the value of the specified cell in the data set.

Definition at line 172 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogSearch::onLinkTextComplete(), Zbl::ZLogViewport::onRowMatched(), and Zbl::ZLogViewport::onUpdateBookmarks().

◆ putValue() [2/2]

void Zbl::ZTableModel::putValue ( int  role,
int  row,
int  column,
const QVariant &  value 
)

Sets the value of the specified cell in the data set.

Definition at line 210 of file ZTableModel.cpp.

◆ readData()

Q_INVOKABLE QVariant Zbl::ZTableModel::readData ( ) const

Returns a JSON object containing a copy of the table data. Data in the table is unaffected. Data is formatted as for ZTableModel::writeData(QVariant jsonData)

Returns
a JSON object

◆ registerLogCategory()

void Zbl::ZTableModel::registerLogCategory ( )
staticprotected

Definition at line 47 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::zInit().

◆ registerType()

void Zbl::ZTableModel::registerType ( )
static

Registers ZTableModel as a QML type.

Definition at line 52 of file ZTableModel.cpp.

Referenced by Zbl::Zblcore::registerTypes().

◆ removeRow()

void Zbl::ZTableModel::removeRow ( int  row)

Definition at line 566 of file ZTableModel.cpp.

Referenced by Zbl::ZLogReader::removeSearchModel().

◆ removeRows()

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

Definition at line 571 of file ZTableModel.cpp.

Referenced by removeRow(), and truncate().

◆ roleMap()

QVariantMap Zbl::ZTableModel::roleMap ( ) const

Determines which roles are in the data set. This method may block the current thread.

Returns
A map of current role names to role numbers.

Definition at line 1033 of file ZTableModel.cpp.

◆ roleNames()

QHash< int, QByteArray > Zbl::ZTableModel::roleNames ( ) const
virtual

QAbstractTableModel override.

Definition at line 119 of file ZTableModel.cpp.

Referenced by dumpModelData(), getJsonData(), and roleMap().

◆ roles()

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

Determines which roles are in the data set. This method may block the current thread.

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

Definition at line 1012 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::createRuleModel(), getJsonData(), and mergeCells().

◆ rowCount()

int Zbl::ZTableModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

◆ sendTableColumnRows()

void Zbl::ZTableModel::sendTableColumnRows ( QVariant  rows,
int  startRow,
int  col 
)

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

This method is the same as putTableColumnRows() except that this method returns immediately and performs the model update some time in the future. Note that readers of the model will continue to see old model data for the specified cells until the asynchronous update occurrs.

Only data for the model roles 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 1167 of file ZTableModel.cpp.

◆ setColumnCount()

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

Sets the number of columns the table will contain. This method may block the current thread.

Although the table model allows only 2 dimensions (row X role) to be accessed through the QAbstractTableModel interface the ZTableModel class provides an additional axis of data storage (row X role X column) that is accessible through ZTableModel's custom interface.

This method must be called before adding rows to the table. It will fail if called when the table contains data.

Parameters
countThe number of columns to allocate for the data model.

Definition at line 927 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogManager::createLogBufferModel(), Zbl::ZblLogReclinkData::createMapModel(), Zbl::ZblLogManager::createRuleModel(), Zbl::ZLogMap::getReader(), Zbl::ZsqlQuery::getTableModel(), and Zbl::ZLogViewport::ZLogViewport().

◆ sync()

void Zbl::ZTableModel::sync ( )

Blocks thread until model's event queue has been processed.

This method should be called by background threads after updating the data model to ensure updates have completed before using model.

Definition at line 910 of file ZTableModel.cpp.

Referenced by Zbl::ZblLogReader::move(), and Zbl::ZblLogManager::saveFilterRules().

◆ tableModelReset

void Zbl::ZTableModel::tableModelReset ( )
signal

Sent when the table model has been reset.

See also
ZTableModel::invalidateModel()

◆ tableModified

void Zbl::ZTableModel::tableModified ( int  dataRole,
int  rowNumber 
)
signal

Sent when a table cell has been modified.

Parameters
dataRoleThe role number that was modified
rowNumberThe row that was modified

Referenced by Zbl::ZblLogManager::createRuleModel(), and putValue().

◆ truncate()

void Zbl::ZTableModel::truncate ( int  rowCount,
bool  removeFromFront = false 
)

◆ writeData()

Q_INVOKABLE bool Zbl::ZTableModel::writeData ( QVariant  jsonData)

Writes data from the specified JSON object into the data table. Previous data in the table is discarded.

The JSON object should be formatted to contain the following keys:

  • column-names - an array of column/role names
  • column-headers - an array of column headers (optional)
  • data - an array of arrays of row data

Column names will become role names in the data model. Example:

{"column-names": [ "col-1","col-2","col-3"] "column-headers": [ "header-1","header-2","header-3"] "data": [ ["value-1","value-2","value-3"] ["value-4","value-5","value-6"] ]}

Parameters
jsonDataa JSON object constructed with the specified format
Returns
Returns true if successful; otherwise returns false.

Friends And Related Function Documentation

◆ ZblLogManager

friend class ZblLogManager
friend

Definition at line 100 of file ZTableModel.h.

Member Data Documentation

◆ m_defaultRole

int Zbl::ZTableModel::m_defaultRole
protected

The role used for data access methods that don't specify a role.

Definition at line 661 of file ZTableModel.h.

◆ m_model

ZblDataModel Zbl::ZTableModel::m_model
protected

Property Documentation

◆ roleCount

int Zbl::ZTableModel::roleCount
read

Returns the number of roles defined for this model.

Definition at line 125 of file ZTableModel.h.

Referenced by coalesceCellRow(), coalesceCellRows(), getJsonData(), mergeCells(), and putJsonData().

◆ userRole

int Zbl::ZTableModel::userRole
read

Returns the value of Qt::UserRole to javascript client code. ie: the first role number available for user defined roles.

Definition at line 119 of file ZTableModel.h.


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