mirror of
https://github.com/fralx/LimeReport.git
synced 2025-10-11 06:22:35 +03:00
Merge tag '1.7.17' into develop
Finish 1.7.17
This commit is contained in:
17
console/CMakeLists.txt
Normal file
17
console/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
project(console)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
limereport-qt${QT_VERSION_MAJOR}
|
||||
)
|
||||
|
@@ -1,17 +1,21 @@
|
||||
#include "../limereport/version.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QUuid>
|
||||
#include <LimeReport>
|
||||
#include <iostream>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QCommandLineParser>
|
||||
#include <QPrinterInfo>
|
||||
#include "../limereport/version.h"
|
||||
#include <QUuid>
|
||||
|
||||
#include <LimeReport>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
enum PrintType{ Printer, PDF, Display};
|
||||
@@ -26,17 +30,22 @@ int main(int argc, char *argv[])
|
||||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
QCommandLineOption sourceOption(QStringList() << "s" << "source",
|
||||
QCoreApplication::translate("main", "Limereport pattern file name"),
|
||||
QCoreApplication::translate("main", "source"));
|
||||
QCommandLineOption sourceOption(
|
||||
QStringList() << "s"
|
||||
<< "source",
|
||||
QCoreApplication::translate("main", "Limereport pattern file name"),
|
||||
QCoreApplication::translate("main", "source"));
|
||||
parser.addOption(sourceOption);
|
||||
QCommandLineOption destinationOption(QStringList() << "d" << "destination",
|
||||
QCoreApplication::translate("main", "Output file name"),
|
||||
QCoreApplication::translate("main", "destination"));
|
||||
QCommandLineOption destinationOption(QStringList() << "d"
|
||||
<< "destination",
|
||||
QCoreApplication::translate("main", "Output file name"),
|
||||
QCoreApplication::translate("main", "destination"));
|
||||
parser.addOption(destinationOption);
|
||||
QCommandLineOption variablesOption(QStringList() << "p" << "param",
|
||||
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
|
||||
QCoreApplication::translate("main", "param_name=param_value"));
|
||||
QCommandLineOption variablesOption(
|
||||
QStringList() << "p"
|
||||
<< "param",
|
||||
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
|
||||
QCoreApplication::translate("main", "param_name=param_value"));
|
||||
parser.addOption(variablesOption);
|
||||
QCommandLineOption typeOption(QStringList() << "t" << "type",
|
||||
QCoreApplication::translate("main", "Output type (Printer | PDF)"),
|
||||
@@ -46,21 +55,22 @@ int main(int argc, char *argv[])
|
||||
|
||||
LimeReport::ReportEngine report;
|
||||
|
||||
if (parser.value(sourceOption).isEmpty()){
|
||||
std::cerr<<"Error! Report file is not specified !! \n";
|
||||
if (parser.value(sourceOption).isEmpty()) {
|
||||
std::cerr << "Error! Report file is not specified !! \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!report.loadFromFile(parser.value(sourceOption))){
|
||||
std::cerr<<"Error! Report file \""+parser.value(sourceOption).toStdString()+"\" not found \n";
|
||||
if (!report.loadFromFile(parser.value(sourceOption))) {
|
||||
std::cerr << "Error! Report file \"" + parser.value(sourceOption).toStdString()
|
||||
+ "\" not found \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!parser.values(variablesOption).isEmpty()){
|
||||
foreach(QString var, parser.values(variablesOption)){
|
||||
if (!parser.values(variablesOption).isEmpty()) {
|
||||
foreach (QString var, parser.values(variablesOption)) {
|
||||
QStringList varItem = var.split("=");
|
||||
if (varItem.size() == 2)
|
||||
report.dataManager()->setReportVariable(varItem.at(0),varItem.at(1));
|
||||
report.dataManager()->setReportVariable(varItem.at(0), varItem.at(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,23 +115,23 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
#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
|
||||
// QUuid uid = QUuid::createUuid();
|
||||
// QString uidStr = uid.toString()+".pdf";
|
||||
// report.printToPDF(uidStr);
|
||||
// QFile in(uidStr);
|
||||
// QFile out;
|
||||
// out.open(stdout, QFile::WriteOnly);
|
||||
// in.open(QIODevice::ReadOnly);
|
||||
//#ifdef _WIN32
|
||||
// _setmode(fileno(stdout),O_BINARY);
|
||||
//#endif
|
||||
// QByteArray buffer = in.readAll();
|
||||
// fwrite(buffer,1,buffer.size(),stdout);
|
||||
// in.close();
|
||||
// in.remove();
|
||||
// QUuid uid = QUuid::createUuid();
|
||||
// QString uidStr = uid.toString()+".pdf";
|
||||
// report.printToPDF(uidStr);
|
||||
// QFile in(uidStr);
|
||||
// QFile out;
|
||||
// out.open(stdout, QFile::WriteOnly);
|
||||
// in.open(QIODevice::ReadOnly);
|
||||
//#ifdef _WIN32
|
||||
// _setmode(fileno(stdout),O_BINARY);
|
||||
//#endif
|
||||
// QByteArray buffer = in.readAll();
|
||||
// fwrite(buffer,1,buffer.size(),stdout);
|
||||
// in.close();
|
||||
// in.remove();
|
||||
|
||||
return 0;
|
||||
//return a.exec();
|
||||
// return a.exec();
|
||||
}
|
||||
|
Reference in New Issue
Block a user