old render cleanup part 3

This commit is contained in:
Agel committed 2026-10-25 15:43:51 +01:00
1 parent cef762c3ee
commit 3faedd4251
45 files changed
+1057 -1135

No files matched your search

+39 -9
View File
@@ -1,7 +1,7 @@
#ifndef READINGMODEL_H
#define READINGMODEL_H
#include <QObject>
#include <QAbstractListModel>
#include <QSize>
#include <QString>
#include <QVariantList>
@@ -10,31 +10,53 @@
#include "reading/MangaPagination.h"
#include "state/BookPositionStore.h"
class ReadingModel : public QObject {
class ReadingModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(double progress READ progress NOTIFY currentPageChanged)
Q_PROPERTY(bool isTextMode READ isTextMode NOTIFY modeChanged)
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
};
Q_ENUM(ReadingRoles)
explicit ReadingModel(BookPositionStore &positions, QObject *parent = nullptr);
~ReadingModel() override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
bool isTextMode() 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);
// Called from QML on every page navigation
// 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();
// Manga page-pair API
Q_INVOKABLE QVariantList pagePair(int pairIndex) const;
Q_INVOKABLE int pairIndexForChunk(int chunkIndex) const;
@@ -43,36 +65,44 @@ public:
// Called from MangaPageView when window orientation changes
Q_INVOKABLE void setMangaLandscape(bool landscape);
// Per-book page-shift toggle: when ON, page 1 is shown alone after the cover.
// currentPairIndex must be the pair the view is currently displaying.
// Per-book page-shift toggle
Q_INVOKABLE void setPageShift(bool shift, int currentPairIndex = 0);
Q_INVOKABLE void setMangaRTL(bool rtl);
signals:
void modeChanged();
void progressChanged();
void currentPageChanged();
void totalPagesChanged();
void currentChapterChanged();
void chapterCountChanged();
void totalPagePairsChanged();
void pageShiftChanged();
void mangaRTLChanged();
// Fired after setPageShift rebuilds pairs; carries the new pair index to display.
void pagePairsRebuilt(int newPairIndex);
void restoreReady(int chunkIndex);
void positionSaved();
private:
void loadPages();
void rebuildPagePairs();
void saveCurrentPosition(int chunkIndex);
FormatReader *m_reader = nullptr;
bool m_isTextMode = false;
int m_currentPage = 0;
int m_totalPages = 0;
int m_currentChapter = 0;
int m_chapterCount = 0;
Chapter m_currentChapterData;
bool m_mangaLandscape = false;
bool m_pageShift = true;
bool m_mangaRTL = true;
QVector<PageInfo> m_pages;
MangaPagination m_pagination;
qreal m_yOffset = 0.0;
qreal m_progress = 0.0;
BookPositionStore &m_positions;
};