mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Merge pull request #256 from YACReader/feature/improve_reading_lists
Feature: Improve reading lists
This commit is contained in:
commit
63b1f9401b
@ -118,18 +118,22 @@ int main(int argc, char *argv[])
|
||||
parser.addPositionalArgument("[File|Directory]", "File or directory to open.");
|
||||
QCommandLineOption comicId("comicId", "", "comicId");
|
||||
QCommandLineOption libraryId("libraryId", "", "libraryId");
|
||||
QCommandLineOption readingListId("readingListId", "", "readingListId");
|
||||
// hide comicId and libraryId from help
|
||||
#if QT_VERSION >= 0x050800
|
||||
comicId.setFlags(QCommandLineOption::HiddenFromHelp);
|
||||
libraryId.setFlags(QCommandLineOption::HiddenFromHelp);
|
||||
readingListId.setFlags(QCommandLineOption::HiddenFromHelp);
|
||||
#else
|
||||
comicId.setHidden(true);
|
||||
libraryId.setHidden(true);
|
||||
readingListId.setHidden(true);
|
||||
#endif
|
||||
|
||||
// process
|
||||
parser.addOption(comicId);
|
||||
parser.addOption(libraryId);
|
||||
parser.addOption(readingListId);
|
||||
parser.process(app);
|
||||
|
||||
QString destLog = YACReader::getSettingsPath() + "/yacreader.log";
|
||||
@ -173,7 +177,15 @@ int main(int argc, char *argv[])
|
||||
// some arguments need to be parsed after MainWindowViewer creation
|
||||
QStringList arglist = parser.positionalArguments();
|
||||
if (parser.isSet(comicId) && parser.isSet(libraryId) && arglist.count() >= 1) {
|
||||
mwv->open(arglist.at(0), parser.value(comicId).toULongLong(), parser.value(libraryId).toULongLong());
|
||||
OpenComicSource source;
|
||||
|
||||
if (parser.isSet(readingListId)) {
|
||||
source = OpenComicSource { OpenComicSource::ReadingList, parser.value(readingListId).toULongLong() };
|
||||
} else {
|
||||
source = OpenComicSource { OpenComicSource::Folder, 33 }; //Folder is not needed to get the comic information, the comid id points to a unique comic
|
||||
}
|
||||
|
||||
mwv->open(arglist.at(0), parser.value(comicId).toULongLong(), parser.value(libraryId).toULongLong(), source);
|
||||
} else if (arglist.count() >= 1) {
|
||||
mwv->openComicFromPath(arglist.at(0));
|
||||
}
|
||||
|
@ -851,11 +851,12 @@ void MainWindowViewer::open(QString path, ComicDB &comic, QList<ComicDB> &siblin
|
||||
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
|
||||
}
|
||||
|
||||
void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId)
|
||||
void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source)
|
||||
{
|
||||
currentDirectory = path;
|
||||
|
||||
this->libraryId = libraryId;
|
||||
this->source = source;
|
||||
|
||||
enableActions();
|
||||
|
||||
@ -863,7 +864,7 @@ void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId)
|
||||
YACReaderLocalClient client;
|
||||
int tries = 1;
|
||||
bool success = false;
|
||||
while (!(success = client.requestComicInfo(libraryId, currentComicDB, siblingComics)) && tries != 0)
|
||||
while (!(success = client.requestComicInfo(libraryId, currentComicDB, siblingComics, source)) && tries != 0)
|
||||
tries--;
|
||||
|
||||
if (success) {
|
||||
@ -1507,6 +1508,9 @@ void MainWindowViewer::openNextComic()
|
||||
if (currentIndex + 1 > 0 && currentIndex + 1 < siblingComics.count()) {
|
||||
siblingComics[currentIndex] = currentComicDB; //updated
|
||||
currentComicDB = siblingComics.at(currentIndex + 1);
|
||||
|
||||
QMessageBox::warning(nullptr, "", QString(" current dir %1 - path %2").arg(currentDirectory).arg(currentComicDB.path));
|
||||
|
||||
open(currentDirectory + currentComicDB.path, currentComicDB, siblingComics);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
class Comic;
|
||||
class Viewer;
|
||||
@ -25,6 +26,8 @@ class YACReaderSliderAction;
|
||||
class YACReaderSlider;
|
||||
class EditShortcutsDialog;
|
||||
|
||||
namespace YACReader {
|
||||
|
||||
class MainWindowViewer : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -32,7 +35,7 @@ class MainWindowViewer : public QMainWindow
|
||||
public slots:
|
||||
void open();
|
||||
void open(QString path, ComicDB &comic, QList<ComicDB> &siblings);
|
||||
void open(QString path, qint64 comicId, qint64 libraryId);
|
||||
void open(QString path, qint64 comicId, qint64 libraryId, OpenComicSource source);
|
||||
void openFolder();
|
||||
void openRecent();
|
||||
void openLatestComic();
|
||||
@ -175,6 +178,7 @@ private:
|
||||
bool isClient;
|
||||
QString startComicPath;
|
||||
quint64 libraryId;
|
||||
OpenComicSource source;
|
||||
|
||||
//fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309
|
||||
Qt::WindowFlags previousWindowFlags;
|
||||
@ -191,4 +195,7 @@ public:
|
||||
MainWindowViewer();
|
||||
~MainWindowViewer() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ void YACReaderLocalClient::readMessage()
|
||||
}
|
||||
#include <QMessageBox>
|
||||
|
||||
bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings)
|
||||
bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings, OpenComicSource source)
|
||||
{
|
||||
localSocket->connectToServer(YACREADERLIBRARY_GUID);
|
||||
if (localSocket->isOpen()) {
|
||||
@ -38,6 +38,7 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB &comic, Q
|
||||
out << (quint32)0;
|
||||
out << (quint8)YACReader::RequestComicInfo;
|
||||
out << libraryId;
|
||||
out << source;
|
||||
out << comic;
|
||||
out.device()->seek(0);
|
||||
out << (quint32)(block.size() - sizeof(quint32));
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef YACREADER_LOCAL_CLIENT_H
|
||||
#define YACREADER_LOCAL_CLIENT_H
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QLocalSocket;
|
||||
@ -16,7 +18,7 @@ signals:
|
||||
void finished();
|
||||
public slots:
|
||||
void readMessage();
|
||||
bool requestComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings);
|
||||
bool requestComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings, YACReader::OpenComicSource source);
|
||||
bool sendComicInfo(quint64 libraryId, ComicDB &comic);
|
||||
bool sendComicInfo(quint64 libraryId, ComicDB &comic, qulonglong nextComicId);
|
||||
|
||||
|
@ -78,6 +78,7 @@ HEADERS += comic_flow.h \
|
||||
db/comic_query_result_processor.h \
|
||||
db/folder_query_result_processor.h \
|
||||
db/query_lexer.h \
|
||||
library_comic_opener.h \
|
||||
library_creator.h \
|
||||
library_window.h \
|
||||
add_library_dialog.h \
|
||||
@ -156,6 +157,7 @@ SOURCES += comic_flow.cpp \
|
||||
db/comic_query_result_processor.cpp \
|
||||
db/folder_query_result_processor.cpp \
|
||||
db/query_lexer.cpp \
|
||||
library_comic_opener.cpp \
|
||||
library_creator.cpp \
|
||||
library_window.cpp \
|
||||
main.cpp \
|
||||
|
@ -546,6 +546,7 @@ void ComicModel::setupFavoritesModelData(const QString &databasePath)
|
||||
{
|
||||
enableResorting = true;
|
||||
mode = Favorites;
|
||||
sourceId = -1;
|
||||
|
||||
beginResetModel();
|
||||
qDeleteAll(_data);
|
||||
@ -574,6 +575,7 @@ void ComicModel::setupReadingModelData(const QString &databasePath)
|
||||
{
|
||||
enableResorting = false;
|
||||
mode = Reading;
|
||||
sourceId = -1;
|
||||
|
||||
beginResetModel();
|
||||
qDeleteAll(_data);
|
||||
|
@ -129,6 +129,7 @@ public:
|
||||
bool isFavorite(const QModelIndex &index);
|
||||
|
||||
ComicModel::Mode getMode() { return mode; }
|
||||
unsigned long long int getSourceId() { return sourceId; }
|
||||
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
|
@ -359,7 +359,7 @@ QList<ReadingList> DBHelper::getReadingLists(qulonglong libraryId)
|
||||
return list;
|
||||
}
|
||||
|
||||
QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulonglong readingListId)
|
||||
QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulonglong readingListId, bool getFullComicInfoFields)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QList<ComicDB> list;
|
||||
@ -382,26 +382,52 @@ QList<ComicDB> DBHelper::getReadingListFullContent(qulonglong libraryId, qulongl
|
||||
|
||||
foreach (qulonglong id, ids) {
|
||||
QSqlQuery selectQuery(db);
|
||||
selectQuery.prepare("SELECT c.id,c.parentId,c.fileName,ci.title,ci.currentPage,ci.numPages,ci.hash,ci.read,ci.coverSizeRatio "
|
||||
"FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) "
|
||||
"INNER JOIN comic_reading_list crl ON (c.id == crl.comic_id) "
|
||||
"WHERE crl.reading_list_id = :parentReadingList "
|
||||
"ORDER BY crl.ordering");
|
||||
|
||||
QString params;
|
||||
if (getFullComicInfoFields) {
|
||||
params = "*";
|
||||
} else {
|
||||
params = "c.id,c.parentId,c.fileName,c.path,ci.title,ci.currentPage,ci.numPages,ci.hash,ci.read,ci.coverSizeRatio";
|
||||
}
|
||||
|
||||
selectQuery.prepare("SELECT " + params + " "
|
||||
"FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) "
|
||||
"INNER JOIN comic_reading_list crl ON (c.id == crl.comic_id) "
|
||||
"WHERE crl.reading_list_id = :parentReadingList "
|
||||
"ORDER BY crl.ordering");
|
||||
selectQuery.bindValue(":parentReadingList", id);
|
||||
selectQuery.exec();
|
||||
|
||||
auto record = selectQuery.record();
|
||||
|
||||
int idComicIndex = record.indexOf("id");
|
||||
int parentIdIndex = record.indexOf("parentId");
|
||||
int fileName = record.indexOf("fileName");
|
||||
int path = record.indexOf("path");
|
||||
|
||||
while (selectQuery.next()) {
|
||||
ComicDB comic;
|
||||
|
||||
comic.id = selectQuery.value(0).toULongLong();
|
||||
comic.parentId = selectQuery.value(1).toULongLong();
|
||||
comic.name = selectQuery.value(2).toString();
|
||||
comic.info.title = selectQuery.value(3).toString();
|
||||
comic.info.currentPage = selectQuery.value(4).toInt();
|
||||
comic.info.numPages = selectQuery.value(5).toInt();
|
||||
comic.info.hash = selectQuery.value(6).toString();
|
||||
comic.info.read = selectQuery.value(7).toBool();
|
||||
comic.info.coverSizeRatio = selectQuery.value(8).toFloat();
|
||||
if (getFullComicInfoFields) {
|
||||
comic.id = selectQuery.value(idComicIndex).toULongLong();
|
||||
comic.parentId = selectQuery.value(parentIdIndex).toULongLong();
|
||||
comic.name = selectQuery.value(fileName).toString();
|
||||
comic.path = selectQuery.value(path).toString();
|
||||
|
||||
comic.info = getComicInfoFromQuery(selectQuery, "comicInfoId");
|
||||
} else {
|
||||
comic.id = selectQuery.value(0).toULongLong();
|
||||
comic.parentId = selectQuery.value(1).toULongLong();
|
||||
comic.name = selectQuery.value(2).toString();
|
||||
comic.path = selectQuery.value(3).toString();
|
||||
|
||||
comic.info.title = selectQuery.value(4).toString();
|
||||
comic.info.currentPage = selectQuery.value(5).toInt();
|
||||
comic.info.numPages = selectQuery.value(6).toInt();
|
||||
comic.info.hash = selectQuery.value(7).toString();
|
||||
comic.info.read = selectQuery.value(8).toBool();
|
||||
comic.info.coverSizeRatio = selectQuery.value(9).toFloat();
|
||||
}
|
||||
|
||||
list.append(comic);
|
||||
}
|
||||
@ -1333,64 +1359,6 @@ QList<ComicDB> DBHelper::getSortedComicsFromParent(qulonglong parentId, QSqlData
|
||||
int fileName = record.indexOf("fileName");
|
||||
int path = record.indexOf("path");
|
||||
|
||||
int hash = record.indexOf("hash");
|
||||
int comicInfoId = record.indexOf("comicInfoId");
|
||||
int read = record.indexOf("read");
|
||||
int edited = record.indexOf("edited");
|
||||
|
||||
//new 7.0 fields
|
||||
int hasBeenOpened = record.indexOf("hasBeenOpened");
|
||||
int currentPage = record.indexOf("currentPage");
|
||||
int bookmark1 = record.indexOf("bookmark1");
|
||||
int bookmark2 = record.indexOf("bookmark2");
|
||||
int bookmark3 = record.indexOf("bookmark3");
|
||||
int brightness = record.indexOf("brightness");
|
||||
int contrast = record.indexOf("contrast");
|
||||
int gamma = record.indexOf("gamma");
|
||||
int rating = record.indexOf("rating");
|
||||
//--
|
||||
|
||||
int title = record.indexOf("title");
|
||||
int numPages = record.indexOf("numPages");
|
||||
|
||||
int coverPage = record.indexOf("coverPage");
|
||||
|
||||
int number = record.indexOf("number");
|
||||
int isBis = record.indexOf("isBis");
|
||||
int count = record.indexOf("count");
|
||||
|
||||
int volume = record.indexOf("volume");
|
||||
int storyArc = record.indexOf("storyArc");
|
||||
int arcNumber = record.indexOf("arcNumber");
|
||||
int arcCount = record.indexOf("arcCount");
|
||||
|
||||
int genere = record.indexOf("genere");
|
||||
|
||||
int writer = record.indexOf("writer");
|
||||
int penciller = record.indexOf("penciller");
|
||||
int inker = record.indexOf("inker");
|
||||
int colorist = record.indexOf("colorist");
|
||||
int letterer = record.indexOf("letterer");
|
||||
int coverArtist = record.indexOf("coverArtist");
|
||||
|
||||
int date = record.indexOf("date");
|
||||
int publisher = record.indexOf("publisher");
|
||||
int format = record.indexOf("format");
|
||||
int color = record.indexOf("color");
|
||||
int ageRating = record.indexOf("ageRating");
|
||||
int manga = record.indexOf("manga");
|
||||
|
||||
int synopsis = record.indexOf("synopsis");
|
||||
int characters = record.indexOf("characters");
|
||||
int notes = record.indexOf("notes");
|
||||
|
||||
int comicVineID = record.indexOf("comicVineID");
|
||||
|
||||
int lastTimeOpened = record.indexOf("lastTimeOpened");
|
||||
|
||||
int coverSizeRatio = record.indexOf("coverSizeRatio");
|
||||
int originalCoverSize = record.indexOf("originalCoverSize");
|
||||
|
||||
ComicDB currentItem;
|
||||
while (selectQuery.next()) {
|
||||
currentItem.id = selectQuery.value(id).toULongLong();
|
||||
@ -1398,65 +1366,7 @@ QList<ComicDB> DBHelper::getSortedComicsFromParent(qulonglong parentId, QSqlData
|
||||
currentItem.name = selectQuery.value(fileName).toString();
|
||||
currentItem.path = selectQuery.value(path).toString();
|
||||
|
||||
currentItem.info.hash = selectQuery.value(hash).toString();
|
||||
currentItem.info.id = selectQuery.value(comicInfoId).toULongLong();
|
||||
currentItem.info.read = selectQuery.value(read).toBool();
|
||||
currentItem.info.edited = selectQuery.value(edited).toBool();
|
||||
|
||||
//new 7.0 fields
|
||||
currentItem.info.hasBeenOpened = selectQuery.value(hasBeenOpened).toBool();
|
||||
currentItem.info.currentPage = selectQuery.value(currentPage).toInt();
|
||||
currentItem.info.bookmark1 = selectQuery.value(bookmark1).toInt();
|
||||
currentItem.info.bookmark2 = selectQuery.value(bookmark2).toInt();
|
||||
currentItem.info.bookmark3 = selectQuery.value(bookmark3).toInt();
|
||||
currentItem.info.brightness = selectQuery.value(brightness).toInt();
|
||||
currentItem.info.contrast = selectQuery.value(contrast).toInt();
|
||||
currentItem.info.gamma = selectQuery.value(gamma).toInt();
|
||||
currentItem.info.rating = selectQuery.value(rating).toInt();
|
||||
//--
|
||||
|
||||
currentItem.info.title = selectQuery.value(title);
|
||||
currentItem.info.numPages = selectQuery.value(numPages);
|
||||
|
||||
currentItem.info.coverPage = selectQuery.value(coverPage);
|
||||
|
||||
currentItem.info.number = selectQuery.value(number);
|
||||
currentItem.info.isBis = selectQuery.value(isBis);
|
||||
currentItem.info.count = selectQuery.value(count);
|
||||
|
||||
currentItem.info.volume = selectQuery.value(volume);
|
||||
currentItem.info.storyArc = selectQuery.value(storyArc);
|
||||
currentItem.info.arcNumber = selectQuery.value(arcNumber);
|
||||
currentItem.info.arcCount = selectQuery.value(arcCount);
|
||||
|
||||
currentItem.info.genere = selectQuery.value(genere);
|
||||
|
||||
currentItem.info.writer = selectQuery.value(writer);
|
||||
currentItem.info.penciller = selectQuery.value(penciller);
|
||||
currentItem.info.inker = selectQuery.value(inker);
|
||||
currentItem.info.colorist = selectQuery.value(colorist);
|
||||
currentItem.info.letterer = selectQuery.value(letterer);
|
||||
currentItem.info.coverArtist = selectQuery.value(coverArtist);
|
||||
|
||||
currentItem.info.date = selectQuery.value(date);
|
||||
currentItem.info.publisher = selectQuery.value(publisher);
|
||||
currentItem.info.format = selectQuery.value(format);
|
||||
currentItem.info.color = selectQuery.value(color);
|
||||
currentItem.info.ageRating = selectQuery.value(ageRating);
|
||||
currentItem.info.manga = selectQuery.value(manga);
|
||||
|
||||
currentItem.info.synopsis = selectQuery.value(synopsis);
|
||||
currentItem.info.characters = selectQuery.value(characters);
|
||||
currentItem.info.notes = selectQuery.value(notes);
|
||||
|
||||
currentItem.info.comicVineID = selectQuery.value(comicVineID);
|
||||
|
||||
currentItem.info.lastTimeOpened = selectQuery.value(lastTimeOpened);
|
||||
|
||||
currentItem.info.coverSizeRatio = selectQuery.value(coverSizeRatio);
|
||||
currentItem.info.originalCoverSize = selectQuery.value(originalCoverSize);
|
||||
|
||||
currentItem.info.existOnDb = true;
|
||||
currentItem.info = getComicInfoFromQuery(selectQuery, "comicInfoId");
|
||||
|
||||
list.append(currentItem);
|
||||
}
|
||||
@ -1738,9 +1648,20 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase &db)
|
||||
findComicInfo.bindValue(":hash", hash);
|
||||
findComicInfo.exec();
|
||||
|
||||
QSqlRecord record = findComicInfo.record();
|
||||
if (findComicInfo.next()) {
|
||||
comicInfo = getComicInfoFromQuery(findComicInfo);
|
||||
} else
|
||||
comicInfo.existOnDb = false;
|
||||
|
||||
int id = record.indexOf("id");
|
||||
return comicInfo;
|
||||
}
|
||||
|
||||
ComicInfo DBHelper::getComicInfoFromQuery(QSqlQuery &query, const QString &idKey)
|
||||
{
|
||||
QSqlRecord record = query.record();
|
||||
|
||||
int hash = record.indexOf("hash");
|
||||
int id = record.indexOf(idKey);
|
||||
int read = record.indexOf("read");
|
||||
int edited = record.indexOf("edited");
|
||||
|
||||
@ -1797,72 +1718,71 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase &db)
|
||||
int coverSizeRatio = record.indexOf("coverSizeRatio");
|
||||
int originalCoverSize = record.indexOf("originalCoverSize");
|
||||
|
||||
if (findComicInfo.next()) {
|
||||
comicInfo.hash = hash;
|
||||
comicInfo.id = findComicInfo.value(id).toULongLong();
|
||||
comicInfo.read = findComicInfo.value(read).toBool();
|
||||
comicInfo.edited = findComicInfo.value(edited).toBool();
|
||||
ComicInfo comicInfo;
|
||||
|
||||
//new 7.0 fields
|
||||
comicInfo.hasBeenOpened = findComicInfo.value(hasBeenOpened).toBool();
|
||||
comicInfo.currentPage = findComicInfo.value(currentPage).toInt();
|
||||
comicInfo.bookmark1 = findComicInfo.value(bookmark1).toInt();
|
||||
comicInfo.bookmark2 = findComicInfo.value(bookmark2).toInt();
|
||||
comicInfo.bookmark3 = findComicInfo.value(bookmark3).toInt();
|
||||
comicInfo.brightness = findComicInfo.value(brightness).toInt();
|
||||
comicInfo.contrast = findComicInfo.value(contrast).toInt();
|
||||
comicInfo.gamma = findComicInfo.value(gamma).toInt();
|
||||
comicInfo.rating = findComicInfo.value(rating).toInt();
|
||||
//--
|
||||
comicInfo.title = findComicInfo.value(title);
|
||||
comicInfo.numPages = findComicInfo.value(numPages);
|
||||
comicInfo.hash = query.value(hash).toString();
|
||||
comicInfo.id = query.value(id).toULongLong();
|
||||
comicInfo.read = query.value(read).toBool();
|
||||
comicInfo.edited = query.value(edited).toBool();
|
||||
|
||||
comicInfo.coverPage = findComicInfo.value(coverPage);
|
||||
//new 7.0 fields
|
||||
comicInfo.hasBeenOpened = query.value(hasBeenOpened).toBool();
|
||||
comicInfo.currentPage = query.value(currentPage).toInt();
|
||||
comicInfo.bookmark1 = query.value(bookmark1).toInt();
|
||||
comicInfo.bookmark2 = query.value(bookmark2).toInt();
|
||||
comicInfo.bookmark3 = query.value(bookmark3).toInt();
|
||||
comicInfo.brightness = query.value(brightness).toInt();
|
||||
comicInfo.contrast = query.value(contrast).toInt();
|
||||
comicInfo.gamma = query.value(gamma).toInt();
|
||||
comicInfo.rating = query.value(rating).toInt();
|
||||
//--
|
||||
comicInfo.title = query.value(title);
|
||||
comicInfo.numPages = query.value(numPages);
|
||||
|
||||
comicInfo.number = findComicInfo.value(number);
|
||||
comicInfo.isBis = findComicInfo.value(isBis);
|
||||
comicInfo.count = findComicInfo.value(count);
|
||||
comicInfo.coverPage = query.value(coverPage);
|
||||
|
||||
comicInfo.volume = findComicInfo.value(volume);
|
||||
comicInfo.storyArc = findComicInfo.value(storyArc);
|
||||
comicInfo.arcNumber = findComicInfo.value(arcNumber);
|
||||
comicInfo.arcCount = findComicInfo.value(arcCount);
|
||||
comicInfo.number = query.value(number);
|
||||
comicInfo.isBis = query.value(isBis);
|
||||
comicInfo.count = query.value(count);
|
||||
|
||||
comicInfo.genere = findComicInfo.value(genere);
|
||||
comicInfo.volume = query.value(volume);
|
||||
comicInfo.storyArc = query.value(storyArc);
|
||||
comicInfo.arcNumber = query.value(arcNumber);
|
||||
comicInfo.arcCount = query.value(arcCount);
|
||||
|
||||
comicInfo.writer = findComicInfo.value(writer);
|
||||
comicInfo.penciller = findComicInfo.value(penciller);
|
||||
comicInfo.inker = findComicInfo.value(inker);
|
||||
comicInfo.colorist = findComicInfo.value(colorist);
|
||||
comicInfo.letterer = findComicInfo.value(letterer);
|
||||
comicInfo.coverArtist = findComicInfo.value(coverArtist);
|
||||
comicInfo.genere = query.value(genere);
|
||||
|
||||
comicInfo.date = findComicInfo.value(date);
|
||||
comicInfo.publisher = findComicInfo.value(publisher);
|
||||
comicInfo.format = findComicInfo.value(format);
|
||||
comicInfo.color = findComicInfo.value(color);
|
||||
comicInfo.ageRating = findComicInfo.value(ageRating);
|
||||
comicInfo.writer = query.value(writer);
|
||||
comicInfo.penciller = query.value(penciller);
|
||||
comicInfo.inker = query.value(inker);
|
||||
comicInfo.colorist = query.value(colorist);
|
||||
comicInfo.letterer = query.value(letterer);
|
||||
comicInfo.coverArtist = query.value(coverArtist);
|
||||
|
||||
comicInfo.synopsis = findComicInfo.value(synopsis);
|
||||
comicInfo.characters = findComicInfo.value(characters);
|
||||
comicInfo.notes = findComicInfo.value(notes);
|
||||
comicInfo.date = query.value(date);
|
||||
comicInfo.publisher = query.value(publisher);
|
||||
comicInfo.format = query.value(format);
|
||||
comicInfo.color = query.value(color);
|
||||
comicInfo.ageRating = query.value(ageRating);
|
||||
|
||||
comicInfo.comicVineID = findComicInfo.value(comicVineID);
|
||||
comicInfo.synopsis = query.value(synopsis);
|
||||
comicInfo.characters = query.value(characters);
|
||||
comicInfo.notes = query.value(notes);
|
||||
|
||||
//new 9.5 fields
|
||||
comicInfo.lastTimeOpened = findComicInfo.value(lastTimeOpened);
|
||||
comicInfo.comicVineID = query.value(comicVineID);
|
||||
|
||||
comicInfo.coverSizeRatio = findComicInfo.value(coverSizeRatio);
|
||||
comicInfo.originalCoverSize = findComicInfo.value(originalCoverSize);
|
||||
//--
|
||||
//new 9.5 fields
|
||||
comicInfo.lastTimeOpened = query.value(lastTimeOpened);
|
||||
|
||||
//new 9.8 fields
|
||||
comicInfo.manga = findComicInfo.value(manga);
|
||||
//--
|
||||
comicInfo.coverSizeRatio = query.value(coverSizeRatio);
|
||||
comicInfo.originalCoverSize = query.value(originalCoverSize);
|
||||
//--
|
||||
|
||||
comicInfo.existOnDb = true;
|
||||
} else
|
||||
comicInfo.existOnDb = false;
|
||||
//new 9.8 fields
|
||||
comicInfo.manga = query.value(manga);
|
||||
//--
|
||||
|
||||
comicInfo.existOnDb = true;
|
||||
|
||||
return comicInfo;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
static QList<ComicDB> getFavorites(qulonglong libraryId);
|
||||
static QList<ComicDB> getReading(qulonglong libraryId);
|
||||
static QList<ReadingList> getReadingLists(qulonglong libraryId);
|
||||
static QList<ComicDB> getReadingListFullContent(qulonglong libraryId, qulonglong readingListId);
|
||||
static QList<ComicDB> getReadingListFullContent(qulonglong libraryId, qulonglong readingListId, bool getFullComicInfoFields = false);
|
||||
|
||||
//objects management
|
||||
//deletes
|
||||
@ -96,6 +96,7 @@ public:
|
||||
static ComicDB loadComic(qulonglong id, QSqlDatabase &db);
|
||||
static ComicDB loadComic(QString cname, QString cpath, QString chash, QSqlDatabase &database);
|
||||
static ComicInfo loadComicInfo(QString hash, QSqlDatabase &db);
|
||||
static ComicInfo getComicInfoFromQuery(QSqlQuery &query, const QString &idKey = "id");
|
||||
static QList<QString> loadSubfoldersNames(qulonglong folderId, QSqlDatabase &db);
|
||||
//queries
|
||||
static bool isFavoriteComic(qulonglong id, QSqlDatabase &db);
|
||||
|
47
YACReaderLibrary/library_comic_opener.cpp
Normal file
47
YACReaderLibrary/library_comic_opener.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "library_comic_opener.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtWidgets>
|
||||
|
||||
bool YACReader::openComic(const ComicDB &comic,
|
||||
unsigned long long libraryId,
|
||||
const QString &path,
|
||||
OpenComicSource source)
|
||||
{
|
||||
bool yacreaderFound = false;
|
||||
|
||||
QString labelParam;
|
||||
|
||||
if (source.source == OpenComicSource::ReadingList) {
|
||||
labelParam = QString("--readingListId=%1").arg(source.sourceId);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
QStringList possiblePaths { QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../../../") };
|
||||
possiblePaths += QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
|
||||
|
||||
for (auto &&ypath : possiblePaths) {
|
||||
QString yacreaderPath = QDir::cleanPath(ypath + "/YACReader.app");
|
||||
if (QFileInfo(yacreaderPath).exists()) {
|
||||
yacreaderFound = true;
|
||||
QStringList parameters { "-n", yacreaderPath, "--args", path, QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId), labelParam };
|
||||
QProcess::startDetached("open", parameters);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QStringList parameters { path, QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId), labelParam };
|
||||
yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath() + "/YACReader.exe"), parameters);
|
||||
#endif
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
QStringList parameters { path, QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId), labelParam };
|
||||
yacreaderFound = QProcess::startDetached(QStringLiteral("YACReader"), parameters);
|
||||
#endif
|
||||
|
||||
return yacreaderFound;
|
||||
}
|
18
YACReaderLibrary/library_comic_opener.h
Normal file
18
YACReaderLibrary/library_comic_opener.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef LIBRARYCOMICOPENER_H
|
||||
#define LIBRARYCOMICOPENER_H
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
class ComicDB;
|
||||
class QString;
|
||||
|
||||
namespace YACReader {
|
||||
|
||||
bool openComic(const ComicDB &comic,
|
||||
unsigned long long libraryId,
|
||||
const QString &path,
|
||||
OpenComicSource source);
|
||||
|
||||
}
|
||||
|
||||
#endif // LIBRARYCOMICOPENER_H
|
@ -86,6 +86,8 @@
|
||||
|
||||
#include "whats_new_controller.h"
|
||||
|
||||
#include "library_comic_opener.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@ -1825,37 +1827,27 @@ void LibraryWindow::checkEmptyFolder()
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::openComic(const ComicDB &comic)
|
||||
void LibraryWindow::openComic()
|
||||
{
|
||||
if (!importedCovers) {
|
||||
//TODO generate IDS for libraries...
|
||||
quint64 libraryId = libraries.getId(selectedLibrary->currentText());
|
||||
bool yacreaderFound = false;
|
||||
auto libraryId = libraries.getId(selectedLibrary->currentText());
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
QStringList possiblePaths { QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../../../") };
|
||||
possiblePaths += QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
|
||||
auto comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex());
|
||||
auto mode = comicsModel->getMode();
|
||||
|
||||
for (auto &&ypath : possiblePaths) {
|
||||
QString yacreaderPath = QDir::cleanPath(ypath + "/YACReader.app");
|
||||
if (QFileInfo(yacreaderPath).exists()) {
|
||||
yacreaderFound = true;
|
||||
QStringList parameters { "-n", yacreaderPath, "--args", currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId) };
|
||||
QProcess::startDetached("open", parameters);
|
||||
break;
|
||||
}
|
||||
OpenComicSource::Source source;
|
||||
|
||||
if (mode == ComicModel::ReadingList) {
|
||||
source = OpenComicSource::Source::ReadingList;
|
||||
} else if (mode == ComicModel::Reading) {
|
||||
//TODO check where the comic was opened from the last time it was read
|
||||
source = OpenComicSource::Source::Folder;
|
||||
} else {
|
||||
source = OpenComicSource::Source::Folder;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QStringList parameters { currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId) };
|
||||
yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath() + "/YACReader.exe"), parameters);
|
||||
#endif
|
||||
auto yacreaderFound = YACReader::openComic(comic, libraryId, currentPath(), OpenComicSource { source, comicsModel->getSourceId() });
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
QStringList parameters { currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId) };
|
||||
yacreaderFound = QProcess::startDetached(QStringLiteral("YACReader"), parameters);
|
||||
#endif
|
||||
if (!yacreaderFound) {
|
||||
#ifdef Q_OS_WIN
|
||||
QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. YACReader should be installed in the same folder as YACReaderLibrary."));
|
||||
@ -1866,14 +1858,6 @@ void LibraryWindow::openComic(const ComicDB &comic)
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::openComic()
|
||||
{
|
||||
if (!importedCovers) {
|
||||
ComicDB comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex());
|
||||
openComic(comic);
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus)
|
||||
{
|
||||
comicsModel->setComicsRead(getSelectedComics(), readStatus);
|
||||
|
@ -313,7 +313,6 @@ public slots:
|
||||
void selectSubfolder(const QModelIndex &mi, int child);
|
||||
void checkEmptyFolder();
|
||||
void openComic();
|
||||
void openComic(const ComicDB &comic);
|
||||
void createLibrary();
|
||||
void create(QString source, QString dest, QString name);
|
||||
void showAddLibrary();
|
||||
|
@ -23,6 +23,7 @@ ComicControllerV2::ComicControllerV2() { }
|
||||
|
||||
void ComicControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
|
||||
QByteArray token = request.getHeader("x-request-id");
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
|
||||
|
||||
|
@ -5,10 +5,6 @@
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
#include <QThread>
|
||||
class Comic;
|
||||
class QString;
|
||||
|
||||
class ComicControllerV2 : public stefanfrings::HttpRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -0,0 +1,101 @@
|
||||
#include "comiccontrollerinreadinglist_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
#include "yacreader_http_session.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
using stefanfrings::HttpRequest;
|
||||
using stefanfrings::HttpResponse;
|
||||
|
||||
ComicControllerInReadingListV2::ComicControllerInReadingListV2() { }
|
||||
|
||||
void ComicControllerInReadingListV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
|
||||
QByteArray token = request.getHeader("x-request-id");
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
|
||||
|
||||
if (ySession == nullptr) {
|
||||
response.setStatus(404, "not found");
|
||||
response.write("404 not found", true);
|
||||
return;
|
||||
}
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
qulonglong libraryId = pathElements.at(3).toLongLong();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong readingListId = pathElements.at(5).toULongLong();
|
||||
qulonglong comicId = pathElements.at(7).toULongLong();
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
Comic *comicFile = FactoryComic::newComic(libraries.getPath(libraryId) + comic.path);
|
||||
|
||||
if (comicFile != nullptr) {
|
||||
QThread *thread = nullptr;
|
||||
|
||||
thread = new QThread();
|
||||
|
||||
comicFile->moveToThread(thread);
|
||||
|
||||
connect(comicFile, SIGNAL(errorOpening()), thread, SLOT(quit()));
|
||||
connect(comicFile, SIGNAL(errorOpening(QString)), thread, SLOT(quit()));
|
||||
connect(comicFile, SIGNAL(imagesLoaded()), thread, SLOT(quit()));
|
||||
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
comicFile->load(libraries.getPath(libraryId) + comic.path);
|
||||
|
||||
if (thread != nullptr)
|
||||
thread->start();
|
||||
|
||||
QLOG_TRACE() << "remote comic requested";
|
||||
ySession->setCurrentRemoteComic(comic.id, comicFile);
|
||||
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
//TODO this field is not used by the client!
|
||||
response.write(QString("library:%1\r\n").arg(libraryName).toUtf8());
|
||||
response.write(QString("libraryId:%1\r\n").arg(libraryId).toUtf8());
|
||||
|
||||
QList<ComicDB> siblings = DBHelper::getReadingListFullContent(libraryId, readingListId);
|
||||
|
||||
bool found = false;
|
||||
int i;
|
||||
for (i = 0; i < siblings.length(); i++) {
|
||||
if (siblings.at(i).id == comic.id) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (i > 0)
|
||||
response.write(QString("previousComic:%1\r\n").arg(siblings.at(i - 1).id).toUtf8());
|
||||
if (i < siblings.length() - 1)
|
||||
response.write(QString("nextComic:%1\r\n").arg(siblings.at(i + 1).id).toUtf8());
|
||||
} else {
|
||||
//ERROR
|
||||
}
|
||||
|
||||
response.write(comic.toTXT().toUtf8(), true);
|
||||
} else {
|
||||
//delete comicFile;
|
||||
response.setStatus(404, "not found");
|
||||
response.write("404 not found", true);
|
||||
}
|
||||
//response.write(t.toLatin1(),true);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
#ifndef COMICCONTROLLERINREADINGLISTV2_H
|
||||
#define COMICCONTROLLERINREADINGLISTV2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ComicControllerInReadingListV2 : public stefanfrings::HttpRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ComicControllerInReadingListV2)
|
||||
public:
|
||||
ComicControllerInReadingListV2();
|
||||
|
||||
void service(stefanfrings::HttpRequest &request, stefanfrings::HttpResponse &response) override;
|
||||
};
|
||||
|
||||
#endif // COMICCONTROLLERINREADINGLISTV2_H
|
@ -46,6 +46,12 @@ void PageControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
currentComicId = ySession->getCurrentComicId();
|
||||
}
|
||||
|
||||
if (comicFile == nullptr) {
|
||||
response.setStatus(404, "not found");
|
||||
response.write("404 not found", true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comicFile->hasBeenAnErrorOpening()) {
|
||||
//delete comicFile;
|
||||
if (remote)
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "controllers/v2/readinglistcontentcontroller_v2.h"
|
||||
#include "controllers/v2/readinglistinfocontroller_v2.h"
|
||||
#include "controllers/v2/comicfullinfocontroller_v2.h"
|
||||
#include "controllers/v2/comiccontrollerinreadinglist_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
@ -234,6 +235,7 @@ void RequestMapper::serviceV2(HttpRequest &request, HttpResponse &response)
|
||||
QRegExp comicDownloadInfo("/v2/library/.+/comic/[0-9]+/info/?"); //get comic info (full download info)
|
||||
QRegExp comicOpenForDownloading("/v2/library/.+/comic/[0-9]+/?"); //get comic info (full info + opening)
|
||||
QRegExp comicOpenForRemoteReading("/v2/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||
QRegExp comicOpenForRemoteReadingInAReadingList("/v2/library/.+/reading_list/[0-9]+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||
QRegExp comicFullInfo("/v2/library/.+/comic/[0-9]+/fullinfo/?"); //get comic info
|
||||
QRegExp comicUpdate("/v2/library/.+/comic/[0-9]+/update/?"); //get comic info
|
||||
QRegExp comicClose("/v2/library/.+/comic/[0-9]+/close/?"); //the server will close the comic and free memory
|
||||
@ -277,8 +279,9 @@ void RequestMapper::serviceV2(HttpRequest &request, HttpResponse &response)
|
||||
CoverControllerV2().service(request, response);
|
||||
} else if (comicDownloadInfo.exactMatch(path)) {
|
||||
ComicDownloadInfoControllerV2().service(request, response);
|
||||
} else if (comicOpenForDownloading.exactMatch(path) || comicOpenForRemoteReading.exactMatch(path)) //start download or start remote reading
|
||||
{
|
||||
} else if (comicOpenForRemoteReadingInAReadingList.exactMatch(path)) {
|
||||
ComicControllerInReadingListV2().service(request, response);
|
||||
} else if (comicOpenForDownloading.exactMatch(path) || comicOpenForRemoteReading.exactMatch(path)) { //start download or start remote reading
|
||||
ComicControllerV2().service(request, response);
|
||||
} else if (comicFullInfo.exactMatch(path)) {
|
||||
ComicFullinfoController_v2().service(request, response);
|
||||
|
@ -46,7 +46,8 @@ HEADERS += \
|
||||
$$PWD/controllers/v2/readinglistcontentcontroller_v2.h \
|
||||
$$PWD/controllers/v2/comicfullinfocontroller_v2.h \
|
||||
$$PWD/controllers/v2/readinglistinfocontroller_v2.h \
|
||||
$$PWD/controllers/v2/taginfocontroller_v2.h
|
||||
$$PWD/controllers/v2/taginfocontroller_v2.h \
|
||||
$$PWD/controllers/v2/comiccontrollerinreadinglist_v2.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
@ -87,7 +88,8 @@ SOURCES += \
|
||||
$$PWD/controllers/v2/readinglistcontentcontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/comicfullinfocontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/readinglistinfocontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/taginfocontroller_v2.cpp
|
||||
$$PWD/controllers/v2/taginfocontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/comiccontrollerinreadinglist_v2.cpp
|
||||
|
||||
include(../../third_party/QtWebApp/httpserver/httpserver.pri)
|
||||
include(../../third_party/QtWebApp/templateengine/templateengine.pri)
|
||||
|
@ -95,6 +95,7 @@ void YACReaderClientConnectionWorker::run()
|
||||
|
||||
quint64 libraryId;
|
||||
ComicDB comic;
|
||||
OpenComicSource source = { OpenComicSource::ReadingList, 0 };
|
||||
qulonglong nextComicId;
|
||||
int tries = 0;
|
||||
int dataAvailable = 0;
|
||||
@ -136,22 +137,20 @@ void YACReaderClientConnectionWorker::run()
|
||||
QDataStream dataStream(data);
|
||||
quint8 msgType;
|
||||
dataStream >> msgType;
|
||||
dataStream >> libraryId;
|
||||
dataStream >> comic;
|
||||
|
||||
bool nextComicInfoAvailable;
|
||||
|
||||
if (dataStream.atEnd()) {
|
||||
nextComicInfoAvailable = false;
|
||||
} else {
|
||||
nextComicInfoAvailable = true;
|
||||
dataStream >> nextComicId;
|
||||
}
|
||||
|
||||
switch (msgType) {
|
||||
case YACReader::RequestComicInfo: {
|
||||
dataStream >> libraryId;
|
||||
dataStream >> source;
|
||||
dataStream >> comic;
|
||||
|
||||
QList<ComicDB> siblings;
|
||||
getComicInfo(libraryId, comic, siblings);
|
||||
|
||||
if (source.source == OpenComicSource::ReadingList) {
|
||||
getComicInfoFromReadingList(libraryId, source.sourceId, comic, siblings);
|
||||
} else {
|
||||
getComicInfo(libraryId, comic, siblings);
|
||||
}
|
||||
|
||||
QByteArray block;
|
||||
QDataStream out(&block, QIODevice::WriteOnly);
|
||||
@ -179,6 +178,18 @@ void YACReaderClientConnectionWorker::run()
|
||||
break;
|
||||
}
|
||||
case YACReader::SendComicInfo: {
|
||||
bool nextComicInfoAvailable;
|
||||
|
||||
dataStream >> libraryId;
|
||||
dataStream >> comic;
|
||||
|
||||
if (dataStream.atEnd()) {
|
||||
nextComicInfoAvailable = false;
|
||||
} else {
|
||||
nextComicInfoAvailable = true;
|
||||
dataStream >> nextComicId;
|
||||
}
|
||||
|
||||
if (nextComicInfoAvailable) {
|
||||
updateComic(libraryId, comic, nextComicId);
|
||||
} else {
|
||||
@ -208,6 +219,13 @@ void YACReaderClientConnectionWorker::getComicInfo(quint64 libraryId, ComicDB &c
|
||||
siblings = DBHelper::getSiblings(libraryId, comic.parentId);
|
||||
}
|
||||
|
||||
void YACReaderClientConnectionWorker::getComicInfoFromReadingList(quint64 libraryId, unsigned long long readingListId, ComicDB &comic, QList<ComicDB> &siblings)
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
comic = DBHelper::getComicInfo(libraryId, comic.id);
|
||||
siblings = DBHelper::getReadingListFullContent(libraryId, readingListId, true);
|
||||
}
|
||||
|
||||
void YACReaderClientConnectionWorker::updateComic(quint64 libraryId, ComicDB &comic)
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
|
@ -42,7 +42,8 @@ private:
|
||||
//static int count;
|
||||
void run();
|
||||
|
||||
void getComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &sibling);
|
||||
void getComicInfo(quint64 libraryId, ComicDB &comic, QList<ComicDB> &siblings);
|
||||
void getComicInfoFromReadingList(quint64 libraryId, unsigned long long readingListId, ComicDB &comic, QList<ComicDB> &siblings);
|
||||
void updateComic(quint64 libraryId, ComicDB &comic);
|
||||
void updateComic(quint64 libraryId, ComicDB &comic, qulonglong nextComicId);
|
||||
|
||||
|
@ -88,3 +88,19 @@ QString YACReader::labelColorToRGBString(LabelColors color)
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
QDataStream &YACReader::operator<<(QDataStream &stream, const OpenComicSource &source)
|
||||
{
|
||||
stream << (quint8)source.source;
|
||||
stream << source.sourceId;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &YACReader::operator>>(QDataStream &stream, OpenComicSource &source)
|
||||
{
|
||||
quint8 sourceRaw;
|
||||
stream >> sourceRaw;
|
||||
source.source = (OpenComicSource::Source)sourceRaw;
|
||||
stream >> source.sourceId;
|
||||
return stream;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define __YACREADER_GLOBAL_H
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <QDataStream>
|
||||
|
||||
#define VERSION "9.8.0"
|
||||
|
||||
@ -54,9 +55,26 @@ enum LabelColors {
|
||||
YDark
|
||||
};
|
||||
|
||||
struct OpenComicSource {
|
||||
enum Source {
|
||||
Folder = 0,
|
||||
ReadingList
|
||||
};
|
||||
|
||||
Source source;
|
||||
qulonglong sourceId;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &stream, const OpenComicSource &source);
|
||||
QDataStream &operator>>(QDataStream &stream, OpenComicSource &source);
|
||||
|
||||
QString getSettingsPath();
|
||||
QString colorToName(LabelColors colors);
|
||||
QString labelColorToRGBString(LabelColors color);
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(YACReader::OpenComicSource::Source)
|
||||
Q_DECLARE_METATYPE(YACReader::OpenComicSource)
|
||||
|
||||
#endif
|
||||
|
@ -62,7 +62,7 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent)
|
||||
"<span style=\"font-weight:600\">Server</span><br/>"
|
||||
" • New `manga` field is sent to YACReader for iOS, so comics tagged as manga will be recognized as such when reading remotely or importing comics.<br/>"
|
||||
"<br/>"
|
||||
"I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in <a href=\"https://www.patreon.com/yacreader\" style=\"color:#E8B800;\">Patreon</a> or donate some money using <a href=\"https://www.paypal.com/donate/?token=xi5MT7fEzaKBbx1-CKNgRHKr3vPp7zjaCc8Ic4VUIxHln58eHfDqdO2K0wlubfxNeFK9IWUKSaB54RhB&locale.x=US\" style=\"color:#E8B800;\">Pay-Pal</a> and help keeping the project alive. Remember that there is an iOS version available in the <a href=\"https://apps.apple.com/app/id635717885\" style=\"color:#E8B800;\">Apple App Store</a>.");
|
||||
"I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in <a href=\"https://www.patreon.com/yacreader\" style=\"color:#E8B800;\">Patreon</a> or donate some money using <a href=\"https://www.paypal.com/donate/?token=zK6u00aWMSj8nvYqGdJ0r9g6_0Ksi4ShkeGMDULDxS9AoVXwLuTOvex3VxHVrJA4FGiqSH6zuiCGJXbr&locale.x=US&Z3JncnB0=\" style=\"color:#E8B800;\">Pay-Pal</a> and help keeping the project alive. Remember that there is an iOS version available in the <a href=\"https://apps.apple.com/app/id635717885\" style=\"color:#E8B800;\">Apple App Store</a>.");
|
||||
QFont textLabelFont("Arial", 15, QFont::Light);
|
||||
text->setFont(textLabelFont);
|
||||
text->setStyleSheet("padding:51px;"
|
||||
|
Loading…
Reference in New Issue
Block a user