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

Method nextItemIndex

plugins/grepview/grepoutputmodel.cpp:310–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310QModelIndex GrepOutputModel::nextItemIndex(const QModelIndex &currentIdx) const
311{
312 GrepOutputItem* current_item = nullptr;
313
314 if (!currentIdx.isValid()) {
315 QStandardItem *it = item(0,0);
316 if (!it) return QModelIndex();
317 current_item = static_cast<GrepOutputItem*>(it);
318 }
319 else
320 current_item = static_cast<GrepOutputItem*>(itemFromIndex(currentIdx));
321
322 if (current_item->parent() == nullptr) {
323 // root item with overview of search results
324 if (current_item->rowCount() > 0)
325 return nextItemIndex(current_item->child(0)->index());
326 else
327 return QModelIndex();
328 } else {
329 int row = currentIdx.row();
330 if(!current_item->isText()) // the item is a file
331 {
332 int item_row = current_item->row();
333 if(item_row < current_item->parent()->rowCount())
334 {
335 return current_item->parent()->child(item_row)->child(0)->index();
336 }
337 }
338 else // the item is a match
339 {
340 if(row < current_item->parent()->rowCount() - 1)
341 return current_item->parent()->child(row + 1)->index();
342 else // we return the index of the first item of the next file
343 {
344 int parrent_row = current_item->parent()->row();
345 if(parrent_row < current_item->parent()->parent()->rowCount() - 1)
346 {
347 return current_item->parent()->parent()->child(parrent_row + 1)->child(0)->index();
348 }
349 }
350 }
351 }
352 return currentIdx;
353}
354
355const GrepOutputItem *GrepOutputModel::getRootItem() const {
356 return m_rootItem;

Callers 3

selectNextItemMethod · 0.80

Calls 8

isTextMethod · 0.80
QModelIndexClass · 0.70
isValidMethod · 0.45
parentMethod · 0.45
rowCountMethod · 0.45
indexMethod · 0.45
childMethod · 0.45
rowMethod · 0.45

Tested by 2