| 405 | } |
| 406 | |
| 407 | void 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 | |
| 457 | void ExpandingWidgetModel::placeExpandingWidgets() |
| 458 | { |
no test coverage detected