Display all chapters
This commit is contained in:
4 files changed
+170
-159
No files matched your search
@@ -13,7 +13,7 @@ class ReadingModel : public QAbstractListModel {
|
||||
Q_PROPERTY(QString chapterTitle READ chapterTitle NOTIFY chapterChanged)
|
||||
Q_PROPERTY(int currentChapter READ currentChapter NOTIFY chapterChanged)
|
||||
Q_PROPERTY(int totalChapters READ totalChapters NOTIFY totalChaptersChanged)
|
||||
Q_PROPERTY(double progress READ progress NOTIFY chapterChanged)
|
||||
Q_PROPERTY(double progress READ progress NOTIFY currentPageChanged)
|
||||
Q_PROPERTY(int currentPage READ currentPage NOTIFY currentPageChanged)
|
||||
Q_PROPERTY(int totalPages READ totalPages NOTIFY totalPagesChanged)
|
||||
Q_PROPERTY(bool hasChapters READ hasChapters NOTIFY totalChaptersChanged)
|
||||
@@ -51,9 +51,10 @@ signals:
|
||||
void totalChaptersChanged();
|
||||
void currentPageChanged();
|
||||
void totalPagesChanged();
|
||||
void scrollToChunkRequested(int chunkIndex);
|
||||
|
||||
private:
|
||||
void loadChapterData(int index);
|
||||
void loadAllChapters();
|
||||
void computeChunkBytes();
|
||||
void recalculateCurrentPage();
|
||||
|
||||
@@ -66,11 +67,12 @@ private:
|
||||
bool m_atYEnd = false;
|
||||
|
||||
QStringList m_chunks;
|
||||
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;
|
||||
QVector<int> m_chapterStartIndices; // m_chapterStartIndices[i] = first global chunk index of chapter i
|
||||
QVector<QString> m_chapterTitles; // title of each chapter
|
||||
|
||||
QString m_chapterTitle;
|
||||
QVector<qsizetype> m_chunkBytes; // UTF-8 byte size of each chunk (all chapters)
|
||||
QVector<qsizetype> m_chunkByteOffsets; // prefix sums: offset[i] = sum of bytes[0..i-1]
|
||||
qsizetype m_totalBookBytes = 0;
|
||||
};
|
||||
|
||||
#endif // READINGMODEL_H
|
||||
Reference in new issue
Block a user