mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Revert "Backout changeset c42e71e42d7968ddb6c63fd39011669503b9122c"
This reverts commit 040664d3baff905fa9f1b4723b664c1a8d6cf586.
This commit is contained in:
parent
68ae40fda7
commit
cc71f419cc
@ -381,8 +381,8 @@ Render::Render()
|
||||
|
||||
Render::~Render()
|
||||
{
|
||||
if (comic != nullptr) {
|
||||
comic->moveToThread(QApplication::instance()->thread());
|
||||
if (comic != 0) {
|
||||
//comic->moveToThread(QApplication::instance()->thread());
|
||||
comic->deleteLater();
|
||||
}
|
||||
|
||||
@ -607,8 +607,8 @@ void Render::setRotation(int degrees)
|
||||
|
||||
void Render::setComic(Comic *c)
|
||||
{
|
||||
if (comic != nullptr) {
|
||||
comic->moveToThread(QApplication::instance()->thread());
|
||||
if (comic != 0) {
|
||||
//comic->moveToThread(QApplication::instance()->thread());
|
||||
comic->disconnect();
|
||||
comic->deleteLater();
|
||||
}
|
||||
|
197
common/comic.cpp
197
common/comic.cpp
@ -234,6 +234,21 @@ void Comic::updateBookmarkImage(int index)
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
}
|
||||
|
||||
if (bm->isBookmark(index)) {
|
||||
QImage p;
|
||||
p.loadFromData(_pages[index]);
|
||||
bm->setBookmark(index, p);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
}
|
||||
if (bm->getLastPage() == index) {
|
||||
QImage p;
|
||||
p.loadFromData(_pages[index]);
|
||||
bm->setLastPage(index, p);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::setPageLoaded(int page)
|
||||
@ -378,7 +393,7 @@ bool FileComic::load(const QString &path, const ComicDB &comic)
|
||||
return true;
|
||||
} else {
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
@ -502,6 +517,26 @@ QList<QVector<quint32>> FileComic::getSections(int §ionIndex)
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (sectionIndex == sectionCount) //found
|
||||
{
|
||||
if (section.indexOf(realIdx) != 0) {
|
||||
QVector<quint32> section1;
|
||||
QVector<quint32> section2;
|
||||
foreach (quint32 si, section) {
|
||||
if (si < realIdx) {
|
||||
section1.append(si);
|
||||
} else {
|
||||
section2.append(si);
|
||||
}
|
||||
}
|
||||
sectionIndex++;
|
||||
sections.append(section1);
|
||||
sections.append(section2);
|
||||
//out << "SPLIT" << endl;
|
||||
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (sectionIndex == sectionCount) //found
|
||||
{
|
||||
if (section.indexOf(realIdx) != 0) {
|
||||
@ -528,19 +563,19 @@ QList<QVector<quint32>> FileComic::getSections(int §ionIndex)
|
||||
|
||||
//out << "se han encontrado : " << sections.count() << " sectionIndex : " << sectionIndex << endl;
|
||||
return sections;
|
||||
}
|
||||
}
|
||||
|
||||
void FileComic::process()
|
||||
{
|
||||
void FileComic::process()
|
||||
{
|
||||
CompressedArchive archive(_path);
|
||||
if (!archive.toolsLoaded()) {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening(tr("7z not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!archive.isValid()) {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening(tr("Format not supported"));
|
||||
return;
|
||||
}
|
||||
@ -551,7 +586,7 @@ void FileComic::process()
|
||||
|
||||
if (_fileNames.size() == 0) {
|
||||
//QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return;
|
||||
}
|
||||
@ -587,14 +622,14 @@ void FileComic::process()
|
||||
|
||||
for (int i = sectionIndex; i < sections.count(); i++) {
|
||||
if (_invalidated) {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
archive.getAllData(sections.at(i), this);
|
||||
}
|
||||
for (int i = 0; i < sectionIndex; i++) {
|
||||
if (_invalidated) {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
archive.getAllData(sections.at(i), this);
|
||||
@ -609,31 +644,31 @@ void FileComic::process()
|
||||
emit imageLoaded(sortedIndex);
|
||||
emit imageLoaded(sortedIndex,_pages[sortedIndex]);
|
||||
}*/
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit imagesLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FolderComic::FolderComic()
|
||||
FolderComic::FolderComic()
|
||||
: Comic()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
FolderComic::FolderComic(const QString &path, int atPage)
|
||||
FolderComic::FolderComic(const QString &path, int atPage)
|
||||
: Comic(path, atPage)
|
||||
{
|
||||
{
|
||||
load(path, atPage);
|
||||
}
|
||||
}
|
||||
|
||||
FolderComic::~FolderComic()
|
||||
{
|
||||
}
|
||||
FolderComic::~FolderComic()
|
||||
{
|
||||
}
|
||||
|
||||
bool FolderComic::load(const QString &path, int atPage)
|
||||
{
|
||||
bool FolderComic::load(const QString &path, int atPage)
|
||||
{
|
||||
_path = path;
|
||||
if (atPage == -1) {
|
||||
bm->newComic(_path);
|
||||
@ -642,10 +677,10 @@ bool FolderComic::load(const QString &path, int atPage)
|
||||
_firstPage = atPage;
|
||||
//emit bookmarksLoaded(*bm);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void FolderComic::process()
|
||||
{
|
||||
void FolderComic::process()
|
||||
{
|
||||
QDir d(_path);
|
||||
|
||||
d.setNameFilters(getSupportedImageFormats());
|
||||
@ -664,7 +699,7 @@ void FolderComic::process()
|
||||
if (nPages == 0) {
|
||||
//TODO emitir este mensaje en otro sitio
|
||||
//QMessageBox::critical(NULL,QObject::tr("No images found"),QObject::tr("There are not images on the selected folder"));
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
} else {
|
||||
if (_firstPage == -1) {
|
||||
@ -687,7 +722,7 @@ void FolderComic::process()
|
||||
int i = _firstPage;
|
||||
while (count < nPages) {
|
||||
if (_invalidated) {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -703,33 +738,33 @@ void FolderComic::process()
|
||||
count++;
|
||||
}
|
||||
}
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit imagesLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef NO_PDF
|
||||
|
||||
PDFComic::PDFComic()
|
||||
PDFComic::PDFComic()
|
||||
: Comic()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
PDFComic::PDFComic(const QString &path, int atPage)
|
||||
PDFComic::PDFComic(const QString &path, int atPage)
|
||||
: Comic(path, atPage)
|
||||
{
|
||||
{
|
||||
load(path, atPage);
|
||||
}
|
||||
}
|
||||
|
||||
PDFComic::~PDFComic()
|
||||
{
|
||||
}
|
||||
PDFComic::~PDFComic()
|
||||
{
|
||||
}
|
||||
|
||||
bool PDFComic::load(const QString &path, int atPage)
|
||||
{
|
||||
bool PDFComic::load(const QString &path, int atPage)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
|
||||
if (fi.exists()) {
|
||||
@ -742,14 +777,14 @@ bool PDFComic::load(const QString &path, int atPage)
|
||||
//emit bookmarksLoaded(*bm);
|
||||
return true;
|
||||
} else {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PDFComic::load(const QString &path, const ComicDB &comic)
|
||||
{
|
||||
bool PDFComic::load(const QString &path, const ComicDB &comic)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
|
||||
if (fi.exists()) {
|
||||
@ -763,14 +798,14 @@ bool PDFComic::load(const QString &path, const ComicDB &comic)
|
||||
return true;
|
||||
} else {
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PDFComic::process()
|
||||
{
|
||||
void PDFComic::process()
|
||||
{
|
||||
#if defined Q_OS_MAC && defined USE_PDFKIT
|
||||
pdfComic = new MacOSXPDFComic();
|
||||
if (!pdfComic->openComic(_path)) {
|
||||
@ -790,12 +825,12 @@ void PDFComic::process()
|
||||
if (!pdfComic) {
|
||||
//delete pdfComic;
|
||||
//pdfComic = 0;
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return;
|
||||
}
|
||||
if (pdfComic->isLocked()) {
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return;
|
||||
}
|
||||
@ -830,7 +865,7 @@ void PDFComic::process()
|
||||
for (int i = buffered_index; i < nPages; i++) {
|
||||
if (_invalidated) {
|
||||
delete pdfComic;
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -839,19 +874,19 @@ void PDFComic::process()
|
||||
for (int i = 0; i < buffered_index; i++) {
|
||||
if (_invalidated) {
|
||||
delete pdfComic;
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
renderPage(i);
|
||||
}
|
||||
|
||||
delete pdfComic;
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
//moveToThread(QCoreApplication::instance()->thread());
|
||||
emit imagesLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFComic::renderPage(int page)
|
||||
{
|
||||
void PDFComic::renderPage(int page)
|
||||
{
|
||||
#if defined Q_OS_MAC && defined USE_PDFKIT
|
||||
QImage img = pdfComic->getPage(page);
|
||||
if (!img.isNull()) {
|
||||
@ -871,12 +906,12 @@ void PDFComic::renderPage(int page)
|
||||
emit imageLoaded(page);
|
||||
emit imageLoaded(page, _pages[page]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //NO_PDF
|
||||
|
||||
Comic *FactoryComic::newComic(const QString &path)
|
||||
{
|
||||
Comic *FactoryComic::newComic(const QString &path)
|
||||
{
|
||||
|
||||
QFileInfo fi(path);
|
||||
if (fi.exists()) {
|
||||
@ -899,10 +934,10 @@ Comic *FactoryComic::newComic(const QString &path)
|
||||
}
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_double_page(const QString &pageName, const QString &commonPrefix, const int maxExpectedDoublePagesNumberLenght)
|
||||
{
|
||||
bool is_double_page(const QString &pageName, const QString &commonPrefix, const int maxExpectedDoublePagesNumberLenght)
|
||||
{
|
||||
if (pageName.startsWith(commonPrefix)) {
|
||||
QString substringContainingPageNumbers = pageName.mid(commonPrefix.length());
|
||||
QString pageNumbersSubString;
|
||||
@ -924,10 +959,10 @@ bool is_double_page(const QString &pageName, const QString &commonPrefix, const
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString get_most_common_prefix(const QList<QString> &pageNames)
|
||||
{
|
||||
QString get_most_common_prefix(const QList<QString> &pageNames)
|
||||
{
|
||||
if (pageNames.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
@ -988,10 +1023,10 @@ QString get_most_common_prefix(const QList<QString> &pageNames)
|
||||
}
|
||||
|
||||
return common_prefix;
|
||||
}
|
||||
}
|
||||
|
||||
void get_double_pages(const QList<QString> &pageNames, QList<QString> &singlePageNames /*out*/, QList<QString> &doublePageNames /*out*/)
|
||||
{
|
||||
void get_double_pages(const QList<QString> &pageNames, QList<QString> &singlePageNames /*out*/, QList<QString> &doublePageNames /*out*/)
|
||||
{
|
||||
uint maxExpectedDoublePagesNumberLenght = (int)(log10(pageNames.length()) + 1) * 2;
|
||||
|
||||
QString mostCommonPrefix = get_most_common_prefix(pageNames);
|
||||
@ -1003,10 +1038,10 @@ void get_double_pages(const QList<QString> &pageNames, QList<QString> &singlePag
|
||||
singlePageNames.append(pageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<QString> merge_pages(QList<QString> &singlePageNames, QList<QString> &doublePageNames)
|
||||
{
|
||||
QList<QString> merge_pages(QList<QString> & singlePageNames, QList<QString> & doublePageNames)
|
||||
{
|
||||
//NOTE: this implementation doesn't differ from std::merge using a custom comparator, but it can be easily tweaked if merging requeries an additional heuristic behaviour
|
||||
QList<QString> pageNames;
|
||||
|
||||
@ -1030,10 +1065,10 @@ QList<QString> merge_pages(QList<QString> &singlePageNames, QList<QString> &doub
|
||||
}
|
||||
|
||||
return pageNames;
|
||||
}
|
||||
}
|
||||
|
||||
void comic_pages_sort(QList<QString> &pageNames, YACReaderPageSortingMode sortingMode)
|
||||
{
|
||||
void comic_pages_sort(QList<QString> & pageNames, YACReaderPageSortingMode sortingMode)
|
||||
{
|
||||
switch (sortingMode) {
|
||||
case YACReaderNumericalSorting:
|
||||
std::sort(pageNames.begin(), pageNames.end(), naturalSortLessThanCI);
|
||||
@ -1056,4 +1091,4 @@ void comic_pages_sort(QList<QString> &pageNames, YACReaderPageSortingMode sortin
|
||||
std::sort(pageNames.begin(), pageNames.end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user