MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / mousePressEvent

Method mousePressEvent

launcher/ui/instanceview/InstanceView.cpp:290–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290void InstanceView::mousePressEvent(QMouseEvent *event)
291{
292 executeDelayedItemsLayout();
293
294 QPoint visualPos = event->pos();
295 QPoint geometryPos = event->pos() + offset();
296
297 QPersistentModelIndex index = indexAt(visualPos);
298
299 m_pressedIndex = index;
300 m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex);
301 m_pressedPosition = geometryPos;
302
303 VisualGroup::HitResults hitresult;
304 m_pressedCategory = categoryAt(geometryPos, hitresult);
305 if (m_pressedCategory && hitresult & VisualGroup::CheckboxHit)
306 {
307 setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState);
308 event->accept();
309 return;
310 }
311
312 if (index.isValid() && (index.flags() & Qt::ItemIsEnabled))
313 {
314 if(index != currentIndex())
315 {
316 // FIXME: better!
317 m_currentCursorColumn = -1;
318 }
319 // we disable scrollTo for mouse press so the item doesn't change position
320 // when the user is interacting with it (ie. clicking on it)
321 bool autoScroll = hasAutoScroll();
322 setAutoScroll(false);
323 selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
324
325 setAutoScroll(autoScroll);
326 QRect rect(visualPos, visualPos);
327 setSelection(rect, QItemSelectionModel::ClearAndSelect);
328
329 // signal handlers may change the model
330 emit pressed(index);
331 }
332 else
333 {
334 // Forces a finalize() even if mouse is pressed, but not on a item
335 selectionModel()->select(QModelIndex(), QItemSelectionModel::Select);
336 }
337}
338
339void InstanceView::mouseMoveEvent(QMouseEvent *event)
340{

Callers

nothing calls this directly

Calls 5

QModelIndexClass · 0.85
isSelectedMethod · 0.80
acceptMethod · 0.45
isValidMethod · 0.45
flagsMethod · 0.45

Tested by

no test coverage detected