}
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());
}
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;
+ 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));
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();
}
}
void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
- if(_isSelecting && event->buttons() & Qt::LeftButton) {
+ if(_isSelecting && event->buttons() == Qt::LeftButton) {
updateSelection(event->scenePos());
event->accept();
} else {
}
void ChatScene::mousePressEvent(QGraphicsSceneMouseEvent *event) {
- if(event->buttons() & Qt::LeftButton && _selectionStart >= 0) {
+ if(event->buttons() == Qt::LeftButton && _selectionStart >= 0) {
for(int l = qMin(_selectionStart, _selectionEnd); l <= qMax(_selectionStart, _selectionEnd); l++) {
_lines[l]->setSelected(false);
}
}
void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
- if(_isSelecting) {
+ if(_isSelecting && event->buttons() == Qt::LeftButton) {
# ifdef Q_WS_X11
QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection);
# endif