MCPcopy Create free account
hub / github.com/KDAB/GammaRay / dataForObject

Method dataForObject

core/objectmodelbase.h:73–100  ·  view source on GitHub ↗

! * Returns the data for the specified object. * @param object is a pointer to a QObject. * @param index is the model QModelIndex. * @param role is the Qt role. * * @return on success, a QVariant containing the data for the specified QObject; * QVariant() if some anamoly occurs. */

Source from the content-addressed store, hash-verified

71 * QVariant() if some anamoly occurs.
72 */
73 QVariant dataForObject(QObject *object, const QModelIndex &index, int role) const
74 {
75 if (role == Qt::DisplayRole) {
76 if (index.column() == 0)
77 return Util::shortDisplayString(object);
78 else if (index.column() == 1)
79 return ObjectDataProvider::typeName(object);
80 } else if (role == ObjectModel::ObjectRole) {
81 return QVariant::fromValue(object);
82 } else if (role == ObjectModel::ObjectIdRole) {
83 return QVariant::fromValue(ObjectId(object));
84 } else if (role == Qt::ToolTipRole) {
85 return Util::tooltipForObject(object);
86 } else if (role == ObjectModel::DecorationIdRole && index.column() == 0) {
87 const int id = Util::iconIdForObject(object);
88 return id >= 0 ? QVariant(id) : QVariant();
89 } else if (role == ObjectModel::CreationLocationRole) {
90 const auto loc = ObjectDataProvider::creationLocation(object);
91 if (loc.isValid())
92 return QVariant::fromValue(loc);
93 } else if (role == ObjectModel::DeclarationLocationRole) {
94 const auto loc = ObjectDataProvider::declarationLocation(object);
95 if (loc.isValid())
96 return QVariant::fromValue(loc);
97 }
98
99 return QVariant();
100 }
101
102 QMap<int, QVariant> itemData(const QModelIndex &index) const override
103 {

Callers

nothing calls this directly

Calls 5

iconIdForObjectFunction · 0.85
columnMethod · 0.80
QVariantClass · 0.70
ObjectIdClass · 0.50
isValidMethod · 0.45

Tested by

no test coverage detected