X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=051151c5e3a5566e662670515c05094be9224417;hp=14fd3addb049f37bcca246496f950a9dc78f2291;hb=c95e8cea9060b25fa5115d19090b51f03290adc5;hpb=f5f53f6c963f376b3003582f22314d744d157229 diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 14fd3add..051151c5 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -60,11 +60,11 @@ QVariant ChatItem::data(int role) const { return model()->data(index, role); } -qreal ChatItem::setWidth(qreal w) { +qreal ChatItem::setGeometry(qreal w, qreal h) { if(w == _boundingRect.width()) return _boundingRect.height(); prepareGeometryChange(); _boundingRect.setWidth(w); - qreal h = computeHeight(); + if(h < 0) h = computeHeight(); _boundingRect.setHeight(h); if(haveLayout()) updateLayout(); return h; @@ -204,11 +204,11 @@ void ChatItem::continueSelecting(const QPointF &pos) { } void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if(event->buttons() & Qt::LeftButton) { + if(event->buttons() == Qt::LeftButton) { if(_selectionMode == NoSelection) { chatScene()->setSelectingItem(this); // removes earlier selection if exists _selectionStart = _selectionEnd = posToCursor(event->pos()); - _selectionMode = PartialSelection; + //_selectionMode = PartialSelection; } else { chatScene()->setSelectingItem(0); _selectionMode = NoSelection; @@ -221,24 +221,31 @@ void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } void ChatItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - if(contains(event->pos())) { - qint16 end = posToCursor(event->pos()); - if(end != _selectionEnd) { - _selectionEnd = end; - update(); + if(event->buttons() == Qt::LeftButton) { + if(contains(event->pos())) { + qint16 end = posToCursor(event->pos()); + if(end != _selectionEnd) { + _selectionEnd = end; + if(_selectionStart != _selectionEnd) _selectionMode = PartialSelection; + else _selectionMode = NoSelection; + update(); + } + } else { + setFullSelection(); + chatScene()->startGlobalSelection(this, event->pos()); } + event->accept(); } else { - setFullSelection(); - chatScene()->startGlobalSelection(this, event->pos()); + event->ignore(); } } void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if(_selectionMode != NoSelection) { + 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 + chatScene()->putToClipboard(selection); event->accept(); } else { event->ignore(); @@ -266,17 +273,17 @@ void ChatItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { 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(); }