// Claim the selection.
void ScintillaQt::ClaimSelection()
{
    bool isSel = !sel.Empty();

    if (isSel)
    {
        QClipboard *cb = QApplication::clipboard();

        // If we support X11 style selection then make it available now.
        if (cb->supportsSelection())
        {
            SelectionText text;

            CopySelectionRange(&text);

            if (text.s)
                cb->setMimeData(mimeSelection(text), QClipboard::Selection);
        }

        primarySelection = true;
    }
    else
        primarySelection = false;

    emit qsb->QSCN_SELCHANGED(isSel);
}
Ejemplo n.º 2
0
// Start a drag.
void QsciScintillaQt::StartDrag()
{
    inDragDrop = ddDragging;

    QDrag *qdrag = new QDrag(qsb);
    qdrag->setMimeData(mimeSelection(drag));

# if QT_VERSION >= 0x040300
    Qt::DropAction action = qdrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction);
# else
    Qt::DropAction action = qdrag->start(Qt::MoveAction);
# endif

    // Remove the dragged text if it was a move to another widget or
    // application.
    if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
        ClearSelection();

    SetDragPosition(QSCI_SCI_NAMESPACE(SelectionPosition)());
    inDragDrop = ddNone;
}
// Start a drag.
void ScintillaQt::StartDrag()
{
    inDragDrop = ddDragging;

    QDrag *qdrag = new QDrag(qsb);
    qdrag->setMimeData(mimeSelection(drag));

# if QT_VERSION >= 0x040300
    // The default action is to copy so that the cursor is correct when over
    // another widget or application (when we have no control over it).  We
    // make sure it is correct over ourself in the event handlers.
    Qt::DropAction action = qdrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction);
# else
    Qt::DropAction action = qdrag->start(Qt::MoveAction);
# endif

    // Remove the dragged text if it was a move to another widget or
    // application.
    if (action == Qt::MoveAction && qdrag->target() != qsb->viewport())
        ClearSelection();

    SetDragPosition(SelectionPosition());
    inDragDrop = ddNone;
}
// Copy the selected text to the clipboard.
void ScintillaQt::CopyToClipboard(const SelectionText &selectedText)
{
    QApplication::clipboard()->setMimeData(mimeSelection(selectedText));
}