+
+void ChatItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+ if(event->buttons() == Qt::LeftButton) {
+ if(contains(event->pos())) {
+ qint16 end = posToCursor(event->pos());
+ if(end != _selectionEnd) {
+ _selectionEnd = end;
+ update();
+ }
+ } else {
+ setFullSelection();
+ chatScene()->startGlobalSelection(this, event->pos());
+ }
+ event->accept();
+ } else {
+ event->ignore();
+ }
+}
+
+void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
+ if(_selectionMode != NoSelection && !event->buttons() & Qt::LeftButton) {
+ _selectionEnd = posToCursor(event->pos());
+ QString selection
+ = data(MessageModel::DisplayRole).toString().mid(qMin(_selectionStart, _selectionEnd), qAbs(_selectionStart - _selectionEnd));
+ QApplication::clipboard()->setText(selection, QClipboard::Clipboard); // TODO configure where selections should go
+ event->accept();
+ } else {
+ event->ignore();
+ }
+}
+
+void ChatItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
+ // FIXME dirty and fast hack to make http:// urls klickable
+
+ QRegExp regex("\\b([hf]t{1,2}ps?://[^\\s]+)\\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;
+ }
+ mi += regex.matchedLength();
+ } while(mi >= 0);
+ event->accept();
+}
+
+void ChatItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
+ //qDebug() << (void*)this << "entering";
+ event->ignore();
+}
+
+void ChatItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
+ //qDebug() << (void*)this << "leaving";
+ event->ignore();
+}
+
+void ChatItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
+ //qDebug() << (void*)this << event->pos();
+ event->ignore();
+}
+