From b10b27864a2ea4f4a0f261b311d024b7d38ea793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 15 Jul 2013 10:20:48 +0200 Subject: [PATCH] a?adido c?lculo de secciones para optimizar la extracci?n de c?mics --- YACReader/comic.cpp | 118 +++++++++++++++++++++- YACReader/comic.h | 5 +- compressed_archive/compressed_archive.cpp | 8 +- compressed_archive/compressed_archive.h | 2 +- 4 files changed, 125 insertions(+), 8 deletions(-) diff --git a/YACReader/comic.cpp b/YACReader/comic.cpp index 7a3d21de..1a61282d 100644 --- a/YACReader/comic.cpp +++ b/YACReader/comic.cpp @@ -240,7 +240,12 @@ QList FileComic::filter(const QList & src) } void FileComic::fileExtracted(int index, const QByteArray & rawData) { + QFile f("c:/temp/out2.txt"); + f.open(QIODevice::Append); + QTextStream out(&f); int sortedIndex = _fileNames.indexOf(_order.at(index)); + out << sortedIndex << " , "; + f.close(); if(sortedIndex == -1) return; _pages[sortedIndex] = rawData; @@ -248,6 +253,104 @@ void FileComic::fileExtracted(int index, const QByteArray & rawData) emit imageLoaded(sortedIndex,_pages[sortedIndex]); } +QList > FileComic::getSections(int & sectionIndex) +{ + QVector sortedIndexes; + foreach(QString name, _fileNames) + { + sortedIndexes.append(_order.indexOf(name)); + } + QList > sections; + quint32 previous = 0; + sectionIndex = -1; + int sectionCount = 0; + QVector section; + int idx = 0; + int realIdx; + foreach(quint32 i, sortedIndexes) + { + + if(_firstPage == idx) + { + sectionIndex = sectionCount; + realIdx = i; + } + if(previous <= i) + { + //out << "idx : " << i << endl; + section.append(i); + previous = i; + } + else + { + if(sectionIndex == sectionCount) //found + { + if(section.indexOf(realIdx)!=0) + { + QVector section1; + QVector section2; + foreach(quint32 si,section) + { + if(si (); + //out << "---------------" << endl; + section.append(i); + //out << "idx : " << i << endl; + previous = i; + sectionCount++; + } + + idx++; + } + if(sectionIndex == sectionCount) //found + { + if(section.indexOf(realIdx)!=0) + { + QVector section1; + QVector section2; + foreach(quint32 si,section) + { + if(si allData = archive.getAllData(this); - + _firstPage = 0; + _index = 0; + + int sectionIndex; + QList > sections = getSections(sectionIndex); + + for(int i = sectionIndex; i(),this); out << "tiempo en obtener datos : " << myTimer.elapsed() << endl; /* foreach(QString name,_fileNames) @@ -303,7 +415,7 @@ void FileComic::process() emit imageLoaded(sortedIndex,_pages[sortedIndex]); }*/ - out << "tiempo en copiar datos : " << myTimer.elapsed() << endl; + out << "--tiempo en copiar datos : " << myTimer.elapsed() << endl; f.close(); emit imagesLoaded(); } diff --git a/YACReader/comic.h b/YACReader/comic.h index 2ee53392..e2811efd 100644 --- a/YACReader/comic.h +++ b/YACReader/comic.h @@ -29,8 +29,8 @@ int _cfi; - - + //open the comic at this point + int _firstPage; bool _isPDF; public: @@ -86,6 +86,7 @@ Q_OBJECT private: QList filter(const QList & src); + QList > getSections(int & sectionIndex); public: FileComic(); FileComic(const QString & path); diff --git a/compressed_archive/compressed_archive.cpp b/compressed_archive/compressed_archive.cpp index 623020fb..0c55c08d 100644 --- a/compressed_archive/compressed_archive.cpp +++ b/compressed_archive/compressed_archive.cpp @@ -166,14 +166,18 @@ int CompressedArchive::getNumFiles() szInterface->archive->GetNumberOfItems(&numItems); return numItems; } -QList CompressedArchive::getAllData(ExtractDelegate * delegate) +QList CompressedArchive::getAllData(const QVector & indexes, ExtractDelegate * delegate) { CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback(true,delegate); CMyComPtr extractCallback(extractCallbackSpec); extractCallbackSpec->Init(szInterface->archive, L""); // second parameter is output folder path extractCallbackSpec->PasswordIsDefined = false; - HRESULT result = szInterface->archive->Extract(NULL, -1, false, extractCallback); + HRESULT result; + if(indexes.isEmpty()) + result = szInterface->archive->Extract(NULL, -1, false, extractCallback); + else + result = szInterface->archive->Extract(indexes.data(), indexes.count(), false, extractCallback); if (result != S_OK) { qDebug() << "Extract Error" << endl; diff --git a/compressed_archive/compressed_archive.h b/compressed_archive/compressed_archive.h index 4d526029..23935753 100644 --- a/compressed_archive/compressed_archive.h +++ b/compressed_archive/compressed_archive.h @@ -36,7 +36,7 @@ signals: public slots: int getNumFiles(); - QList getAllData(ExtractDelegate * delegate = 0); + QList getAllData(const QVector & indexes, ExtractDelegate * delegate = 0); QByteArray getRawDataAtIndex(int index); QList getFileNames(); private: