diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d1cb225..80ee3d92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Version counting is based on semantic versioning (Major.Feature.Patch) +## 9.14.2 + +### 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. +* Improve and fix comic file size format. + ## 9.14.1 ### YACReader diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 6c69254a..e1153700 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -35,6 +35,10 @@ #include #include +#ifdef use_unarr +#include "unarr.h" +#endif + MainWindowViewer::MainWindowViewer() : QMainWindow(), fullscreen(false), toolbars(true), currentDirectory("."), currentDirectoryImgDest("."), isClient(false) { @@ -781,8 +785,10 @@ void MainWindowViewer::open() QFileDialog openDialog; #ifndef use_unarr QString pathFile = openDialog.getOpenFileName(this, tr("Open Comic"), currentDirectory, tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.7z *.cb7 *.arj *.cbt)"); -#else +#elif (UNARR_API_VERSION < 110) QString pathFile = openDialog.getOpenFileName(this, tr("Open Comic"), currentDirectory, tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.cbt)"); +#else + QString pathFile = openDialog.getOpenFileName(this, tr("Open Comic"), currentDirectory, tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.cbt *.7z *.cb7)"); #endif if (!pathFile.isEmpty()) { openComicFromPath(pathFile); @@ -1435,6 +1441,10 @@ void MainWindowViewer::getSiblingComics(QString path, QString currentComic) << "*.zip" << "*.tar" << "*.pdf" +#if (UNARR_API_VERSION >= 110) + << "*.7z" + << "*.cb7" +#endif << "*.cbt"); #endif d.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index 23e4cd78..013bf883 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -11,6 +11,9 @@ #include "comic_db.h" #include "db_helper.h" #include "reading_list_model.h" +#ifdef use_unarr +#include +#endif // ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read #include "QsLog.h" @@ -290,7 +293,18 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const auto item = static_cast(index.internalPointer()); auto sizeString = [=] { - return QString::number(item->data(ComicModel::Hash).toString().right(item->data(ComicModel::Hash).toString().length() - 40).toInt() / 1024.0 / 1024.0, 'f', 2) + "Mb"; + auto bytes = item->data(ComicModel::Hash).toString().right(item->data(ComicModel::Hash).toString().length() - 40).toULongLong(); + + QStringList units = { "B", "KB", "MB", "GB", "TB" }; + int i; + double outputSize = bytes; + for (i = 0; i < units.size() - 1; i++) { + if (outputSize < 1024) { + break; + } + outputSize = outputSize / 1024; + } + return QString("%1 %2").arg(outputSize, 0, 'f', 2).arg(units[i]); }; if (role == NumberRole) @@ -433,7 +447,7 @@ QVariant ComicModel::headerData(int section, Qt::Orientation orientation, return QVariant(QIcon(":/images/zip.png")); else if (ext.compare("rar", Qt::CaseInsensitive) == 0) return QVariant(QIcon(":/images/rar.png")); -#ifndef use_unarr +#if !defined(use_unarr) || (UNARR_API_VERSION >= 110) else if (ext.compare("7z", Qt::CaseInsensitive) == 0) return QVariant(QIcon(":/images/7z.png")); else if (ext.compare("cb7", Qt::CaseInsensitive) == 0) diff --git a/YACReaderLibrary/db/query_parser.h b/YACReaderLibrary/db/query_parser.h index 7a992aae..3e22c9dd 100644 --- a/YACReaderLibrary/db/query_parser.h +++ b/YACReaderLibrary/db/query_parser.h @@ -10,7 +10,7 @@ #include #define SEARCH_FOLDERS_QUERY "SELECT DISTINCT f.* FROM folder f LEFT JOIN comic c ON (f.id = c.parentId) INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) WHERE " -#define SEARCH_COMICS_QUERY "SELECT ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis,ci.currentPage,ci.rating,ci.hasBeenOpened,ci.date,ci.added,ci.type FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) LEFT JOIN folder f ON (f.id == c.parentId) WHERE " +#define SEARCH_COMICS_QUERY "SELECT ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.currentPage,ci.rating,ci.hasBeenOpened,ci.date,ci.added,ci.type,ci.lastTimeOpened,ci.series,ci.volume,ci.storyArc FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) LEFT JOIN folder f ON (f.id == c.parentId) WHERE " /** * This class is used to generate an SQL query string from a search expression, 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 @@ class Folder : public LibraryItem Folder(const Folder &folder); Folder &operator=(const Folder &other); + static Folder rootFolder(); + inline void setId(qulonglong sid) { id = sid; diff --git a/common/yacreader_global.h b/common/yacreader_global.h index ebc87b29..ff29767e 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -6,7 +6,7 @@ #include #include -#define VERSION "9.14.1" +#define VERSION "9.14.2" // Used to check if the database needs to be updated, the version is stored in the database. // This value is only incremented when the database structure changes. diff --git a/custom_widgets/whats_new_dialog.cpp b/custom_widgets/whats_new_dialog.cpp index c560b877..5a86f44e 100644 --- a/custom_widgets/whats_new_dialog.cpp +++ b/custom_widgets/whats_new_dialog.cpp @@ -66,6 +66,10 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent) " • Improve style of the webui status page.
" " • Fix type not being propagated to new files in a folder.
" " • Mark the current type in the context menu so the user can know the current type.
" + " • Fix columns in the search results. (new in 9.14.2)
" + " • Fix type not being propagated to new folders from their parents. (new in 9.14.2)
" + " • Fix default type set to folders in the root folder when they are added. (new in 9.14.2)
" + " • Improve and fix comic file size format. (new in 9.14.2)
" "
" "YACReaderLibraryServer
" " • Add `rescan-xml-info` command.
"