MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / mousePressEvent

Method mousePressEvent

launcher/ui/instanceview/InstanceView.cpp:268–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268void 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
314void InstanceView::mouseMoveEvent(QMouseEvent* event)
315{

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