QXRD  0.11.16
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QcepDataObjectPropertiesModel Class Reference

#include <qcepdataobjectpropertiesmodel.h>

Inheritance diagram for QcepDataObjectPropertiesModel:
Inheritance graph
[legend]
Collaboration diagram for QcepDataObjectPropertiesModel:
Collaboration graph
[legend]

Public Member Functions

 QcepDataObjectPropertiesModel (QcepDataObjectWPtr obj)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
- Public Member Functions inherited from QcepPropertiesModel
 QcepPropertiesModel ()
 

Private Member Functions

int propertyCount () const
 
int dynamicPropertyCount () const
 

Private Attributes

QcepDataObjectWPtr m_Object
 

Detailed Description

Definition at line 7 of file qcepdataobjectpropertiesmodel.h.

Constructor & Destructor Documentation

QcepDataObjectPropertiesModel::QcepDataObjectPropertiesModel ( QcepDataObjectWPtr  obj)

Definition at line 6 of file qcepdataobjectpropertiesmodel.cpp.

6  :
7  m_Object(obj)
8 {
9 
10 }

Member Function Documentation

int QcepDataObjectPropertiesModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 17 of file qcepdataobjectpropertiesmodel.cpp.

18 {
19  return 2;
20 }
QVariant QcepDataObjectPropertiesModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

Definition at line 22 of file qcepdataobjectpropertiesmodel.cpp.

References dynamicPropertyCount(), m_Object, and propertyCount().

23 {
24  QVariant res = QVariant();
25  int pc = propertyCount();
26  int dpc = dynamicPropertyCount();
28 
29  if (role == Qt::DisplayRole) {
30  if (index.isValid()) {
31  int r = index.row(), c = index.column();
32 
33  if (r == 0) {
34  if (c == 0) {
35  res = "Static";
36  } else if (c == 1) {
37  res = "Properties";
38  }
39  } else if (r < (pc+1)) {
40  if (obj) {
41  QMetaProperty mp = obj->metaObject()->property(r-1);
42  if (c == 0) {
43  res = mp.name();
44  } else if (c == 1) {
45  res = obj->property(mp.name());
46  }
47  }
48  } else if (r == (pc+1)) {
49  if (c == 0) {
50  res = "Dynamic";
51  } else if (c == 1) {
52  res = "Properties";
53  }
54  } else {
55  int idx = r - pc - 2;
56  if (obj) {
57  QString name = obj->dynamicPropertyNames().value(idx);
58 
59  if (c == 0) {
60  res = name;
61  } else if (c == 1) {
62  res = obj->property(qPrintable(name));
63  }
64  }
65  }
66  }
67  }
68 
69  return res;
70 }
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the call graph for this function:

int QcepDataObjectPropertiesModel::dynamicPropertyCount ( ) const
private

Definition at line 113 of file qcepdataobjectpropertiesmodel.cpp.

References m_Object.

Referenced by data(), headerData(), and rowCount().

114 {
116 
117  if (obj) {
118  return obj->dynamicPropertyNames().count();
119  } else {
120  return 0;
121  }
122 }
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the caller graph for this function:

QVariant QcepDataObjectPropertiesModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const

Definition at line 72 of file qcepdataobjectpropertiesmodel.cpp.

References dynamicPropertyCount(), and propertyCount().

73 {
74  QVariant res = QVariant();
75 
76  if (role == Qt::DisplayRole) {
77  if (orientation == Qt::Horizontal) {
78  if (section == 0) {
79  res = "Name";
80  } else if (section == 1) {
81  res = "Value";
82  }
83  } else if (orientation == Qt::Vertical) {
84  int pc = propertyCount();
85  int dpc = dynamicPropertyCount();
86 
87  if (section == 0) {
88 
89  } else if (section < (pc+1)) {
90  return section - 1;
91  } else if (section == (pc+1)) {
92 
93  } else {
94  return section - pc - 2;
95  }
96  }
97  }
98 
99  return res;
100 }

Here is the call graph for this function:

int QcepDataObjectPropertiesModel::propertyCount ( ) const
private

Definition at line 102 of file qcepdataobjectpropertiesmodel.cpp.

References m_Object.

Referenced by data(), headerData(), and rowCount().

103 {
105 
106  if (obj) {
107  return obj->metaObject()->propertyCount();
108  } else {
109  return 0;
110  }
111 }
QSharedPointer< QcepDataObject > QcepDataObjectPtr

Here is the caller graph for this function:

int QcepDataObjectPropertiesModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Definition at line 12 of file qcepdataobjectpropertiesmodel.cpp.

References dynamicPropertyCount(), and propertyCount().

Here is the call graph for this function:

Member Data Documentation

QcepDataObjectWPtr QcepDataObjectPropertiesModel::m_Object
private

Definition at line 22 of file qcepdataobjectpropertiesmodel.h.

Referenced by data(), dynamicPropertyCount(), and propertyCount().


The documentation for this class was generated from the following files: