Exemplo n.º 1
0
void StyledLabel::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        Clickable click = _clickables.atCursorPos(posToCursor(event->posF()));
        if (click.isValid())
            emit clickableActivated(click);
    }
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
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();
    }
}
Exemplo n.º 4
0
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();
    }
}
Exemplo n.º 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();
    }
}
Exemplo n.º 6
0
void ChatItem::continueSelecting(const QPointF &pos)
{
    _selectionMode = PartialSelection;
    _selectionEnd = posToCursor(pos);
    chatLine()->update();
}