Esempio n. 1
3
  // ! [1]
  protected void dropEvent(QDropEvent event) {
    if (event.source() == this && event.possibleActions().isSet(Qt.DropAction.MoveAction)) return;
    // ! [1]

    // ! [2]
    if (event.proposedAction().equals(Qt.DropAction.MoveAction)) {
      event.acceptProposedAction();
      // Process the data from the event.
      // ! [2]
      dragResult.emit(tr("The data was moved here."));
      // ! [3]
    } else if (event.proposedAction().equals(Qt.DropAction.CopyAction)) {
      event.acceptProposedAction();
      // Process the data from the event.
      // ! [3]
      dragResult.emit(tr("The data was copied here."));
      // ! [4]
    } else {
      // Ignore the drop.
      return;
    }
    // ! [4]
    // End of quote

    mimeTypes.emit(event.mimeData().formats());
    setData(
        event.mimeData().formats().get(0),
        event.mimeData().data(event.mimeData().formats().get(0)));
    // ! [5]
  }
Esempio n. 2
0
  // ! [7]
  protected void mouseMoveEvent(QMouseEvent event) {
    if (!(event.buttons().isSet(Qt.MouseButton.LeftButton))) return;
    if ((event.pos().subtract(dragStartPosition)).manhattanLength()
        < QApplication.startDragDistance()) return;

    QDrag drag = new QDrag(this);
    QMimeData mimeData = new QMimeData();

    mimeData.setData(mimeType, data);
    drag.setMimeData(mimeData);

    Qt.DropAction dropAction = drag.exec(Qt.DropAction.CopyAction, Qt.DropAction.MoveAction);
    // ! [7]

    switch (dropAction) {
      case CopyAction:
        dragResult.emit(tr("The text was copied."));
        break;
      case MoveAction:
        dragResult.emit(tr("The text was moved."));
        break;
      default:
        dragResult.emit(tr("Unknown action."));
        break;
    }
    // ! [8]
  }
Esempio n. 3
0
 public static void connect(PythonSignal signal, PyMethod method) {
   PythonSlot receiver = new PythonSlot(method);
   if (signal instanceof Signal0) {
     ((Signal0) signal).signal.connect(receiver, signature(0));
   } else if (signal instanceof Signal1) {
     ((Signal1) signal).signal.connect(receiver, signature(1));
   } else if (signal instanceof Signal2) {
     ((Signal2) signal).signal.connect(receiver, signature(2));
   } else if (signal instanceof Signal3) {
     ((Signal3) signal).signal.connect(receiver, signature(3));
   } else if (signal instanceof Signal4) {
     ((Signal4) signal).signal.connect(receiver, signature(4));
   } else if (signal instanceof Signal5) {
     ((Signal5) signal).signal.connect(receiver, signature(5));
   } else if (signal instanceof Signal6) {
     ((Signal6) signal).signal.connect(receiver, signature(6));
   } else if (signal instanceof Signal7) {
     ((Signal7) signal).signal.connect(receiver, signature(7));
   } else if (signal instanceof Signal8) {
     ((Signal8) signal).signal.connect(receiver, signature(8));
   } else if (signal instanceof Signal9) {
     ((Signal9) signal).signal.connect(receiver, signature(9));
   }
 }