예제 #1
0
void AbstractContent::keyPressEvent(QKeyEvent * event)
{
    // discard key events for unselectable items
    if (!(flags() & ItemIsSelectable)) {
        event->ignore();
        return;
    }
    event->accept();
    int step = (event->modifiers() & Qt::ShiftModifier) ? 50 : (event->modifiers() & Qt::ControlModifier ? 1 : 10);
    switch (event->key()) {
        // cursor keys: 10px, 50 if Shift pressed, 1 if Control pressed
        case Qt::Key_Left:      setPos(pos() - QPointF(step, 0));   break;
        case Qt::Key_Up:        setPos(pos() - QPointF(0, step));   break;
        case Qt::Key_Right:     setPos(pos() + QPointF(step, 0));   break;
        case Qt::Key_Down:      setPos(pos() + QPointF(0, step));   break;

        // deletion
        case Qt::Key_Delete: emit requestRemoval(); break;

        // editing
        case Qt::Key_Return: emit requestEditing(); break;

        // ignore unhandled key
        default: event->ignore();
    }
}
예제 #2
0
void TextContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
{
#ifdef ICT
    emit requestEditing();
#else
    emit requestBackgrounding();
#endif
}
예제 #3
0
void AbstractContent::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
{
    // emitting the edit request by default. some subclasses request backgrounding
    emit requestEditing();
}