0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00

Display type has been added to console application

This commit is contained in:
Alexander Arin 2019-12-19 23:42:05 +03:00
parent 621a6a8492
commit 3a97bf192e

View File

@ -13,6 +13,8 @@
#include <fcntl.h> #include <fcntl.h>
#endif #endif
enum PrintType{ Printer, PDF, Display};
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
@ -61,20 +63,29 @@ int main(int argc, char *argv[])
} }
} }
bool printToPDF = true;
PrintType printType = PDF;
if (!parser.value(typeOption).isEmpty()){ if (!parser.value(typeOption).isEmpty()){
printToPDF = !(parser.value(typeOption).compare("Printer",Qt::CaseInsensitive) == 0); if (parser.value(typeOption).compare("Printer",Qt::CaseInsensitive) == 0)
printType = Printer;
if (parser.value(typeOption).compare("Display",Qt::CaseInsensitive) == 0)
printType = Display;
} }
if (printToPDF){
QPrinterInfo pi;
QPrinter printer;
switch(printType){
case PDF:
if (parser.value(destinationOption).isEmpty()){ if (parser.value(destinationOption).isEmpty()){
report.printToPDF(QFileInfo(parser.value(sourceOption)).baseName()); report.printToPDF(QFileInfo(parser.value(sourceOption)).baseName());
} else { } else {
report.printToPDF(parser.value(destinationOption)); report.printToPDF(parser.value(destinationOption));
} }
} else { break;
QPrinterInfo pi; case Printer:
QPrinter printer;
if (parser.value(destinationOption).isEmpty()){ if (parser.value(destinationOption).isEmpty()){
if (!pi.defaultPrinterName().isEmpty()){ if (!pi.defaultPrinterName().isEmpty()){
printer.setPrinterName(pi.defaultPrinterName()); printer.setPrinterName(pi.defaultPrinterName());
@ -86,7 +97,12 @@ int main(int argc, char *argv[])
printer.setPrinterName(parser.value(destinationOption)); printer.setPrinterName(parser.value(destinationOption));
report.printReport(&printer); report.printReport(&printer);
} }
break;
case Display:
report.previewReport();
break;
} }
#else #else
std::cerr<<"This demo intended for Qt 5.2 and higher\n"; std::cerr<<"This demo intended for Qt 5.2 and higher\n";
#endif #endif