Skip to content

Commit

Permalink
scide: code editor / post window - copy using plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
totalgee committed Nov 20, 2012
1 parent 0bd1438 commit 04cbd76
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions editors/sc-ide/widgets/code_editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion editors/sc-ide/widgets/code_editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 * );
Expand Down
10 changes: 10 additions & 0 deletions editors/sc-ide/widgets/post_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QScrollBar>
#include <QShortcut>
#include <QKeyEvent>
#include <QTextDocumentFragment>

namespace ScIDE {

Expand Down Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions editors/sc-ide/widgets/post_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 04cbd76

Please sign in to comment.