void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (_selectionMode != NoSelection && event->button() == Qt::LeftButton) { chatScene()->selectionToClipboard(QClipboard::Selection); event->accept(); } else event->ignore(); }
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(); } }
bool ChatLine::sceneEvent(QEvent *event) { if(event->type() == QEvent::GrabMouse) { // get mouse cursor pos relative to us ChatView *view = chatScene()->chatView(); QPointF linePos = mapFromScene(view->mapToScene(view->mapFromGlobal(QCursor::pos()))); setMouseGrabberItem(itemAt(linePos)); } else if(event->type() == QEvent::UngrabMouse) { setMouseGrabberItem(0); } return QGraphicsItem::sceneEvent(event); }
QTextDocument *ChatItem::document() const { if (mDoc) return &(mDoc->doc); ChatItem *that = const_cast<ChatItem *>(this); mDoc = new ChatItemDocument(that); mDoc->callInitDocument(); if(chatScene()) chatView()->setHasCache(chatLine(), true); return &(mDoc->doc); }
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(); } }
ChatView *ChatItem::chatView() const { return chatScene()->chatView(); }
inline ChatView *chatView() const { return chatScene() ? chatScene()->chatView() : 0; }