QXRD  0.11.16
qcepdatagroupspreadsheetmodel.cpp
Go to the documentation of this file.
2 #include "qcepdatagroup.h"
3 
5  m_Group(group)
6 {
7 
8 }
9 
10 int QcepDataGroupSpreadsheetModel::rowCount(const QModelIndex &parent) const
11 {
13 
14  if (grp) {
15  return grp->childCount();
16  } else {
17  return 0;
18  }
19 }
20 
21 int QcepDataGroupSpreadsheetModel::columnCount(const QModelIndex &parent) const
22 {
23  return 3;
24 }
25 
26 QVariant QcepDataGroupSpreadsheetModel::data(const QModelIndex &index, int role) const
27 {
28  QVariant res = QVariant();
29 
30  if (role == Qt::DisplayRole) {
31  if (index.isValid()) {
33 
34  if (grp) {
35  QcepDataObjectPtr obj = grp->item(index.row());
36 
37  if (obj) {
38  res = obj->columnData(index.column());
39  }
40  }
41  }
42  }
43 
44  return res;
45 }
46 
47 QVariant QcepDataGroupSpreadsheetModel::headerData(int section, Qt::Orientation orientation, int role) const
48 {
49  QVariant res = QVariant();
50 
51  if (role == Qt::DisplayRole) {
52  if (orientation == Qt::Horizontal) {
53  switch (section) {
54  case 0:
55  res = "Name";
56  break;
57 
58  case 1:
59  res = "Type";
60  break;
61 
62  case 2:
63  res = "Description";
64  break;
65  }
66  } else if (orientation == Qt::Vertical) {
67  res = section;
68  }
69  }
70 
71  return res;
72 }
int columnCount(const QModelIndex &parent=QModelIndex()) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QSharedPointer< QcepDataGroup > QcepDataGroupPtr
int rowCount(const QModelIndex &parent=QModelIndex()) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QcepDataGroupSpreadsheetModel(QcepDataGroupWPtr group)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QWeakPointer< QcepDataGroup > QcepDataGroupWPtr