Commit 2bacaf9e authored by Luigi Toscano's avatar Luigi Toscano

New method to get the proper PrintError from the printFile* return value

svn path=/trunk/KDE/kdegraphics/okular/; revision=1115578
parent bc6cfcd6
...@@ -307,6 +307,43 @@ QSize FilePrinter::psPaperSize( QPrinter &printer ) ...@@ -307,6 +307,43 @@ QSize FilePrinter::psPaperSize( QPrinter &printer )
return size; return size;
} }
Generator::PrintError FilePrinter::printError( int c )
{
Generator::PrintError pe;
if ( c >= 0 )
{
pe = Generator::NoPrintError;
}
else {
switch ( c )
{
case -1:
pe = Generator::PrintingProcessCrashPrintError;
break;
case -2:
pe = Generator::PrintingProcessStartPrintError;
break;
case -5:
pe = Generator::PrintToFilePrintError;
break;
case -6:
pe = Generator::InvalidPrinterStatePrintError;
break;
case -7:
pe = Generator::UnableToFindFilePrintError;
break;
case -8:
pe = Generator::NoFileToPrintError;
break;
case -9:
pe = Generator::NoBinaryToPrintError;
break;
default:
pe = Generator::UnknownPrintError;
}
}
return pe;
}
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <QtCore/QString> #include <QtCore/QString>
#include <okular/core/okular_export.h> #include <okular/core/okular_export.h>
#include <okular/core/generator.h>
class QPrinter; class QPrinter;
class QSize; class QSize;
...@@ -146,6 +147,12 @@ public: ...@@ -146,6 +147,12 @@ public:
*/ */
static QSize psPaperSize( QPrinter &printer ); static QSize psPaperSize( QPrinter &printer );
/**
* Convert the code returned by printFile* to PrintError
* @since 0.11 (KDE 4.5)
*/
static Generator::PrintError printError( int c );
protected: protected:
bool detectCupsService(); bool detectCupsService();
......
...@@ -937,19 +937,10 @@ bool PDFGenerator::print( QPrinter& printer ) ...@@ -937,19 +937,10 @@ bool PDFGenerator::print( QPrinter& printer )
Okular::FilePrinter::SystemDeletesFiles, Okular::FilePrinter::SystemDeletesFiles,
Okular::FilePrinter::ApplicationSelectsPages, Okular::FilePrinter::ApplicationSelectsPages,
document()->bookmarkedPageRange() ); document()->bookmarkedPageRange() );
if ( ret >= 0 )
{ lastPrintError = Okular::FilePrinter::printError( ret );
lastPrintError = NoPrintError;
return true; return (lastPrintError == NoPrintError);
}
else if (ret == -1) lastPrintError = PrintingProcessCrashPrintError;
else if (ret == -2) lastPrintError = PrintingProcessStartPrintError;
else if (ret == -5) lastPrintError = PrintToFilePrintError;
else if (ret == -6) lastPrintError = InvalidPrinterStatePrintError;
else if (ret == -7) lastPrintError = UnableToFindFilePrintError;
else if (ret == -8) lastPrintError = NoFileToPrintError;
else if (ret == -9) lastPrintError = NoBinaryToPrintError;
else lastPrintError = UnknownPrintError;
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment