More refactor
This commit is contained in:
6 files changed
+83
-283
No files matched your search
@@ -6,8 +6,6 @@
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
|
||||
#include "IChunkMeasurer.h"
|
||||
|
||||
class FormatReader;
|
||||
|
||||
class ReadingModel : public QAbstractListModel {
|
||||
@@ -40,10 +38,7 @@ public:
|
||||
int totalPages() const;
|
||||
bool hasChapters() const;
|
||||
void setReader(FormatReader *reader);
|
||||
void setChunkMeasurer(IChunkMeasurer *measurer);
|
||||
|
||||
// Called from QML on resize
|
||||
Q_INVOKABLE void setViewportSize(qreal width, qreal height);
|
||||
// Called from QML on every scroll (real-time)
|
||||
Q_INVOKABLE void setScrollInfo(int topChunkIndex, qreal offsetInChunk, bool atYEnd = false);
|
||||
|
||||
@@ -59,25 +54,21 @@ signals:
|
||||
|
||||
private:
|
||||
void loadChapterData(int index);
|
||||
void computeChunkHeights();
|
||||
void recalculateTotalPages();
|
||||
void computeChunkBytes();
|
||||
void recalculateCurrentPage();
|
||||
|
||||
FormatReader *m_reader = nullptr;
|
||||
IChunkMeasurer *m_chunkMeasurer = nullptr;
|
||||
int m_currentChapter = 0;
|
||||
int m_totalChapters = 0;
|
||||
int m_currentPage = 0;
|
||||
int m_totalPages = 0;
|
||||
qreal m_viewportWidth = 0;
|
||||
qreal m_viewportHeight = 0;
|
||||
qreal m_absoluteScrollY = 0;
|
||||
int m_topChunkIndex = 0;
|
||||
bool m_atYEnd = false;
|
||||
|
||||
QStringList m_chunks;
|
||||
QVector<qreal> m_chunkHeights; // rendered height of each chunk
|
||||
QVector<qreal> m_chunkOffsets; // prefix sums: offset[i] = sum of heights[0..i-1]
|
||||
qreal m_totalContentHeight = 0;
|
||||
bool m_atYEnd = false;
|
||||
QVector<qsizetype> m_chunkBytes; // UTF-8 byte size of each chunk
|
||||
QVector<qsizetype> m_chunkByteOffsets; // prefix sums: offset[i] = sum of bytes[0..i-1]
|
||||
qsizetype m_totalChapterBytes = 0;
|
||||
|
||||
QString m_chapterTitle;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user