31 #include <QAbstractTableModel> 34 #include <QJsonObject> 35 #include <QItemSelection> 146 virtual
int rowCount(const QModelIndex & parent = QModelIndex()) const;
152 virtual
int columnCount(const QModelIndex & parent = QModelIndex()) const;
157 virtual QVariant
data(
158 const QModelIndex & index,
159 int role = Qt::DisplayRole) const;
166 virtual QHash<
int, QByteArray>
roleNames() const;
183 Q_INVOKABLE
void putValue(
int role,
int row, const QVariant& value);
189 Q_INVOKABLE
void putValue(
int role,
int row,
int column, const QVariant& value);
198 Q_INVOKABLE QVariant
getValue(
int role,
int row);
213 Q_INVOKABLE QVariant
getValue(
int role,
int row,
int column);
295 Q_INVOKABLE
void appendRow(ZRoleRow roleRow);
299 Q_INVOKABLE
void appendRows(ZRoleRowList roleRowList);
305 Q_INVOKABLE
void prependRow(ZRoleRow roleRow);
307 Q_INVOKABLE
void prependRows(ZRoleRowList roleRowList);
311 Q_INVOKABLE
void removeRows(
int row,
int count);
313 Q_INVOKABLE
void truncate(
int rowCount,
bool removeFromFront = false);
315 Q_INVOKABLE
bool copyColumn(
int fromColumn,
int toColumn);
335 Q_INVOKABLE
void appendCells(QVariant data,
bool truncateModel=false);
347 Q_INVOKABLE
void prependCells(QVariant data,
bool truncateModel=false);
395 Q_INVOKABLE
bool addRole(
int roleNumber);
408 Q_INVOKABLE
bool addRole(
int roleNumber, const QString& roleName);
417 Q_INVOKABLE QList<
int> roles() const;
425 Q_INVOKABLE QVariantMap
roleMap() const;
464 bool caseSensitive = true,
465 bool forwardDirection = true,
466 bool keySearch = false
480 const QString& keyText,
492 const QString& keyText,
525 Q_INVOKABLE
bool writeData(QVariant jsonData);
536 Q_INVOKABLE QVariant
readData() const;
587 Q_INVOKABLE
void sync();
640 Q_INVOKABLE
void mergeCells(QVariant data,
bool front=true,
bool truncateModel=true);
647 const QList<
int> roles,
651 const ZDataRow cells,
653 const QList<
int> roles);
669 Q_DECLARE_METATYPE(
Zbl::ZRoleNames)
671 Q_DECLARE_METATYPE(
Zbl::ZDataRow)
672 Q_DECLARE_METATYPE(
Zbl::ZRoleRow)
673 Q_DECLARE_METATYPE(
Zbl::ZRoleRowList)
677 #endif // ZTABLEMODEL_H The Zuble Log Manager is a singleton object that controls logging in Zuble applications.
void tableModified(int dataRole, int rowNumber)
Sent when a table cell has been modified.
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.
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 ...
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
QAbstractTableModel override.
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 t...
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)
#define ZBL_DECLARE_LOGGED_OBJECT
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QAbstractTableModel override.
Q_INVOKABLE void clearData()
Removes all data from the model. Roles and role names remain intact.
int getUserRole()
Returns the value of Qt::UserRole. ie: the first role number available for user defined roles...
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
QAbstractTableModel override.
Q_INVOKABLE int appendRowIndex(ZRoleRow roleRow)
void moveModelToThread(QThread *targetThread)
Q_INVOKABLE QJsonObject getJsonData() const
Copies data from the table model into a newly created JSON object and returns it. ...
Q_INVOKABLE void putValue(int role, int row, const QVariant &value)
Sets the value of the specified cell in the data set.
Q_INVOKABLE void prependRow(QVariant data)
int getRoleCount() const
Returns the number of roles defined for this model.
Q_INVOKABLE void truncate(int rowCount, bool removeFromFront=false)
Q_INVOKABLE QVariantMap roleMap() const
Determines which roles are in the data set. This method may block the current thread.
void invalidateModel()
Resets the model.
Q_INVOKABLE void dumpModelData() const
dumps diagnostic information about the model to the debug output.
ZRoleRowList coalesceCellRows(const ZDataRow cells, int columnCount, const QList< int > roles)
Q_INVOKABLE QList< int > roles() const
Determines which roles are in the data set. This method may block the current thread.
Q_INVOKABLE QVariant getValue(int role, int row)
Obtains the value of the specified data cell.
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.
int m_defaultRole
The role used for data access methods that don't specify a role.
Q_INVOKABLE void appendRows(QVariant data)
QMap< int, QList< QVariant > > ZRoleRow
Represents a single row (or column for column headers) of data cell values for multiple roles...
static void registerType()
Registers ZTableModel as a QML type.
ZTableModel(QObject *parent=0)
This two dimensional table model is used to store and manipulate data.
Q_INVOKABLE void clearRoles()
Removes all roles, role names and data from the model.
Q_INVOKABLE void putJsonData(QJsonObject data)
Writes data from the specified JSON object into the data table. Previous contents of the data table a...
QList< QMap< int, QVariant > > ZTableRowList
Represents multiple rows of data cell values for multiple roles for a single column.
int userRole
Returns the value of Qt::UserRole to javascript client code. ie: the first role number available for ...
Q_INVOKABLE bool copyColumn(int fromColumn, int toColumn)
ZRoleRow coalesceCellRow(const ZDataRow cells, int startIndex, int columnCount, const QList< int > roles, int &nextIndex)
QHash< int, QByteArray > ZRoleNames
Maps role numbers to role names as a hash table object.
Q_INVOKABLE bool writeData(QVariant jsonData)
Writes data from the specified JSON object into the data table. Previous data in the table is discard...
Q_INVOKABLE void setColumnCount(int count)
Sets the number of columns the table will contain. This method may block the current thread...
Q_INVOKABLE int modelRowCount() const
Returns the number of rows in the data set. This method may block the current thread.
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.
Q_INVOKABLE void putTableColumnRows(QVariant rows, int startRow, int col)
Replaces the current value for a set of rows for a single model column.
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 ...
int roleCount
Returns the number of roles defined for this model.
This class is an implementation of an N+1 dimensional data store suitable for use as a generic QAbstr...
static void registerLogCategory()
Q_INVOKABLE bool addRole(int roleNumber)
Adds the specified role to the data model. This method may block the current thread.
Q_INVOKABLE void sync()
Blocks thread until model's event queue has been processed.
QList< QMap< int, QList< QVariant > > > ZRoleRowList
Represents multiple rows of data cell values for multiple roles for multiple columns.
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.
void insertTableColumnRows(QVariant rows, int startRow, int col, bool asynchronous)
Q_INVOKABLE void removeRows(int row, int count)
Q_INVOKABLE void removeRow(int row)
virtual QHash< int, QByteArray > roleNames() const
QAbstractTableModel override.
void tableModelReset()
Sent when the table model has been reset.
QList< QVariant > ZDataRow
Represents a single row (or column for column headers) of data cell values for a single role...
Q_INVOKABLE void appendRow(QVariant data)
Q_INVOKABLE void prependRows(QVariant data)
Q_INVOKABLE int modelColumnCount() const
Returns the number of columns in the data set. This method may block the current thread.