added error managing methods to 7z extraction delegate

This commit is contained in:
Luis Ángel San Martín 2013-08-16 23:11:02 +02:00
parent 9d392416a5
commit 31d1ebb1a8
4 changed files with 28 additions and 37 deletions

View File

@ -242,6 +242,8 @@ QList<QString> FileComic::filter(const QList<QString> & src)
return filtered; return filtered;
} }
//DELEGATE methods
void FileComic::fileExtracted(int index, const QByteArray & rawData) void FileComic::fileExtracted(int index, const QByteArray & rawData)
{ {
/*QFile f("c:/temp/out2.txt"); /*QFile f("c:/temp/out2.txt");
@ -257,6 +259,18 @@ void FileComic::fileExtracted(int index, const QByteArray & rawData)
emit imageLoaded(sortedIndex,_pages[sortedIndex]); emit imageLoaded(sortedIndex,_pages[sortedIndex]);
} }
void FileComic::crcError(int index)
{
emit errorOpening(tr("CRC error"));
}
void FileComic::unknownError(int index)
{
emit errorOpening(tr("Unknown error opening the file"));
}
//--------------------------------------
QList<QVector<quint32> > FileComic::getSections(int & sectionIndex) QList<QVector<quint32> > FileComic::getSections(int & sectionIndex)
{ {
QVector<quint32> sortedIndexes; QVector<quint32> sortedIndexes;
@ -414,38 +428,7 @@ void FileComic::process()
emit imagesLoaded(); emit imagesLoaded();
moveToThread(QApplication::instance()->thread()); moveToThread(QApplication::instance()->thread());
} }
//-----------------------------------------------------------------------------
void FileComic::loadSizes()
{
}
//-----------------------------------------------------------------------------
void FileComic::loadImages()
{
}
//-----------------------------------------------------------------------------
void FileComic::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();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -75,6 +75,7 @@
void openAt(int index); void openAt(int index);
void numPages(unsigned int numPages); void numPages(unsigned int numPages);
void errorOpening(); void errorOpening();
void errorOpening(QString);
void isBookmark(bool); void isBookmark(bool);
void bookmarksUpdated(); void bookmarksUpdated();
void isCover(); void isCover();
@ -94,12 +95,10 @@
~FileComic(); ~FileComic();
void fileExtracted(int index, const QByteArray & rawData); void fileExtracted(int index, const QByteArray & rawData);
virtual bool load(const QString & path, int atPage = -1); virtual bool load(const QString & path, int atPage = -1);
void crcError(int index);
void unknownError(int index);
public slots: public slots:
void process(); void process();
void loadImages();
void loadSizes();
void openingError(QProcess::ProcessError error);
}; };
class FolderComic : public Comic class FolderComic : public Comic

View File

@ -267,21 +267,28 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
break; break;
default: default:
{ {
//TODO comunicar los fallos usando el delegado
NumErrors++; NumErrors++;
qDebug() << " "; qDebug() << " ";
switch(operationResult) switch(operationResult)
{ {
case NArchive::NExtract::NOperationResult::kUnSupportedMethod: case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
if(delegate != 0)
delegate->unknownError(_index);
qDebug() << kUnsupportedMethod; qDebug() << kUnsupportedMethod;
break; break;
case NArchive::NExtract::NOperationResult::kCRCError: case NArchive::NExtract::NOperationResult::kCRCError:
if(delegate != 0)
delegate->crcError(_index);
qDebug() << kCRCFailed; qDebug() << kCRCFailed;
break; break;
case NArchive::NExtract::NOperationResult::kDataError: case NArchive::NExtract::NOperationResult::kDataError:
if(delegate != 0)
delegate->unknownError(_index);
qDebug() << kDataError; qDebug() << kDataError;
break; break;
default: default:
if(delegate != 0)
delegate->unknownError(_index);
qDebug() << kUnknownError; qDebug() << kUnknownError;
} }
} }

View File

@ -7,6 +7,8 @@ class ExtractDelegate
{ {
public: public:
virtual void fileExtracted(int index, const QByteArray & rawData) = 0; virtual void fileExtracted(int index, const QByteArray & rawData) = 0;
virtual void crcError(int index) = 0;
virtual void unknownError(int index) = 0;
}; };
#endif //EXTRACT_DELEGATE_H #endif //EXTRACT_DELEGATE_H