! * 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. */
| 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 | { |
nothing calls this directly
no test coverage detected