]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Paste of multi-line text from middle mouse button click (selection buffer)
authorvsr <vsr@opencascade.com>
Fri, 5 Apr 2013 13:47:32 +0000 (13:47 +0000)
committervsr <vsr@opencascade.com>
Fri, 5 Apr 2013 13:47:32 +0000 (13:47 +0000)
src/PyConsole/PyConsole_Editor.cxx

index 2d7317ba49859c458ad34324366a2a08d6504bc3..636ee54a7c2667537f86cdd68d4795c542a937b6 100644 (file)
   - <Ctrl><C>            : copy
   - <Ctrl><X>            : cut
   - <Ctrl><V>            : 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 );