33 #ifndef GAMMARAY_OBJECTMODELBASE_H
34 #define GAMMARAY_OBJECTMODELBASE_H
39 #include <QModelIndex>
47 template<
typename Base>
65 int columnCount(
const QModelIndex &parent = QModelIndex())
const
80 QVariant
dataForObject(QObject *
object,
const QModelIndex &index,
int role)
const
82 if (role == Qt::DisplayRole) {
83 if (index.column() == 0) {
85 object->objectName().isEmpty() ?
88 }
else if (index.column() == 1) {
89 return object->metaObject()->className();
92 return QVariant::fromValue(
object);
93 }
else if (role == Qt::ToolTipRole) {
95 QObject::tr(
"Object name: %1\nType: %2\nParent: %3 (Address: %4)\nNumber of children: %5").
96 arg(object->objectName().isEmpty() ?
"<Not set>" :
object->objectName()).
97 arg(object->metaObject()->className()).
98 arg(object->parent() ?
object->parent()->metaObject()->className() :
"<No parent>").
100 arg(object->children().size());
101 }
else if (role == Qt::DecorationRole && index.column() == 0) {
119 QVariant
headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const
121 if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
124 return QObject::tr(
"Object");
126 return QObject::tr(
"Type");