| 94 | } |
| 95 | |
| 96 | void FocusedTreeView::resizeEvent(QResizeEvent* event) |
| 97 | { |
| 98 | QTreeView::resizeEvent(event); |
| 99 | |
| 100 | // Rewrap lines when the width changes. |
| 101 | if (wordWrap() && event->size().width() != event->oldSize().width()) { |
| 102 | // fitColumns() calls resizeColumnToContents(), which executes items layout |
| 103 | // scheduled here (QTreeView::setWordWrap() also schedules items layout). |
| 104 | // Redoing the items layout is necessary for correct rewrapping, but causes a roughly |
| 105 | // 5-second-long UI freeze inside QItemDelegate::sizeHint() when the user selects |
| 106 | // a 100'000th line of output. The freeze happens because non-uniform row heights (necessary |
| 107 | // for word-wrapping) force QTreeView to calculate heights of all items above the selected one. |
| 108 | // The number of consecutive resize events does not affect the duration of the resulting UI freeze. |
| 109 | scheduleDelayedItemsLayout(); |
| 110 | // Resizing columns to contents here rewraps lines immediately rather than only after subsequent vertical |
| 111 | // scrolling. This is relatively fast and does not noticeably contribute to the UI freeze duration. |
| 112 | fitColumns(); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void FocusedTreeView::delayedAutoScrollAndResize() |
| 117 | { |