Temporarily disable topic to make quassel compile again after sputdev merge
[quassel.git] / src / qtui / chatitem.cpp
index 286fd62..adfcd9c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <QApplication>
 #include <QClipboard>
+#include <QDesktopServices>
 #include <QFontMetrics>
 #include <QGraphicsSceneMouseEvent>
 #include <QPainter>
@@ -197,9 +198,15 @@ void ChatItem::continueSelecting(const QPointF &pos) {
 
 void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
   if(event->buttons() & Qt::LeftButton) {
-    chatScene()->setSelectingItem(this);  // removes earlier selection if exists
-    _selectionStart = _selectionEnd = posToCursor(event->pos());
-    _selectionMode = PartialSelection;
+    if(_selectionMode == NoSelection) {
+      chatScene()->setSelectingItem(this);  // removes earlier selection if exists
+      _selectionStart = _selectionEnd = posToCursor(event->pos());
+      _selectionMode = PartialSelection;
+    } else {
+      chatScene()->setSelectingItem(0);
+      _selectionMode = NoSelection;
+      update();
+    }
     event->accept();
   } else {
     event->ignore();
@@ -231,6 +238,24 @@ void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
   }
 }
 
+void ChatItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
+  // FIXME dirty and fast hack to make http:// urls klickable
+
+  QRegExp regex("\\b((?:h|f)t{1,2}ps?:\\/\\/.+)\\b");
+  QString str = data(ChatLineModel::DisplayRole).toString();
+  int idx = posToCursor(event->pos());
+  int mi = 0;
+  do {
+    mi = regex.indexIn(str, mi);
+    if(mi < 0) break;
+    if(idx >= mi && idx < mi + regex.matchedLength()) {
+      QDesktopServices::openUrl(QUrl(regex.capturedTexts()[1]));
+      break;
+    }
+  } while(mi >= 0);
+  event->accept();
+}
+
 void ChatItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
   //qDebug() << (void*)this << "entering";