void SelectSameTileTool::mousePressed(QGraphicsSceneMouseEvent *event) { if (event->button() != Qt::LeftButton) return; const Qt::KeyboardModifiers modifiers = event->modifiers(); MapDocument *document = mapDocument(); QRegion selection = document->selectedArea(); if (modifiers == Qt::ShiftModifier) selection += mSelectedRegion; else if (modifiers == Qt::ControlModifier) selection -= mSelectedRegion; else if (modifiers == (Qt::ControlModifier | Qt::ShiftModifier)) selection &= mSelectedRegion; else selection = mSelectedRegion; if (selection != document->selectedArea()) { QUndoCommand *cmd = new ChangeSelectedArea(document, selection); document->undoStack()->push(cmd); } }
void TileSelectionTool::mouseReleased(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { mSelecting = false; MapDocument *document = mapDocument(); QRegion selection = document->selectedArea(); const QRect area = selectedArea(); switch (mSelectionMode) { case Replace: selection = area; break; case Add: selection += area; break; case Subtract: selection -= area; break; case Intersect: selection &= area; break; } if (selection != document->selectedArea()) { QUndoCommand *cmd = new ChangeSelectedArea(document, selection); document->undoStack()->push(cmd); } brushItem()->setTileRegion(QRegion()); updateStatusInfo(); } }