Beispiel #1
0
void DividerItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
  QMenu menu;
  QAction *editAction     = menu.addAction("Change Divider");
  QAction *deleteAction   = menu.addAction("Delete Divider");

  editAction->setWhatsThis("Put the steps in this row together with the steps after this");
  
  QAction *selectedAction = menu.exec(event->screenPos());

  if (selectedAction == NULL) {
    return;
  }
  
  Step *nextStep = step->nextStep();
  if ( ! nextStep) {
    return;
  }
  
  Where topOfStep    = nextStep->topOfStep();
  Where bottomOfStep = nextStep->bottomOfStep();
  Range *range = step->range();

  if (selectedAction == editAction) {
    changeDivider("Divider",topOfStep,bottomOfStep,&range->sepMeta,1,false);
  } else if (selectedAction == deleteAction) {
    deleteDivider(parentRelativeType,topOfStep);
  }
}
void Segmenter::mousePressEvent (QGraphicsSceneMouseEvent * event)
{
    // left click in the scene with no mods - add a divider
    if (moveMode()) {
        this->QGraphicsScene::mousePressEvent(event);
    } else if (deleteMode()) {
        Divider* todelete = static_cast<Divider*>(this->itemAt(event->scenePos()));
        // TODO: Figure out why this causes a weird crash
        // it's supposed to test if we can delete an intermediate
        // point instead of the whole divider
        //if (!todelete->deletePointAt(event->scenePos())) {
        //    deleteDivider(todelete);
        //}
        deleteDivider(todelete);
    } else if (drawMode() && event->buttons() & Qt::LeftButton) {
        Divider* newdiv = addDivider(m_markerdivider->mapRectToScene(m_captivedivider->boundingRect()).center());
        // set the new div to match the marker poly
        newdiv->setPolygon(m_markerdivider->polygon());        
        // hide the marker and grab the new div - bit dodgy this...
        m_markerdivider->setVisible(false);
        grabDivider(newdiv);
    }
}