| 266 | } |
| 267 | |
| 268 | void InstanceView::mousePressEvent(QMouseEvent* event) |
| 269 | { |
| 270 | executeDelayedItemsLayout(); |
| 271 | |
| 272 | QPoint visualPos = event->pos(); |
| 273 | QPoint geometryPos = event->pos() + offset(); |
| 274 | |
| 275 | QPersistentModelIndex index = indexAt(visualPos); |
| 276 | |
| 277 | m_pressedIndex = index; |
| 278 | m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex); |
| 279 | m_pressedPosition = geometryPos; |
| 280 | |
| 281 | if (event->button() == Qt::LeftButton) { |
| 282 | VisualGroup::HitResults hitResult; |
| 283 | m_pressedCategory = categoryAt(geometryPos, hitResult); |
| 284 | if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) { |
| 285 | setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState); |
| 286 | event->accept(); |
| 287 | return; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | if (index.isValid() && (index.flags() & Qt::ItemIsEnabled)) { |
| 292 | if (index != currentIndex()) { |
| 293 | // FIXME: better! |
| 294 | m_currentCursorColumn = -1; |
| 295 | } |
| 296 | // we disable scrollTo for mouse press so the item doesn't change position |
| 297 | // when the user is interacting with it (ie. clicking on it) |
| 298 | bool autoScroll = hasAutoScroll(); |
| 299 | setAutoScroll(false); |
| 300 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); |
| 301 | |
| 302 | setAutoScroll(autoScroll); |
| 303 | QRect rect(visualPos, visualPos); |
| 304 | setSelection(rect, QItemSelectionModel::ClearAndSelect); |
| 305 | |
| 306 | // signal handlers may change the model |
| 307 | emit pressed(index); |
| 308 | } else { |
| 309 | // Forces a finalize() even if mouse is pressed, but not on a item |
| 310 | selectionModel()->select(QModelIndex(), QItemSelectionModel::Select); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | void InstanceView::mouseMoveEvent(QMouseEvent* event) |
| 315 | { |
nothing calls this directly
no test coverage detected