mirror of
https://github.com/YACReader/yacreader
synced 2026-03-02 10:50:04 -05:00
Remove FolderModel and QModelIndex dependencies from LibraryCreator
This commit is contained in:
@ -17,8 +17,6 @@
|
||||
#include "pdf_comic.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
#include "folder_model.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -67,11 +65,11 @@ void LibraryCreator::updateLibrary(const QString &source, const QString &target)
|
||||
_mode = UPDATER;
|
||||
}
|
||||
|
||||
void LibraryCreator::updateFolder(const QString &source, const QString &target, const QString &sourceFolder, const QModelIndex &dest)
|
||||
void LibraryCreator::updateFolder(const QString &source, const QString &target, const QString &sourceFolder, qulonglong folderId)
|
||||
{
|
||||
checkModifiedDatesOnUpdate = settings->value(COMPARE_MODIFIED_DATE_ON_LIBRARY_UPDATES, false).toBool();
|
||||
partialUpdate = true;
|
||||
folderDestinationModelIndex = dest;
|
||||
_folderDestinationId = folderId;
|
||||
|
||||
_currentPathFolders.clear();
|
||||
|
||||
@ -224,7 +222,7 @@ void LibraryCreator::run()
|
||||
|
||||
if (!canceled) {
|
||||
if (partialUpdate) {
|
||||
auto folder = DBHelper::updateChildrenInfo(folderDestinationModelIndex.data(FolderModel::IdRole).toULongLong(), _database);
|
||||
auto folder = DBHelper::updateChildrenInfo(_folderDestinationId, _database);
|
||||
DBHelper::propagateFolderUpdatesToParent(folder, _database);
|
||||
} else {
|
||||
DBHelper::updateChildrenInfo(_database);
|
||||
@ -250,7 +248,7 @@ void LibraryCreator::run()
|
||||
}
|
||||
|
||||
if (partialUpdate) {
|
||||
emit updatedCurrentFolder(folderDestinationModelIndex);
|
||||
emit updatedCurrentFolder(_folderDestinationId);
|
||||
}
|
||||
|
||||
creation = false;
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <QSqlDatabase>
|
||||
#include <QModelIndex>
|
||||
|
||||
#include "folder.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
@ -25,7 +23,7 @@ public:
|
||||
LibraryCreator(QSettings *settings);
|
||||
void createLibrary(const QString &source, const QString &target);
|
||||
void updateLibrary(const QString &source, const QString &target);
|
||||
void updateFolder(const QString &source, const QString &target, const QString &folder, const QModelIndex &dest);
|
||||
void updateFolder(const QString &source, const QString &target, const QString &folder, qulonglong folderId);
|
||||
void stop(); // used to stop the process and keep the changes
|
||||
void cancel(); // cancels this run and changes in the DB are rolled back
|
||||
|
||||
@ -56,7 +54,7 @@ private:
|
||||
// LibraryCreator está en modo creación si creation == true;
|
||||
bool creation;
|
||||
bool partialUpdate;
|
||||
QModelIndex folderDestinationModelIndex;
|
||||
qulonglong _folderDestinationId;
|
||||
QSettings *settings;
|
||||
bool checkModifiedDatesOnUpdate;
|
||||
void cleanup(QSqlDatabase &db, const QString &target);
|
||||
@ -69,7 +67,7 @@ signals:
|
||||
void created();
|
||||
void failedCreatingDB(QString);
|
||||
void failedOpeningDB(QString);
|
||||
void updatedCurrentFolder(QModelIndex);
|
||||
void updatedCurrentFolder(qulonglong folderId);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -707,7 +707,9 @@ void LibraryWindow::createConnections()
|
||||
connect(libraryCreator, &LibraryCreator::finished, this, &LibraryWindow::showRootWidget);
|
||||
connect(libraryCreator, &LibraryCreator::updated, this, &LibraryWindow::reloadCurrentLibrary);
|
||||
connect(libraryCreator, &LibraryCreator::created, this, &LibraryWindow::openLastCreated);
|
||||
connect(libraryCreator, &LibraryCreator::updatedCurrentFolder, this, &LibraryWindow::reloadAfterCopyMove);
|
||||
connect(libraryCreator, &LibraryCreator::updatedCurrentFolder, this, [this](qulonglong folderId) {
|
||||
reloadAfterCopyMove(foldersModel->getIndexFromFolderId(folderId));
|
||||
});
|
||||
connect(libraryCreator, &LibraryCreator::comicAdded, importWidget, &ImportWidget::newComic);
|
||||
// libraryCreator errors
|
||||
connect(libraryCreator, &LibraryCreator::failedCreatingDB, this, &LibraryWindow::manageCreatingError);
|
||||
@ -1078,7 +1080,7 @@ void LibraryWindow::updateFolder(const QModelIndex &miFolder)
|
||||
QString currentLibrary = selectedLibrary->currentText();
|
||||
QString path = QDir::cleanPath(libraries.getPath(currentLibrary));
|
||||
_lastAdded = currentLibrary;
|
||||
libraryCreator->updateFolder(path, LibraryPaths::libraryDataPath(path), QDir::cleanPath(currentPath() + foldersModel->getFolderPath(miFolder)), miFolder);
|
||||
libraryCreator->updateFolder(path, LibraryPaths::libraryDataPath(path), QDir::cleanPath(currentPath() + foldersModel->getFolderPath(miFolder)), miFolder.data(FolderModel::IdRole).toULongLong());
|
||||
libraryCreator->start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user