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

Method placeExpandingWidget

plugins/quickopen/expandingtree/expandingwidgetmodel.cpp:407–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407void ExpandingWidgetModel::placeExpandingWidget(const QModelIndex& idx_)
408{
409 Q_ASSERT(idx_.model() == this);
410
411 QModelIndex idx(firstColumn(idx_));
412
413 QWidget* w = nullptr;
414 const auto widgetIt = m_expandingWidgets.constFind(idx);
415 if (widgetIt != m_expandingWidgets.constEnd()) {
416 w = *widgetIt;
417 }
418
419 if (w && isExpanded(idx)) {
420 if (!idx.isValid()) {
421 return;
422 }
423
424 const QModelIndex viewIndex = mapFromSource(idx_);
425 QRect rect = treeView()->visualRect(viewIndex);
426
427 if (!rect.isValid() || rect.bottom() < 0 || rect.top() >= treeView()->height()) {
428 //The item is currently not visible
429 w->hide();
430 return;
431 }
432
433 QModelIndex rightMostIndex = viewIndex;
434 QModelIndex tempIndex = viewIndex;
435 while ((tempIndex = rightMostIndex.sibling(rightMostIndex.row(), rightMostIndex.column() + 1)).isValid())
436 rightMostIndex = tempIndex;
437
438 QRect rightMostRect = treeView()->visualRect(rightMostIndex);
439
440 //Find out the basic height of the row
441 rect.setLeft(rect.left() + 20);
442 rect.setRight(rightMostRect.right() - 5);
443
444 //These offsets must match exactly those used in KateCompletionDeleage::sizeHint()
445 rect.setTop(rect.top() + basicRowHeight(viewIndex) + 5);
446 rect.setHeight(w->height());
447
448 if (w->parent() != treeView()->viewport() || w->geometry() != rect || !w->isVisible()) {
449 w->setParent(treeView()->viewport());
450
451 w->setGeometry(rect);
452 w->show();
453 }
454 }
455}
456
457void ExpandingWidgetModel::placeExpandingWidgets()
458{

Callers 1

paintMethod · 0.80

Calls 13

firstColumnFunction · 0.85
isExpandedFunction · 0.85
constEndMethod · 0.80
topMethod · 0.80
siblingMethod · 0.80
showMethod · 0.80
modelMethod · 0.45
constFindMethod · 0.45
isValidMethod · 0.45
rowMethod · 0.45
columnMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected