X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=8207248e2d2a2f6a5d7d1fb1dde03868554bc6f0;hb=b8393cf7150270830deb26e9621f642ffff77d4c;hp=0671365254a13994d9e665288b8a1ada427543e6;hpb=8efabae6c310d17265eaeb03df43ffe8b555a52e;p=quassel.git diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 06713652..8207248e 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -18,6 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include +#include #include #include @@ -225,6 +227,12 @@ void ChatScene::mousePressEvent(QGraphicsSceneMouseEvent *event) { void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if(_isSelecting) { +# ifdef Q_WS_X11 + QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection); +# endif +//# else + QApplication::clipboard()->setText(selectionToString()); +//# endif _isSelecting = false; event->accept(); } else { @@ -232,3 +240,17 @@ void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { } } +//!\brief Convert current selection to human-readable string. +QString ChatScene::selectionToString() const { + //TODO Make selection format configurable! + if(!_isSelecting) return ""; + QString result; + for(int l = _selectionStart; l <= _selectionEnd; l++) { + if(_selectionMinCol == ChatLineModel::TimestampColumn) + result += _lines[l]->item(ChatLineModel::TimestampColumn)->data(MessageModel::DisplayRole).toString() + " "; + if(_selectionMinCol <= ChatLineModel::SenderColumn) + result += _lines[l]->item(ChatLineModel::SenderColumn)->data(MessageModel::DisplayRole).toString() + " "; + result += _lines[l]->item(ChatLineModel::ContentsColumn)->data(MessageModel::DisplayRole).toString() + "\n"; + } + return result; +}