33 : m_columnCount(1), m_rowCount(0)
38 qDebug(
"format = row/column/role:data;");
40 const int truncatePos = 15;
42 QList<int>roleList =
roles();
46 QByteArray outputAscii;
57 QString outputCell =
"%1/%2/%3:%4;";
59 int roleNum = roleList.at(rl);
60 QVariant data =
getValue(roleNum, row, col);
62 QString strData = data.toString();
64 if(strData.count() > truncatePos)
66 strData.truncate(truncatePos);
70 QString test = outputCell.arg(row).arg(col).arg(roleNum).arg(strData);
71 outputRow.append(test);
79 outputAscii = outputRow.toUtf8();
80 qDebug(
"%s",outputAscii.constData());
87 throw ZblException(QString(
"ZblTableData::putValue - nonexistent cell: " 88 "role %1, row %2, col %3").arg(role).arg(row).arg(col));
94 QVariant& dataVariant = dataRow[col];
103 throw ZblException(QString(
"ZblTableData::getValue - nonexistent cell: " 104 "role %1, row %2, col %3").arg(role).arg(row).arg(col));
106 return m_roles.value(role).at(row).at(col);
115 throw ZblException(
"ZblTableData::putTableColumnRows - Programming Error: " 116 "rows parameter must contain a ZTableRowList object.");
120 const int count = rowList.count();
122 for(
int row = 0; row < count; row++)
125 QList<int>
roles = nextRow.keys();
126 for(
int roleIndex = 0; roleIndex < roles.count(); roleIndex++)
128 int nextRole = roles.at(roleIndex);
129 QVariant nextValue = nextRow.value(nextRole);
130 putValue(nextRole, startRow + row, col, nextValue);
141 qDebug(
"ZblTableData::getTableColumnRows");
147 QSet<int> eliminateDuplicates = QSet<int>::fromList(roles);
149 QList<int> roleSet = eliminateDuplicates.toList();
158 lastRow = startRow + rowCount - 1;
160 qDebug(
"roleCount=%d, startRow=%d, lastRow=%d", roleCount, startRow, lastRow);
163 for(
int row = startRow; row < lastRow; row++ )
167 const int nextRole = roleSet.at(rol);
168 qDebug(
"getting data value at row %d, col %d, role %d", row, col, nextRole);
170 tempRow.insert(nextRole,
getValue(nextRole, row, col));
172 rows.append(tempRow);
176 QVariant vReturn = QVariant::fromValue<zTableRowList>(rows);
227 for(
int i=rowCount-1; i>=0; i--)
241 QMapIterator<int, zDataTable> iRoles(
m_roles);
243 while(iRoles.hasNext())
249 int delCount = count;
254 newRoles.insert(iRoles.key(), dt);
271 QMapIterator<int, zDataTable> iRoles(
m_roles);
273 while(iRoles.hasNext())
276 newRoles.insert(iRoles.key(), dt);
296 throw ZblException(
"ZblTableData::addRole - ERROR: can't add roles when " 297 "data table contains rows.");
304 m_roles.insert(role, newTable);
315 bool forwardDirection,
316 bool keySearch)
const 323 const Qt::CaseSensitivity cs = caseSensitive ?
324 Qt::CaseSensitive : Qt::CaseInsensitive;
327 bool foundFlag =
false;
329 QList<int>roleKeys(
m_roles.keys());
339 if(foundFlag && foundRow <= j)
342 const zDataRow& nextRoleRow = nextRoleTable[j];
344 QString valueString = nextRoleRow[column].toString();
350 if(QString::compare(text, valueString, cs) == 0)
362 if(valueString.contains(text, cs))
377 QList<int>roleList =
roles();
384 int roleNum = roleList.at(rl);
385 QVariant data =
getValue(roleNum, row, fromColumn);
386 putValue(roleNum, row, toColumn, data);
400 "contains no roles.");
404 if(roleCount !=
m_roles.size())
405 throw ZblException(
"ZblTableData::appendRow - new row's " 406 "role count not equivalent to number of data table roles.");
408 QList<int> dataKeys = data.keys();
410 QList<int> tableKeys =
m_roles.keys();
412 if(dataKeys != tableKeys)
413 throw ZblException(
"ZblTableData::appendRow - new row's " 414 "role types not equivalent to data table role types.");
416 QList<int>::iterator nextKey = dataKeys.begin();
417 QList<int>::iterator lastKey = dataKeys.end();
422 while(nextKey != lastKey)
424 const int roleKey = *nextKey++;
426 zDataRow rowData = data.value(roleKey);
429 throw ZblException(
"ZblTableData::appendRow - new row's " 430 "column count not equivalent to number of data table columns.");
435 nextKey = dataKeys.begin();
437 while(nextKey != lastKey)
439 const int roleKey = *nextKey++;
443 const zDataRow& dataRow = data.value(roleKey);
449 dataTable.prepend(dataRow);
451 dataTable.append(dataRow);
482 throw ZblException(
"ZblTableData::setColumnCount - ERROR: can't set column count when " 483 "data table contains rows.");
void prependRows(zRoleRowList data)
Prepends a list of rows of role values to the table data.
void clearRoles()
Removes all roles and data rows from the data table.
int roleCount() const
Determines the current number of roles in the data table.
void putTableColumnRows(QVariant rows, int startRow, int col)
Replaces the current value for a set of rows for a single model column.
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.
QMap< int, zDataRow > zRoleRow
zRoleTable m_roles
A three dimensional array of child cell data. Dimensions of the array are role, row and column...
void dumpData() const
Prints diagnostic information about the state of the contained data to debug output.
void prependRow(zRoleRow data)
Prepends a row of role values to the table data.
bool addRole(int role)
Adds the specified role to the data table. The table must not contain data rows when calling this met...
void removeRows(int row, int count)
Removes one or more rows from the table.
bool hasCell(int role, int row, int col) const
Determines if the specified cell and role combination exists in the data table.
QMap< int, QVariant > zTableRow
int findNextItemRow(int startRow, const QString &text, int column=0, bool caseSensitive=true, bool forwardDirection=true, bool keySearch=false) const
int columnCount() const
Determines the number of columns in the data table.
bool hasRole(int role) const
Determines if a specified role already exists in the data table.
void clearData()
Removes all rows from the data table.
QList< zTableRow > zTableRowList
QList< int > roles() const
Determines which roles are in the data set.
bool copyColumn(int fromColumn, int toColumn)
QList< zRoleRow > zRoleRowList
QVariant getValue(int role, int row, int col) const
Obtains the value of the specified cell and role. This is a blocking call.
void pushRow(zRoleRow data, bool front=false)
void appendRow(zRoleRow data)
Appends a row of role values to the table data.
int m_rowCount
The number of rows in the child data table.
void setColumnCount(int count)
Sets the number of columns in the data table. This method fails if the data table contains rows...
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...
QList< QVariant > zDataRow
Zuble's Qt Exception Object.
QList< zDataRow > zDataTable
void appendRows(zRoleRowList data)
Appends a list of rows of role values to the table data.
int m_columnCount
The number of columns in the child data table.
QMap< int, zDataTable > zRoleTable
int rowCount() const
Determines the number of rows in the data table.