diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f0794ff..7206e4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Version counting is based on semantic versioning (Major.Feature.Patch) ### YACReaderLibrary * Fix columns in the search results. +* Fix type not being propagated to new folders from their parents. +* Fix default type set to folders in the root folder when they are added. ## 9.14.1 diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index 1a329233..32e53129 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -1270,12 +1270,14 @@ qulonglong DBHelper::insert(Folder *folder, QSqlDatabase &db) folder->added = added; QSqlQuery query(db); - query.prepare("INSERT INTO folder (parentId, name, path, added) " - "VALUES (:parentId, :name, :path, :added)"); + query.prepare("INSERT INTO folder (parentId, name, path, added, type) " + "VALUES (:parentId, :name, :path, :added, :type)"); query.bindValue(":parentId", folder->parentId); query.bindValue(":name", folder->name); query.bindValue(":path", folder->path); query.bindValue(":added", added); + auto intType = static_cast(folder->type); + query.bindValue(":type", intType); query.exec(); return query.lastInsertId().toULongLong(); diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index c77ba1bb..953cd0c9 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -54,7 +54,7 @@ void LibraryCreator::updateFolder(const QString &source, const QString &target, folderDestinationModelIndex = dest; _currentPathFolders.clear(); - _currentPathFolders.append(Folder(1, 1, "root", "/")); + _currentPathFolders.append(Folder::rootFolder()); QString relativeFolderPath = sourceFolder; relativeFolderPath = relativeFolderPath.remove(QDir::cleanPath(source)); @@ -139,7 +139,7 @@ void LibraryCreator::run() if (_mode == CREATOR) { QLOG_INFO() << "Starting to create new library ( " << _source << "," << _target << ")"; _currentPathFolders.clear(); - _currentPathFolders.append(Folder(1, 1, "root", "/")); + _currentPathFolders.append(Folder::rootFolder()); // se crean los directorios .yacreaderlibrary y .yacreaderlibrary/covers QDir dir; dir.mkpath(_target + "/covers"); @@ -173,7 +173,7 @@ void LibraryCreator::run() QLOG_INFO() << "Starting to update folder" << _sourceFolder << "in library ( " << _source << "," << _target << ")"; if (!partialUpdate) { _currentPathFolders.clear(); - _currentPathFolders.append(Folder(1, 1, "root", "/")); + _currentPathFolders.append(Folder::rootFolder()); QLOG_DEBUG() << "update whole library"; } { diff --git a/common/folder.cpp b/common/folder.cpp index c31f9a2a..311058d0 100644 --- a/common/folder.cpp +++ b/common/folder.cpp @@ -70,6 +70,14 @@ Folder &Folder::operator=(const Folder &other) return *this; } + +Folder Folder::rootFolder() +{ + auto root = Folder(1, 1, "root", "/"); + root.type = YACReader::FileType::Comic; // TODO: make this configurable by the user so it can set a default type for a library + return root; +} + Folder::Folder(const QString &folderName, const QString &folderPath) : knownParent(false), knownId(false), diff --git a/common/folder.h b/common/folder.h index 942ceec4..ab25ee03 100644 --- a/common/folder.h +++ b/common/folder.h @@ -41,6 +41,8 @@ public: Folder(const Folder &folder); Folder &operator=(const Folder &other); + static Folder rootFolder(); + inline void setId(qulonglong sid) { id = sid;