void ChatLog::insertChatlineOnTop(ChatLine::Ptr l) { if (!l.get()) return; insertChatlineOnTop(QList<ChatLine::Ptr>() << l); }
void ChatLog::scrollToLine(ChatLine::Ptr line) { if (!line.get()) return; updateSceneRect(); verticalScrollBar()->setValue(line->sceneBoundingRect().top()); }
void ChatLog::setBusyNotification(ChatLine::Ptr notification) { if (!notification.get()) return; busyNotification = notification; busyNotification->addToScene(busyScene); busyNotification->visibilityChanged(true); }
void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l) { if (!l.get()) return; bool stickToBtm = stickToBottom(); //insert l->setRow(lines.size()); l->addToScene(scene); lines.append(l); //partial refresh layout(lines.last()->getRow(), lines.size(), useableWidth()); updateSceneRect(); if (stickToBtm) scrollToBottom(); checkVisibility(); updateTypingNotification(); }
void ChatLog::mouseMoveEvent(QMouseEvent* ev) { QGraphicsView::mouseMoveEvent(ev); QPointF scenePos = mapToScene(ev->pos()); if (ev->buttons() & Qt::LeftButton) { //autoscroll if (ev->pos().y() < 0) selectionScrollDir = Up; else if (ev->pos().y() > height()) selectionScrollDir = Down; else selectionScrollDir = NoDirection; //select if (selectionMode == None && (clickPos - ev->pos()).manhattanLength() > QApplication::startDragDistance()) { QPointF sceneClickPos = mapToScene(clickPos.toPoint()); ChatLine::Ptr line = findLineByPosY(scenePos.y()); ChatLineContent* content = getContentFromPos(sceneClickPos); if (content) { selClickedRow = content->getRow(); selClickedCol = content->getColumn(); selFirstRow = content->getRow(); selLastRow = content->getRow(); content->selectionStarted(sceneClickPos); selectionMode = Precise; // ungrab mouse grabber if (scene->mouseGrabberItem()) scene->mouseGrabberItem()->ungrabMouse(); } else if (line.get()) { selClickedRow = line->getRow(); selFirstRow = selClickedRow; selLastRow = selClickedRow; selectionMode = Multi; } } if (selectionMode != None) { ChatLineContent* content = getContentFromPos(scenePos); ChatLine::Ptr line = findLineByPosY(scenePos.y()); int row; if (content) { row = content->getRow(); int col = content->getColumn(); if (row == selClickedRow && col == selClickedCol) { selectionMode = Precise; content->selectionMouseMove(scenePos); selGraphItem->hide(); } else if (col != selClickedCol) { selectionMode = Multi; lines[selClickedRow]->selectionCleared(); } } else if (line.get()) { row = line->getRow(); if (row != selClickedRow) { selectionMode = Multi; lines[selClickedRow]->selectionCleared(); } } else { return; } if (row >= selClickedRow) selLastRow = row; if (row <= selClickedRow) selFirstRow = row; updateMultiSelectionRect(); } emit selectionChanged(); } }