mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 09:04:39 +03:00
"Type" parameter has been added to console
This commit is contained in:
parent
15671cf6f4
commit
674528b095
@ -6,6 +6,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
#include <QPrinterInfo>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
@ -34,6 +35,10 @@ int main(int argc, char *argv[])
|
|||||||
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
|
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
|
||||||
QCoreApplication::translate("main", "param_name=param_value"));
|
QCoreApplication::translate("main", "param_name=param_value"));
|
||||||
parser.addOption(variablesOption);
|
parser.addOption(variablesOption);
|
||||||
|
QCommandLineOption typeOption(QStringList() << "t" << "type",
|
||||||
|
QCoreApplication::translate("main", "Output type (Printer | PDF)"),
|
||||||
|
QCoreApplication::translate("main", "type"));
|
||||||
|
parser.addOption(typeOption);
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
|
|
||||||
LimeReport::ReportEngine report;
|
LimeReport::ReportEngine report;
|
||||||
@ -56,11 +61,32 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool printToPDF = true;
|
||||||
|
if (!parser.value(typeOption).isEmpty()){
|
||||||
|
printToPDF = !(parser.value(typeOption).compare("Printer",Qt::CaseInsensitive) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printToPDF){
|
||||||
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 {
|
||||||
|
QPrinterInfo pi;
|
||||||
|
QPrinter printer;
|
||||||
|
if (parser.value(destinationOption).isEmpty()){
|
||||||
|
if (!pi.defaultPrinterName().isEmpty()){
|
||||||
|
printer.setPrinterName(pi.defaultPrinterName());
|
||||||
|
report.printReport(&printer);
|
||||||
|
} else {
|
||||||
|
std::cerr<<"Error! Default printer not found on system";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printer.setPrinterName(parser.value(destinationOption));
|
||||||
|
report.printReport(&printer);
|
||||||
|
}
|
||||||
|
}
|
||||||
#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
|
||||||
|
Loading…
Reference in New Issue
Block a user