MCPcopy Create free account
hub / github.com/KDE/kdevelop / parent

Method parent

kdevplatform/sublime/aggregatemodel.cpp:145–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145QModelIndex AggregateModel::parent(const QModelIndex &index) const
146{
147 Q_D(const AggregateModel);
148
149 if (!index.isValid())
150 return QModelIndex();
151
152 if (index.internalPointer() == d->internal)
153 {
154 //this is aggregator item, it has no parents
155 return QModelIndex();
156 }
157
158 //this is just an item from the model
159 auto *item = static_cast<QStandardItem*>(index.internalPointer());
160 QModelIndex parent;
161 if (!item->parent())
162 {
163 //we need to find the aggregator item that owns this index
164 //first find the model for this index
165 QStandardItemModel *model = item->model();
166 //next find the row number of the aggregator item
167 int row = d->modelList.indexOf(model);
168 parent = createIndex(row, 0, d->internal);
169 }
170 else
171 {
172 //we have a standard item in the source model - just map it into our model
173 parent = createIndex(item->parent()->row(), 0, item->parent());
174 }
175 return parent;
176}
177
178QModelIndex AggregateModel::index(int row, int column, const QModelIndex &parent) const
179{

Callers 1

dataMethod · 0.45

Calls 6

createIndexFunction · 0.85
QModelIndexClass · 0.50
isValidMethod · 0.45
modelMethod · 0.45
indexOfMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected