reintroduced epub support

This commit is contained in:
Agel committed 2026-10-25 19:59:23 +01:00
1 parent 49a959a89d
commit d14170a68f
49 files changed
+5048 -205

No files matched your search

+16 -28
View File
@@ -41,16 +41,13 @@ public:
QByteArray contentHash() const override { return QByteArray("texthash"); }
bool loadMetadata(const QString &) override { return true; }
int chapterCount() const override { return 2; }
Chapter loadChapter(int index) const override
QStringList chunks() const override
{
if (index == 0)
return {0, QStringLiteral("Chapter 1"), {QStringLiteral("<p>Chunk 1</p>"), QStringLiteral("<p>Chunk 2</p>")}};
return {1, QStringLiteral("Chapter 2"), {QStringLiteral("<p>Chunk 3</p>")}};
}
QVector<TocEntry> tableOfContents() const override
{
return {{QStringLiteral("Chapter 1"), 0, 0}, {QStringLiteral("Chapter 2"), 1, 0}};
return {
QStringLiteral("<p>Chunk 1</p>"),
QStringLiteral("<p>Chunk 2</p>"),
QStringLiteral("<p>Chunk 3</p>")
};
}
};
@@ -167,7 +164,7 @@ private slots:
QVERIFY(!model.mangaRTL());
}
void textModeChaptersAndChunks()
void textModeContinuousChunks()
{
Ctx ctx; ReadingModel model(*ctx.store);
FakeTextReader reader;
@@ -178,31 +175,22 @@ private slots:
QCOMPARE(modeSpy.count(), 1);
QVERIFY(model.isTextMode());
QCOMPARE(model.chapterCount(), 2);
QCOMPARE(model.currentChapter(), 0);
QCOMPARE(model.chapterTitle(), QStringLiteral("Chapter 1"));
QCOMPARE(model.rowCount(), 2);
QCOMPARE(model.rowCount(), 3);
QCOMPARE(model.data(model.index(0, 0), ReadingModel::ContentRole).toString(),
QStringLiteral("<p>Chunk 1</p>"));
QCOMPARE(model.data(model.index(1, 0), ReadingModel::ContentRole).toString(),
QStringLiteral("<p>Chunk 2</p>"));
QCOMPARE(model.data(model.index(2, 0), ReadingModel::ContentRole).toString(),
QStringLiteral("<p>Chunk 3</p>"));
QTRY_COMPARE(restoreSpy.count(), 1);
// Next chapter navigation
QSignalSpy chapterSpy(&model, &ReadingModel::currentChapterChanged);
model.nextChapter();
QCOMPARE(chapterSpy.count(), 1);
QCOMPARE(model.currentChapter(), 1);
QCOMPARE(model.chapterTitle(), QStringLiteral("Chapter 2"));
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.data(model.index(0, 0), ReadingModel::ContentRole).toString(),
QStringLiteral("<p>Chunk 3</p>"));
// Previous chapter navigation
model.previousChapter();
QCOMPARE(model.currentChapter(), 0);
QCOMPARE(model.rowCount(), 2);
// Test resize fast path
QSignalSpy dataSpy(&model, &ReadingModel::dataChanged);
model.updateLayoutMetrics(800, 16, 1.2);
QVERIFY(dataSpy.count() >= 1);
QCOMPARE(model.rowCount(), 3);
QCOMPARE(model.data(model.index(0, 0), ReadingModel::LayoutRole).value<ChunkLayout>().contentWidth, 800);
}
void setReaderNullResetsState()