Rename Library to History
This commit is contained in:
11 files changed
+102
-102
No files matched your search
+13
-13
@@ -14,7 +14,7 @@
|
||||
#include "backend/formats/ImageLoaderFactory.h"
|
||||
#include "backend/formats/ImageProviderFactory.h"
|
||||
#include "backend/formats/WebImageProvider.h"
|
||||
#include "backend/LibraryModel.h"
|
||||
#include "backend/HistoryModel.h"
|
||||
#include "backend/ReadingModel.h"
|
||||
#include "backend/NativeFileDialogService.h"
|
||||
#include "backend/formats/ReaderFactory.h"
|
||||
@@ -103,14 +103,14 @@ int main(int argc, char *argv[])
|
||||
[] { return std::make_unique<EpubReader>(); },
|
||||
});
|
||||
|
||||
LibraryModel libraryModel(readerFactory);
|
||||
for (const QVariantMap &entry : appState.loadArray(QStringLiteral("library"))) {
|
||||
HistoryModel historyModel(readerFactory);
|
||||
for (const QVariantMap &entry : appState.loadArray(QStringLiteral("history"))) {
|
||||
const QString fp = entry.value(QStringLiteral("filePath")).toString();
|
||||
if (fp.isEmpty()) continue;
|
||||
double progress = entry.value(QStringLiteral("progress"), 0.0).toDouble();
|
||||
progress = qBound(0.0, progress, 1.0);
|
||||
const QString lo = entry.value(QStringLiteral("lastOpened")).toString();
|
||||
libraryModel.addOrUpdateBook(fp, progress, lo);
|
||||
historyModel.addOrUpdateBook(fp, progress, lo);
|
||||
}
|
||||
|
||||
// Command-line override: treat first argument as the file to open on startup
|
||||
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("readingModel"), &readingModel);
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("readingPreferences"), &readingPreferences);
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("uiState"), &uiState);
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("libraryModel"), &libraryModel);
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("historyModel"), &historyModel);
|
||||
|
||||
// --- Cross-class signal wiring ---
|
||||
|
||||
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
|
||||
// Scroll position is handled by PageView's scroll tracker via book.saveCurrentPosition().
|
||||
QObject::connect(&book, &Book::willOpenNewBook, [&]{
|
||||
if (book.hasBook())
|
||||
libraryModel.addOrUpdateBook(book.filePath(), readingModel.progress());
|
||||
historyModel.addOrUpdateBook(book.filePath(), readingModel.progress());
|
||||
});
|
||||
|
||||
// After the new reader is installed: wire up image provider + ReadingModel
|
||||
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
||||
readingModel.measure(true);
|
||||
|
||||
uiState.setLastFilePath(filePath);
|
||||
libraryModel.addOrUpdateBook(filePath, -1.0);
|
||||
historyModel.addOrUpdateBook(filePath, -1.0);
|
||||
});
|
||||
|
||||
// Propagate content-width changes to image provider + reading model.
|
||||
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
|
||||
// Scroll position was last saved by PageView's scroll tracker; we save library progress here.
|
||||
QObject::connect(&app, &QCoreApplication::aboutToQuit, [&]{
|
||||
if (book.hasBook()) {
|
||||
libraryModel.addOrUpdateBook(book.filePath(), readingModel.progress());
|
||||
historyModel.addOrUpdateBook(book.filePath(), readingModel.progress());
|
||||
uiState.setLastFilePath(book.filePath());
|
||||
} else {
|
||||
uiState.setLastFilePath(QString());
|
||||
@@ -226,14 +226,14 @@ int main(int argc, char *argv[])
|
||||
uiState.save();
|
||||
|
||||
QList<QVariantMap> items;
|
||||
for (int i = 0; i < libraryModel.rowCount(); ++i) {
|
||||
for (int i = 0; i < historyModel.rowCount(); ++i) {
|
||||
items.append({
|
||||
{QStringLiteral("filePath"), libraryModel.filePath(i)},
|
||||
{QStringLiteral("progress"), libraryModel.progress(i)},
|
||||
{QStringLiteral("lastOpened"), libraryModel.lastOpened(i)},
|
||||
{QStringLiteral("filePath"), historyModel.filePath(i)},
|
||||
{QStringLiteral("progress"), historyModel.progress(i)},
|
||||
{QStringLiteral("lastOpened"), historyModel.lastOpened(i)},
|
||||
});
|
||||
}
|
||||
appState.saveArray(QStringLiteral("library"), items);
|
||||
appState.saveArray(QStringLiteral("history"), items);
|
||||
|
||||
qInfo() << "Settings saved to:" << settings.fileName();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user