Remove displayed brackets around sender nicks
[quassel.git] / src / qtui / chatscene.cpp
index 07adaa0..8a5f7d4 100644 (file)
@@ -36,7 +36,9 @@
 #  include <QMenuBar>
 #endif
 
-#ifdef HAVE_WEBKIT
+#ifdef HAVE_WEBENGINE
+#  include <QWebEngineView>
+#elif defined HAVE_WEBKIT
 #  include <QWebView>
 #endif
 
@@ -122,7 +124,7 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w
         this, SLOT(rowsRemoved()));
     connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(dataChanged(QModelIndex, QModelIndex)));
 
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
     webPreview.timer.setSingleShot(true);
     connect(&webPreview.timer, SIGNAL(timeout()), this, SLOT(webPreviewNextStep()));
 #endif
@@ -1024,9 +1026,18 @@ QString ChatScene::selection() const
         for (int l = start; l <= end; 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";
+            if (_selectionMinCol <= ChatLineModel::SenderColumn) {
+                ChatItem *item = _lines[l]->item(ChatLineModel::SenderColumn);
+                if (item->chatLine()->msgType() == Message::Plain) {
+                    // Copying to plain-text, re-add the sender brackets
+                    result += QString("<%1> ").arg(item->data(MessageModel::DisplayRole)
+                                                   .toString());
+                } else {
+                    result += item->data(MessageModel::DisplayRole).toString() + " ";
+                }
+            }
+            result += _lines[l]->item(ChatLineModel::ContentsColumn)
+                    ->data(MessageModel::DisplayRole).toString() + "\n";
         }
         return result;
     }
@@ -1171,9 +1182,9 @@ void ChatScene::updateSceneRect(const QRectF &rect)
 
 
 // ========================================
-//  Webkit Only stuff
+//  Webkit/WebEngine Only stuff
 // ========================================
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
 void ChatScene::loadWebPreview(ChatItem *parentItem, const QUrl &url, const QRectF &urlRect)
 {
     if (!_showWebPreview)