Beispiel #1
0
// public
void kpTool::setUserShapePoints (const QPoint &startPoint,
                                 const QPoint &endPoint,
                                 bool setSize)
{
    m_userShapeStartPoint = startPoint;
    m_userShapeEndPoint = endPoint;
    emit userShapePointsChanged (m_userShapeStartPoint, m_userShapeEndPoint);

    if (setSize)
    {
        if (startPoint != KP_INVALID_POINT &&
            endPoint != KP_INVALID_POINT)
        {
            setUserShapeSize (calculateLength (startPoint.x (), endPoint.x ()),
                              calculateLength (startPoint.y (), endPoint.y ()));
        }
        else
        {
            setUserShapeSize ();
        }
    }
}
// private
void kpAbstractSelectionTool::drawMove (const QPoint &thisPoint, const QRect &/*normalizedRect*/)
{
#if DEBUG_KP_TOOL_SELECTION && 1
    qCDebug(kpLogTools) << "\tmoving selection";
#endif

    kpAbstractSelection *sel = document ()->selection ();

    QRect targetSelRect (thisPoint.x () - d->startMoveDragFromSelectionTopLeft.x (),
                         thisPoint.y () - d->startMoveDragFromSelectionTopLeft.y (),
                         sel->width (),
                         sel->height ());

#if DEBUG_KP_TOOL_SELECTION && 1
    qCDebug(kpLogTools) << "\t\tstartPoint=" << startPoint ()
                        << " thisPoint=" << thisPoint
                        << " startDragFromSel=" << d->startMoveDragFromSelectionTopLeft
                        << " targetSelRect=" << targetSelRect
                        << endl;
#endif

    // Try to make sure selection still intersects document so that it's
    // reachable.

    if (targetSelRect.right () < 0)
        targetSelRect.translate (-targetSelRect.right (), 0);
    else if (targetSelRect.left () >= document ()->width ())
        targetSelRect.translate (document ()->width () - targetSelRect.left () - 1, 0);

    if (targetSelRect.bottom () < 0)
        targetSelRect.translate (0, -targetSelRect.bottom ());
    else if (targetSelRect.top () >= document ()->height ())
        targetSelRect.translate (0, document ()->height () - targetSelRect.top () - 1);

#if DEBUG_KP_TOOL_SELECTION && 1
    qCDebug(kpLogTools) << "\t\t\tafter ensure sel rect clickable=" << targetSelRect;
#endif


    if (!d->dragAccepted &&
            targetSelRect.topLeft () + d->startMoveDragFromSelectionTopLeft == startPoint ())
    {
#if DEBUG_KP_TOOL_SELECTION && 1
        qCDebug(kpLogTools) << "\t\t\t\tnop";
#endif


        if (!d->RMBMoveUpdateGUITimer->isActive ())
        {
            // (slotRMBMoveUpdateGUI() calls similar line)
            setUserShapePoints (sel->topLeft ());
        }

        // Prevent both NOP drag-moves
        return;
    }


    if (d->RMBMoveUpdateGUITimer->isActive ())
    {
        d->RMBMoveUpdateGUITimer->stop ();
        slotRMBMoveUpdateGUI ();
    }


    giveContentIfNeeded ();


    if (!d->currentMoveCommand)
    {
        d->currentMoveCommand = new kpToolSelectionMoveCommand (
            QString()/*uninteresting child of macro cmd*/,
            environ ()->commandEnvironment ());
        d->currentMoveCommandIsSmear = false;
    }


    //viewManager ()->setQueueUpdates ();
    //viewManager ()->setFastUpdates ();

    if (shiftPressed ())
        d->currentMoveCommandIsSmear = true;

    if (!d->dragAccepted && (controlPressed () || shiftPressed ()))
        d->currentMoveCommand->copyOntoDocument ();

    d->currentMoveCommand->moveTo (targetSelRect.topLeft ());

    if (shiftPressed ())
        d->currentMoveCommand->copyOntoDocument ();

    //viewManager ()->restoreFastUpdates ();
    //viewManager ()->restoreQueueUpdates ();

    // REFACTOR: yuck, yuck
    kpAbstractSelection *orgSel = d->currentMoveCommand->originalSelectionClone ();
    QPoint start = orgSel->topLeft ();
    delete orgSel;
    QPoint end = targetSelRect.topLeft ();
    setUserShapePoints (start, end, false/*don't set size*/);
    setUserShapeSize (end.x () - start.x (), end.y () - start.y ());


    d->dragAccepted = true;
}
Beispiel #3
0
// public
void kpTool::setUserShapeSize (int width, int height)
{
    setUserShapeSize (QSize (width, height));
}