Refactor using Fable

This commit is contained in:
Agel committed 2026-07-31 17:31:02 +02:00
1 parent 1a60a6b93c
commit 83968646c6
90 files changed
+2080 -2267

No files matched your search

+8 -14
View File
@@ -2,9 +2,9 @@
#include "HistoryBookModel.h"
#include <QDateTime>
HistoryModel::HistoryModel(ReaderFactory &factory, QObject *parent)
HistoryModel::HistoryModel(FormatRegistry &registry, QObject *parent)
: QAbstractListModel(parent)
, m_factory(factory)
, m_registry(registry)
{
// Initialize role names
m_roleNames[FilePathRole] = "filePath";
@@ -103,7 +103,7 @@ void HistoryModel::addOrUpdateBook(const QString &filePath, double progress, con
}
// New book — HistoryModel takes ownership via parent
auto* book = new HistoryBookModel(filePath, progress, lastOpened, m_factory, this);
auto* book = new HistoryBookModel(filePath, progress, lastOpened, m_registry, this);
connect(book, &HistoryBookModel::metadataLoaded, this, &HistoryModel::onBookMetadataLoaded);
beginInsertRows(QModelIndex(), 0, 0);
@@ -119,14 +119,11 @@ void HistoryModel::removeBook(const QString &filePath)
for (int i = 0; i < m_books.size(); i++) {
if (m_books[i]->filePath() == filePath) {
HistoryBookModel* book = m_books[i];
// Disconnect signals
disconnect(book, &HistoryBookModel::metadataLoaded, this, &HistoryModel::onBookMetadataLoaded);
beginRemoveRows(QModelIndex(), i, i);
m_books.removeAt(i);
endRemoveRows();
book->deleteLater();
emit countChanged();
return;
@@ -150,13 +147,10 @@ void HistoryModel::clear()
return;
beginRemoveRows(QModelIndex(), 0, m_books.size() - 1);
// Disconnect and delete all books
for (HistoryBookModel* book : m_books) {
disconnect(book, &HistoryBookModel::metadataLoaded, this, &HistoryModel::onBookMetadataLoaded);
for (HistoryBookModel* book : m_books)
book->deleteLater();
}
m_books.clear();
endRemoveRows();