isis/src/qisis/objs/PlotWindow/PlotWindow.cpp
void PlotWindow::dropEvent(QDropEvent *event) {
    if (m_allowUserToAddCurves &&
        event->mimeData()->hasFormat("application/isis3-plot-curve")) {
      Qt::DropActions possibleActions = event->possibleActions();
      Qt::DropAction actionToTake = event->proposedAction();

      QFont boldFont;
      boldFont.setBold(true);
      QMenu dropActionsMenu;

      QAction *copyAct = new QAction("&Copy Here", this);
      if (possibleActions.testFlag(Qt::CopyAction)) {
        dropActionsMenu.addAction(copyAct);

        if (actionToTake == Qt::CopyAction)
          copyAct->setFont(boldFont);
      }

      QAction *moveAct = new QAction("&Move Here", this);
      if (possibleActions.testFlag(Qt::MoveAction)) {
        dropActionsMenu.addAction(moveAct);

        if (actionToTake == Qt::MoveAction)
          moveAct->setFont(boldFont);
      }

      if (dropActionsMenu.actions().size() > 1) {
        dropActionsMenu.addSeparator();

        QAction *cancelAct = new QAction("&Cancel", this);
        dropActionsMenu.addAction(cancelAct);

        QAction *chosenAct = dropActionsMenu.exec(mapToGlobal(event->pos()));

        if (chosenAct == copyAct) {
          actionToTake = Qt::CopyAction;
        }
        else if (chosenAct == moveAct) {
          actionToTake = Qt::MoveAction;
        }
        else {
          actionToTake = Qt::IgnoreAction;
        }
      }

      if (actionToTake != Qt::IgnoreAction) {
        CubePlotCurve * newCurve = new CubePlotCurve(
                event->mimeData()->data("application/isis3-plot-curve"));
        // add curve to plot
        add(newCurve);
        emit plotChanged();

        event->setDropAction(actionToTake);
        event->accept();
      }
    }
  }
/**
   * This is called when a user drops data into our window. The dragEnterEvent()
   *   must have said that this curve is compatible with this window. This
   *   provides all of the available options to the user (if any) set by the
   *   creator of the drag & drop event (i.e. whether or not we can move or
   *   just copy). If there are options, we create a context menu - otherwise
   *   the default action is taken.
   *
   * @param event The drop event containing the curve to put into the current
   *              window.
   */
This is called when a user drops data into our window. The dragEnterEvent()
must have said that this curve is compatible with this window. This
provides all of the available options to the user (if any) set by the
creator of the drag & drop event . If there are options, we create a context menu - otherwise
the default action is taken.

@param event The drop event containing the curve to put into the current
window.
This is called when a user drops data into our window . The dragEnterEvent () must have said that this curve is compatible with this window . This provides all of the available options to the user ( if any ) set by the creator of the drag & drop event . If there are options we create a context menu - otherwise the default action is taken . @param event The drop event containing the curve to put into the current window .
void PlotWindow::dropEvent(QDropEvent *event) {
    if (m_allowUserToAddCurves &&
        event->mimeData()->hasFormat("application/isis3-plot-curve")) {
      Qt::DropActions possibleActions = event->possibleActions();
      Qt::DropAction actionToTake = event->proposedAction();
      QFont boldFont;
      boldFont.setBold(true);
      QMenu dropActionsMenu;
      QAction *copyAct = new QAction("&Copy Here", this);
      if (possibleActions.testFlag(Qt::CopyAction)) {
        dropActionsMenu.addAction(copyAct);
        if (actionToTake == Qt::CopyAction)
          copyAct->setFont(boldFont);
      }
      QAction *moveAct = new QAction("&Move Here", this);
      if (possibleActions.testFlag(Qt::MoveAction)) {
        dropActionsMenu.addAction(moveAct);
        if (actionToTake == Qt::MoveAction)
          moveAct->setFont(boldFont);
      }
      if (dropActionsMenu.actions().size() > 1) {
        dropActionsMenu.addSeparator();
        QAction *cancelAct = new QAction("&Cancel", this);
        dropActionsMenu.addAction(cancelAct);
        QAction *chosenAct = dropActionsMenu.exec(mapToGlobal(event->pos()));
        if (chosenAct == copyAct) {
          actionToTake = Qt::CopyAction;
        }
        else if (chosenAct == moveAct) {
          actionToTake = Qt::MoveAction;
        }
        else {
          actionToTake = Qt::IgnoreAction;
        }
      }
      if (actionToTake != Qt::IgnoreAction) {
        CubePlotCurve * newCurve = new CubePlotCurve(
                event->mimeData()->data("application/isis3-plot-curve"));
        add(newCurve);
        emit plotChanged();
        event->setDropAction(actionToTake);
        event->accept();
      }
    }
  }
void PlotWindow :: dropEvent ( QDropEvent * event ) { if ( m_allowUserToAddCurves && event -> mimeData ( ) -> hasFormat ( " " ) ) { Qt :: DropActions possibleActions = event -> possibleActions ( ) ; Qt :: DropAction actionToTake = event -> proposedAction ( ) ; QFont boldFont ; boldFont . setBold ( true ) ; QMenu dropActionsMenu ; QAction * copyAct = new QAction ( " " , this ) ; if ( possibleActions . testFlag ( Qt :: CopyAction ) ) { dropActionsMenu . addAction ( copyAct ) ; if ( actionToTake == Qt :: CopyAction ) copyAct -> setFont ( boldFont ) ; } QAction * moveAct = new QAction ( " " , this ) ; if ( possibleActions . testFlag ( Qt :: MoveAction ) ) { dropActionsMenu . addAction ( moveAct ) ; if ( actionToTake == Qt :: MoveAction ) moveAct -> setFont ( boldFont ) ; } if ( dropActionsMenu . actions ( ) . size ( ) > 1 ) { dropActionsMenu . addSeparator ( ) ; QAction * cancelAct = new QAction ( " " , this ) ; dropActionsMenu . addAction ( cancelAct ) ; QAction * chosenAct = dropActionsMenu . exec ( mapToGlobal ( event -> pos ( ) ) ) ; if ( chosenAct == copyAct ) { actionToTake = Qt :: CopyAction ; } else if ( chosenAct == moveAct ) { actionToTake = Qt :: MoveAction ; } else { actionToTake = Qt :: IgnoreAction ; } } if ( actionToTake != Qt :: IgnoreAction ) { CubePlotCurve * newCurve = new CubePlotCurve ( event -> mimeData ( ) -> data ( " " ) ) ; add ( newCurve ) ; emit plotChanged ( ) ; event -> setDropAction ( actionToTake ) ; event -> accept ( ) ; } } }
This is called when a user drops data into our window.
This is called when a user drops data into our window .
// add curve to plot