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
ZblTableCell.cpp
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: ZblTableCell.cpp
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 #include "ZblTableCell.h"
26 #include "ZblTableData.h"
27 #include "ZblException.h"
28 
29 namespace Zbl
30 {
31 
33  :m_parent(0),
34  m_childCells(0),
35  m_childData(new ZblTableData())
36 {
37 
38 }
39 
41  :m_parent(0),
42  m_childCells(0),
43  m_childData(data)
44 {
45 
46 }
47 
49 {
50  if(m_childData)
51  delete m_childData;
52 
53  if(m_childCells)
54  delete m_childCells;
55 }
56 
58 {
59  return *m_childData;
60 }
61 
63 {
64  return *m_childData;
65 }
66 
67 
69 {
70  if(m_childData)
71  delete m_childData;
72 
73  m_childData = data;
74 }
75 
77 {
78  return m_childCells ? true : false;
79 }
80 
81 
82 ZblTableCell* ZblTableCell::getCell(int row, int col) const
83 {
84  if(!hasChildCells())
85  throw ZblException("ZblTableCell::getCell - cell contains no child cell objects.");
86 
87  return m_childCells->at(row).at(col);
88 }
89 
90 void ZblTableCell::putCell(int row, int col, ZblTableCell* cell)
91 {
92  if(!hasChildCells())
93  throw ZblException("ZblTableCell::putCell - cell contains no child cell objects.");
94 
95  // TBD: MEMORY LEAK!!!???
96 
97  m_childCells->value(row).replace(col, cell);
98 }
99 
100 bool ZblTableCell::hasCell(int row, int col) const
101 {
102  if(!hasChildCells())
103  return false;
104  else
105  return m_childData->hasCell(row, col);
106 }
107 
108 
109 } //Zbl
ZblTableCell * getCell(int row, int col) const
void putCell(int row, int col, ZblTableCell *cell)
ZblTableData * m_childData
A three dimensional array of child cell data. Dimensions of the array are role, row and column...
Definition: ZblTableCell.h:116
ZblTableCell()
Constructs a ZblTableCell object encapsulating a default constructed ZblTableData object...
bool hasChildCells() const
ZblTableData & data()
bool hasCell(int role, int row, int col) const
Determines if the specified cell and role combination exists in the data table.
void setData(ZblTableData *data)
zTableCells * m_childCells
A two dimensional array of child cells. NULL if this cell has no grandchildren.
Definition: ZblTableCell.h:106
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
A table cell object contains the data for its child cells and maintains the cell's positional relatio...
Definition: ZblTableCell.h:47
const ZblTableData & constData() const
Zuble's Qt Exception Object.
Definition: ZblException.h:45
bool hasCell(int row, int col) const
~ZblTableCell()
Destroys encapsulated child data and cell objects if they exist.
ZblTableCell * m_parent
Parent cell of this cell. All cells have a parent except the top cell in the table cell hierarchy...
Definition: ZblTableCell.h:99