From 933adc60de3b0a1c1916d22632c19764a7988151 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 5 Apr 2013 13:47:32 +0000 Subject: [PATCH] Paste of multi-line text from middle mouse button click (selection buffer) --- src/PyConsole/PyConsole_Editor.cxx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx index 2d7317ba4..636ee54a7 100644 --- a/src/PyConsole/PyConsole_Editor.cxx +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -86,11 +86,6 @@ - : copy - : cut - : paste - - TODO: - - paste multiline text: process each line as separate command - (including mouse middle-button click pasting) - - the same for drag-n-drop of multiline text */ #include "PyConsole_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!! @@ -469,11 +464,6 @@ void PyConsole_Editor::mouseReleaseEvent( QMouseEvent* event ) //copy(); } else if ( event->button() == Qt::MidButton ) { - QString text; - if ( QApplication::clipboard()->supportsSelection() ) - text = QApplication::clipboard()->text( QClipboard::Selection ); - if ( text.isEmpty() ) - text = QApplication::clipboard()->text( QClipboard::Clipboard ); QTextCursor cur = cursorForPosition( event->pos() ); // if the position is not in the last line move it to the end of the command line if ( cur.position() < document()->end().previous().position() + promptSize() ) { @@ -482,8 +472,10 @@ void PyConsole_Editor::mouseReleaseEvent( QMouseEvent* event ) else { setTextCursor( cur ); } - textCursor().clearSelection(); - textCursor().insertText( text ); + const QMimeData* md = QApplication::clipboard()->mimeData( QApplication::clipboard()->supportsSelection() ? + QClipboard::Selection : QClipboard::Clipboard ); + if ( md ) + insertFromMimeData( md ); } else { QTextEdit::mouseReleaseEvent( event ); -- 2.39.2