mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Modificada la clase Comic por una jerarqu?a y una factory
corregido bug en go_to_flow_gl
This commit is contained in:
parent
753dba50df
commit
eae74073c0
@ -18,19 +18,15 @@ Comic::Comic()
|
|||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Comic::Comic(const QString pathFile)
|
Comic::Comic(const QString & pathFile)
|
||||||
:_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
|
:_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
|
||||||
{
|
{
|
||||||
setup();
|
setup();
|
||||||
loadFromFile(pathFile);
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Comic::~Comic()
|
Comic::~Comic()
|
||||||
{
|
{
|
||||||
//QThread::~QThread();
|
delete bm; //TODO safe delete
|
||||||
/*delete _7z;
|
|
||||||
delete _7ze;
|
|
||||||
delete bm;*/ //TODO safe delete
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Comic::setup()
|
void Comic::setup()
|
||||||
@ -40,243 +36,6 @@ void Comic::setup()
|
|||||||
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int)));
|
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int)));
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Comic::load(const QString & path)
|
|
||||||
{
|
|
||||||
QFileInfo fi(path);
|
|
||||||
if(fi.exists())
|
|
||||||
{
|
|
||||||
bm->newComic(path);
|
|
||||||
emit bookmarksLoaded(*bm);
|
|
||||||
|
|
||||||
if(fi.isFile())
|
|
||||||
{
|
|
||||||
if(fi.suffix().compare("pdf",Qt::CaseInsensitive) == 0)
|
|
||||||
{
|
|
||||||
_isPDF = true;
|
|
||||||
loadFromPDF(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
loadFromFile(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(fi.isDir())
|
|
||||||
{
|
|
||||||
loadFromDir(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found"));
|
|
||||||
emit errorOpening();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::loadFromFile(const QString & pathFile)
|
|
||||||
{
|
|
||||||
_path = QDir::cleanPath(pathFile);
|
|
||||||
//load files size
|
|
||||||
_7z = new QProcess();
|
|
||||||
QStringList attributes;
|
|
||||||
attributes << "l" << "-ssc-" << "-r" << _path EXTENSIONS;
|
|
||||||
connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadSizes(void)));
|
|
||||||
connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
|
|
||||||
_7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::loadFromDir(const QString & pathDir)
|
|
||||||
{
|
|
||||||
_pathDir = pathDir;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::loadFromPDF(const QString & pathPdf)
|
|
||||||
{
|
|
||||||
_path = pathPdf;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::run()
|
|
||||||
{
|
|
||||||
if(_isPDF)
|
|
||||||
{
|
|
||||||
pdfComic = Poppler::Document::load(_path);
|
|
||||||
if (!pdfComic)
|
|
||||||
{
|
|
||||||
delete pdfComic;
|
|
||||||
pdfComic = 0;
|
|
||||||
QMessageBox::critical(NULL,tr("Bad PDF File"),tr("Invalid PDF file"));
|
|
||||||
emit errorOpening();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//pdfComic->setRenderHint(Poppler::Document::Antialiasing, true);
|
|
||||||
pdfComic->setRenderHint(Poppler::Document::TextAntialiasing, true);
|
|
||||||
int nPages = pdfComic->numPages();
|
|
||||||
emit pageChanged(0); // this indicates new comic, index=0
|
|
||||||
emit numPages(nPages);
|
|
||||||
_loaded = true;
|
|
||||||
//QMessageBox::critical(NULL,QString("%1").arg(nPages),tr("Invalid PDF file"));
|
|
||||||
|
|
||||||
_pages.clear();
|
|
||||||
_pages.resize(nPages);
|
|
||||||
_loadedPages = QVector<bool>(nPages,false);
|
|
||||||
for(int i=0;i<nPages;i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
Poppler::Page* pdfpage = pdfComic->page(i);
|
|
||||||
if (pdfpage)
|
|
||||||
{
|
|
||||||
QImage img = pdfpage->renderToImage(150,150); //TODO use defaults if not using X11 (e.g. MS Win)
|
|
||||||
delete pdfpage;
|
|
||||||
QByteArray ba;
|
|
||||||
QBuffer buf(&ba);
|
|
||||||
img.save(&buf, "jpg");
|
|
||||||
_pages[i] = ba;
|
|
||||||
emit imageLoaded(i);
|
|
||||||
emit imageLoaded(i,_pages[i]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
delete pdfComic;
|
|
||||||
emit imagesLoaded();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QDir d(_pathDir);
|
|
||||||
QStringList l;
|
|
||||||
l EXTENSIONS;
|
|
||||||
d.setNameFilters(l);
|
|
||||||
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
|
||||||
//d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
|
||||||
QFileInfoList list = d.entryInfoList();
|
|
||||||
|
|
||||||
qSort(list.begin(),list.end(),naturalSortLessThanCIFileInfo);
|
|
||||||
|
|
||||||
int nPages = list.size();
|
|
||||||
_pages.clear();
|
|
||||||
_pages.resize(nPages);
|
|
||||||
_loadedPages = QVector<bool>(nPages,false);
|
|
||||||
if(nPages==0)
|
|
||||||
{
|
|
||||||
QMessageBox::critical(NULL,tr("No images found"),tr("There are not images on the selected folder"));
|
|
||||||
emit errorOpening();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
emit pageChanged(0); // this indicates new comic, index=0
|
|
||||||
emit numPages(_pages.size());
|
|
||||||
_loaded = true;
|
|
||||||
|
|
||||||
for(int i=0;i<nPages;i++)
|
|
||||||
{
|
|
||||||
QFile f(list.at(i).absoluteFilePath());
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
_pages[i]=f.readAll();
|
|
||||||
emit imageLoaded(i);
|
|
||||||
emit imageLoaded(i,_pages[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit imagesLoaded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::loadSizes()
|
|
||||||
{
|
|
||||||
QRegExp rx("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]+[0-9]{2}:[0-9]{2}:[0-9]{2}[ ]+.{5}[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)");
|
|
||||||
|
|
||||||
QByteArray ba = _7z->readAllStandardOutput();
|
|
||||||
QList<QByteArray> lines = ba.split('\n');
|
|
||||||
QByteArray line;
|
|
||||||
QString name;
|
|
||||||
foreach(line,lines)
|
|
||||||
{
|
|
||||||
if(rx.indexIn(QString(line))!=-1)
|
|
||||||
{
|
|
||||||
_sizes.push_back(rx.cap(1).toInt());
|
|
||||||
name = rx.cap(3).trimmed();
|
|
||||||
_order.push_back(name);
|
|
||||||
_fileNames.push_back(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(_sizes.size()==0)
|
|
||||||
{
|
|
||||||
QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
|
|
||||||
emit errorOpening();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_pages.resize(_sizes.size());
|
|
||||||
_loadedPages = QVector<bool>(_sizes.size(),false);
|
|
||||||
|
|
||||||
emit pageChanged(0); // this indicates new comic, index=0
|
|
||||||
emit numPages(_pages.size());
|
|
||||||
_loaded = true;
|
|
||||||
|
|
||||||
_cfi=0;
|
|
||||||
qSort(_fileNames.begin(),_fileNames.end(), naturalSortLessThanCI);
|
|
||||||
int i=0;
|
|
||||||
foreach(name,_fileNames)
|
|
||||||
{
|
|
||||||
_newOrder.insert(name,i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
_7ze = new QProcess();
|
|
||||||
QStringList attributes;
|
|
||||||
attributes << "e" << "-ssc-" << "-so" << "-r" << _path EXTENSIONS;
|
|
||||||
connect(_7ze,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
|
|
||||||
connect(_7ze,SIGNAL(readyReadStandardOutput()),this,SLOT(loadImages(void)));
|
|
||||||
connect(_7ze,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadFinished(void)));
|
|
||||||
_7ze->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::loadImages()
|
|
||||||
{
|
|
||||||
|
|
||||||
QByteArray ba = _7ze->readAllStandardOutput();
|
|
||||||
int s;
|
|
||||||
int rigthIndex;
|
|
||||||
while(ba.size()>0)
|
|
||||||
{
|
|
||||||
rigthIndex = _newOrder.value(_order[_cfi]);
|
|
||||||
s = _pages[rigthIndex].size();
|
|
||||||
_pages[rigthIndex].append(ba.left(_sizes[_cfi]-s));
|
|
||||||
ba.remove(0,_sizes[_cfi]-s);
|
|
||||||
if(_pages[rigthIndex].size()==static_cast<int>(_sizes[_cfi]))
|
|
||||||
{
|
|
||||||
emit imageLoaded(rigthIndex);
|
|
||||||
emit imageLoaded(rigthIndex,_pages[rigthIndex]);
|
|
||||||
_cfi++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic::openingError(QProcess::ProcessError error)
|
|
||||||
{
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case QProcess::FailedToStart:
|
|
||||||
QMessageBox::critical(NULL,tr("7z not found"),tr("7z wasn't found in your PATH."));
|
|
||||||
break;
|
|
||||||
case QProcess::Crashed:
|
|
||||||
QMessageBox::critical(NULL,tr("7z crashed"),tr("7z crashed."));
|
|
||||||
break;
|
|
||||||
case QProcess::ReadError:
|
|
||||||
QMessageBox::critical(NULL,tr("7z reading"),tr("problem reading from 7z"));
|
|
||||||
break;
|
|
||||||
case QProcess::UnknownError:
|
|
||||||
QMessageBox::critical(NULL,tr("7z problem"),tr("Unknown error 7z"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//TODO
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_loaded = false;
|
|
||||||
emit errorOpening();
|
|
||||||
}
|
|
||||||
int Comic::nextPage()
|
int Comic::nextPage()
|
||||||
{
|
{
|
||||||
if(_index<_pages.size()-1)
|
if(_index<_pages.size()-1)
|
||||||
@ -286,7 +45,7 @@ int Comic::nextPage()
|
|||||||
|
|
||||||
return _index;
|
return _index;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int Comic::previousPage()
|
int Comic::previousPage()
|
||||||
{
|
{
|
||||||
if(_index>0)
|
if(_index>0)
|
||||||
@ -388,86 +147,57 @@ bool Comic::pageIsLoaded(int page)
|
|||||||
return _loadedPages[page];
|
return _loadedPages[page];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
FileComic::FileComic()
|
||||||
|
:Comic()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FileComic::FileComic(const QString & path)
|
||||||
|
:Comic(path)
|
||||||
|
{
|
||||||
|
load(path);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
FileComic::~FileComic()
|
||||||
Comic2::Comic2()
|
|
||||||
:_pages(),_index(0),_path(),_loaded(false),_loadedPages()
|
|
||||||
{
|
{
|
||||||
setup();
|
//Comic::~Comic();
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
Comic2::Comic2(const QString pathFile)
|
bool FileComic::load(const QString & path)
|
||||||
:_pages(),_index(0),_path(pathFile),_loaded(false),_loadedPages()
|
|
||||||
{
|
|
||||||
setup();
|
|
||||||
loadFromFile(pathFile);
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
Comic2::~Comic2()
|
|
||||||
{
|
|
||||||
/*delete _7z;
|
|
||||||
delete _7ze;
|
|
||||||
delete bm;*/ //TODO safe delete
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::setup()
|
|
||||||
{
|
|
||||||
connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int)));
|
|
||||||
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int)));
|
|
||||||
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int)));
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool Comic2::load(const QString & path)
|
|
||||||
{
|
{
|
||||||
QFileInfo fi(path);
|
QFileInfo fi(path);
|
||||||
|
|
||||||
if(fi.exists())
|
if(fi.exists())
|
||||||
{
|
{
|
||||||
if(fi.isFile())
|
bm->newComic(path);
|
||||||
{
|
emit bookmarksLoaded(*bm);
|
||||||
loadFromFile(path);
|
|
||||||
}
|
_path = QDir::cleanPath(path);
|
||||||
else
|
//load files size
|
||||||
{
|
_7z = new QProcess();
|
||||||
}
|
QStringList attributes;
|
||||||
|
attributes << "l" << "-ssc-" << "-r" << _path EXTENSIONS;
|
||||||
|
connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadSizes(void)));
|
||||||
|
connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
|
||||||
|
_7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found"));
|
||||||
emit errorOpening();
|
emit errorOpening();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Comic2::loadFromFile(const QString & pathFile)
|
void FileComic::loadSizes()
|
||||||
{
|
|
||||||
_path = QDir::cleanPath(pathFile);
|
|
||||||
//load files size
|
|
||||||
_7z = new QProcess();
|
|
||||||
QStringList attributes;
|
|
||||||
attributes << "l" << "-ssc-" << "-r" << _path EXTENSIONS;
|
|
||||||
connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadSizes(void)));
|
|
||||||
connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError)));
|
|
||||||
_7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::loadSizes()
|
|
||||||
{
|
{
|
||||||
QRegExp rx("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]+[0-9]{2}:[0-9]{2}:[0-9]{2}[ ]+.{5}[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)");
|
QRegExp rx("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]+[0-9]{2}:[0-9]{2}:[0-9]{2}[ ]+.{5}[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)");
|
||||||
|
|
||||||
@ -487,7 +217,7 @@ void Comic2::loadSizes()
|
|||||||
}
|
}
|
||||||
if(_sizes.size()==0)
|
if(_sizes.size()==0)
|
||||||
{
|
{
|
||||||
//QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
|
QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
|
||||||
emit errorOpening();
|
emit errorOpening();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -515,7 +245,7 @@ void Comic2::loadSizes()
|
|||||||
_7ze->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
|
_7ze->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Comic2::loadImages()
|
void FileComic::loadImages()
|
||||||
{
|
{
|
||||||
|
|
||||||
QByteArray ba = _7ze->readAllStandardOutput();
|
QByteArray ba = _7ze->readAllStandardOutput();
|
||||||
@ -536,7 +266,7 @@ void Comic2::loadImages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Comic2::openingError(QProcess::ProcessError error)
|
void FileComic::openingError(QProcess::ProcessError error)
|
||||||
{
|
{
|
||||||
switch(error)
|
switch(error)
|
||||||
{
|
{
|
||||||
@ -559,98 +289,166 @@ void Comic2::openingError(QProcess::ProcessError error)
|
|||||||
_loaded = false;
|
_loaded = false;
|
||||||
emit errorOpening();
|
emit errorOpening();
|
||||||
}
|
}
|
||||||
int Comic2::nextPage()
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FolderComic::FolderComic()
|
||||||
|
:Comic()
|
||||||
{
|
{
|
||||||
if(_index<_pages.size()-1)
|
|
||||||
_index++;
|
|
||||||
|
|
||||||
emit pageChanged(_index);
|
|
||||||
|
|
||||||
return _index;
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int Comic2::previousPage()
|
FolderComic::FolderComic(const QString & path)
|
||||||
|
:Comic(path)
|
||||||
{
|
{
|
||||||
if(_index>0)
|
load(path);
|
||||||
_index--;
|
|
||||||
|
|
||||||
emit pageChanged(_index);
|
|
||||||
|
|
||||||
return _index;
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::setIndex(unsigned int index)
|
FolderComic::~FolderComic()
|
||||||
{
|
{
|
||||||
if(static_cast<int>(index)<_pages.size()-1)
|
|
||||||
_index = index;
|
}
|
||||||
|
|
||||||
|
bool FolderComic::load(const QString & path)
|
||||||
|
{
|
||||||
|
_path = path;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FolderComic::process()
|
||||||
|
{
|
||||||
|
QDir d(_path);
|
||||||
|
QStringList l;
|
||||||
|
l EXTENSIONS;
|
||||||
|
d.setNameFilters(l);
|
||||||
|
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
||||||
|
//d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||||
|
QFileInfoList list = d.entryInfoList();
|
||||||
|
|
||||||
|
qSort(list.begin(),list.end(),naturalSortLessThanCIFileInfo);
|
||||||
|
|
||||||
|
int nPages = list.size();
|
||||||
|
_pages.clear();
|
||||||
|
_pages.resize(nPages);
|
||||||
|
_loadedPages = QVector<bool>(nPages,false);
|
||||||
|
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"));
|
||||||
|
emit errorOpening();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_index = _pages.size()-1;
|
{
|
||||||
|
emit pageChanged(0); // this indicates new comic, index=0
|
||||||
|
emit numPages(_pages.size());
|
||||||
|
_loaded = true;
|
||||||
|
|
||||||
emit pageChanged(_index);
|
for(int i=0;i<nPages;i++)
|
||||||
}
|
{
|
||||||
//-----------------------------------------------------------------------------
|
QFile f(list.at(i).absoluteFilePath());
|
||||||
QPixmap * Comic2::currentPage()
|
f.open(QIODevice::ReadOnly);
|
||||||
{
|
_pages[i]=f.readAll();
|
||||||
QPixmap * p = new QPixmap();
|
emit imageLoaded(i);
|
||||||
p->loadFromData(_pages[_index]);
|
emit imageLoaded(i,_pages[i]);
|
||||||
return p;
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
QPixmap * Comic2::operator[](unsigned int index)
|
|
||||||
{
|
|
||||||
QPixmap * p = new QPixmap();
|
|
||||||
p->loadFromData(_pages[index]);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool Comic2::loaded()
|
|
||||||
{
|
|
||||||
return _loaded;
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::loadFinished()
|
|
||||||
{
|
|
||||||
emit imagesLoaded();
|
emit imagesLoaded();
|
||||||
|
|
||||||
|
moveToThread(QApplication::instance()->thread());
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::setBookmark()
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
PDFComic::PDFComic()
|
||||||
|
:Comic()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::removeBookmark()
|
PDFComic::PDFComic(const QString & path)
|
||||||
|
:Comic(path)
|
||||||
{
|
{
|
||||||
|
load(path);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::saveBookmarks()
|
PDFComic::~PDFComic()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::checkIsBookmark(int index)
|
bool PDFComic::load(const QString & path)
|
||||||
{
|
{
|
||||||
|
_path = path;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void Comic2::updateBookmarkImage(int index)
|
void PDFComic::process()
|
||||||
|
{
|
||||||
|
pdfComic = Poppler::Document::load(_path);
|
||||||
|
if (!pdfComic)
|
||||||
|
{
|
||||||
|
delete pdfComic;
|
||||||
|
pdfComic = 0;
|
||||||
|
//TODO emitir este mensaje en otro sitio
|
||||||
|
//QMessageBox::critical(NULL,QObject::tr("Bad PDF File"),QObject::tr("Invalid PDF file"));
|
||||||
|
emit errorOpening();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//pdfComic->setRenderHint(Poppler::Document::Antialiasing, true);
|
||||||
|
pdfComic->setRenderHint(Poppler::Document::TextAntialiasing, true);
|
||||||
|
int nPages = pdfComic->numPages();
|
||||||
|
emit pageChanged(0); // this indicates new comic, index=0
|
||||||
|
emit numPages(nPages);
|
||||||
|
_loaded = true;
|
||||||
|
//QMessageBox::critical(NULL,QString("%1").arg(nPages),tr("Invalid PDF file"));
|
||||||
|
|
||||||
|
_pages.clear();
|
||||||
|
_pages.resize(nPages);
|
||||||
|
_loadedPages = QVector<bool>(nPages,false);
|
||||||
|
for(int i=0;i<nPages;i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
Poppler::Page* pdfpage = pdfComic->page(i);
|
||||||
|
if (pdfpage)
|
||||||
|
{
|
||||||
|
QImage img = pdfpage->renderToImage(150,150); //TODO use defaults if not using X11 (e.g. MS Win)
|
||||||
|
delete pdfpage;
|
||||||
|
QByteArray ba;
|
||||||
|
QBuffer buf(&ba);
|
||||||
|
img.save(&buf, "jpg");
|
||||||
|
_pages[i] = ba;
|
||||||
|
emit imageLoaded(i);
|
||||||
|
emit imageLoaded(i,_pages[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
delete pdfComic;
|
||||||
|
emit imagesLoaded();
|
||||||
|
|
||||||
|
moveToThread(QApplication::instance()->thread());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Comic * FactoryComic::newComic(const QString & path)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
QFileInfo fi(path);
|
||||||
//-----------------------------------------------------------------------------
|
if(fi.exists())
|
||||||
void Comic2::setPageLoaded(int page)
|
if(fi.isFile())
|
||||||
{
|
if(fi.suffix().compare("pdf",Qt::CaseInsensitive) == 0)
|
||||||
_loadedPages[page] = true;
|
return new PDFComic();
|
||||||
}
|
else
|
||||||
//-----------------------------------------------------------------------------
|
return new FileComic();
|
||||||
QByteArray Comic2::getRawPage(int page)
|
else
|
||||||
{
|
if(fi.isDir())
|
||||||
if(page < 0 || page >= _pages.size())
|
return new FolderComic();
|
||||||
return QByteArray();
|
else
|
||||||
return _pages[page];
|
return NULL;
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
bool Comic2::pageIsLoaded(int page)
|
|
||||||
{
|
|
||||||
if(page < 0 || page >= _pages.size())
|
|
||||||
return false;
|
|
||||||
return _loadedPages[page];
|
|
||||||
}
|
}
|
@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
#include "poppler-qt4.h"
|
#include "poppler-qt4.h"
|
||||||
|
|
||||||
class Comic : public QThread
|
class Comic : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
protected:
|
||||||
//Comic pages, one QPixmap for each file.
|
//Comic pages, one QPixmap for each file.
|
||||||
QVector<QByteArray> _pages;
|
QVector<QByteArray> _pages;
|
||||||
QVector<bool> _loadedPages;
|
QVector<bool> _loadedPages;
|
||||||
@ -24,26 +24,25 @@
|
|||||||
int _index;
|
int _index;
|
||||||
QString _path;
|
QString _path;
|
||||||
bool _loaded;
|
bool _loaded;
|
||||||
QProcess * _7z;
|
|
||||||
QProcess * _7ze;
|
|
||||||
int _cfi;
|
int _cfi;
|
||||||
QString _pathDir;
|
|
||||||
Bookmarks * bm;
|
Bookmarks * bm;
|
||||||
void run();
|
|
||||||
//pdf
|
|
||||||
Poppler::Document * pdfComic;
|
|
||||||
bool _isPDF;
|
bool _isPDF;
|
||||||
public:
|
public:
|
||||||
//Constructors
|
//Constructors
|
||||||
Comic();
|
Comic();
|
||||||
Comic(const QString pathFile);
|
Comic(const QString & pathFile);
|
||||||
~Comic();
|
~Comic();
|
||||||
void setup();
|
void setup();
|
||||||
//Load pages from file
|
//Load pages from file
|
||||||
bool load(const QString & path);
|
virtual bool load(const QString & path) = 0;
|
||||||
void loadFromFile(const QString & pathFile);
|
|
||||||
|
/*void loadFromFile(const QString & pathFile);
|
||||||
void loadFromDir(const QString & pathDir);
|
void loadFromDir(const QString & pathDir);
|
||||||
void loadFromPDF(const QString & pathPDF);
|
void loadFromPDF(const QString & pathPDF);*/
|
||||||
int nextPage();
|
int nextPage();
|
||||||
int previousPage();
|
int previousPage();
|
||||||
void setIndex(unsigned int index);
|
void setIndex(unsigned int index);
|
||||||
@ -57,9 +56,6 @@
|
|||||||
bool pageIsLoaded(int page);
|
bool pageIsLoaded(int page);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadImages();
|
|
||||||
void loadSizes();
|
|
||||||
void openingError(QProcess::ProcessError error);
|
|
||||||
void loadFinished();
|
void loadFinished();
|
||||||
void setBookmark();
|
void setBookmark();
|
||||||
void removeBookmark();
|
void removeBookmark();
|
||||||
@ -79,69 +75,64 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FileComic : public Comic
|
||||||
|
|
||||||
class Comic2 : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
//Comic pages, one QPixmap for each file.
|
|
||||||
QVector<QByteArray> _pages;
|
|
||||||
QVector<bool> _loadedPages;
|
|
||||||
QVector<uint> _sizes;
|
|
||||||
QStringList _fileNames;
|
|
||||||
QMap<QString,int> _newOrder;
|
|
||||||
QVector<QString> _order;
|
|
||||||
int _index;
|
|
||||||
QString _path;
|
|
||||||
bool _loaded;
|
|
||||||
QProcess * _7z;
|
QProcess * _7z;
|
||||||
QProcess * _7ze;
|
QProcess * _7ze;
|
||||||
int _cfi;
|
|
||||||
QString _pathDir;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Constructors
|
FileComic();
|
||||||
Comic2();
|
FileComic(const QString & path);
|
||||||
Comic2(const QString pathFile);
|
~FileComic();
|
||||||
~Comic2();
|
|
||||||
void setup();
|
|
||||||
//Load pages from file
|
|
||||||
bool load(const QString & path);
|
|
||||||
void loadFromFile(const QString & pathFile);
|
|
||||||
int nextPage();
|
|
||||||
int previousPage();
|
|
||||||
void setIndex(unsigned int index);
|
|
||||||
unsigned int getIndex(){return _index;};
|
|
||||||
unsigned int numPages(){return _pages.size();}
|
|
||||||
QPixmap * currentPage();
|
|
||||||
bool loaded();
|
|
||||||
QPixmap * operator[](unsigned int index);
|
|
||||||
QVector<QByteArray> * getRawData(){return &_pages;};
|
|
||||||
QByteArray getRawPage(int page);
|
|
||||||
bool pageIsLoaded(int page);
|
|
||||||
|
|
||||||
public slots:
|
virtual bool load(const QString & path);
|
||||||
void loadImages();
|
|
||||||
void loadSizes();
|
public slots:
|
||||||
void openingError(QProcess::ProcessError error);
|
void loadImages();
|
||||||
void loadFinished();
|
void loadSizes();
|
||||||
void setBookmark();
|
void openingError(QProcess::ProcessError error);
|
||||||
void removeBookmark();
|
};
|
||||||
void saveBookmarks();
|
|
||||||
void checkIsBookmark(int index);
|
class FolderComic : public Comic
|
||||||
void updateBookmarkImage(int);
|
{
|
||||||
void setPageLoaded(int page);
|
Q_OBJECT
|
||||||
signals:
|
private:
|
||||||
void imagesLoaded();
|
//void run();
|
||||||
void imageLoaded(int index);
|
public:
|
||||||
void imageLoaded(int index,const QByteArray & image);
|
FolderComic();
|
||||||
void pageChanged(int index);
|
FolderComic(const QString & path);
|
||||||
void numPages(unsigned int numPages);
|
~FolderComic();
|
||||||
void errorOpening();
|
|
||||||
void isBookmark(bool);
|
virtual bool load(const QString & path);
|
||||||
void bookmarksLoaded(const Bookmarks &);
|
public slots:
|
||||||
|
void process();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PDFComic : public Comic
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
//pdf
|
||||||
|
Poppler::Document * pdfComic;
|
||||||
|
|
||||||
|
//void run();
|
||||||
|
public:
|
||||||
|
PDFComic();
|
||||||
|
PDFComic(const QString & path);
|
||||||
|
~PDFComic();
|
||||||
|
|
||||||
|
virtual bool load(const QString & path);
|
||||||
|
public slots:
|
||||||
|
void process();
|
||||||
|
};
|
||||||
|
|
||||||
|
class FactoryComic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Comic * newComic(const QString & path);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,8 +13,21 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WIN32) && defined(_DEBUG)
|
||||||
|
#define _CRTDBG_MAP_ALLOC
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <crtdbg.h>
|
||||||
|
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
|
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||||
|
#endif
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
@ -29,6 +42,8 @@ int main(int argc, char * argv[])
|
|||||||
int ret = app.exec();
|
int ret = app.exec();
|
||||||
|
|
||||||
Configuration::getConfiguration().save();
|
Configuration::getConfiguration().save();
|
||||||
|
|
||||||
|
_CrtDumpMemoryLeaks();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
|
|||||||
{
|
{
|
||||||
QDir d(path);
|
QDir d(path);
|
||||||
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
|
||||||
d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar");
|
d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf");
|
||||||
d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||||
QStringList list = d.entryList();
|
QStringList list = d.entryList();
|
||||||
int index = list.indexOf(currentComic);
|
int index = list.indexOf(currentComic);
|
||||||
|
@ -378,7 +378,11 @@ void Render::setRotation(int degrees)
|
|||||||
void Render::setComic(Comic * c)
|
void Render::setComic(Comic * c)
|
||||||
{
|
{
|
||||||
if(comic !=0)
|
if(comic !=0)
|
||||||
delete comic;
|
{
|
||||||
|
comic->moveToThread(QApplication::instance()->thread());
|
||||||
|
comic->disconnect();
|
||||||
|
comic->deleteLater();
|
||||||
|
}
|
||||||
comic = c;
|
comic = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,9 +402,29 @@ void Render::update()
|
|||||||
void Render::load(const QString & path)
|
void Render::load(const QString & path)
|
||||||
{
|
{
|
||||||
if(comic!=0)
|
if(comic!=0)
|
||||||
delete comic;
|
{
|
||||||
comic = new Comic();
|
comic->moveToThread(QApplication::instance()->thread());
|
||||||
|
comic->disconnect();
|
||||||
|
comic->deleteLater();
|
||||||
|
}
|
||||||
|
//comic->moveToThread(QApplication::instance()->thread());
|
||||||
|
comic = FactoryComic::newComic(path);
|
||||||
|
|
||||||
|
if(comic == NULL) //archivo no encontrado o no válido
|
||||||
|
return;
|
||||||
|
|
||||||
previousIndex = currentIndex = 0;
|
previousIndex = currentIndex = 0;
|
||||||
|
QThread * thread = NULL;
|
||||||
|
if (typeid(*comic) != typeid(FileComic))
|
||||||
|
{
|
||||||
|
thread = new QThread();
|
||||||
|
|
||||||
|
comic->moveToThread(thread);
|
||||||
|
|
||||||
|
connect(thread, SIGNAL(started()), comic, SLOT(process()));
|
||||||
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()));
|
connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()));
|
||||||
connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()));
|
connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()));
|
||||||
@ -413,12 +437,18 @@ void Render::load(const QString & path)
|
|||||||
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)));
|
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)));
|
||||||
connect(comic,SIGNAL(bookmarksLoaded(const Bookmarks &)),this,SIGNAL(bookmarksLoaded(const Bookmarks &)));
|
connect(comic,SIGNAL(bookmarksLoaded(const Bookmarks &)),this,SIGNAL(bookmarksLoaded(const Bookmarks &)));
|
||||||
pagesReady.clear();
|
pagesReady.clear();
|
||||||
if(comic->load(path)) //garantiza que se va a intentar abrir el cómic
|
|
||||||
{
|
|
||||||
invalidate();
|
|
||||||
loadedComic = true;
|
comic->load(path); //garantiza que se va a intentar abrir el cómic
|
||||||
update();
|
|
||||||
}
|
if(thread != NULL)
|
||||||
|
thread->start();
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
loadedComic = true;
|
||||||
|
update();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
LibraryWindow * mw;
|
LibraryWindow * mw;
|
||||||
Startup * s;
|
Startup * s;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char ** argv )
|
int main( int argc, char ** argv )
|
||||||
{
|
{
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
@ -10,31 +10,6 @@ extern LibraryWindow * mw;
|
|||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
#include "comic.h"
|
#include "comic.h"
|
||||||
|
|
||||||
Synchronizer::Synchronizer(Comic2 * c,QString p,QThread * f)
|
|
||||||
:QThread(),comic(c),path(p),from(f)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Synchronizer::run()
|
|
||||||
{
|
|
||||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(waitedSignal()));
|
|
||||||
loaded = comic->load(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Synchronizer::waitedSignal()
|
|
||||||
{
|
|
||||||
if(loaded)
|
|
||||||
{
|
|
||||||
comic->moveToThread(from);
|
|
||||||
quit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ComicController::ComicController() {}
|
ComicController::ComicController() {}
|
||||||
|
|
||||||
@ -64,21 +39,31 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
|
|
||||||
ComicDB comic = mw->getComicInfo(libraryName, comicId);
|
ComicDB comic = mw->getComicInfo(libraryName, comicId);
|
||||||
|
|
||||||
Comic2 * comicFile = new Comic2;
|
Comic * comicFile = FactoryComic::newComic(libraries.value(libraryName)+comic.path);
|
||||||
//Synchronizer * synchronizer = new Synchronizer(comicFile,libraries.value(libraryName)+comic.path, this->thread());
|
|
||||||
//comicFile->moveToThread(synchronizer);
|
|
||||||
|
|
||||||
|
|
||||||
//synchronizer->start();
|
if(comicFile != NULL)
|
||||||
//QApplication::instance()->exec();
|
|
||||||
//synchronizer->wait(20000);
|
|
||||||
|
|
||||||
if(comicFile->load(libraries.value(libraryName)+comic.path))
|
|
||||||
{
|
{
|
||||||
|
QThread * thread = NULL;
|
||||||
|
if (typeid(*comicFile) != typeid(FileComic))
|
||||||
|
{
|
||||||
|
thread = new QThread();
|
||||||
|
|
||||||
|
comicFile->moveToThread(thread);
|
||||||
|
|
||||||
|
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||||
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
comicFile->load(libraries.value(libraryName)+comic.path);
|
||||||
|
|
||||||
|
if(thread != NULL)
|
||||||
|
thread->start();
|
||||||
|
|
||||||
session.setCurrentComic(comic.id, comicFile);
|
session.setCurrentComic(comic.id, comicFile);
|
||||||
|
|
||||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||||
|
|
||||||
response.writeText(QString("library:%1\r\n").arg(libraryName));
|
response.writeText(QString("library:%1\r\n").arg(libraryName));
|
||||||
response.writeText(comic.toTXT(),true);
|
response.writeText(comic.toTXT(),true);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "httprequesthandler.h"
|
#include "httprequesthandler.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
class Comic2;
|
class Comic;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class ComicController : public HttpRequestHandler {
|
class ComicController : public HttpRequestHandler {
|
||||||
@ -20,21 +20,4 @@ public:
|
|||||||
void service(HttpRequest& request, HttpResponse& response);
|
void service(HttpRequest& request, HttpResponse& response);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Synchronizer : public QThread
|
|
||||||
{
|
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Synchronizer(Comic2 * c, QString p, QThread * f);
|
|
||||||
bool loaded;
|
|
||||||
private:
|
|
||||||
Comic2 * comic;
|
|
||||||
QString path;
|
|
||||||
QThread * from;
|
|
||||||
|
|
||||||
void run();
|
|
||||||
public slots:
|
|
||||||
void waitedSignal();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // COMICCONTROLLER_H
|
#endif // COMICCONTROLLER_H
|
||||||
|
@ -19,8 +19,8 @@ void PageController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||||
unsigned int page = pathElements.at(6).toUInt();
|
unsigned int page = pathElements.at(6).toUInt();
|
||||||
|
|
||||||
Comic2 * comicFile = session.getCurrentComic();
|
Comic * comicFile = session.getCurrentComic();
|
||||||
if(session.getCurrentComicId() != 0 && !QPointer<Comic2>(comicFile).isNull())
|
if(session.getCurrentComicId() != 0 && !QPointer<Comic>(comicFile).isNull())
|
||||||
{
|
{
|
||||||
if(comicId == session.getCurrentComicId() && page < comicFile->numPages())
|
if(comicId == session.getCurrentComicId() && page < comicFile->numPages())
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ qulonglong HttpSession::getCurrentComicId()
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Comic2* HttpSession::getCurrentComic()
|
Comic* HttpSession::getCurrentComic()
|
||||||
{
|
{
|
||||||
if(dataPtr)
|
if(dataPtr)
|
||||||
{
|
{
|
||||||
@ -233,13 +233,13 @@ void HttpSession::dismissCurrentComic()
|
|||||||
{
|
{
|
||||||
if(dataPtr->yacreaderSessionData.comic != 0)
|
if(dataPtr->yacreaderSessionData.comic != 0)
|
||||||
{
|
{
|
||||||
delete dataPtr->yacreaderSessionData.comic;
|
dataPtr->yacreaderSessionData.comic->deleteLater();
|
||||||
dataPtr->yacreaderSessionData.comic = 0;
|
dataPtr->yacreaderSessionData.comic = 0;
|
||||||
}
|
}
|
||||||
dataPtr->yacreaderSessionData.comicId = 0;
|
dataPtr->yacreaderSessionData.comicId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void HttpSession::setCurrentComic(qulonglong id, Comic2 * comic)
|
void HttpSession::setCurrentComic(qulonglong id, Comic * comic)
|
||||||
{
|
{
|
||||||
if(dataPtr)
|
if(dataPtr)
|
||||||
{
|
{
|
||||||
|
@ -104,9 +104,9 @@ public:
|
|||||||
|
|
||||||
//current comic
|
//current comic
|
||||||
qulonglong getCurrentComicId();
|
qulonglong getCurrentComicId();
|
||||||
Comic2 * getCurrentComic();
|
Comic * getCurrentComic();
|
||||||
void dismissCurrentComic();
|
void dismissCurrentComic();
|
||||||
void setCurrentComic(qulonglong id, Comic2 * comic);
|
void setCurrentComic(qulonglong id, Comic * comic);
|
||||||
|
|
||||||
//device identification
|
//device identification
|
||||||
QString getDeviceType();
|
QString getDeviceType();
|
||||||
@ -125,7 +125,7 @@ private:
|
|||||||
QString device;
|
QString device;
|
||||||
QString display;
|
QString display;
|
||||||
qulonglong comicId;
|
qulonglong comicId;
|
||||||
Comic2 * comic;
|
Comic * comic;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HttpSessionData {
|
struct HttpSessionData {
|
||||||
|
@ -198,7 +198,7 @@ struct Preset pressetYACReaderFlowDownConfig = {
|
|||||||
};
|
};
|
||||||
/*Constructor*/
|
/*Constructor*/
|
||||||
YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p)
|
YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p)
|
||||||
:QGLWidget(QGLFormat(QGL::SampleBuffers), parent),numObjects(0),lazyPopulateObjects(-1),bUseVSync(false)
|
:QGLWidget(QGLFormat(QGL::SampleBuffers), parent),numObjects(0),lazyPopulateObjects(-1),bUseVSync(false),hasBeenInitialized(false)
|
||||||
{
|
{
|
||||||
updateCount = 0;
|
updateCount = 0;
|
||||||
config = p;
|
config = p;
|
||||||
@ -278,6 +278,8 @@ void YACReaderFlowGL::initializeGL()
|
|||||||
|
|
||||||
if(lazyPopulateObjects!=-1)
|
if(lazyPopulateObjects!=-1)
|
||||||
populate(lazyPopulateObjects);
|
populate(lazyPopulateObjects);
|
||||||
|
|
||||||
|
hasBeenInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderFlowGL::paintGL()
|
void YACReaderFlowGL::paintGL()
|
||||||
@ -690,7 +692,7 @@ void YACReaderFlowGL::populate(int n)
|
|||||||
float x = 1;
|
float x = 1;
|
||||||
float y = 1 * (700.f/480.0f);
|
float y = 1 * (700.f/480.0f);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0;i<n;i++){
|
for(i = 0;i<n;i++){
|
||||||
insert("cover", defaultTexture, x, y);
|
insert("cover", defaultTexture, x, y);
|
||||||
}
|
}
|
||||||
@ -715,6 +717,7 @@ void YACReaderFlowGL::reset()
|
|||||||
{
|
{
|
||||||
currentSelected = 0;
|
currentSelected = 0;
|
||||||
loaded.clear();
|
loaded.clear();
|
||||||
|
|
||||||
for(int i = 0;i<numObjects;i++){
|
for(int i = 0;i<numObjects;i++){
|
||||||
if(cfImages[i].img != defaultTexture)
|
if(cfImages[i].img != defaultTexture)
|
||||||
deleteTexture(cfImages[i].img);
|
deleteTexture(cfImages[i].img);
|
||||||
@ -723,6 +726,8 @@ void YACReaderFlowGL::reset()
|
|||||||
delete[] cfImages;
|
delete[] cfImages;
|
||||||
numObjects = 0;
|
numObjects = 0;
|
||||||
|
|
||||||
|
if(!hasBeenInitialized)
|
||||||
|
lazyPopulateObjects = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderFlowGL::reload()
|
void YACReaderFlowGL::reload()
|
||||||
|
@ -139,6 +139,7 @@ protected:
|
|||||||
QVector<bool> marks;
|
QVector<bool> marks;
|
||||||
QList<QString> paths;
|
QList<QString> paths;
|
||||||
CFImage * cfImages;
|
CFImage * cfImages;
|
||||||
|
bool hasBeenInitialized;
|
||||||
|
|
||||||
Performance performance;
|
Performance performance;
|
||||||
bool bUseVSync;
|
bool bUseVSync;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user