reintroduced epub support
This commit is contained in:
49 files changed
+5048
-205
No files matched your search
+34
-19
@@ -2,30 +2,35 @@
|
||||
#define READINGMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QFuture>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QVariantList>
|
||||
#include <QVector>
|
||||
#include "backend/FormatReader.h"
|
||||
#include "backend/reading/BookImageResolver.h"
|
||||
#include "backend/reading/layout/ChunkLayoutEngine.h"
|
||||
#include "reading/MangaPagination.h"
|
||||
#include "state/BookPositionStore.h"
|
||||
|
||||
class ReadingModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isTextMode READ isTextMode NOTIFY modeChanged)
|
||||
Q_PROPERTY(bool isMangaMode READ isMangaMode NOTIFY modeChanged)
|
||||
Q_PROPERTY(bool measuring READ measuring NOTIFY measuringChanged)
|
||||
Q_PROPERTY(double progress READ progress NOTIFY progressChanged)
|
||||
Q_PROPERTY(int currentPage READ currentPage NOTIFY currentPageChanged)
|
||||
Q_PROPERTY(int totalPages READ totalPages NOTIFY totalPagesChanged)
|
||||
Q_PROPERTY(int currentChapter READ currentChapter NOTIFY currentChapterChanged)
|
||||
Q_PROPERTY(int chapterCount READ chapterCount NOTIFY chapterCountChanged)
|
||||
Q_PROPERTY(QString chapterTitle READ chapterTitle NOTIFY currentChapterChanged)
|
||||
Q_PROPERTY(int totalPagePairs READ totalPagePairs NOTIFY totalPagePairsChanged)
|
||||
Q_PROPERTY(bool pageShift READ pageShift NOTIFY pageShiftChanged)
|
||||
Q_PROPERTY(bool mangaRTL READ mangaRTL NOTIFY mangaRTLChanged)
|
||||
|
||||
public:
|
||||
enum ReadingRoles {
|
||||
ContentRole = Qt::UserRole + 1
|
||||
ContentRole = Qt::UserRole + 1,
|
||||
LayoutRole,
|
||||
PixelHeightRole
|
||||
};
|
||||
Q_ENUM(ReadingRoles)
|
||||
|
||||
@@ -37,25 +42,24 @@ public:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
bool isTextMode() const;
|
||||
bool isMangaMode() const;
|
||||
bool measuring() const;
|
||||
double progress() const;
|
||||
int currentPage() const;
|
||||
int totalPages() const;
|
||||
int currentChapter() const;
|
||||
int chapterCount() const;
|
||||
QString chapterTitle() const;
|
||||
int totalPagePairs() const;
|
||||
bool pageShift() const;
|
||||
bool mangaRTL() const;
|
||||
|
||||
void setReader(FormatReader *reader);
|
||||
void setImageResolver(IBookImageResolver *resolver);
|
||||
|
||||
// Text layout metrics
|
||||
Q_INVOKABLE void updateLayoutMetrics(int contentWidth, int fontSize, qreal lineSpacing, int anchorChunk = -1);
|
||||
|
||||
// Called on navigation
|
||||
Q_INVOKABLE void setScrollInfo(int topChunkIndex, qreal proportion);
|
||||
|
||||
// Text chapter navigation
|
||||
Q_INVOKABLE void loadChapter(int index);
|
||||
Q_INVOKABLE void nextChapter();
|
||||
Q_INVOKABLE void previousChapter();
|
||||
Q_INVOKABLE void setScrollPosition(int topChunkIndex, qreal intraOffset, qreal proportion);
|
||||
|
||||
// Manga page-pair API
|
||||
Q_INVOKABLE QVariantList pagePair(int pairIndex) const;
|
||||
@@ -71,30 +75,40 @@ public:
|
||||
|
||||
signals:
|
||||
void modeChanged();
|
||||
void measuringChanged();
|
||||
void progressChanged();
|
||||
void currentPageChanged();
|
||||
void totalPagesChanged();
|
||||
void currentChapterChanged();
|
||||
void chapterCountChanged();
|
||||
void totalPagePairsChanged();
|
||||
void pageShiftChanged();
|
||||
void mangaRTLChanged();
|
||||
void pagePairsRebuilt(int newPairIndex);
|
||||
void restoreReady(int chunkIndex);
|
||||
void restoreReady(int chunkIndex, qreal intraOffset = 0.0);
|
||||
void positionSaved();
|
||||
|
||||
private:
|
||||
void loadPages();
|
||||
void rebuildPagePairs();
|
||||
void saveCurrentPosition(int chunkIndex);
|
||||
void startLayoutMeasurement(int restoreChunk = 0, qreal restoreIntraOffset = 0.0);
|
||||
void runRemainingLayout();
|
||||
void saveCurrentPosition(int chunkIndex, qreal intraOffset = 0.0);
|
||||
|
||||
FormatReader *m_reader = nullptr;
|
||||
IBookImageResolver *m_imageResolver = nullptr;
|
||||
bool m_isTextMode = false;
|
||||
bool m_measuring = false;
|
||||
int m_currentPage = 0;
|
||||
int m_totalPages = 0;
|
||||
int m_currentChapter = 0;
|
||||
int m_chapterCount = 0;
|
||||
Chapter m_currentChapterData;
|
||||
QStringList m_chunks;
|
||||
QVector<ChunkLayoutEngine::PreparedChunk> m_preparedChunks;
|
||||
QVector<ChunkLayout> m_chunkLayouts;
|
||||
|
||||
int m_layoutContentWidth = 600;
|
||||
int m_layoutFontSize = 16;
|
||||
qreal m_layoutLineSpacing = 1.0;
|
||||
int m_layoutGeneration = 0;
|
||||
QFuture<void> m_layoutFuture;
|
||||
QTimer *m_remainingLayoutTimer = nullptr;
|
||||
|
||||
bool m_mangaLandscape = false;
|
||||
bool m_pageShift = true;
|
||||
@@ -103,6 +117,7 @@ private:
|
||||
QVector<PageInfo> m_pages;
|
||||
MangaPagination m_pagination;
|
||||
qreal m_progress = 0.0;
|
||||
qreal m_intraOffset = 0.0;
|
||||
|
||||
BookPositionStore &m_positions;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user