| 459 | } |
| 460 | |
| 461 | void RDTableView::updateGeometries() |
| 462 | { |
| 463 | if(!m_horizontalHeader->customSizing()) |
| 464 | return QTableView::updateGeometries(); |
| 465 | |
| 466 | static bool recurse = false; |
| 467 | if(recurse) |
| 468 | return; |
| 469 | recurse = true; |
| 470 | |
| 471 | QAbstractButton *cornerButton = findChild<QAbstractButton *>(); |
| 472 | cornerButton->setVisible(false); |
| 473 | |
| 474 | QRect geom = viewport()->geometry(); |
| 475 | |
| 476 | // assume no vertical header |
| 477 | |
| 478 | int horizHeight = |
| 479 | qBound(horizontalHeader()->minimumHeight(), horizontalHeader()->sizeHint().height(), |
| 480 | horizontalHeader()->maximumHeight()); |
| 481 | |
| 482 | setViewportMargins(0, horizHeight, 0, 0); |
| 483 | |
| 484 | horizontalHeader()->setGeometry(geom.left(), geom.top() - horizHeight, geom.width(), horizHeight); |
| 485 | |
| 486 | // even though it's not visible we need to set the geometry right so that it looks up rows by |
| 487 | // position properly. |
| 488 | verticalHeader()->setGeometry(0, horizHeight, 0, geom.height()); |
| 489 | |
| 490 | // if the headers are hidden nothing else will update their geometries and some things like |
| 491 | // scrolling etc depend on it being up to date, so hackily call the protected slot. Yuk! |
| 492 | if(verticalHeader()->isHidden()) |
| 493 | QMetaObject::invokeMethod(verticalHeader(), "updateGeometries"); |
| 494 | if(horizontalHeader()->isHidden()) |
| 495 | QMetaObject::invokeMethod(horizontalHeader(), "updateGeometries"); |
| 496 | |
| 497 | // assume per-item vertical scrolling and per-pixel horizontal scrolling |
| 498 | |
| 499 | // vertical scroll bar |
| 500 | { |
| 501 | int firstRow = qMax(verticalHeader()->visualIndexAt(0), 0); |
| 502 | int lastRow = verticalHeader()->visualIndexAt(viewport()->height()); |
| 503 | bool last = false; |
| 504 | if(lastRow == -1) |
| 505 | { |
| 506 | last = true; |
| 507 | lastRow = verticalHeader()->count(); |
| 508 | } |
| 509 | |
| 510 | int visibleRows = lastRow - firstRow + 1; |
| 511 | |
| 512 | // a partially displayed row doesn't count |
| 513 | if(verticalHeader()->sectionViewportPosition(lastRow) + verticalHeader()->sectionSize(lastRow) > |
| 514 | viewport()->height()) |
| 515 | visibleRows--; |
| 516 | |
| 517 | verticalScrollBar()->setRange(0, verticalHeader()->count() - visibleRows); |
| 518 | verticalScrollBar()->setSingleStep(1); |
no test coverage detected