void StyledLabel::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { Clickable click = _clickables.atCursorPos(posToCursor(event->posF())); if (click.isValid()) emit clickableActivated(click); } }
bool ChatItem::isPosOverSelection(const QPointF &pos) const { if(_selectionMode == FullSelection) return true; if(_selectionMode == PartialSelection) { int cursor = posToCursor(pos); return cursor >= qMin(_selectionStart, _selectionEnd) && cursor <= qMax(_selectionStart, _selectionEnd); } return false; }
void ChatItem::handleClick(const QPointF &pos, ChatScene::ClickMode clickMode) { // single clicks are already handled by the scene (for clearing the selection) if (clickMode == ChatScene::DragStartClick) { chatScene()->setSelectingItem(this); _selectionStart = _selectionEnd = posToCursor(pos); _selectionMode = NoSelection; // will be set to PartialSelection by mouseMoveEvent chatLine()->update(); } }
void StyledLabel::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() == Qt::NoButton) { Clickable click = _clickables.atCursorPos(posToCursor(event->posF())); if (click.isValid()) setHoverMode(click.start(), click.length()); else endHoverMode(); } }
void ChatItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if (event->buttons() == Qt::LeftButton) { if (boundingRect().contains(event->pos())) { qint16 end = posToCursor(event->pos()); if (end != _selectionEnd) { _selectionEnd = end; _selectionMode = (_selectionStart != _selectionEnd ? PartialSelection : NoSelection); chatLine()->update(); } } else { setFullSelection(); chatScene()->startGlobalSelection(this, event->pos()); } event->accept(); } else { event->ignore(); } }
void ChatItem::continueSelecting(const QPointF &pos) { _selectionMode = PartialSelection; _selectionEnd = posToCursor(pos); chatLine()->update(); }