X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fqtui%2Fchatview.cpp;h=f8fb586627ea77ab02828d5265a20f3886d308c9;hb=02966c1d1a668b2382de899008e6fefb42da4bbb;hp=3074882df1ffdcbdb571eb770b10efb2fc4441e6;hpb=00cc0dfd645cce97c120111f5e5fd4c02ed021c1;p=quassel.git diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index 3074882d..f8fb5866 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -100,8 +100,7 @@ bool ChatView::event(QEvent* event) case Qt::Key_Down: case Qt::Key_PageUp: case Qt::Key_PageDown: - if (!verticalScrollBar()->isVisible()) { - scene()->requestBacklog(); + if (requestBacklogForScroll()) { return true; } default: @@ -145,8 +144,7 @@ bool ChatView::event(QEvent* event) if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type() == QTouchDevice::TouchScreen) || event->type() == QEvent::TouchUpdate) { - if (!verticalScrollBar()->isVisible()) { - scene()->requestBacklog(); + if (requestBacklogForScroll()) { return true; } } @@ -409,6 +407,23 @@ void ChatView::setHasCache(ChatLine* line, bool hasCache) _linesWithCache.remove(line); } +bool ChatView::requestBacklogForScroll() +{ + if (!verticalScrollBar()->isVisible()) { + // Not able to scroll, fetch backlog + // + // Future improvement: continue fetching backlog in chunks until the scrollbar is visible, + // or the beginning of the buffer has been reached. + scene()->requestBacklog(); + // Backlog has been requested + return true; + } + else { + // Scrollbar already visible, no backlog requested + return false; + } +} + void ChatView::checkChatLineCaches() { qreal top = mapToScene(viewport()->rect().topLeft()).y() - 10; // some grace area to avoid premature cleaning