diff --git a/editors/sc-ide/widgets/code_editor/editor.cpp b/editors/sc-ide/widgets/code_editor/editor.cpp index 3e4324dc8a1..738419f91d8 100644 --- a/editors/sc-ide/widgets/code_editor/editor.cpp +++ b/editors/sc-ide/widgets/code_editor/editor.cpp @@ -903,4 +903,13 @@ void GenericCodeEditor::hideMouseCursor() QApplication::setOverrideCursor( Qt::BlankCursor ); } +QMimeData *GenericCodeEditor::createMimeDataFromSelection() const +{ + // Here, we bundle up just the plaintext (not HTML, as is the default) of + // the editor's selected contents. + QMimeData *data = new QMimeData; + data->setText(textCursor().selection().toPlainText()); + return data; +} + } // namespace ScIDE diff --git a/editors/sc-ide/widgets/code_editor/editor.hpp b/editors/sc-ide/widgets/code_editor/editor.hpp index 90b72dd5587..8335bd8d3e7 100644 --- a/editors/sc-ide/widgets/code_editor/editor.hpp +++ b/editors/sc-ide/widgets/code_editor/editor.hpp @@ -59,7 +59,7 @@ class GenericCodeEditor : public QPlainTextEdit virtual void wheelEvent( QWheelEvent * ); virtual void dragEnterEvent( QDragEnterEvent * ); void hideMouseCursor(QKeyEvent *); - + virtual QMimeData *createMimeDataFromSelection() const; public slots: void applySettings( Settings::Manager * ); diff --git a/editors/sc-ide/widgets/post_window.cpp b/editors/sc-ide/widgets/post_window.cpp index ef171a91e4c..f0e720b0473 100644 --- a/editors/sc-ide/widgets/post_window.cpp +++ b/editors/sc-ide/widgets/post_window.cpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace ScIDE { @@ -268,6 +269,15 @@ void PostWindow::mouseDoubleClickEvent(QMouseEvent *e) cursor.endEditBlock(); } +QMimeData *PostWindow::createMimeDataFromSelection() const +{ + // Here, we bundle up just the plaintext (not HTML, as is the default) of + // the post window's selected contents. + QMimeData *data = new QMimeData; + data->setText(textCursor().selection().toPlainText()); + return data; +} + bool PostWindow::openDocumentation() { return Main::openDocumentation(symbolUnderCursor()); diff --git a/editors/sc-ide/widgets/post_window.hpp b/editors/sc-ide/widgets/post_window.hpp index fad81056c01..8bfd3c360f4 100644 --- a/editors/sc-ide/widgets/post_window.hpp +++ b/editors/sc-ide/widgets/post_window.hpp @@ -77,6 +77,7 @@ public slots: virtual void wheelEvent( QWheelEvent * ); virtual void focusOutEvent (QFocusEvent *e); virtual void mouseDoubleClickEvent(QMouseEvent *e); + virtual QMimeData *createMimeDataFromSelection() const; private slots: void onAutoScrollTriggered(bool);