| 90 | } |
| 91 | |
| 92 | void ScreenSetupView::dragMoveEvent(QDragMoveEvent *event) |
| 93 | { |
| 94 | if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType())) { |
| 95 | // where does the event come from? myself or someone else? |
| 96 | if (event->source() == this) { |
| 97 | // myself is ok, but then it must be a move action, never a copy |
| 98 | event->setDropAction(Qt::MoveAction); |
| 99 | event->accept(); |
| 100 | } else { |
| 101 | const auto &point = event->position().toPoint(); |
| 102 | int col = columnAt(point.x()); |
| 103 | int row = rowAt(point.y()); |
| 104 | |
| 105 | // a drop from outside is not allowed if there's a screen already there. |
| 106 | if (!model()->screen(col, row).isNull()) |
| 107 | event->ignore(); |
| 108 | else { |
| 109 | event->acceptProposedAction(); |
| 110 | } |
| 111 | } |
| 112 | } else |
| 113 | event->ignore(); |
| 114 | } |
| 115 | |
| 116 | // this is reimplemented from QAbstractItemView::startDrag() |
| 117 | void ScreenSetupView::startDrag(Qt::DropActions) |