示例#1
0
void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if (_selectionMode != NoSelection && event->button() == Qt::LeftButton) {
        chatScene()->selectionToClipboard(QClipboard::Selection);
        event->accept();
    }
    else
        event->ignore();
}
示例#2
0
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();
    }
}
示例#3
0
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);
}
示例#4
0
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);
}
示例#5
0
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();
    }
}
示例#6
0
ChatView *ChatItem::chatView() const
{
    return chatScene()->chatView();
}
 inline ChatView *chatView() const {
     return chatScene() ? chatScene()->chatView() : 0;
 }