|
|
@ -76,17 +76,17 @@ ChatLog::ChatLog(QWidget* parent) |
|
|
|
connect(workerTimer, &QTimer::timeout, this, [this] { |
|
|
|
connect(workerTimer, &QTimer::timeout, this, [this] { |
|
|
|
const int stepSize = 400; |
|
|
|
const int stepSize = 400; |
|
|
|
|
|
|
|
|
|
|
|
workerDy += layout(lastWorkerIndex, lastWorkerIndex+stepSize, useableWidth()); |
|
|
|
workerDy += layout(workerLastIndex, workerLastIndex+stepSize, useableWidth()); |
|
|
|
|
|
|
|
|
|
|
|
if(!visibleLines.isEmpty()) |
|
|
|
if(!visibleLines.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int firstVisLineIndex = visibleLines.first()->getRowIndex(); |
|
|
|
int firstVisLineIndex = visibleLines.first()->getRowIndex(); |
|
|
|
int delta = firstVisLineIndex - lastWorkerIndex; |
|
|
|
int delta = firstVisLineIndex - workerLastIndex; |
|
|
|
if(delta > 0 && delta < stepSize) |
|
|
|
if(delta > 0 && delta < stepSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
lastWorkerIndex += delta+1; |
|
|
|
workerLastIndex += delta+1; |
|
|
|
|
|
|
|
|
|
|
|
if(!stickToBottom()) |
|
|
|
if(!workerStb) |
|
|
|
verticalScrollBar()->setValue(verticalScrollBar()->value() - workerDy); |
|
|
|
verticalScrollBar()->setValue(verticalScrollBar()->value() - workerDy); |
|
|
|
|
|
|
|
|
|
|
|
workerDy = 0.0; |
|
|
|
workerDy = 0.0; |
|
|
@ -94,21 +94,19 @@ ChatLog::ChatLog(QWidget* parent) |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
lastWorkerIndex += stepSize; |
|
|
|
workerLastIndex += stepSize; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
lastWorkerIndex += stepSize; |
|
|
|
workerLastIndex += stepSize; |
|
|
|
|
|
|
|
|
|
|
|
if(lastWorkerIndex >= lines.size()) |
|
|
|
if(workerLastIndex >= lines.size()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
workerTimer->stop(); |
|
|
|
workerTimer->stop(); |
|
|
|
lastWorkerIndex = 0; |
|
|
|
workerLastIndex = 0; |
|
|
|
workerDy = 0.0; |
|
|
|
workerDy = 0.0; |
|
|
|
|
|
|
|
|
|
|
|
bool stb = stickToBottom(); |
|
|
|
if(workerStb) |
|
|
|
updateSceneRect(); |
|
|
|
|
|
|
|
if(stb) |
|
|
|
|
|
|
|
scrollToBottom(); |
|
|
|
scrollToBottom(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -186,6 +184,8 @@ void ChatLog::partialUpdate() |
|
|
|
if(visibleLines.empty()) |
|
|
|
if(visibleLines.empty()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool stb = stickToBottom(); |
|
|
|
|
|
|
|
|
|
|
|
auto oldUpdateMode = viewportUpdateMode(); |
|
|
|
auto oldUpdateMode = viewportUpdateMode(); |
|
|
|
setViewportUpdateMode(NoViewportUpdate); |
|
|
|
setViewportUpdateMode(NoViewportUpdate); |
|
|
|
|
|
|
|
|
|
|
@ -207,6 +207,9 @@ void ChatLog::partialUpdate() |
|
|
|
checkVisibility(); |
|
|
|
checkVisibility(); |
|
|
|
|
|
|
|
|
|
|
|
setViewportUpdateMode(oldUpdateMode); |
|
|
|
setViewportUpdateMode(oldUpdateMode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(stb) |
|
|
|
|
|
|
|
scrollToBottom(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ChatLog::fullUpdate() |
|
|
|
void ChatLog::fullUpdate() |
|
|
@ -631,6 +634,14 @@ void ChatLog::scrollContentsBy(int dx, int dy) |
|
|
|
|
|
|
|
|
|
|
|
void ChatLog::resizeEvent(QResizeEvent* ev) |
|
|
|
void ChatLog::resizeEvent(QResizeEvent* ev) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if(!workerTimer->isActive()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
workerStb = stickToBottom(); |
|
|
|
|
|
|
|
workerLastIndex = 0; |
|
|
|
|
|
|
|
workerDy = 0.0; |
|
|
|
|
|
|
|
workerTimer->start(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool stb = stickToBottom(); |
|
|
|
bool stb = stickToBottom(); |
|
|
|
|
|
|
|
|
|
|
|
QGraphicsView::resizeEvent(ev); |
|
|
|
QGraphicsView::resizeEvent(ev); |
|
|
@ -644,10 +655,6 @@ void ChatLog::resizeEvent(QResizeEvent* ev) |
|
|
|
scrollToBottom(); |
|
|
|
scrollToBottom(); |
|
|
|
|
|
|
|
|
|
|
|
updateMultiSelectionRect(); |
|
|
|
updateMultiSelectionRect(); |
|
|
|
|
|
|
|
|
|
|
|
lastWorkerIndex = 0; |
|
|
|
|
|
|
|
workerDy = 0.0; |
|
|
|
|
|
|
|
workerTimer->start(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ChatLog::updateMultiSelectionRect() |
|
|
|
void ChatLog::updateMultiSelectionRect() |
|
|
|