Refactor using Fable
This commit is contained in:
90 files changed
+2080
-2267
No files matched your search
@@ -2,13 +2,13 @@
|
||||
#define READINGMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QFuture>
|
||||
#include <QPair>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <memory>
|
||||
#include "IImageLoader.h"
|
||||
#include "reading/MangaPagination.h"
|
||||
#include "reading/MeasurementController.h"
|
||||
#include "state/BookPositionStore.h"
|
||||
|
||||
class FormatReader;
|
||||
@@ -19,6 +19,7 @@ struct ContentChunk {
|
||||
int chunkInChapter = 0; // 0-based index within chapter (-1 for cover)
|
||||
int pixelHeight = -1; // -1 = not yet measured
|
||||
QSize naturalSize; // image pixel dimensions (null for text chunks)
|
||||
QString imageUrl; // src of the chunk's img tag (empty for text chunks)
|
||||
};
|
||||
|
||||
class ReadingModel : public QAbstractListModel {
|
||||
@@ -114,13 +115,15 @@ signals:
|
||||
|
||||
void restoreReady(int chunkIndex, int intraChunkOffset);
|
||||
|
||||
private slots:
|
||||
void onHeightsReady(const QVector<int> &heights, bool isNew);
|
||||
|
||||
private:
|
||||
static constexpr qreal page_ratio = 1.5;
|
||||
|
||||
void loadAllChapters();
|
||||
void recalculateCurrentPage();
|
||||
void rebuildPagePairs();
|
||||
void runMeasurement(const QStringList &htmls, bool isNew);
|
||||
void emitRestoreReady(bool isNew);
|
||||
|
||||
FormatReader *m_reader = nullptr;
|
||||
@@ -129,7 +132,6 @@ private:
|
||||
int m_totalChapters = 0;
|
||||
int m_currentPage = 0;
|
||||
int m_totalPages = 0;
|
||||
bool m_measuring = false;
|
||||
bool m_isMangaMode = false;
|
||||
bool m_mangaLandscape = false;
|
||||
bool m_pageShift = true;
|
||||
@@ -139,9 +141,8 @@ private:
|
||||
QVector<int> m_chapterStartIndices;
|
||||
QVector<QString> m_chapterTitles;
|
||||
|
||||
// Manga page pairs: each QPair holds (leftChunkIdx, rightChunkIdx) where rightChunkIdx
|
||||
// may be -1 for solo pages. In RTL mode the "left" slot is the later page visually.
|
||||
QVector<QPair<int,int>> m_pagePairs;
|
||||
// Manga page-pair layout. In RTL mode the "left" slot is the later page visually.
|
||||
MangaPagination m_pagination;
|
||||
|
||||
qreal m_totalPixelHeight = 0.0;
|
||||
qreal m_yOffset = 0.0;
|
||||
@@ -150,8 +151,7 @@ private:
|
||||
qreal m_lineSpacing = 0;
|
||||
|
||||
BookPositionStore &m_positions;
|
||||
std::unique_ptr<IImageLoader> m_imageLoader;
|
||||
QFuture<void> m_measureFuture;
|
||||
MeasurementController m_measurer;
|
||||
};
|
||||
|
||||
#endif // READINGMODEL_H
|
||||
Reference in new issue
Block a user