From 0ca4366ad8eebc9a4c488e3550c6811a3c8583ec Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 20 Feb 2019 21:06:18 +0300 Subject: [PATCH] Console demo has been refactored and added to the limereport.pro --- console/console.pro | 36 ++++++++++---------- console/main.cpp | 80 +++++++++++++++++++++++++++------------------ limereport.pro | 1 + 3 files changed, 68 insertions(+), 49 deletions(-) diff --git a/console/console.pro b/console/console.pro index 80bf88b..cea280f 100644 --- a/console/console.pro +++ b/console/console.pro @@ -1,33 +1,35 @@ -QT += core widgets +include(../common.pri) +QT += core QT -= gui -CONFIG += c++11 - -TARGET = console +TARGET = limereport CONFIG += console CONFIG -= app_bundle TEMPLATE = app - SOURCES += main.cpp -# The following define makes your compiler emit warnings if you use -# any feature of Qt which as been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS -include(../common.pri) +DESTDIR = $${DEST_BINS} + INCLUDEPATH += $$PWD/../include DEPENDPATH += $$PWD/../include -LIBS += -L$${DEST_LIBS} -llimereport + +LIBS += -L$${DEST_LIBS} + +CONFIG(debug, debug|release) { + LIBS += -llimereportd +} else { + LIBS += -llimereport +} !contains(CONFIG, static_build){ contains(CONFIG,zint){ - LIBS += -L$${DEST_LIBS} -lQtZint + LIBS += -L$${DEST_LIBS} + CONFIG(debug, debug|release) { + LIBS += -lQtZintd + } else { + LIBS += -lQtZint + } } } - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 diff --git a/console/main.cpp b/console/main.cpp index 574b599..526eb81 100644 --- a/console/main.cpp +++ b/console/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -14,49 +15,64 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR); QStringList vars; + + QCommandLineParser parser; + parser.addHelpOption(); + parser.addVersionOption(); + 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")); + 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")); + parser.addOption(variablesOption); + parser.process(a); + LimeReport::ReportEngine report; - if (a.arguments().count() < 2 ){ - std::cerr<<"Error! Report file is not specified !!"; + + if (parser.value(sourceOption).isEmpty()){ + std::cerr<<"Error! Report file is not specified !! \n"; return 1; } - if (a.arguments().count()>2){ - vars = a.arguments().at(2).split(";"); - qDebug()<setReportVariable(varItem.at(0),varItem.at(1)); + if (varItem.size() == 2) + report.dataManager()->setReportVariable(varItem.at(0),varItem.at(1)); } } - QString reportFile = a.arguments().at(1); - - if (!report.loadFromFile(reportFile)){ - qDebug()<