This commit is contained in:
Rodrigo Torres 2021-08-24 04:22:30 -03:00
parent fa6cbef6a7
commit 67d8146b9c
25 changed files with 360 additions and 44 deletions

View File

@ -18,7 +18,7 @@ int main(int argc, char *argv[])
QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR); QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR);
QStringList vars; QStringList vars;
#if QT_VERSION > QT_VERSION_CHECK(5, 2, 0) #if QT_VERSION > 0x050200
QCommandLineParser parser; QCommandLineParser parser;
parser.addHelpOption(); parser.addHelpOption();
parser.addVersionOption(); parser.addVersionOption();

View File

@ -67,7 +67,11 @@ QString replaceHTMLSymbols(const QString &value)
return result; return result;
} }
#if QT_VERSION < 0x060000
QVector<QString> normalizeCaptures(const QRegExp& reg){ QVector<QString> normalizeCaptures(const QRegExp& reg){
#else
QVector<QString> normalizeCaptures(const QRegularExpressionMatch &reg){
#endif
QVector<QString> result; QVector<QString> result;
foreach (QString cap, reg.capturedTexts()) { foreach (QString cap, reg.capturedTexts()) {
if (!cap.isEmpty()) if (!cap.isEmpty())

View File

@ -51,7 +51,7 @@ namespace LimeReport {
#define VARIABLE_IS_NOT_USED #define VARIABLE_IS_NOT_USED
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) #if QT_VERSION >= 0x050800
Q_NAMESPACE Q_NAMESPACE
#endif #endif
@ -107,7 +107,7 @@ namespace Const{
#if QT_VERSION < 0x060000 #if QT_VERSION < 0x060000
QVector<QString> normalizeCaptures(const QRegExp &reg); QVector<QString> normalizeCaptures(const QRegExp &reg);
#else #else
QVector<QString> normalizeCaptures(const QRegularExpression &reg); QVector<QString> normalizeCaptures(const QRegularExpressionMatch &reg);
#endif #endif
bool isColorDark(QColor color); bool isColorDark(QColor color);
@ -162,7 +162,7 @@ namespace Const{
{ {
public: public:
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(VariableDataType) Q_ENUM(VariableDataType)
#else #else
Q_ENUMS(VariableDataType) Q_ENUMS(VariableDataType)

View File

@ -31,7 +31,7 @@
#define LRSCRIPTENGINEMANAGERINTF_H #define LRSCRIPTENGINEMANAGERINTF_H
#include "qglobal.h" #include "qglobal.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= 0x050600
#ifndef USE_QTSCRIPTENGINE #ifndef USE_QTSCRIPTENGINE
#ifndef USE_QJSENGINE #ifndef USE_QJSENGINE
#define USE_QJSENGINE #define USE_QJSENGINE

View File

@ -13,7 +13,7 @@ class AbstractLayout: public LayoutDesignIntf
Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing) Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing)
public: public:
enum LayoutType{Layout,Table}; enum LayoutType{Layout,Table};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(LayoutType) Q_ENUM(LayoutType)
#else #else
Q_ENUMS(LayoutType) Q_ENUMS(LayoutType)

View File

@ -152,7 +152,7 @@ public:
KANJI_INPUT_MODE = 3, KANJI_INPUT_MODE = 3,
SJIS_INPUT_MODE = 4 SJIS_INPUT_MODE = 4
}; };
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(BarcodeType) Q_ENUM(BarcodeType)
Q_ENUM(AngleType) Q_ENUM(AngleType)
Q_ENUM(InputMode) Q_ENUM(InputMode)

View File

@ -33,7 +33,7 @@ class SeriesItem : public QObject{
Q_PROPERTY(SeriesItemPreferredType preferredType READ preferredType WRITE setPreferredType) Q_PROPERTY(SeriesItemPreferredType preferredType READ preferredType WRITE setPreferredType)
public: public:
enum SeriesItemPreferredType {Bar, Line}; enum SeriesItemPreferredType {Bar, Line};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(SeriesItemPreferredType) Q_ENUM(SeriesItemPreferredType)
#else #else
Q_ENUMS(SeriesItemPreferredType) Q_ENUMS(SeriesItemPreferredType)
@ -135,7 +135,7 @@ public:
enum LegendAlign{LegendAlignTop,LegendAlignCenter,LegendAlignBottom}; enum LegendAlign{LegendAlignTop,LegendAlignCenter,LegendAlignBottom};
enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight}; enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight};
enum ChartType{Pie, VerticalBar, HorizontalBar, Lines}; enum ChartType{Pie, VerticalBar, HorizontalBar, Lines};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(LegendAlign) Q_ENUM(LegendAlign)
Q_ENUM(TitleAlign) Q_ENUM(TitleAlign)
Q_ENUM(ChartType) Q_ENUM(ChartType)

View File

@ -58,7 +58,7 @@ public:
Hex = 1, Hex = 1,
Base64 = 2 Base64 = 2
}; };
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(Format) Q_ENUM(Format)
#else #else
Q_ENUMS(Format) Q_ENUMS(Format)

View File

@ -47,7 +47,7 @@ class ShapeItem: public LimeReport::ItemDesignIntf
Q_PROPERTY(int cornerRadius READ cornerRadius WRITE setCornerRadius) Q_PROPERTY(int cornerRadius READ cornerRadius WRITE setCornerRadius)
public: public:
enum ShapeType{HorizontalLine,VerticalLine,Ellipse,Rectangle}; enum ShapeType{HorizontalLine,VerticalLine,Ellipse,Rectangle};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(ShapeType) Q_ENUM(ShapeType)
#else #else
Q_ENUMS(ShapeType) Q_ENUMS(ShapeType)

View File

@ -28,14 +28,18 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrsimpletagparser.h" #include "lrsimpletagparser.h"
#include <QRegExp>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
#if QT_VERSION < 0x060000
#include <QRegExp>
#else
#include <QRegularExpression>
#endif
namespace LimeReport{ namespace LimeReport{
void HtmlContext::fillTagVector(QString html) void HtmlContext::fillTagVector(QString html)
{ {
#if QT_VERSION < 0x060000
QRegExp rx("<[^<]*>"); QRegExp rx("<[^<]*>");
QString buff=html; QString buff=html;
int curPos=0; int curPos=0;
@ -49,10 +53,20 @@ void HtmlContext::fillTagVector(QString html)
} }
buff=buff.right(buff.length()-rx.matchedLength()); buff=buff.right(buff.length()-rx.matchedLength());
} }
#else
QRegularExpression rx("<[^<]*>");
QString buff=html;
while(buff.contains(rx)){
QRegularExpressionMatch match = rx.match(buff);
// TODO: Qt6 port
}
#endif
} }
QString HtmlContext::parseTag(QVector<Tag *> &storage, QString text, int &curPos, bool createTag) QString HtmlContext::parseTag(QVector<Tag *> &storage, QString text, int &curPos, bool createTag)
{ {
#if QT_VERSION < 0x060000
QRegExp rx("<[^<]*>"); QRegExp rx("<[^<]*>");
int pos=rx.indexIn(text); int pos=rx.indexIn(text);
int begPos=pos+curPos; int begPos=pos+curPos;
@ -78,12 +92,16 @@ QString HtmlContext::parseTag(QVector<Tag *> &storage, QString text, int &curPos
buff=buff.right(buff.length()-rx.matchedLength()); buff=buff.right(buff.length()-rx.matchedLength());
} }
} }
#else
QRegularExpression rx("<[^<]*>");
// TODO: Qt6 port
#endif
return ""; return "";
} }
void HtmlContext::parseSymbs(QString text) void HtmlContext::parseSymbs(QString text)
{ {
#if QT_VERSION < 0x060000
QRegExp rx("<[^<]*[^/]>"); QRegExp rx("<[^<]*[^/]>");
while (text.contains(rx)){ while (text.contains(rx)){
int pos=rx.indexIn(text); int pos=rx.indexIn(text);
@ -100,6 +118,10 @@ void HtmlContext::parseSymbs(QString text)
text.replace(rx.cap(0)," "); text.replace(rx.cap(0)," ");
} }
} }
#else
QRegularExpression rx("<[^<]*>");
// TODO: Qt6 port
#endif
} }
void HtmlContext::initSymbPatterns() void HtmlContext::initSymbPatterns()

View File

@ -79,7 +79,7 @@ public:
enum AutoWidth{NoneAutoWidth, MaxWordLength, MaxStringLength}; enum AutoWidth{NoneAutoWidth, MaxWordLength, MaxStringLength};
enum AngleType{Angle0, Angle90, Angle180, Angle270, Angle45, Angle315}; enum AngleType{Angle0, Angle90, Angle180, Angle270, Angle45, Angle315};
enum ValueType{Default, DateTime, Double}; enum ValueType{Default, DateTime, Double};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(AutoWidth) Q_ENUM(AutoWidth)
Q_ENUM(AngleType) Q_ENUM(AngleType)
Q_ENUM(ValueType) Q_ENUM(ValueType)

View File

@ -138,7 +138,7 @@ public:
enum BandColumnsLayoutType{ enum BandColumnsLayoutType{
Horizontal, Vertical, VerticalUniform Horizontal, Vertical, VerticalUniform
}; };
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(BandColumnsLayoutType) Q_ENUM(BandColumnsLayoutType)
#else #else
Q_ENUMS(BandColumnsLayoutType) Q_ENUMS(BandColumnsLayoutType)

View File

@ -144,7 +144,7 @@ public:
enum ItemAlign {LeftItemAlign,RightItemAlign,CenterItemAlign,ParentWidthItemAlign,DesignedItemAlign}; enum ItemAlign {LeftItemAlign,RightItemAlign,CenterItemAlign,ParentWidthItemAlign,DesignedItemAlign};
enum UnitType {Millimeters, Inches}; enum UnitType {Millimeters, Inches};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(BGMode) Q_ENUM(BGMode)
Q_ENUM(BrushStyle) Q_ENUM(BrushStyle)
Q_ENUM(ResizeFlags) Q_ENUM(ResizeFlags)

View File

@ -31,7 +31,9 @@
#include "lrdatadesignintf.h" #include "lrdatadesignintf.h"
#include <QStringList> #include <QStringList>
#include <QSqlQuery> #include <QSqlQuery>
#if QT_VERSION < 0x060000
#include <QRegExp> #include <QRegExp>
#endif
#include <QSqlError> #include <QSqlError>
#include <QSqlQueryModel> #include <QSqlQueryModel>
#include <QFileInfo> #include <QFileInfo>
@ -421,6 +423,7 @@ QString DataSourceManager::extractField(QString source)
} }
QString DataSourceManager::replaceVariables(QString value){ QString DataSourceManager::replaceVariables(QString value){
#if QT_VERSION < 0x060000
QRegExp rx(Const::VARIABLE_RX); QRegExp rx(Const::VARIABLE_RX);
if (value.contains(rx)){ if (value.contains(rx)){
@ -438,10 +441,16 @@ QString DataSourceManager::replaceVariables(QString value){
} }
} }
return value; return value;
#else
QRegularExpression rx(Const::VARIABLE_RX);
// TODO: Qt6 port
#endif
return QString();
} }
QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam) QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam)
{ {
#if QT_VERSION < 0x060000
QRegExp rx(Const::VARIABLE_RX); QRegExp rx(Const::VARIABLE_RX);
int curentAliasIndex = 0; int curentAliasIndex = 0;
if (query.contains(rx)){ if (query.contains(rx)){
@ -480,10 +489,16 @@ QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString>
} }
} }
return query; return query;
#else
QRegularExpression rx(Const::VARIABLE_RX);
// TODO: Qt6 port
#endif
return QString();
} }
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource) QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
{ {
#if QT_VERSION < 0x060000
QRegExp rx(Const::FIELD_RX); QRegExp rx(Const::FIELD_RX);
if (query.contains(rx)){ if (query.contains(rx)){
int curentAliasIndex=0; int curentAliasIndex=0;
@ -510,6 +525,11 @@ QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &a
} }
} }
return query; return query;
#else
QRegularExpression rx(Const::FIELD_RX);
// TODO: Qt6 port
#endif
return QString();
} }
void DataSourceManager::setReportVariable(const QString &name, const QVariant &value) void DataSourceManager::setReportVariable(const QString &name, const QVariant &value)

View File

@ -67,7 +67,11 @@ QString replaceHTMLSymbols(const QString &value)
return result; return result;
} }
#if QT_VERSION < 0x060000
QVector<QString> normalizeCaptures(const QRegExp& reg){ QVector<QString> normalizeCaptures(const QRegExp& reg){
#else
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg){
#endif
QVector<QString> result; QVector<QString> result;
foreach (QString cap, reg.capturedTexts()) { foreach (QString cap, reg.capturedTexts()) {
if (!cap.isEmpty()) if (!cap.isEmpty())

View File

@ -51,7 +51,7 @@ namespace LimeReport {
#define VARIABLE_IS_NOT_USED #define VARIABLE_IS_NOT_USED
#endif #endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) #if QT_VERSION >= 0x050800
Q_NAMESPACE Q_NAMESPACE
#endif #endif
@ -107,7 +107,7 @@ namespace Const{
#if QT_VERSION < 0x060000 #if QT_VERSION < 0x060000
QVector<QString> normalizeCaptures(const QRegExp &reg); QVector<QString> normalizeCaptures(const QRegExp &reg);
#else #else
QVector<QString> normalizeCaptures(const QRegularExpression &reg); QVector<QString> normalizeCaptures(const QRegularExpressionMatch &reg);
#endif #endif
bool isColorDark(QColor color); bool isColorDark(QColor color);
@ -162,7 +162,7 @@ namespace Const{
{ {
public: public:
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(VariableDataType) Q_ENUM(VariableDataType)
#else #else
Q_ENUMS(VariableDataType) Q_ENUMS(VariableDataType)

View File

@ -34,7 +34,9 @@
#include "lrscriptenginemanager.h" #include "lrscriptenginemanager.h"
#include "lrpageitemdesignintf.h" #include "lrpageitemdesignintf.h"
#if QT_VERSION < 0x060000
#include <QRegExp> #include <QRegExp>
#endif
namespace LimeReport { namespace LimeReport {
@ -42,13 +44,24 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
{ {
ScriptEngineManager& sm = ScriptEngineManager::instance(); ScriptEngineManager& sm = ScriptEngineManager::instance();
#if QT_VERSION < 0x060000
QRegExp rxField(Const::FIELD_RX); QRegExp rxField(Const::FIELD_RX);
QRegExp rxVar(Const::VARIABLE_RX); QRegExp rxVar(Const::VARIABLE_RX);
#else
QRegularExpression rxField(Const::FIELD_RX);
QRegularExpression rxVar(Const::VARIABLE_RX);
#endif
switch (m_dataType){ switch (m_dataType){
case Field: case Field:{
#if QT_VERSION < 0x060000
if (rxField.indexIn(m_data) != -1){ if (rxField.indexIn(m_data) != -1){
QString field = rxField.cap(1); QString field = rxField.cap(1);
#else
QRegularExpressionMatch matchField = rxField.match(m_data);
if(matchField.hasMatch()){
QString field = matchField.captured(1);
#endif
if (m_dataManager->containsField(field)){ if (m_dataManager->containsField(field)){
m_values.push_back(m_dataManager->fieldData(field)); m_values.push_back(m_dataManager->fieldData(field));
m_valuesByBand.insert(band, m_dataManager->fieldData(field)); m_valuesByBand.insert(band, m_dataManager->fieldData(field));
@ -57,9 +70,16 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
} }
} }
break; break;
case Variable: }
case Variable:{
#if QT_VERSION < 0x060000
if (rxVar.indexIn(m_data) != -1){ if (rxVar.indexIn(m_data) != -1){
QString var = rxVar.cap(1); QString var = rxVar.cap(1);
#else
QRegularExpressionMatch matchVar = rxVar.match(m_data);
if(matchVar.hasMatch()){
QString var = matchVar.captured(1);
#endif
if (m_dataManager->containsVariable(var)){ if (m_dataManager->containsVariable(var)){
m_values.push_back(m_dataManager->variable(var)); m_values.push_back(m_dataManager->variable(var));
m_valuesByBand.insert(band, m_dataManager->variable(var)); m_valuesByBand.insert(band, m_dataManager->variable(var));
@ -68,6 +88,7 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
} }
} }
break; break;
}
case Script: case Script:
{ {
QVariant value = sm.evaluateScript(m_data); QVariant value = sm.evaluateScript(m_data);
@ -128,21 +149,41 @@ QVariant GroupFunction::multiplication(QVariant value1, QVariant value2)
GroupFunction::GroupFunction(const QString &expression, const QString &dataBandName, DataSourceManager* dataManager) GroupFunction::GroupFunction(const QString &expression, const QString &dataBandName, DataSourceManager* dataManager)
:m_data(expression), m_dataBandName(dataBandName), m_dataManager(dataManager), m_isValid(true), m_errorMessage("") :m_data(expression), m_dataBandName(dataBandName), m_dataManager(dataManager), m_isValid(true), m_errorMessage("")
{ {
#if QT_VERSION < 0x060000
QRegExp rxField(Const::FIELD_RX,Qt::CaseInsensitive); QRegExp rxField(Const::FIELD_RX,Qt::CaseInsensitive);
QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive); QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive);
QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive); QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive);
#else
QRegularExpression rxField(Const::FIELD_RX, QRegularExpression::CaseInsensitiveOption);
QRegularExpression rxVariable(Const::VARIABLE_RX, QRegularExpression::CaseInsensitiveOption);
QRegularExpression rxScript(Const::SCRIPT_RX, QRegularExpression::CaseInsensitiveOption);
#endif
#if QT_VERSION < 0x060000
if (rxScript.indexIn(expression) != -1){ if (rxScript.indexIn(expression) != -1){
#else
QRegularExpressionMatch matchScript = rxScript.match(expression);
if(matchScript.hasMatch()){
#endif
m_dataType = Script; m_dataType = Script;
return; return;
} }
#if QT_VERSION < 0x060000
if (rxField.indexIn(expression) != -1){ if (rxField.indexIn(expression) != -1){
#else
QRegularExpressionMatch matchField = rxField.match(expression);
if(matchField.hasMatch()){
#endif
m_dataType=Field; m_dataType=Field;
return; return;
} }
#if QT_VERSION < 0x060000
if (rxVariable.indexIn(expression) != -1){ if (rxVariable.indexIn(expression) != -1){
#else
QRegularExpressionMatch matchVariable = rxVariable.match(expression);
if(matchVariable.hasMatch()){
#endif
m_dataType = Variable; m_dataType = Variable;
return; return;
} }

View File

@ -43,7 +43,7 @@ class ItemDesignIntf : public BaseDesignIntf
Q_PROPERTY(ItemAlign itemAlign READ itemAlign WRITE setItemAlign) Q_PROPERTY(ItemAlign itemAlign READ itemAlign WRITE setItemAlign)
public: public:
enum LocationType{Band,Page}; enum LocationType{Band,Page};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(LocationType) Q_ENUM(LocationType)
#else #else
Q_ENUMS(LocationType) Q_ENUMS(LocationType)

View File

@ -762,10 +762,18 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
if (!isVar){ if (!isVar){
BandDesignIntf* parentBand = dynamic_cast<BandDesignIntf*>(ti->parentItem()); BandDesignIntf* parentBand = dynamic_cast<BandDesignIntf*>(ti->parentItem());
if (parentBand && parentBand->datasourceName().isEmpty()){ if (parentBand && parentBand->datasourceName().isEmpty()){
#if QT_VERSION < 0x060000
QRegExp dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})"); QRegExp dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})");
if (dataSource.indexIn(data) != -1){ if (dataSource.indexIn(data) != -1){
parentBand->setProperty("datasource",dataSource.cap(1)); parentBand->setProperty("datasource",dataSource.cap(1));
} }
#else
QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})");
QRegularExpressionMatch match = dataSource.match(data);
if(match.hasMatch()){
parentBand->setProperty("datasource", match.captured(1));
}
#endif
} }
} }
} }

View File

@ -102,7 +102,7 @@ public:
}; };
#endif #endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) #if QT_VERSION >= 0x050500
Q_ENUM(Orientation) Q_ENUM(Orientation)
Q_ENUM(PrintBehavior) Q_ENUM(PrintBehavior)
Q_ENUM(PageSize) Q_ENUM(PageSize)

View File

@ -241,14 +241,10 @@ void PreviewReportWidget::print()
QPrinter lp(QPrinter::HighResolution); QPrinter lp(QPrinter::HighResolution);
if (!pi.defaultPrinter().isNull()){ if (!pi.defaultPrinter().isNull()){
#if QT_VERSION < 0x050000 #if QT_VERSION >= 0x050300
lp.setPrinterName(pi.defaultPrinter().printerName());
#else
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
lp.setPrinterName(pi.defaultPrinterName()); lp.setPrinterName(pi.defaultPrinterName());
#else #else
lp.setPrinterName(pi.defaultPrinter().printerName()); lp.setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif #endif
} }

View File

@ -276,14 +276,10 @@ bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
if (!printer&&!m_printerSelected){ if (!printer&&!m_printerSelected){
QPrinterInfo pi; QPrinterInfo pi;
if (!pi.defaultPrinter().isNull()) if (!pi.defaultPrinter().isNull())
#if QT_VERSION < 0x050000 #if QT_VERSION >= 0x050300
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#else
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName()); m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else #else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName()); m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif #endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow()); QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected; m_printerSelected = dialog.exec()!=QDialog::Rejected;
@ -397,14 +393,10 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
if (!printer&&!m_printerSelected){ if (!printer&&!m_printerSelected){
QPrinterInfo pi; QPrinterInfo pi;
if (!pi.defaultPrinter().isNull()) if (!pi.defaultPrinter().isNull())
#if QT_VERSION < 0x050000 #if QT_VERSION >= 0x050300
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#else
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName()); m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else #else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName()); m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif #endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow()); QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected; m_printerSelected = dialog.exec()!=QDialog::Rejected;
@ -1826,6 +1818,7 @@ PrintProcessor::PrintProcessor(QPrinter* printer)
bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page) bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
{ {
#if QT_VERSION < 0x060000
if (!m_firstPage && !m_painter->isActive()) return false; if (!m_firstPage && !m_painter->isActive()) return false;
PageDesignIntf* backupPage = dynamic_cast<PageDesignIntf*>(page->scene()); PageDesignIntf* backupPage = dynamic_cast<PageDesignIntf*>(page->scene());
@ -1887,11 +1880,77 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
page->setPos(backupPagePos); page->setPos(backupPagePos);
m_renderPage.removePageItem(page); m_renderPage.removePageItem(page);
if (backupPage) backupPage->reactivatePageItem(page); if (backupPage) backupPage->reactivatePageItem(page);
#else
if (!m_firstPage && !m_painter->isActive()) return false;
PageDesignIntf* backupPage = dynamic_cast<PageDesignIntf*>(page->scene());
QPointF backupPagePos = page->pos();
page->setPos(0,0);
m_renderPage.setPageItem(page);
m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect());
initPrinter(m_renderPage.pageItem());
if (!m_firstPage){
m_printer->newPage();
} else {
m_painter = new QPainter(m_printer);
if (!m_painter->isActive()) return false;
m_firstPage = false;
}
qreal leftMargin = m_printer->pageLayout().margins().left();
qreal topMargin = m_printer->pageLayout().margins().top();
qreal rightMargin = m_printer->pageLayout().margins().right();
qreal bottomMargin = m_printer->pageLayout().margins().bottom();
QRectF printerPageRect = m_printer->pageRect(QPrinter::Millimeter);
printerPageRect = QRectF(0,0,(printerPageRect.size().width() + rightMargin + leftMargin) * page->unitFactor(),
(printerPageRect.size().height() + bottomMargin + topMargin) * page->unitFactor());
if (page->printBehavior() == PageItemDesignIntf::Split && m_printer->pageLayout().pageSize() != (QPageSize::PageSizeId)page->pageSize() &&
printerPageRect.width() < page->geometry().width())
{
qreal pageWidth = page->geometry().width();
qreal pageHeight = page->geometry().height();
QRectF currentPrintingRect = printerPageRect;
qreal curHeight = 0;
qreal curWidth = 0;
bool first = true;
while (pageHeight > 0){
while (curWidth < pageWidth){
if (!first) m_printer->newPage(); else first = false;
m_renderPage.render(m_painter, m_printer->pageRect(QPrinter::Millimeter), currentPrintingRect);
currentPrintingRect.adjust(printerPageRect.size().width(), 0, printerPageRect.size().width(), 0);
curWidth += printerPageRect.size().width();
}
pageHeight -= printerPageRect.size().height();
curHeight += printerPageRect.size().height();
currentPrintingRect = printerPageRect;
currentPrintingRect.adjust(0, curHeight, 0, curHeight);
curWidth = 0;
}
} else {
if (page->getSetPageSizeToPrinter()){
QRectF source = page->geometry();
QSizeF inchSize = source.size() / (100 * 2.54);
QRectF target = QRectF(QPoint(0,0), inchSize * m_printer->resolution());
m_renderPage.render(m_painter, target, source);
} else {
m_renderPage.render(m_painter);
}
}
page->setPos(backupPagePos);
m_renderPage.removePageItem(page);
if (backupPage) backupPage->reactivatePageItem(page);
#endif
return true; return true;
} }
void PrintProcessor::initPrinter(PageItemDesignIntf* page) void PrintProcessor::initPrinter(PageItemDesignIntf* page)
{ {
#if QT_VERSION < 0x060000
if (page->oldPrintMode()){ if (page->oldPrintMode()){
m_printer->setPageMargins(page->leftMargin(), m_printer->setPageMargins(page->leftMargin(),
page->topMargin(), page->topMargin(),
@ -1919,6 +1978,31 @@ void PrintProcessor::initPrinter(PageItemDesignIntf* page)
m_printer->setPaperSize(static_cast<QPrinter::PageSize>(page->pageSize())); m_printer->setPaperSize(static_cast<QPrinter::PageSize>(page->pageSize()));
} }
} }
#else
if (page->oldPrintMode()){
m_printer->setPageMargins(QMarginsF(page->leftMargin(), page->topMargin(), page->rightMargin(), page->bottomMargin()),QPageLayout::Millimeter);
m_printer->setPageOrientation((QPageLayout::Orientation)page->pageOrientation());
QSizeF pageSize = (page->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(page->sizeMM().height(),page->sizeMM().width()):
page->sizeMM();
m_printer->setPageSize(QPageSize(pageSize, QPageSize::Millimeter));
} else {
m_printer->setFullPage(page->fullPage());
if (page->dropPrinterMargins())
m_printer->setPageMargins(QMarginsF(0, 0, 0, 0), QPageLayout::Point);
m_printer->setPageOrientation((QPageLayout::Orientation)page->pageOrientation());
if (page->pageSize()==PageItemDesignIntf::Custom){
QSizeF pageSize = (page->pageOrientation()==PageItemDesignIntf::Landscape)?
QSizeF(page->sizeMM().height(),page->sizeMM().width()):
page->sizeMM();
if (page->getSetPageSizeToPrinter() || m_printer->outputFormat() == QPrinter::PdfFormat)
m_printer->setPageSize(QPageSize(pageSize, QPageSize::Millimeter));
} else {
if (page->getSetPageSizeToPrinter() || m_printer->outputFormat() == QPrinter::PdfFormat)
m_printer->setPageSize(QPageSize((QPageSize::PageSizeId)page->pageSize()));
}
}
#endif
} }
qreal ItemGeometry::x() const qreal ItemGeometry::x() const

View File

@ -196,11 +196,15 @@ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignInt
QString content = contentItem->content(); QString content = contentItem->content();
QVector<QString> functions; QVector<QString> functions;
foreach(const QString &functionName, m_datasources->groupFunctionNames()){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){
#if QT_VERSION < 0x060000
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
rx.setMinimal(true); rx.setMinimal(true);
if (rx.indexIn(content)>=0){ if (rx.indexIn(content)>=0){
functions.append(functionName); functions.append(functionName);
} }
#else
// TODO: Qt6 port
#endif
} }
if (functions.size()>0) if (functions.size()>0)
m_groupfunctionItems.insert(contentItem->patternName(), functions); m_groupfunctionItems.insert(contentItem->patternName(), functions);
@ -361,10 +365,14 @@ bool ReportRender::containsGroupFunctions(BandDesignIntf *band){
if (contentItem){ if (contentItem){
QString content = contentItem->content(); QString content = contentItem->content();
foreach(QString functionName, m_datasources->groupFunctionNames()){ foreach(QString functionName, m_datasources->groupFunctionNames()){
#if QT_VERSION < 0x060000
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
if (rx.indexIn(content)>=0){ if (rx.indexIn(content)>=0){
return true; return true;
} }
#else
// TODO: Qt6 port
#endif
} }
} }
} }
@ -372,6 +380,7 @@ bool ReportRender::containsGroupFunctions(BandDesignIntf *band){
} }
void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
#if QT_VERSION < 0x060000
if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){ if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){
foreach(const QString &functionName, m_datasources->groupFunctionNames()){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
@ -406,6 +415,9 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt
} }
} }
} }
#else
// TODO: Qt6 port
#endif
} }
void ReportRender::extractGroupFunctionsFromContainer(BaseDesignIntf* baseItem, BandDesignIntf* band){ void ReportRender::extractGroupFunctionsFromContainer(BaseDesignIntf* baseItem, BandDesignIntf* band){
@ -428,6 +440,7 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
if (m_groupfunctionItems.contains(contentItem->patternName())){ if (m_groupfunctionItems.contains(contentItem->patternName())){
QString content = contentItem->content(); QString content = contentItem->content();
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){ foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
#if QT_VERSION < 0x060000
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
rx.setMinimal(true); rx.setMinimal(true);
if (rx.indexIn(content)>=0){ if (rx.indexIn(content)>=0){
@ -450,6 +463,9 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
pos += rx.matchedLength(); pos += rx.matchedLength();
} }
} }
#else
// TODO: Qt6 port
#endif
} }
contentItem->setContent(content); contentItem->setContent(content);
} }

View File

@ -354,6 +354,7 @@ void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue) QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue)
{ {
#if QT_VERSION < 0x060000
QRegExp rx(Const::VARIABLE_RX); QRegExp rx(Const::VARIABLE_RX);
if (context.contains(rx)){ if (context.contains(rx)){
int pos = 0; int pos = 0;
@ -396,10 +397,62 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /*
} }
} }
return context; return context;
#else
QRegularExpression rx(Const::VARIABLE_RX);
if (context.contains(rx)){
int pos = 0;
QRegularExpressionMatch match = rx.match(context, pos);
while (match.hasMatch()){
QString variable=match.captured(1);
pos = match.capturedEnd();
if (dataManager()->containsVariable(variable) ){
try {
varValue = dataManager()->variable(variable);
switch (expandType){
case EscapeSymbols:
context.replace(match.captured(0), escapeSimbols(varValue.toString()));
break;
case NoEscapeSymbols:
context.replace(match.captured(0), varValue.toString());
break;
case ReplaceHTMLSymbols:
context.replace(match.captured(0), replaceHTMLSymbols(varValue.toString()));
break;
}
pos = 0;
} catch (ReportError &e){
dataManager()->putError(e.what());
if (!dataManager()->reportSettings() || dataManager()->reportSettings()->suppressAbsentFieldsAndVarsWarnings())
context.replace(match.captured(0), e.what());
else
context.replace(match.captured(0), "");
}
} else {
QString error;
error = tr("Variable %1 not found").arg(variable);
dataManager()->putError(error);
if (!dataManager()->reportSettings() || dataManager()->reportSettings()->suppressAbsentFieldsAndVarsWarnings())
context.replace(match.captured(0), error);
else
context.replace(match.captured(0), "");
}
match = rx.match(context, pos);
}
}
return context;
#endif
} }
QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem) QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem)
{ {
#if QT_VERSION < 0x060000
QRegExp rx(Const::FIELD_RX); QRegExp rx(Const::FIELD_RX);
if (context.contains(rx)){ if (context.contains(rx)){
@ -450,13 +503,74 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand
} }
return context; return context;
#else
QRegularExpression rx(Const::FIELD_RX);
if (context.contains(rx)){
QRegularExpressionMatch match = rx.match(context);
while (match.hasMatch()){
QString field=match.captured(1);
if (dataManager()->containsField(field)) {
QString fieldValue;
varValue = dataManager()->fieldData(field);
if (expandType == EscapeSymbols) {
if (varValue.isNull()) {
fieldValue="\"\"";
} else {
fieldValue = escapeSimbols(varValue.toString());
switch (dataManager()->fieldData(field).type()) {
case QVariant::Char:
case QVariant::String:
case QVariant::StringList:
case QVariant::Date:
case QVariant::DateTime:
fieldValue = "\""+fieldValue+"\"";
break;
default:
break;
}
}
} else {
if (expandType == ReplaceHTMLSymbols)
fieldValue = replaceHTMLSymbols(varValue.toString());
else fieldValue = varValue.toString();
}
context.replace(match.captured(0),fieldValue);
} else {
QString error;
if (reportItem){
error = tr("Field %1 not found in %2!").arg(field).arg(reportItem->objectName());
dataManager()->putError(error);
}
varValue = QVariant();
if (!dataManager()->reportSettings() || !dataManager()->reportSettings()->suppressAbsentFieldsAndVarsWarnings())
context.replace(match.captured(0), error);
else
context.replace(match.captured(0), "");
}
match = rx.match(context);
}
}
return context;
#endif
} }
QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, QObject *reportItem) QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, QObject *reportItem)
{ {
#if QT_VERSION < 0x060000
QRegExp rx(Const::SCRIPT_RX); QRegExp rx(Const::SCRIPT_RX);
if (context.contains(rx)){ if (context.contains(rx)){
#else
QRegularExpression rx(Const::SCRIPT_RX, QRegularExpression::DotMatchesEverythingOption);
if(context.contains(rx)){
#endif
if (ScriptEngineManager::instance().dataManager() != dataManager()) if (ScriptEngineManager::instance().dataManager() != dataManager())
ScriptEngineManager::instance().setDataManager(dataManager()); ScriptEngineManager::instance().setDataManager(dataManager());
@ -517,10 +631,17 @@ QString ScriptEngineManager::replaceScripts(QString context, QVariant &varValue,
QVariant ScriptEngineManager::evaluateScript(const QString& script){ QVariant ScriptEngineManager::evaluateScript(const QString& script){
#if QT_VERSION < 0x060000
QRegExp rx(Const::SCRIPT_RX); QRegExp rx(Const::SCRIPT_RX);
QVariant varValue; QVariant varValue;
if (script.contains(rx)){ if (script.contains(rx)){
#else
QRegularExpression rx(Const::SCRIPT_RX);
QVariant varValue;
if (script.contains(rx)){
#endif
if (ScriptEngineManager::instance().dataManager()!=dataManager()) if (ScriptEngineManager::instance().dataManager()!=dataManager())
ScriptEngineManager::instance().setDataManager(dataManager()); ScriptEngineManager::instance().setDataManager(dataManager());

View File

@ -31,7 +31,7 @@
#define LRSCRIPTENGINEMANAGERINTF_H #define LRSCRIPTENGINEMANAGERINTF_H
#include "qglobal.h" #include "qglobal.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= 0x050600
#ifndef USE_QTSCRIPTENGINE #ifndef USE_QTSCRIPTENGINE
#ifndef USE_QJSENGINE #ifndef USE_QJSENGINE
#define USE_QJSENGINE #define USE_QJSENGINE