Skip to content

Commit

Permalink
Merge pull request #420 from YACReader/develop
Browse files Browse the repository at this point in the history
9.14.2
  • Loading branch information
luisangelsm authored Feb 14, 2024
2 parents a44b0d6 + b8d5f35 commit 7945f65
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion YACReader/main_window_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <QDate>
#include <QMenuBar>

#ifdef use_unarr
#include "unarr.h"
#endif

MainWindowViewer::MainWindowViewer()
: QMainWindow(), fullscreen(false), toolbars(true), currentDirectory("."), currentDirectoryImgDest("."), isClient(false)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 16 additions & 2 deletions YACReaderLibrary/db/comic_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "comic_db.h"
#include "db_helper.h"
#include "reading_list_model.h"
#ifdef use_unarr
#include <unarr.h>
#endif

// ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read
#include "QsLog.h"
Expand Down Expand Up @@ -290,7 +293,18 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
auto item = static_cast<ComicItem *>(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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion YACReaderLibrary/db/query_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <list>

#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,
Expand Down
6 changes: 4 additions & 2 deletions YACReaderLibrary/db_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(folder->type);
query.bindValue(":type", intType);
query.exec();

return query.lastInsertId().toULongLong();
Expand Down
6 changes: 3 additions & 3 deletions YACReaderLibrary/library_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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";
}
{
Expand Down
8 changes: 8 additions & 0 deletions common/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions common/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion common/yacreader_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <QMetaType>
#include <QAbstractItemModel>

#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.
Expand Down
4 changes: 4 additions & 0 deletions custom_widgets/whats_new_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent)
" &#8226; Improve style of the webui status page.<br/>"
" &#8226; Fix type not being propagated to new files in a folder.<br/>"
" &#8226; Mark the current type in the context menu so the user can know the current type.<br/>"
" &#8226; Fix columns in the search results. (new in 9.14.2)<br/>"
" &#8226; Fix type not being propagated to new folders from their parents. (new in 9.14.2)<br/>"
" &#8226; Fix default type set to folders in the root folder when they are added. (new in 9.14.2)<br/>"
" &#8226; Improve and fix comic file size format. (new in 9.14.2)<br/>"
"<br/>"
"<span style=\"font-weight:600\">YACReaderLibraryServer</span><br/>"
" &#8226; Add `rescan-xml-info` command.<br/>"
Expand Down

0 comments on commit 7945f65

Please sign in to comment.