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
ZblTableData.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2015 Bob Dinitto
4  *
5  * Filename: ZblTableData.h
6  * Created on: 3/16/2015
7  * Author: Bob Dinitto
8  *
9  * Zuble is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #ifndef ZBLTABLEDATA_H
26 #define ZBLTABLEDATA_H
27 
28 #include <QList>
29 #include <QMap>
30 #include <QVariant>
31 
32 namespace Zbl
33 {
34 
35 class ZblTableCell;
36 
52 {
53 public:
54 
55  typedef QList<QString> zColumnNames; // index = column index
56 
57  typedef QList<QList<int> > zFlagsTable; // index = row x column
58 
59  typedef QMap<int,QVariant> zCellValue; // a map of cell's role values
60 
61  typedef QList<QVariant> zDataRow; // index = column
62 
63  typedef QList<zDataRow> zDataTable; // index = row x column
64 
65  typedef QMap<int, zDataRow> zRoleRow; // index = role x column
66 
67  typedef QList<zRoleRow> zRoleRowList; // index = row
68 
69  typedef QMap<int, QVariant> zTableRow; // index = role
70 
71  typedef QList<zTableRow> zTableRowList; // index = row
72 
73  typedef QMap<int, zDataTable> zRoleTable; // index = role x row x column
74 
75  ZblTableData();
76 
87  void putValue(int role, int row, int col, const QVariant value);
88 
97  QVariant getValue(int role, int row, int col) const;
98 
99 
117  void putTableColumnRows(
118  QVariant rows,
119  int startRow,
120  int col);
121 
122 
123 
144  QVariant getTableColumnRows(
145  QList<int> roles,
146  int startRow,
147  int col,
148  int rowCount) const;
149 
150 
161  bool hasCell(int role, int row, int col) const;
162 
172  bool hasCell(int row, int col) const;
173 
190  void appendRow(zRoleRow data);
191 
208  void appendRows(zRoleRowList data);
209 
226  void prependRow(zRoleRow data);
227 
244  void prependRows(zRoleRowList data);
245 
253  void removeRows(int row, int count);
254 
255 
259  void clearData();
260 
274  bool addRole(int role);
275 
282  bool hasRole(int role) const;
283 
290  QList<int> roles() const;
291 
296  int roleCount() const;
297 
301  void clearRoles();
302 
303 
304 
305 #if 0
306 
311  QHash<int, QByteArray> roleNames() const;
312 #endif
313 
318  int columnCount() const;
319 
324  void setColumnCount(int count);
325 
330  int rowCount() const;
331 
337  void dumpData() const;
338 
339  int findNextItemRow(
340  int startRow,
341  const QString& text,
342  int column = 0,
343  bool caseSensitive = true,
344  bool forwardDirection = true,
345  bool keySearch = false) const;
346 
347 
348  bool copyColumn(int fromColumn, int toColumn);
349 
350 
351  /*
352 
353  void prependRow(zRow data)
354  {
355  m_table.prepend(data);
356  }
357 
358 
359  void insertRow(int position, zRow data)
360  {
361  m_table.insert(position, data);
362  }
363 
364  void removeRow(int position)
365  {
366  m_table.removeAt(position);
367  }
368 
369  void removeFirstRow(){m_table.removeFirst();}
370 
371  void removeLastRow(){m_table.removeLast();}
372  */
373 
374 
375 private:
376 
377  void pushRow(zRoleRow data, bool front=false);
378 
384  zFlagsTable m_childFlags;
385 
395  zRoleTable m_roles;
396 
402 
408 
409 
410 
411 
412 };
413 
414 } //Zbl
415 
416 #endif // ZBLTABLEDATA_H
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
Definition: ZblTableData.h:65
zRoleTable m_roles
A three dimensional array of child cell data. Dimensions of the array are role, row and column...
Definition: ZblTableData.h:395
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.
QMap< int, QVariant > zCellValue
Definition: ZblTableData.h:59
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.
zFlagsTable m_childFlags
A two dimensional array of child cell flags. Dimensions of the array are row and column. TBD: Sorry, not yet implemented!
Definition: ZblTableData.h:384
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
Definition: ZblTableData.h:69
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.
Definition: ZAndGate.cpp:6
A table data object contains the role data and model item flags for a 2 dimensional array of model da...
Definition: ZblTableData.h:51
QList< QString > zColumnNames
Definition: ZblTableData.h:55
void clearData()
Removes all rows from the data table.
QList< zTableRow > zTableRowList
Definition: ZblTableData.h:71
QList< QList< int > > zFlagsTable
Definition: ZblTableData.h:57
QList< int > roles() const
Determines which roles are in the data set.
bool copyColumn(int fromColumn, int toColumn)
QList< zRoleRow > zRoleRowList
Definition: ZblTableData.h:67
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.
Definition: ZblTableData.h:407
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&#39;s role. This is a blocking call. with the specified value...
QList< QVariant > zDataRow
Definition: ZblTableData.h:61
QList< zDataRow > zDataTable
Definition: ZblTableData.h:63
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.
Definition: ZblTableData.h:401
QMap< int, zDataTable > zRoleTable
Definition: ZblTableData.h:73
int rowCount() const
Determines the number of rows in the data table.