| 270 | } |
| 271 | |
| 272 | QRect ExpandingWidgetModel::partialExpandRect(const QModelIndex& idx_) const |
| 273 | { |
| 274 | Q_ASSERT(idx_.model() == this); |
| 275 | |
| 276 | QModelIndex idx(firstColumn(idx_)); |
| 277 | |
| 278 | if (!idx.isValid()) { |
| 279 | return QRect(); |
| 280 | } |
| 281 | |
| 282 | ExpansionType expansion = ExpandDownwards; |
| 283 | |
| 284 | if (m_partiallyExpanded.find(idx) != m_partiallyExpanded.constEnd()) { |
| 285 | expansion = m_partiallyExpanded[idx]; |
| 286 | } |
| 287 | |
| 288 | //Get the whole rectangle of the row: |
| 289 | const QModelIndex viewIndex = mapFromSource(idx); |
| 290 | QModelIndex rightMostIndex = viewIndex; |
| 291 | QModelIndex tempIndex = viewIndex; |
| 292 | while ((tempIndex = rightMostIndex.sibling(rightMostIndex.row(), rightMostIndex.column() + 1)).isValid()) |
| 293 | rightMostIndex = tempIndex; |
| 294 | |
| 295 | QRect rect = treeView()->visualRect(viewIndex); |
| 296 | QRect rightMostRect = treeView()->visualRect(rightMostIndex); |
| 297 | |
| 298 | rect.setLeft(rect.left() + 20); |
| 299 | rect.setRight(rightMostRect.right() - 5); |
| 300 | |
| 301 | //These offsets must match exactly those used in ExpandingDelegate::sizeHint() |
| 302 | int top = rect.top() + 5; |
| 303 | int bottom = rightMostRect.bottom() - 5; |
| 304 | |
| 305 | if (expansion == ExpandDownwards) { |
| 306 | top += basicRowHeight(viewIndex); |
| 307 | } else { |
| 308 | bottom -= basicRowHeight(viewIndex); |
| 309 | } |
| 310 | |
| 311 | rect.setTop(top); |
| 312 | rect.setBottom(bottom); |
| 313 | |
| 314 | return rect; |
| 315 | } |
| 316 | |
| 317 | bool ExpandingWidgetModel::isExpandable(const QModelIndex& idx_) const |
| 318 | { |