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