Init infinite scroll.

It constanatly crashes, TBD.
This commit is contained in:
Black Hat
2018-09-28 19:47:17 +08:00
parent 6b10c2ef2d
commit 01196e8b50
3 changed files with 215 additions and 171 deletions

View File

@@ -147,3 +147,31 @@ QDateTime SpectralRoom::lastActiveTime() {
}
float SpectralRoom::orderForTag(QString name) { return tag(name).order; }
int SpectralRoom::savedTopVisibleIndex() const {
return firstDisplayedMarker() == timelineEdge()
? 0
: firstDisplayedMarker() - messageEvents().rbegin();
}
int SpectralRoom::savedBottomVisibleIndex() const {
return lastDisplayedMarker() == timelineEdge()
? 0
: lastDisplayedMarker() - messageEvents().rbegin();
}
void SpectralRoom::saveViewport(int topIndex, int bottomIndex) {
if (topIndex == -1 || bottomIndex == -1 ||
(bottomIndex == savedBottomVisibleIndex() &&
(bottomIndex == 0 || topIndex == savedTopVisibleIndex())))
return;
if (bottomIndex == 0) {
qDebug() << "Saving viewport as the latest available";
setFirstDisplayedEventId({});
setLastDisplayedEventId({});
return;
}
qDebug() << "Saving viewport:" << topIndex << "thru" << bottomIndex;
setFirstDisplayedEvent(maxTimelineIndex() - topIndex);
setLastDisplayedEvent(maxTimelineIndex() - bottomIndex);
}

View File

@@ -38,6 +38,9 @@ class SpectralRoom : public Room {
QDateTime lastActiveTime();
Q_INVOKABLE float orderForTag(QString name);
Q_INVOKABLE int savedTopVisibleIndex() const;
Q_INVOKABLE int savedBottomVisibleIndex() const;
Q_INVOKABLE void saveViewport(int topIndex, int bottomIndex);
private:
QString m_cachedInput;