Ejemplo n.º 1
0
void ChatItem::setFullSelection()
{
    if (_selectionMode != FullSelection) {
        _selectionMode = FullSelection;
        chatLine()->update();
    }
}
Ejemplo n.º 2
0
void ChatItem::setSelection(ChatItem::SelectionMode mode, qint16 start, qint16 end)
{
    _selectionMode = mode;
    _selectionStart = start;
    _selectionEnd = end;
    chatLine()->update();
}
Ejemplo n.º 3
0
void ChatItem::clearSelection()
{
    if (_selectionMode != NoSelection) {
        _selectionMode = NoSelection;
        chatLine()->update();
    }
}
Ejemplo n.º 4
0
Highlight *ChatItem::addHighlight(int start, int length)
{
     Highlight *h = new Highlight(Highlight::Found, this, start,length);
     mHighlights << h;
     chatLine()->update();

    return h;
}
Ejemplo n.º 5
0
QTextLayout *ChatItem::layout() const {
  if(_cachedLayout)
    return _cachedLayout;

  _cachedLayout = new QTextLayout;
  initLayout(_cachedLayout);
  chatView()->setHasCache(chatLine());
  return _cachedLayout;
}
Ejemplo n.º 6
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();
    }
}
Ejemplo n.º 7
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);
}
Ejemplo n.º 8
0
void ChatItem::highlightRemove(Highlight *h)
{
    int pos = mHighlights.indexOf(h);
    if (mHighlights.count() == 0 || pos < 0) {
        return;
    }

    if(h) {
        delete h;
        h = nullptr;
    }
    mHighlights.removeAt(pos);
    chatLine()->update();
}
Ejemplo n.º 9
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();
    }
}
Ejemplo n.º 10
0
QPointF ChatItem::mapFromScene(const QPointF &p) const
{
    return chatLine()->mapFromScene(p) /* - pos() */;
}
Ejemplo n.º 11
0
QPointF ChatItem::mapToScene(const QPointF &p) const
{
    return chatLine()->mapToScene(p /* + pos() */);
}
Ejemplo n.º 12
0
int ChatItem::row() const
{
    return chatLine()->row();
}
Ejemplo n.º 13
0
ChatScene *ChatItem::chatScene() const
{
    return chatLine()->chatScene();
}
Ejemplo n.º 14
0
const QAbstractItemModel *ChatItem::model() const
{
    return chatLine()->model();
}
Ejemplo n.º 15
0
void ChatItem::continueSelecting(const QPointF &pos)
{
    _selectionMode = PartialSelection;
    _selectionEnd = posToCursor(pos);
    chatLine()->update();
}
Ejemplo n.º 16
0
void HWChatWidget::returnPressed()
{
    emit chatLine(chatEditLine->text());
    chatEditLine->clear();
}