#ifndef FORMATREADER_H #define FORMATREADER_H #include #include #include #include #include struct TocEntry { QString title; int chapterIndex; int depth; // 0 = top level }; struct Chapter { int index; QString title; QStringList contentChunks; }; class FormatReader { public: enum class RenderingMode { Scroll, Manga }; virtual ~FormatReader() = default; virtual bool open(const QString &filePath) = 0; virtual bool loadMetadata(const QString &filePath) = 0; virtual QString lastError() = 0; virtual int chapterCount() = 0; virtual Chapter loadChapter(int index) = 0; virtual QList tableOfContents() = 0; virtual QString filePath() = 0; virtual QString title() = 0; virtual QString author() = 0; virtual QString coverImagePath() = 0; // MD5 of file contents, computed once during open(). Used as a stable key for // per-book state (bookmarks, etc.) that survives file renames. virtual QByteArray contentHash() = 0; // Returns the lowercase file extension this reader handles (e.g. "txt", "epub"). virtual QString fileType() const = 0; // Rendering mode this format prefers. Defaults to Scroll; image-only formats override to Manga. virtual RenderingMode preferredRenderingMode() const { return RenderingMode::Scroll; } // Natural pixel sizes for each chunk in a chapter, parallel to loadChapter().contentChunks. // Empty by default; image-based readers override to provide aspect ratios for page pairing. virtual QVector chapterPageSizes(int chapterIndex) const { Q_UNUSED(chapterIndex); return {}; } }; #endif // FORMATREADER_H