fixed pagination

This commit is contained in:
Agel committed 2026-03-19 23:00:10 +01:00
1 parent 43e75d3d8f
commit 10f0fc52c7
3 files changed
+8 -4

No files matched your search

+5 -2
View File
@@ -77,19 +77,20 @@ void ReadingModel::setViewportSize(qreal width, qreal height)
m_viewportWidth = width;
m_viewportHeight = height;
if (widthChanged && !m_chunks.isEmpty())
if (!m_chunks.isEmpty() && (widthChanged || m_chunkHeights.isEmpty()))
computeChunkHeights();
recalculateTotalPages();
recalculateCurrentPage();
}
void ReadingModel::setScrollInfo(int topChunkIndex, qreal offsetInChunk)
void ReadingModel::setScrollInfo(int topChunkIndex, qreal offsetInChunk, bool atYEnd)
{
if (topChunkIndex < 0 || topChunkIndex >= m_chunkOffsets.size())
return;
m_absoluteScrollY = m_chunkOffsets.at(topChunkIndex) + offsetInChunk;
m_atYEnd = atYEnd;
recalculateCurrentPage();
}
@@ -156,6 +157,8 @@ void ReadingModel::recalculateCurrentPage()
int page = 0;
if (m_viewportHeight > 0 && m_totalPages > 0) {
page = static_cast<int>(std::floor(m_absoluteScrollY / m_viewportHeight)) + 1;
if (m_atYEnd)
page = m_totalPages;
page = std::max(1, std::min(page, m_totalPages));
}
if (m_currentPage == page)