From 81f27782be5de8fe020e63c7caf5d47309c4d02d Mon Sep 17 00:00:00 2001 From: fralx Date: Wed, 20 Jan 2021 14:47:05 +0300 Subject: [PATCH] Qt6 support added --- 3rdparty/zint-2.6.1/backend_qt/qzint.cpp | 1 + common.pri | 7 +- demo_r1/demo_r1.pro | 77 ++++++----- .../change_item_from_script.lrxml | 90 ++++--------- demo_r1/demo_reports/northwind.db | Bin 925696 -> 925696 bytes demo_r1/mainicon.rc | 2 +- demo_r1/mainwindow.cpp | 79 ++++++------ demo_r1/mainwindow.h | 3 + demo_r1/mainwindow.ui | 41 +++++- demo_r2/mainwindow.cpp | 12 +- include/lrglobal.h | 7 + limereport/databrowser/lrdatabrowser.cpp | 11 +- .../designerintegrationv2/formresizer.cpp | 13 +- .../items/charts/lrhorizontalbarchart.cpp | 4 + limereport/items/charts/lrpiechart.cpp | 16 +++ .../items/editors/lrfonteditorwidget.cpp | 4 + limereport/items/lrchartitem.cpp | 84 +++++++++++- limereport/items/lrchartitemeditor.cpp | 4 + limereport/items/lrtextitem.cpp | 36 +++++- limereport/items/lrtextitem.h | 1 + limereport/limereport.pri | 4 +- limereport/lrbanddesignintf.cpp | 20 ++- limereport/lrdatasourcemanager.cpp | 110 +++++++++++++++- limereport/lrglobal.h | 7 + limereport/lrgraphicsviewzoom.cpp | 9 ++ limereport/lrpagedesignintf.cpp | 2 +- limereport/lrpreviewreportwidget.cpp | 14 +- limereport/lrpreviewreportwindow.cpp | 12 +- limereport/lrreportdesignwidget.cpp | 42 ++++-- limereport/lrreportdesignwindow.cpp | 35 ++++- limereport/lrreportengine.cpp | 2 + limereport/lrreportrender.cpp | 2 +- limereport/lrscriptenginemanager.cpp | 122 +++++++++++++++++- .../editors/lrbuttonlineeditor.cpp | 17 ++- .../lrobjectinspectorwidget.cpp | 21 +++ limereport/objectsbrowser/lrobjectbrowser.cpp | 17 ++- limereport/scriptbrowser/lrscriptbrowser.cpp | 9 ++ limereport/scripteditor/lrcodeeditor.cpp | 14 +- limereport/scripteditor/lrscripteditor.cpp | 12 +- 39 files changed, 759 insertions(+), 204 deletions(-) diff --git a/3rdparty/zint-2.6.1/backend_qt/qzint.cpp b/3rdparty/zint-2.6.1/backend_qt/qzint.cpp index cec92ce..922e348 100644 --- a/3rdparty/zint-2.6.1/backend_qt/qzint.cpp +++ b/3rdparty/zint-2.6.1/backend_qt/qzint.cpp @@ -17,6 +17,7 @@ #include "qzint.h" #include +#include namespace Zint { diff --git a/common.pri b/common.pri index 1b5ac18..ae200d5 100644 --- a/common.pri +++ b/common.pri @@ -1,5 +1,5 @@ #BINARY_RESULT_DIR = $${TOP_BUILD_DIR} -CONFIG *= qtxlsx +#CONFIG *= qtxlsx isEmpty(BINARY_RESULT_DIR) { BINARY_RESULT_DIR = $${PWD} @@ -51,6 +51,11 @@ lessThan(QT_MAJOR_VERSION, 5){ } } +greaterThan(QT_MAJOR_VERSION, 5){ + CONFIG -= qtscriptengine + CONFIG *= qjsengine +} + contains(CONFIG, qtscriptengine){ CONFIG -= qjsengine QT *= script diff --git a/demo_r1/demo_r1.pro b/demo_r1/demo_r1.pro index 36505d3..128cc34 100644 --- a/demo_r1/demo_r1.pro +++ b/demo_r1/demo_r1.pro @@ -1,12 +1,7 @@ include(../common.pri) QT += core gui -CONFIG(release, debug|release) { - TARGET = LRDemo_r1 -} else { - TARGET = LRDemo_r1d -} - +TARGET = LRDemo_r1 TEMPLATE = app SOURCES += main.cpp\ @@ -31,9 +26,27 @@ macx{ } unix:{ + LIBS += -L$${DEST_LIBS} + CONFIG(debug, debug|release) { + LIBS += -llimereportd + } else { + LIBS += -llimereport + } + + !contains(CONFIG, static_build){ + contains(CONFIG,zint){ + LIBS += -L$${DEST_LIBS} + + CONFIG(debug, debug|release) { + LIBS += -lQtZintd + } else { + LIBS += -lQtZint + } + } + } DESTDIR = $$DEST_DIR # QMAKE_POST_LINK += mkdir -p $$quote($$REPORTS_DIR) | - QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\" $$escape_expand(\n\t) + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$REPORTS_DIR) $$escape_expand(\n\t) linux{ #Link share lib to ../lib rpath @@ -47,33 +60,33 @@ unix:{ } win32 { + EXTRA_DIR ~= s,/,\\,g + DEST_DIR ~= s,/,\\,g + REPORTS_DIR ~= s,/,\\,g + DESTDIR = $$DEST_DIR - contains(QMAKE_HOST.os, Linux){ - QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\" $$escape_expand(\n\t) - } else { - EXTRA_DIR ~= s,/,\\,g - DEST_DIR ~= s,/,\\,g - REPORTS_DIR ~= s,/,\\,g - RC_FILE += mainicon.rc - QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\\demo_reports\" $$escape_expand(\\n\\t) - } -} + RC_FILE += mainicon.rc -LIBS += -L$${DEST_LIBS} -CONFIG(debug, debug|release) { - LIBS += -llimereportd -} else { - LIBS += -llimereport -} -message($$LIBS) - -!contains(CONFIG, static_build){ - contains(CONFIG,zint){ - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -lQtZintd - } else { - LIBS += -lQtZint + QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\\demo_reports\" $$escape_expand(\\n\\t) + #QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR\\*) $$quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) + !contains(CONFIG, static_build){ + + contains(CONFIG,zint){ + LIBS += -L$${DEST_LIBS} + CONFIG(debug, debug|release) { + LIBS += -lQtZintd + } else { + LIBS += -lQtZint + } } + } + + LIBS += -L$${DEST_LIBS} + CONFIG(debug, debug|release) { + LIBS += -llimereportd + } else { + LIBS += -llimereport } } + + diff --git a/demo_r1/demo_reports/change_item_from_script.lrxml b/demo_r1/demo_reports/change_item_from_script.lrxml index 301c326..6d92ba8 100644 --- a/demo_r1/demo_reports/change_item_from_script.lrxml +++ b/demo_r1/demo_reports/change_item_from_script.lrxml @@ -1,27 +1,27 @@ - + - + page1 - + - + - + ReportPage1 - + - + DataBand1 - + - + TextItem2 - + @@ -51,7 +51,7 @@ if ($D{customers.CustomerID}=="ANTON"){ - + @@ -65,13 +65,6 @@ if ($D{customers.CustomerID}=="ANTON"){ - - - - - - - @@ -85,7 +78,6 @@ if ($D{customers.CustomerID}=="ANTON"){ - customers @@ -96,16 +88,14 @@ if ($D{customers.CustomerID}=="ANTON"){ - - - + ReportHeader1 - + - + TextItem1 - + @@ -117,10 +107,10 @@ if ($D{customers.CustomerID}=="ANTON"){ $S{ -var color = LimeReport.color('#DEB887'); -var font = LimeReport.font('Times New Roman',26,false,true); +var color = new QColor('#DEB887'); +var font = new QFont('Times New Roman',26,false,true); THIS.backgroundColor = color; -THIS.fontColor = LimeReport.color('red'); +THIS.fontColor = QColor('red'); THIS.font = font; 'Test'} @@ -128,7 +118,7 @@ THIS.font = font; - + @@ -142,17 +132,10 @@ THIS.font = font; - - - - - - - - + TextItem3 - + @@ -168,7 +151,7 @@ THIS.font = font; - + @@ -182,13 +165,6 @@ THIS.font = font; - - - - - - - @@ -202,10 +178,8 @@ THIS.font = font; - - @@ -223,19 +197,13 @@ THIS.font = font; - - - - - - - + datasources - + test QSQLITE @@ -244,11 +212,10 @@ THIS.font = font; - - + customers Select * from customers limit 5 @@ -258,21 +225,18 @@ THIS.font = font; - + TestName TestValue - - - + - diff --git a/demo_r1/demo_reports/northwind.db b/demo_r1/demo_reports/northwind.db index 42a4ef6df97df487dd5ba977b839db5e50ab5192..1b7032af5dbfcf194cd48d57df6b04fb510cac38 100644 GIT binary patch delta 10045 zcmd5?O>7&-6(+f~Y{~K=Mbn^g+^)7okT|X>$v<_1m0?+;Qa1V*omNTPXi1K!jmcel zcWIkxgSAnh_NhNM0s=YpAXGW!5F=FpADV-T_S~F$DEi-^KyLwh?t8N{v;QQe*g*wQ z5_jj#yq|C0`{wQ5`sl)~k1qWD_!D2uWTd;9Ol~rh$=LAu>Mu^6fs3cJuO5PLhon#7 zclOqU(R@cbmOc42e0loIaOvb19{g82`pdkun>qC0(DwUM9xj%C{BY;a!<{UAa=QdB5h~h$=tg?G5RBEXl!Wr?d|;C94@4G$9D1;y6a|s=O^#xfA#L6<&k5k zr*tnP-Fq-GdRKCP_eORoGj{uDmu57F)J;n#wz^7MrsZ5bHX_TaS$Tt09l6|Tktt<~ zeo^F^hGyG~S`#kK>rLW~fAK}{Z_%jh23fZB>oB82XQA`Jx}V_cL)nir((k2?bRzdb zPI@N$F(~qzth=HNJ@x$axphaYG>Cnzp*!Stn_O!XqZ<91y*;y9oGusT^7Q5Tq8u6g ztO1Ih0@3GgkB%LF>iF^8?IxYnqGs9bPu2}hQr%$JH{@qWhBr#H8^fi=a`C0&s=T;V zmKU$g&&$iJrG@F$b@}Dux;%ZQyi{6*DHe*0WzWBBs? z(&droy6v&Fb1dDc zD;L#*2hWHBAcN|4q9QKJv@EmMt~$1779ArDqe@fJGP%h?FIHP4Xrp{m-n7i7%;%AB zY!QpdZ2NRdv+|Vu_1Pa*z3tRF?caFIWozQ(;Wfjth?+S_(7@)VW;?`+3Ufu&Ler%K z0xQQN?FUwjQsElddJ_P^rVa$V;19d5SvuXi@lkw`i{Of2q6Z{i(X2;=2E)USi#be$ zvrKFU5uz6GHrEj$AgkB4MmvT!6nF)1s0DgIAQE$=@CF;C7HXPvQnSsr1?g--GqgIf z=sk{M_@WlPBm)0JE`QC<{y8GRT-zrN&uWggMi*l1`1^^a^XSIFeF6IM)tE{ybq_ND zoZ^Et0SRK*zCsKMlI5U;NW1>#j)Iyy4Gjsb3~OU7qoV`+Cm!k=6sq{HSy@||cT43W z#Esq$FM__RXf{dmIpt~#WWjAaN-#50~itW(qx>NKE#kj z(70(lYWo zHd{`I3-?vq^;2S0Z(jVp9qnaxt~OU%R_zwBSV}zyTQjnosQtjxw)92~A|IMxeRIjG zLE2)QU)XZZB3gKh!q%!lnjn@P8%&ILbK0oQHMF`N@tO)Ta~ayA#-}1tbxu_-ly30L$b!JblH`9XN7T$y=1z_RafP*RxvF?D8Rr>Fy*3=uFDP`Jnb=XRB z#cb5@Mi^auCDqSNOOO+FKfO$h3q9lDPY_=)YXU!B!F55mK^*L>aG>Ofx~S-`u=M!2 zI}SfQ(y6(Xifcx_A+#4VgDAggTExrjG5@(@q8<)}lVFo3L5{9;vLc)wKHvJ6BbnB( zKk|OkEp^BNQZAMAYrI@`Y0pKRSG=>qvIcqJZ-C%IoZ}-Sj;{XT^7fxUM;IRimR@RA z61w_>i~C=FEa>X*KUY>C9lBtT^*;F`E5v%>AJ(}26rep$Zd`IQ^;AS>fM05zm`&nX z9iACip`oG3H>Z^I7cMCB7A25V$~o{2WI%UvQju?9=AKd};aW-tpL7cg{xR5G7OqX?8gFJKD>z<;$kC174DnyB<^;Grz~siQtFYKm#J+|A6xk#Ddg=G$33&^|78T zFWCIahu_ur$HcNSbrYna8ZB{UvrZg%R>6s~NG-hHL~?@a?zevdn*m!ybEXN;A@;qT z4JR-%505BT%^Ot5Q2t9)GSV<%=N(s;}{}wl}A5ADVSyO`g#$TVyM;sK)4?^^_ z5CwDv_s_X;m$J|RQr(^&5an-KuR3iD zp8V0<$(CZLD%b_=&mI!<7wF*ieBEf%m+IFSxR3|_h3{-6anb}54-6LijLcu5?7`0; zeGaa{H$awQE_jj${lb#rYz8xIkJNz*BxMb{|5Uq540yvtyo0hL&aB@ErqeUy--P4} z`IKJe`81j_)Qa6ITLg4$`TfYWCN-QtdUCrL`Zp2RG{ctH;O&XcfH zrU2aK?>J$C4q}<^I ze4Xe&2YhYl!KKl)?4A7H;UnX=J)F%{=l1e3)2C>14GH4Kj3T$X;kopsX!lA7)1Yc7W4i}sn zr0d*+-r(YJ$Nqt)e%s>G;?iK}PY4`7hwnWXF6Z1@uUP99Z{{XF0K5W_O8{`eGPn8V z84niwQHxK61Fj;6zc|Dn90UdT6djS8# zom5#(MRhi^$|^mw4jUc1?^t`Pxt2H%=2K5NRw=pb(x<$wDIeJ#>!p8=(k!_XKADKa zi=Xose=FBGnT&Yh{L0?gJNsat?2Gl)j&Z6naml&HE_`Dg7G*IOXKrXrV&mWs`a6%^ diff --git a/demo_r1/mainicon.rc b/demo_r1/mainicon.rc index ef4125c..83c0128 100644 --- a/demo_r1/mainicon.rc +++ b/demo_r1/mainicon.rc @@ -1 +1 @@ -IDI_ICON1 ICON "main.ico" +DI_ICON1 ICON "main.ico" diff --git a/demo_r1/mainwindow.cpp b/demo_r1/mainwindow.cpp index 348cbb1..afb60b4 100644 --- a/demo_r1/mainwindow.cpp +++ b/demo_r1/mainwindow.cpp @@ -37,15 +37,8 @@ #include #include #include -#include - -#ifdef BUILD_WITH_EASY_PROFILER -#include "easy/profiler.h" -#else -# define EASY_BLOCK(...) -# define EASY_END_BLOCK -# define EASY_PROFILER_ENABLE -#endif +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -77,7 +70,7 @@ MainWindow::MainWindow(QWidget *parent) : int index = m_customers->record().indexOf("CustomerID"); m_orders->bindValue(":id",m_customers->value(index)); m_orders->exec(); - } + }; } LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasource("master"); @@ -104,8 +97,8 @@ MainWindow::MainWindow(QWidget *parent) : report->dataManager()->addModel("string_list",stringListModel,true); QStringList strList; strList<<"value1"<<"value2"; - //QScriptValue value = qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList); - //report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value); + // QScriptValue value = qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList); + // report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value); } @@ -119,58 +112,35 @@ MainWindow::~MainWindow() void MainWindow::on_pushButton_clicked() { - EASY_PROFILER_ENABLE; - EASY_BLOCK("design report"); report->dataManager()->clearUserVariables(); if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()){ report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text()); + report->dataManager()->setReportVariable("SecondPage", false); } report->setShowProgressDialog(false); report->designReport(); - EASY_END_BLOCK; -#ifdef BUILD_WITH_EASY_PROFILER - profiler::dumpBlocksToFile("test.prof"); -#endif } void MainWindow::on_pushButton_2_clicked() { QString fileName = QFileDialog::getOpenFileName(this,"Select report file",QApplication::applicationDirPath()+"/demo_reports/","*.lrxml"); if (!fileName.isEmpty()) { - EASY_PROFILER_ENABLE; - EASY_BLOCK("Load file"); report->loadFromFile(fileName); - EASY_END_BLOCK; - EASY_BLOCK("Set report variable"); if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()){ report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text()); } - EASY_END_BLOCK; -#ifdef BUILD_WITH_EASY_PROFILER - profiler::dumpBlocksToFile("test.prof"); -#endif -// QPrinter* printer = new QPrinter; -// QPrintDialog dialog(printer); -// if (dialog.exec()){ -// QMap printers; -// printers.insert("default",printer); -// report->printReport(printers); -// } - report->setShowProgressDialog(true); report->previewReport(); } } void MainWindow::renderStarted() { - if (report->isShowProgressDialog()){ - m_currentPage = 0; - m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this); - //m_progressDialog->setWindowModality(Qt::WindowModal); - connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender())); - QApplication::processEvents(); - m_progressDialog->show(); - } + m_currentPage = 0; + m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this); + m_progressDialog->setWindowModality(Qt::WindowModal); + connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender())); + m_progressDialog->show(); + QApplication::processEvents(); } void MainWindow::renderPageFinished(int renderedPageCount) @@ -272,5 +242,28 @@ void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data) } break; default: break; - } + } +} + +void MainWindow::slotOnSave(bool& saved) +{ + QSqlQuery reports; + reports.prepare("Update reports set Content = ? where ReportName = ?"); + reports.bindValue(0, report->saveToByteArray()); + reports.bindValue(1,report->reportName()); + if (!reports.exec()) qDebug() << reports.lastError(); + saved = true; + m_db.commit(); +} + +void MainWindow::on_pushButton_3_clicked() +{ + QSqlQuery reports("Select ReportName, Content from reports limit 1",m_db); + reports.first(); + QByteArray source = reports.value(1).toByteArray(); + report->loadFromByteArray(&source); + report->setReportName(reports.value(0).toString()); + connect(report, SIGNAL(onSave(bool&)), this, SLOT(slotOnSave(bool&))); + report->designReport(); + disconnect(report,SIGNAL(onSave(bool&)), this, SLOT(slotOnSave(bool&))); } diff --git a/demo_r1/mainwindow.h b/demo_r1/mainwindow.h index e8d7ff1..fe2fe8d 100644 --- a/demo_r1/mainwindow.h +++ b/demo_r1/mainwindow.h @@ -58,6 +58,9 @@ private slots: void slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data); void slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant& data); + void slotOnSave(bool &saved); + void on_pushButton_3_clicked(); + private: void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data); private: diff --git a/demo_r1/mainwindow.ui b/demo_r1/mainwindow.ui index 52eebe9..ab4c0aa 100644 --- a/demo_r1/mainwindow.ui +++ b/demo_r1/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 369 - 192 + 426 + 214 @@ -185,6 +185,43 @@ + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Load from Database + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/demo_r2/mainwindow.cpp b/demo_r2/mainwindow.cpp index 6f2aa7b..a0f6d34 100644 --- a/demo_r2/mainwindow.cpp +++ b/demo_r2/mainwindow.cpp @@ -3,7 +3,12 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3) #include +#endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +#include +#endif MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -40,11 +45,14 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionOne_to_One, SIGNAL(triggered()), this, SLOT(slotOneToOne())); initPercentCombobox(); enableUI(false); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + int screenWidth = QGuiApplication::primaryScreen()->geometry().width(); + int screenHeight = QGuiApplication::primaryScreen()->geometry().height(); +#else QDesktopWidget *desktop = QApplication::desktop(); - int screenWidth = desktop->screenGeometry().width(); int screenHeight = desktop->screenGeometry().height(); - +#endif int x = screenWidth*0.1; int y = screenHeight*0.1; diff --git a/include/lrglobal.h b/include/lrglobal.h index 8a312d8..6a0e14e 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -34,6 +34,7 @@ #include #include #include +#include #if defined(LIMEREPORT_EXPORTS) # define LIMEREPORT_EXPORT Q_DECL_EXPORT @@ -51,6 +52,12 @@ namespace LimeReport { #define VARIABLE_IS_NOT_USED #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +typedef QRegularExpression LRRegularExpression; +#else +typedef QRegExp LRRegularExpression; +#endif + #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) Q_NAMESPACE #endif diff --git a/limereport/databrowser/lrdatabrowser.cpp b/limereport/databrowser/lrdatabrowser.cpp index d475826..c24766f 100644 --- a/limereport/databrowser/lrdatabrowser.cpp +++ b/limereport/databrowser/lrdatabrowser.cpp @@ -62,9 +62,16 @@ DataBrowser::DataBrowser(QWidget *parent) : connect(ui->deleteDataSource,SIGNAL(clicked()),this,SLOT(slotDeleteDatasource())); connect(ui->changeConnection,SIGNAL(clicked()),this,SLOT(slotChangeConnection())); connect(ui->pbConnect,SIGNAL(clicked()),this,SLOT(slotChangeConnectionState())); - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + ui->verticalLayout_2->setContentsMargins( + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS + ); +#else ui->verticalLayout_2->setMargin(Const::DOCKWIDGET_MARGINS); - +#endif ui->dataTree->setHeaderLabel(tr("Datasources")); ui->pbConnect->setEnabled(false); } diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp index e0d88ed..302cc66 100644 --- a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp @@ -50,18 +50,23 @@ FormResizer::FormResizer(QWidget *parent) : m_frame(new QFrame), m_formWindow(0) { - // Make the resize grip of a mainwindow form find us as resizable window. setWindowFlags(windowFlags() | Qt::SubWindow); setBackgroundRole(QPalette::Base); QVBoxLayout *handleLayout = new QVBoxLayout(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + handleLayout->setContentsMargins( + SELECTION_MARGIN, + SELECTION_MARGIN, + SELECTION_MARGIN, + SELECTION_MARGIN + ); +#else handleLayout->setMargin(SELECTION_MARGIN); +#endif handleLayout->addWidget(m_frame); m_frame->setFrameStyle(QFrame::Panel | QFrame::Raised); - QVBoxLayout *layout = new QVBoxLayout(m_frame); - layout->setMargin(0); - // handles m_handles.reserve(SizeHandleRect::Left); for (int i = SizeHandleRect::LeftTop; i <= SizeHandleRect::Left; ++i) { SizeHandleRect *shr = new SizeHandleRect(this, static_cast(i), this); diff --git a/limereport/items/charts/lrhorizontalbarchart.cpp b/limereport/items/charts/lrhorizontalbarchart.cpp index 3d539d9..c0af19f 100644 --- a/limereport/items/charts/lrhorizontalbarchart.cpp +++ b/limereport/items/charts/lrhorizontalbarchart.cpp @@ -36,7 +36,11 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect) delta = genNextValue(delta); qreal vStep = (barsRect.height()-painter->fontMetrics().height()) / valuesCount() / seriesCount(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + qreal hStep = (barsRect.width()-painter->fontMetrics().horizontalAdvance(QString::number(maxValue()))) / delta; +#else qreal hStep = (barsRect.width()-painter->fontMetrics().width(QString::number(maxValue()))) / delta; +#endif if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){ int curSeries = 0; diff --git a/limereport/items/charts/lrpiechart.cpp b/limereport/items/charts/lrpiechart.cpp index d6afb0c..a9c886d 100644 --- a/limereport/items/charts/lrpiechart.cpp +++ b/limereport/items/charts/lrpiechart.cpp @@ -14,7 +14,13 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle #ifdef HAVE_QT5 qreal radAngle = qDegreesToRadians(angle/2+startAngle); #endif + +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + qreal radius = painter->fontMetrics().horizontalAdvance("99,9%"); +#else qreal radius = painter->fontMetrics().width("99,9%"); +#endif + qreal border = chartRect.height()*0.02; qreal length = (chartRect.height())/2-(radius/2+border); qreal x,y; @@ -155,14 +161,24 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font) SeriesItem* si = m_chartItem->series().at(0); foreach(QString label, si->data()->labels()){ cw += fm.height(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + if (maxWidth= QT_VERSION_CHECK(5, 12, 3) + if (maxWidthsetModel(&m_fontSizeModel); m_fontSizeEditor->setEditable(true); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + connect(m_fontSizeEditor,SIGNAL(currentTextChanged(QString)), this, SLOT(slotFontSizeChanged(QString))); +#else connect(m_fontSizeEditor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotFontSizeChanged(QString))); +#endif addWidget(m_fontSizeEditor); addSeparator(); diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index 15f76fa..7b410d2 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -348,7 +348,11 @@ void ChartItem::paintChartTitle(QPainter *painter, QRectF titleRect) painter->save(); QFont tmpFont = painter->font(); QFontMetrics fm(tmpFont); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + while ((fm.height()>titleRect.height() || fm.horizontalAdvance(m_title) > titleRect.width()) +#else while ((fm.height()>titleRect.height() || fm.width(m_title)>titleRect.width()) +#endif && tmpFont.pixelSize()>1) { tmpFont.setPixelSize(tmpFont.pixelSize()-1); fm = QFontMetrics(tmpFont); @@ -566,7 +570,21 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font) qreal cw = 0; qreal maxWidth = 0; - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + if (!m_chartItem->series().isEmpty()){ + foreach(SeriesItem* series, m_chartItem->series()){ + cw += fm.height(); + if (maxWidthname())) + maxWidth = fm.horizontalAdvance(series->name())+10; + } + } else { + foreach(QString label, m_designLabels){ + cw += fm.height(); + if (maxWidthseries().isEmpty()){ foreach(SeriesItem* series, m_chartItem->series()){ cw += fm.height(); @@ -580,6 +598,7 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font) maxWidth = fm.width(label)+10; } } +#endif cw += fm.height(); return QSizeF(maxWidth+fm.height()*2,cw); } @@ -591,9 +610,16 @@ bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect) qreal hStep = (labelsRect.width() / valuesCount()); QFontMetrics fm = painter->fontMetrics(); foreach(QString label, m_chartItem->labels()){ - if (fm.width(label) > hStep){ +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + if (fm.horizontalAdvance(label) > hStep){ return true; } +#else + if (fm.width(label) > hStep){ + return true; + } +#endif + } return false; } @@ -656,7 +682,11 @@ void AbstractSeriesChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect delta = genNextValue(delta); painter->setRenderHint(QPainter::Antialiasing,false); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + qreal hStep = (gridRect.width() - painter->fontMetrics().horizontalAdvance(QString::number(maxValue()))) / 4; +#else qreal hStep = (gridRect.width() - painter->fontMetrics().width(QString::number(maxValue()))) / 4; +#endif painter->setFont(adaptValuesFont(hStep-4, painter->font())); @@ -708,7 +738,11 @@ qreal AbstractSeriesChart::valuesHMargin(QPainter *painter) { int delta = int(maxValue()-minValue()); delta = genNextValue(delta); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + return painter->fontMetrics().horizontalAdvance(QString::number(delta))+4; +#else return painter->fontMetrics().width(QString::number(delta))+4; +#endif } qreal AbstractSeriesChart::valuesVMargin(QPainter *painter) @@ -720,9 +754,23 @@ QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font) { QString maxWord; QFontMetrics fm(font); - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) foreach(QString label, m_chartItem->labels()){ - foreach (QString currentWord, label.split(QRegExp("\\W+"))){ + foreach (QString currentWord, label.split(LRRegularExpression("\\W+"))){ + if (fm.horizontalAdvance(maxWord) < fm.horizontalAdvance(currentWord)) maxWord = currentWord; + } + } + + qreal curWidth = fm.horizontalAdvance(maxWord); + QFont tmpFont = font; + while (curWidth>rect.width() && tmpFont.pixelSize() > 1){ + tmpFont.setPixelSize(tmpFont.pixelSize() - 1); + QFontMetricsF tmpFM(tmpFont); + curWidth = tmpFM.horizontalAdvance(maxWord); + } +#else + foreach(QString label, m_chartItem->labels()){ + foreach (QString currentWord, label.split(LRRegularExpression("\\W+"))){ if (fm.width(maxWord) < fm.width(currentWord)) maxWord = currentWord; } } @@ -734,6 +782,7 @@ QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font) QFontMetricsF tmpFM(tmpFont); curWidth = tmpFM.width(maxWord); } +#endif return tmpFont; } @@ -741,6 +790,15 @@ QFont AbstractSeriesChart::adaptValuesFont(qreal width, QFont font) { QString strValue = QString::number(maxValue()); QFont tmpFont = font; +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QScopedPointer fm(new QFontMetricsF(tmpFont)); + qreal curWidth = fm->horizontalAdvance(strValue); + while (curWidth > width && tmpFont.pixelSize() > 1){ + tmpFont.setPixelSize(tmpFont.pixelSize() - 1); + fm.reset(new QFontMetricsF(tmpFont)); + curWidth = fm->horizontalAdvance(strValue); + } +#else QScopedPointer fm(new QFontMetricsF(tmpFont)); qreal curWidth = fm->width(strValue); while (curWidth > width && tmpFont.pixelSize() > 1){ @@ -748,6 +806,7 @@ QFont AbstractSeriesChart::adaptValuesFont(qreal width, QFont font) fm.reset(new QFontMetricsF(tmpFont)); curWidth = fm->width(strValue); } +#endif return tmpFont; } @@ -801,11 +860,17 @@ void AbstractBarChart::paintChartLegend(QPainter *painter, QRectF legendRect) QRectF AbstractBarChart::verticalLabelsRect(QPainter *painter, QRectF labelsRect) { qreal maxWidth = 0; - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + foreach (QString label, m_chartItem->labels()) { + if (painter->fontMetrics().horizontalAdvance(label)>maxWidth) + maxWidth = painter->fontMetrics().horizontalAdvance(label); + } +#else foreach (QString label, m_chartItem->labels()) { if (painter->fontMetrics().width(label)>maxWidth) maxWidth = painter->fontMetrics().width(label); } +#endif if (maxWidth + hPadding(m_chartItem->rect()) * 2 < labelsRect.width()) return labelsRect; @@ -816,12 +881,17 @@ QRectF AbstractBarChart::verticalLabelsRect(QPainter *painter, QRectF labelsRect QRectF AbstractBarChart::horizontalLabelsRect(QPainter *painter, QRectF labelsRect) { qreal maxWidth = 0; - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + foreach (QString label, m_chartItem->labels()) { + if (painter->fontMetrics().horizontalAdvance(label)>maxWidth) + maxWidth = painter->fontMetrics().horizontalAdvance(label); + } +#else foreach (QString label, m_chartItem->labels()) { if (painter->fontMetrics().width(label)>maxWidth) maxWidth = painter->fontMetrics().width(label); } - +#endif if ((maxWidth + vPadding(m_chartItem->rect()) < labelsRect.height()) || !verticalLabels(painter, labelsRect)) return labelsRect; else diff --git a/limereport/items/lrchartitemeditor.cpp b/limereport/items/lrchartitemeditor.cpp index 92ea3fb..dc00e0b 100644 --- a/limereport/items/lrchartitemeditor.cpp +++ b/limereport/items/lrchartitemeditor.cpp @@ -10,7 +10,11 @@ ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDe { ui->setupUi(this); QHBoxLayout* colorLayout = new QHBoxLayout(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + colorLayout->setContentsMargins(0, 0, 0, 0); +#else colorLayout->setMargin(0); +#endif m_colorButton = new QToolButton(); m_colorButton->setText("..."); m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 50de9d5..b1eb3bd 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -38,7 +38,7 @@ #include "lrdesignelementsfactory.h" #include "lrglobal.h" #include "lrdatasourcemanager.h" -#include "lrsimpletagparser.h" +//#include "lrsimpletagparser.h" #include "lrtextitemeditor.h" #include "lrreportengine_p.h" #include @@ -59,7 +59,7 @@ namespace LimeReport{ TextItem::TextItem(QObject *owner, QGraphicsItem *parent) : ContentItemDesignIntf(xmlTag,owner,parent), m_angle(Angle0), m_trimValue(true), m_allowHTML(false), m_allowHTMLInFields(false), m_replaceCarriageReturns(false), m_followTo(""), m_follower(0), m_textIndent(0), - m_textLayoutDirection(Qt::LayoutDirectionAuto), m_hideIfEmpty(false), m_fontLetterSpacing(0) + m_textLayoutDirection(Qt::LayoutDirectionAuto), m_hideIfEmpty(false), m_fontLetterSpacing(0), m_adaptedFont(0) { PageItemDesignIntf* pageItem = dynamic_cast(parent); BaseDesignIntf* parentItem = dynamic_cast(parent); @@ -75,7 +75,9 @@ TextItem::TextItem(QObject *owner, QGraphicsItem *parent) Init(); } -TextItem::~TextItem(){} +TextItem::~TextItem(){ + if (m_adaptedFont) delete m_adaptedFont; +} int TextItem::fakeMarginSize() const{ return marginSize()+5; @@ -360,8 +362,14 @@ void TextItem::updateLayout() bool TextItem::isNeedExpandContent() const { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QRegularExpression rx("\\$[S|V|D]\\s*\\{[^{].*\\}"); + rx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); +#else QRegExp rx("$*\\{[^{]*\\}"); - return content().contains(rx) || isContentBackedUp(); +#endif + bool result = content().contains(rx) || isContentBackedUp(); + return result; } QString TextItem::replaceBR(QString text) const @@ -448,7 +456,7 @@ QString TextItem::formatNumber(const double value) if (m_format.contains("%")) { - str.sprintf(m_format.toStdString().c_str(), value); + str.asprintf(m_format.toStdString().c_str(), value); str = str.replace(",", QLocale::system().groupSeparator()); str = str.replace(".", QLocale::system().decimalPoint()); } @@ -522,7 +530,12 @@ TextItem::TextPtr TextItem::textDocument() const QFont _font = transformToSceneFont(font()); if (m_adaptFontToSize && (!(m_autoHeight || m_autoWidth))){ - adaptFontSize(text); + if (!m_adaptedFont){ + adaptFontSize(text); + m_adaptedFont = new QFont(text->defaultFont()); + } else { + setTextFont(text, *m_adaptedFont); + } } else { setTextFont(text,_font); } @@ -779,7 +792,12 @@ void TextItem::setTrimValue(bool value) void TextItem::geometryChangedEvent(QRectF , QRectF) -{} +{ + if (m_adaptedFont){ + delete m_adaptedFont; + m_adaptedFont = 0; + } +} bool TextItem::isNeedUpdateSize(RenderPass pass) const { @@ -813,7 +831,11 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass) { QString context=content(); foreach (QString variableName, dataManager->variableNamesByRenderPass(SecondPass)) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); +#else QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); +#endif if (context.contains(rx) && pass == FirstPass){ backupContent(); break; diff --git a/limereport/items/lrtextitem.h b/limereport/items/lrtextitem.h index fbd2bfd..5ee3a3a 100644 --- a/limereport/items/lrtextitem.h +++ b/limereport/items/lrtextitem.h @@ -232,6 +232,7 @@ private: Qt::LayoutDirection m_textLayoutDirection; bool m_hideIfEmpty; int m_fontLetterSpacing; + QFont mutable *m_adaptedFont; }; } diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 68ad8e7..f152147 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -42,7 +42,7 @@ SOURCES += \ $$REPORT_PATH/items/editors/lrfonteditorwidget.cpp \ $$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.cpp \ $$REPORT_PATH/items/editors/lritemsborderseditorwidget.cpp \ - $$REPORT_PATH/items/lrsimpletagparser.cpp \ +# $$REPORT_PATH/items/lrsimpletagparser.cpp \ $$REPORT_PATH/items/lrimageitem.cpp \ $$REPORT_PATH/items/lrimageitemeditor.cpp \ $$REPORT_PATH/items/lrtextitemeditor.cpp \ @@ -137,7 +137,7 @@ HEADERS += \ $$REPORT_PATH/items/lrshapeitem.h \ $$REPORT_PATH/items/lrimageitem.h \ $$REPORT_PATH/items/lrimageitemeditor.h \ - $$REPORT_PATH/items/lrsimpletagparser.h \ +# $$REPORT_PATH/items/lrsimpletagparser.h \ $$REPORT_PATH/items/lrverticallayout.h \ $$REPORT_PATH/items/lrlayoutmarker.h \ $$REPORT_PATH/items/lrabstractlayout.h \ diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 008e9a6..7bf0c10 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -260,7 +260,11 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op QFontMetrics fontMetrics(font); QVector bandNameRects; - bandNameRects.push_back(QRectF(8,8,fontMetrics.width(" "+bandText+" "),fontMetrics.height())); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + bandNameRects.push_back(QRectF(8,8,fontMetrics.horizontalAdvance(" "+bandText+" "), fontMetrics.height())); +#else + bandNameRects.push_back(QRectF(8,8,fontMetrics.width(" "+bandText+" "), fontMetrics.height())); +#endif //bandNameRects.push_back(QRectF(width()-fontMetrics.width(" "+bandText+" "),2,fontMetrics.width(" "+bandText+" "),fontMetrics.height())); //bandNameRects.push_back(QRectF(2,height()-fontMetrics.height(),fontMetrics.width(" "+bandText+" "),fontMetrics.height())); //bandNameRects.push_back(QRectF(width()-fontMetrics.width(" "+bandText+" "),height()-fontMetrics.height(),fontMetrics.width(" "+bandText+" "),fontMetrics.height())); @@ -1209,11 +1213,19 @@ void BandNameLabel::updateLabel(const QString& bandName) QFont font("Arial",7*Const::fontFACTOR,-1,true); QFontMetrics fontMetrics(font); prepareGeometryChange(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) m_rect = QRectF( - m_band->pos().x()+10, - m_band->pos().y()-(fontMetrics.height()+10), - fontMetrics.width(bandName)+20,fontMetrics.height()+10 + m_band->pos().x() + 10, + m_band->pos().y() - (fontMetrics.height() + 10), + fontMetrics.horizontalAdvance(bandName) + 20, fontMetrics.height() + 10 ); +#else + m_rect = QRectF( + m_band->pos().x() + 10, + m_band->pos().y() - (fontMetrics.height()+10), + fontMetrics.width(bandName) + 20, fontMetrics.height() + 10 + ); +#endif update(); } diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index 668aa71..9bc290c 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -421,8 +421,27 @@ QString DataSourceManager::extractField(QString source) } QString DataSourceManager::replaceVariables(QString value){ - QRegExp rx(Const::VARIABLE_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QRegularExpression rx(Const::VARIABLE_RX); + if (value.contains(rx)){ + int pos = -1; + QRegularExpressionMatch match = rx.match(value); + while ((pos=match.capturedStart())!=-1){ + QString var=match.captured(0); + var.remove("$V{"); + var.remove("}"); + + if (variable(var).isValid()){ + value.replace(pos,match.captured(0).length(),variable(var).toString()); + } else { + value.replace(pos,match.captured(0).length(),QString(tr("Variable \"%1\" not found!").arg(var))); + } + match = rx.match(value); + } + } +#else + QRegExp rx(Const::VARIABLE_RX); if (value.contains(rx)){ int pos = -1; while ((pos=rx.indexIn(value))!=-1){ @@ -437,11 +456,53 @@ QString DataSourceManager::replaceVariables(QString value){ } } } +#endif return value; } QString DataSourceManager::replaceVariables(QString query, QMap &aliasesToParam) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QRegularExpression rx(Const::VARIABLE_RX); + int curentAliasIndex = 0; + if (query.contains(rx)){ + int pos = -1; + QRegularExpressionMatch match = rx.match(query); + while ((pos=match.capturedStart())!=-1){ + + QString var=match.captured(0); + var.remove("$V{"); + var.remove("}"); + if (!match.captured(1).isEmpty()){ + if (aliasesToParam.contains(var)){ + curentAliasIndex++; + aliasesToParam.insert(var+"_v_alias"+QString::number(curentAliasIndex),var); + var += "_v_alias"+QString::number(curentAliasIndex); + } else { + aliasesToParam.insert(var,var); + } + query.replace(pos,match.captured(0).length(),":"+var); + } else { + QString varName = match.captured(2).trimmed(); + QString varParam = match.captured(3).trimmed(); + if (!varName.isEmpty()){ + if (!varParam.isEmpty() && varParam.compare("nobind") == 0 ){ + query.replace(pos,match.captured(0).length(), variable(varName).toString()); + } else { + query.replace(pos,match.captured(0).length(), + QString(tr("Unknown parameter \"%1\" for variable \"%2\" found!") + .arg(varName) + .arg(varParam)) + ); + } + } else { + query.replace(pos,match.captured(0).length(),QString(tr("Variable \"%1\" not found!").arg(var))); + } + } + match = rx.match(query); + } + } +#else QRegExp rx(Const::VARIABLE_RX); int curentAliasIndex = 0; if (query.contains(rx)){ @@ -479,9 +540,44 @@ QString DataSourceManager::replaceVariables(QString query, QMap } } } +#endif return query; } +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +QString DataSourceManager::replaceFields(QString query, QMap &aliasesToParam, QString masterDatasource) +{ + QRegularExpression rx(Const::FIELD_RX); + if (query.contains(rx)){ + int curentAliasIndex = 0; + int pos=-1; + QRegularExpressionMatch match = rx.match(query); + while (match.hasMatch()){ + pos = match.capturedStart(); + QString field=match.captured(0); + field.remove("$D{"); + field.remove("}"); + + if (!aliasesToParam.contains(field)){ + if (field.contains(".")) + aliasesToParam.insert(field, field); + else + aliasesToParam.insert(field, masterDatasource + "." + field); + } else { + curentAliasIndex++; + if (field.contains(".")) + aliasesToParam.insert(field + "_f_alias" + QString::number(curentAliasIndex), field); + else + aliasesToParam.insert(field + "_f_alias" + QString::number(curentAliasIndex), masterDatasource + "." + field); + field += "_f_alias" + QString::number(curentAliasIndex); + } + query.replace(pos, match.captured(0).length(), ":" + extractField(field)); + match = rx.match(query); + } + } + return query; +} +#else QString DataSourceManager::replaceFields(QString query, QMap &aliasesToParam, QString masterDatasource) { QRegExp rx(Const::FIELD_RX); @@ -511,6 +607,7 @@ QString DataSourceManager::replaceFields(QString query, QMap &a } return query; } +#endif void DataSourceManager::setReportVariable(const QString &name, const QVariant &value) { @@ -1012,7 +1109,7 @@ void DataSourceManager::disconnectConnection(const QString& connectionName) if (isQuery(datasourceName) || isSubQuery(datasourceName)){ QueryHolder* qh = dynamic_cast(dataSourceHolder(datasourceName)); if (qh && qh->connectionName().compare(connectionName,Qt::CaseInsensitive)==0){ - qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE); + qh->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE, true); qh->setLastError(tr("invalid connection")); } } @@ -1392,7 +1489,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl foreach (const QString& datasourceName, dataSourceNames()){ QueryHolder* holder = dynamic_cast(m_datasources.value(datasourceName)); if (holder){ - QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); + LRRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); if (holder->queryText().contains(rx)){ holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE); datasources.append(datasourceName); @@ -1437,13 +1534,13 @@ void DataSourceManager::clear(ClearMethod method) case All: invalidateLinkedDatasources(dit.key()); delete dit.value(); - m_datasources.erase(dit++); + dit = m_datasources.erase(dit); break; default: if (owned){ invalidateLinkedDatasources(dit.key()); delete dit.value(); - m_datasources.erase(dit++); + dit = m_datasources.erase(dit); } else { ++dit; } @@ -1467,8 +1564,7 @@ void DataSourceManager::clear(ClearMethod method) m_queries.clear(); m_subqueries.clear(); m_proxies.clear(); -// if (method == All) -// clearUserVariables(); + clearReportVariables(); emit cleared(); diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index 8a312d8..6a0e14e 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -34,6 +34,7 @@ #include #include #include +#include #if defined(LIMEREPORT_EXPORTS) # define LIMEREPORT_EXPORT Q_DECL_EXPORT @@ -51,6 +52,12 @@ namespace LimeReport { #define VARIABLE_IS_NOT_USED #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +typedef QRegularExpression LRRegularExpression; +#else +typedef QRegExp LRRegularExpression; +#endif + #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) Q_NAMESPACE #endif diff --git a/limereport/lrgraphicsviewzoom.cpp b/limereport/lrgraphicsviewzoom.cpp index 89ae87e..77c50b8 100644 --- a/limereport/lrgraphicsviewzoom.cpp +++ b/limereport/lrgraphicsviewzoom.cpp @@ -53,12 +53,21 @@ bool GraphicsViewZoomer::eventFilter(QObject *object, QEvent *event) { } else if (event->type() == QEvent::Wheel) { QWheelEvent* wheel_event = static_cast(event); if (QApplication::keyboardModifiers() == m_modifiers) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + if (wheel_event->angleDelta().x() != 0) { + double angle = wheel_event->angleDelta().x(); + double factor = qPow(m_zoomFactorBase, angle); + gentleZoom(factor); + return true; + } +#else if (wheel_event->orientation() == Qt::Vertical) { double angle = wheel_event->delta(); double factor = qPow(m_zoomFactorBase, angle); gentleZoom(factor); return true; } +#endif } } Q_UNUSED(object) diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index b767128..7535caf 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -770,7 +770,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event) BaseDesignIntf* item = addReportItem("TextItem",event->scenePos(),QSize(250, 50)); TextItem* ti = dynamic_cast(item); QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1); - if (isVar) data = data.remove(QRegExp(" \\[.*\\]")); + if (isVar) data = data.remove(LRRegularExpression(" \\[.*\\]")); ti->setContent(data); if (!isVar){ BandDesignIntf* parentBand = dynamic_cast(ti->parentItem()); diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index f37f829..acea520 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -143,7 +143,11 @@ void PreviewReportWidget::initPreview() { if (ui->graphicsView->scene()!=d_ptr->m_previewPage) ui->graphicsView->setScene(d_ptr->m_previewPage); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + ui->graphicsView->resetTransform(); +#else ui->graphicsView->resetMatrix(); +#endif ui->graphicsView->centerOn(0, 0); ui->graphicsView->scene()->setBackgroundBrush(QColor(m_previewPageBackgroundColor)); setScalePercent(d_ptr->m_scalePercent); @@ -309,7 +313,11 @@ void PreviewReportWidget::saveToFile() void PreviewReportWidget::setScalePercent(int percent) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + ui->graphicsView->resetTransform(); +#else ui->graphicsView->resetMatrix(); +#endif d_ptr->m_scalePercent = percent; qreal scaleSize = percent/100.0; ui->graphicsView->scale(scaleSize, scaleSize); @@ -469,7 +477,11 @@ void PreviewReportWidget::reportEngineDestroyed(QObject *object) void PreviewReportWidget::slotZoomed(double ) { - d_ptr->m_scalePercent = ui->graphicsView->matrix().m11()*100; +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + d_ptr->m_scalePercent = ui->graphicsView->transform().m11() * 100; +#else + d_ptr->m_scalePercent = ui->graphicsView->matrix().m11() * 100; +#endif emit scalePercentChanged(d_ptr->m_scalePercent); } diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index 6517b78..d483e69 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -41,7 +41,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3) #include +#endif #include #include #include @@ -57,7 +59,11 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent, m_progressWidget = new QWidget(ui->statusbar); QHBoxLayout* progressLayout = new QHBoxLayout(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + progressLayout->setContentsMargins(0, 0, 0, 0); +#else progressLayout->setMargin(0); +#endif progressLayout->addWidget(new QLabel(tr("Printing"))); m_progressBar = new QProgressBar(ui->statusbar); m_progressBar->setMaximumWidth(100); @@ -139,10 +145,14 @@ void PreviewReportWindow::restoreSetting() if (v.isValid()){ restoreGeometry(v.toByteArray()); } else { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + int screenWidth = QGuiApplication::primaryScreen()->geometry().width(); + int screenHeight = QGuiApplication::primaryScreen()->geometry().height(); +#else QDesktopWidget *desktop = QApplication::desktop(); - int screenWidth = desktop->screenGeometry().width(); int screenHeight = desktop->screenGeometry().height(); +#endif int x = static_cast(screenWidth*0.1); int y = static_cast(screenHeight*0.1); diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index acd6298..e8093b1 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -1057,9 +1057,14 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::Wheel){ QWheelEvent* we = dynamic_cast(event); - if (QApplication::keyboardModifiers()==Qt::ControlModifier){ - if(we->delta()<0) scale(1.2,1.2); + if (QApplication::keyboardModifiers()==Qt::ControlModifier){ +#if QT_VERSION >= 0x060000 + if (we->pixelDelta().x()<0) scale(1.2,1.2); else scale(1/1.2,1/1.2); +#else + if (we->delta()<0) scale(1.2,1.2); + else scale(1/1.2,1/1.2); +#endif } } return QWidget::eventFilter(target,event); @@ -1134,8 +1139,14 @@ void Ruler::paintEvent(QPaintEvent *event){ painter.setBrush(palette().background()); painter.setPen(Qt::NoPen); painter.drawRect(event->rect()); -// painter.setPen(palette().foreground().color()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QColor foregroundColor = palette().windowText().color(); + QColor backgroundColor = palette().window().color(); +#else + QColor foregroundColor = palette().foreground().color(); + QColor backgroundColor = palette().background().color(); +#endif if (m_page){ qreal rulerWidth = m_page->geometry().width() / m_page->unitFactor(); qreal rulerHeight = m_page->geometry().height() / m_page->unitFactor(); @@ -1153,13 +1164,13 @@ void Ruler::paintEvent(QPaintEvent *event){ case Horizontal: painter.setPen(Qt::NoPen); - if (isColorDark(palette().background().color())) + if (isColorDark(backgroundColor)) painter.setBrush(QColor("#64893d")); else painter.setBrush(QColor("#b5da91")); drawItemWithChildren(&painter, m_page); - painter.setPen(palette().foreground().color()); + painter.setPen(foregroundColor); for (int i = 0; i < rulerWidth / 10; ++i){ int hs10 = view->mapFromScene(QPointF(m_page->geometry().topLeft().x() + i * 10 * m_page->unitFactor(), 0)).x(); @@ -1172,24 +1183,31 @@ void Ruler::paintEvent(QPaintEvent *event){ painter.drawLine(hs10, 15, hs10, 20); painter.drawLine(hs5, 10, hs5, 20); if ( i > 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + painter.drawText(QPoint(hs10 - (painter.fontMetrics().horizontalAdvance(QString::number(i))/2), 12), + QString::number(i)); +#else painter.drawText(QPoint(hs10 - (painter.fontMetrics().width(QString::number(i))/2), 12), QString::number(i)); +#endif } } - painter.setPen(palette().foreground().color()); + + painter.setPen(foregroundColor); painter.drawLine(m_mousePos.x() - (hStartPos > 0 ? hStartPos : 0) , 0, m_mousePos.x() - (hStartPos > 0 ? hStartPos : 0) , 20); break; case Vertical: painter.setPen(Qt::NoPen); - if (isColorDark(palette().background().color())) + if (isColorDark(backgroundColor)) painter.setBrush(QColor("#64893d")); else painter.setBrush(QColor("#b5da91")); drawItemWithChildren(&painter, m_page); - painter.setPen(palette().foreground().color()); + painter.setPen(foregroundColor); + for (int i = 0; i < rulerHeight / 10; ++i){ int vs10 = view->mapFromScene(QPointF(0, m_page->geometry().topLeft().y()+i * 10 * m_page->unitFactor())).y(); int vs5 = view->mapFromScene(QPointF(0, m_page->geometry().topLeft().y()+i * 10 * m_page->unitFactor() + 5 * m_page->unitFactor())).y(); @@ -1199,13 +1217,19 @@ void Ruler::paintEvent(QPaintEvent *event){ vs5 -= vStartPos; } painter.drawLine(15, vs10, 20, vs10); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + if ( i > 0 ) + painter.drawText(QPoint( (15 - painter.fontMetrics().horizontalAdvance(QString::number(i))) / 2 , + vs10 + (painter.fontMetrics().height()/2)), QString::number(i)); +#else if ( i > 0 ) painter.drawText(QPoint( (15 - painter.fontMetrics().width(QString::number(i))) / 2 , vs10 + (painter.fontMetrics().height()/2)), QString::number(i)); +#endif painter.drawLine(10, vs5, 20, vs5); } } - painter.setPen(palette().foreground().color()); + painter.setPen(foregroundColor); painter.drawLine(0, m_mousePos.y() - (vStartPos > 0 ? vStartPos : 0), 20, m_mousePos.y() - (vStartPos > 0 ? vStartPos : 0)); break; diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index d863ee9..607e5d9 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -39,7 +39,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3) #include +#endif #include #include #include @@ -69,7 +71,12 @@ void ReportDesignWindow::createProgressBar() { m_progressWidget = new QWidget(m_statusBar); QHBoxLayout* progressLayout = new QHBoxLayout(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + progressLayout->setContentsMargins(0, 0, 0, 0); +#else progressLayout->setMargin(0); +#endif + m_progressLabel = new QLabel(tr("Rendered %1 pages").arg(0)); progressLayout->addWidget(m_progressLabel); m_progressBar = new QProgressBar(m_statusBar); @@ -497,8 +504,11 @@ void ReportDesignWindow::createBandsButton() connect(m_newTearOffBand,SIGNAL(triggered()),m_bandsAddSignalsMap,SLOT(map())); m_bandsAddSignalsMap->setMapping(m_newTearOffBand,BandDesignIntf::TearOffBand); m_newBandButton->addAction(m_newTearOffBand); - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + connect(m_bandsAddSignalsMap,SIGNAL(mappedInt(int)),this,SLOT(slotNewBand(int))); +#else connect(m_bandsAddSignalsMap,SIGNAL(mapped(int)),this,SLOT(slotNewBand(int))); +#endif } void ReportDesignWindow::createMainMenu() @@ -525,7 +535,11 @@ void ReportDesignWindow::createMainMenu() m_infoMenu->addAction(m_aboutAction); m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent Files")); m_recentFilesSignalMap = new QSignalMapper(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + connect(m_recentFilesSignalMap,SIGNAL(mappedString(QString)),this,SLOT(slotLoadRecentFile(QString))); +#else connect(m_recentFilesSignalMap,SIGNAL(mapped(QString)),this,SLOT(slotLoadRecentFile(QString))); +#endif m_recentFilesMenu->setDisabled(m_recentFiles.isEmpty()); } @@ -566,7 +580,11 @@ void ReportDesignWindow::createObjectInspector() QWidget* w = new QWidget(objectDoc); QVBoxLayout* l = new QVBoxLayout(w); l->addWidget(m_objectInspector); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + l->setContentsMargins(0, 0, 0, 0); +#else l->setMargin(0); +#endif w->setLayout(l); objectDoc->setWindowTitle(tr("Object Inspector")); objectDoc->setWidget(w); @@ -832,10 +850,14 @@ void ReportDesignWindow::restoreSetting() if (v.isValid()){ restoreGeometry(v.toByteArray()); } else { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + int screenWidth = QGuiApplication::primaryScreen()->geometry().width(); + int screenHeight = QGuiApplication::primaryScreen()->geometry().height(); +#else QDesktopWidget *desktop = QApplication::desktop(); - - int screenWidth = desktop->screenGeometry().width(); - int screenHeight = desktop->screenGeometry().height(); + int screenWidth = desktop->screen()->geometry().width(); + int screenHeight = desktop->screen()->geometry().height(); +#endif int x = screenWidth * 0.1; int y = screenHeight * 0.1; @@ -1527,7 +1549,12 @@ void ReportDesignWindow::slotPageDeleted() void ReportDesignWindow::slotFilterTextChanged(const QString& filter) { +#if QT_VERSION >= 0x060000 + m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption)); +#else m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString)); +#endif + } #ifdef HAVE_QTDESIGNER_INTEGRATION diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index c28f921..85f4401 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -32,7 +32,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3) #include +#endif #include #include #include diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 65e39c9..ae20ca5 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -370,7 +370,7 @@ bool ReportRender::containsGroupFunctions(BandDesignIntf *band){ } void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){ - if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){ + if ( contentItem && contentItem->content().contains(LRRegularExpression("\\$S\\s*\\{.*\\}"))){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){ QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); rx.setMinimal(true); diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index cf92071..645cbc2 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -352,6 +352,60 @@ void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){ } } +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue) +{ + LRRegularExpression 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; +} +#else QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue) { QRegExp rx(Const::VARIABLE_RX); @@ -397,7 +451,67 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* } return context; } +#endif + +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem) +{ + 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; +} +#else QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem) { QRegExp rx(Const::FIELD_RX); @@ -451,10 +565,16 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand return context; } +#endif QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, QObject *reportItem) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QRegularExpression rx(Const::SCRIPT_RX); + rx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption); +#else QRegExp rx(Const::SCRIPT_RX); +#endif if (context.contains(rx)){ @@ -517,7 +637,7 @@ QString ScriptEngineManager::replaceScripts(QString context, QVariant &varValue, QVariant ScriptEngineManager::evaluateScript(const QString& script){ - QRegExp rx(Const::SCRIPT_RX); + LRRegularExpression rx(Const::SCRIPT_RX); QVariant varValue; if (script.contains(rx)){ diff --git a/limereport/objectinspector/editors/lrbuttonlineeditor.cpp b/limereport/objectinspector/editors/lrbuttonlineeditor.cpp index 8459594..87f649f 100644 --- a/limereport/objectinspector/editors/lrbuttonlineeditor.cpp +++ b/limereport/objectinspector/editors/lrbuttonlineeditor.cpp @@ -34,7 +34,11 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +#include +#else #include +#endif #include "lrtextitempropertyeditor.h" namespace LimeReport{ @@ -66,7 +70,18 @@ void ButtonLineEditor::editButtonClicked() { TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow()); editor->setAttribute(Qt::WA_DeleteOnClose); - editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry())); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + editor->setGeometry( + QStyle::alignedRect( + Qt::LeftToRight, + Qt::AlignCenter, + editor->size(), + QGuiApplication::primaryScreen()->geometry() + ) + ); +#else + editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->geometry())); +#endif editor->setWindowTitle(m_propertyName); editor->setText(m_lineEdit->text()); connect(editor,SIGNAL(accepted()),this,SLOT(editingByEditorFinished())); diff --git a/limereport/objectinspector/lrobjectinspectorwidget.cpp b/limereport/objectinspector/lrobjectinspectorwidget.cpp index 1a3be38..37f6266 100644 --- a/limereport/objectinspector/lrobjectinspectorwidget.cpp +++ b/limereport/objectinspector/lrobjectinspectorwidget.cpp @@ -168,7 +168,11 @@ bool PropertyFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); if (sourceParent.isValid()) return true; +#if QT_VERSION >= 0x060000 + return sourceModel()->data(index).toString().contains(filterRegularExpression()); +#else return sourceModel()->data(index).toString().contains(filterRegExp()); +#endif } ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent) @@ -178,7 +182,11 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent) m_propertyModel = new BaseDesignPropertyModel(this); m_filterModel = new PropertyFilterModel(this); m_filterModel->setSourceModel(m_propertyModel); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + m_filterModel->setFilterRegularExpression(QRegularExpression("", QRegularExpression::CaseInsensitiveOption)); +#else m_filterModel->setFilterRegExp(QRegExp("", Qt::CaseInsensitive, QRegExp::FixedString)); +#endif m_objectInspectorView->setModel(m_filterModel); QVBoxLayout* l = new QVBoxLayout(); QLineEdit* le = new QLineEdit(this); @@ -209,7 +217,16 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent) h->addWidget(settingButton); l->addLayout(h); l->addWidget(m_objectInspectorView); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + l->setContentsMargins( + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS + ); +#else l->setMargin(Const::DOCKWIDGET_MARGINS); +#endif l->setSpacing(2); this->setLayout(l); } @@ -305,7 +322,11 @@ void ObjectInspectorWidget::updateProperty(const QString &propertyName) void ObjectInspectorWidget::slotFilterTextChanged(const QString &filter) { if (m_filterModel) +#if QT_VERSION >= 0x060000 + m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption)); +#else m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString)); +#endif } void ObjectInspectorWidget::slotTranslatePropertiesChecked(bool value) diff --git a/limereport/objectsbrowser/lrobjectbrowser.cpp b/limereport/objectsbrowser/lrobjectbrowser.cpp index a86fac3..af93190 100644 --- a/limereport/objectsbrowser/lrobjectbrowser.cpp +++ b/limereport/objectsbrowser/lrobjectbrowser.cpp @@ -38,11 +38,20 @@ ObjectBrowser::ObjectBrowser(QWidget *parent) :QWidget(parent), m_designerWidget(NULL), m_mainWindow(NULL), m_changingItemSelection(false), m_movingItem(false) { - QVBoxLayout *layout = new QVBoxLayout(this); - setLayout(layout); - layout->setMargin(Const::DOCKWIDGET_MARGINS); + QVBoxLayout *l = new QVBoxLayout(this); + setLayout(l); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + l->setContentsMargins( + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS + ); +#else + l->setMargin(Const::DOCKWIDGET_MARGINS); +#endif m_treeView = new QTreeWidget(this); - layout->addWidget(m_treeView); + l->addWidget(m_treeView); m_treeView->headerItem()->setText(0,tr("Objects")); m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); } diff --git a/limereport/scriptbrowser/lrscriptbrowser.cpp b/limereport/scriptbrowser/lrscriptbrowser.cpp index 4407170..fc5a98e 100644 --- a/limereport/scriptbrowser/lrscriptbrowser.cpp +++ b/limereport/scriptbrowser/lrscriptbrowser.cpp @@ -43,7 +43,16 @@ ScriptBrowser::ScriptBrowser(QWidget *parent) : ui(new Ui::ScriptBrowser) { ui->setupUi(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + ui->verticalLayout->setContentsMargins( + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS, + Const::DOCKWIDGET_MARGINS + ); +#else ui->verticalLayout->setMargin(Const::DOCKWIDGET_MARGINS); +#endif #ifndef HAVE_UI_LOADER ui->tpDialogs->setVisible(false); ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tpDialogs)); diff --git a/limereport/scripteditor/lrcodeeditor.cpp b/limereport/scripteditor/lrcodeeditor.cpp index 308f376..43c93f3 100644 --- a/limereport/scripteditor/lrcodeeditor.cpp +++ b/limereport/scripteditor/lrcodeeditor.cpp @@ -47,7 +47,11 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event) QStyleOption option; option.initFrom(this); //painter.fillRect(event->rect(), QPalette().background().color()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QColor bg = option.palette.window().color().darker(150); +#else QColor bg = option.palette.background().color().darker(150); +#endif painter.fillRect(event->rect(), bg); QTextBlock block = firstVisibleBlock(); @@ -78,8 +82,11 @@ int CodeEditor::lineNumberAreaWidth() max /= 10; ++digits; } - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + int space = fontMetrics().horizontalAdvance(QLatin1Char('9')) * 2 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits; +#else int space = fontMetrics().width(QLatin1Char('9'))*2 + fontMetrics().width(QLatin1Char('9')) * digits; +#endif return space; } @@ -299,8 +306,11 @@ void CodeEditor::highlightCurrentLine() if (!isReadOnly()) { QTextEdit::ExtraSelection selection; - +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + QColor lineColor = QColor(QPalette().window().color()).darker(100); +#else QColor lineColor = QColor(QPalette().background().color()).darker(100); +#endif selection.format.setBackground(lineColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); diff --git a/limereport/scripteditor/lrscripteditor.cpp b/limereport/scripteditor/lrscripteditor.cpp index 7c9656d..0b84677 100644 --- a/limereport/scripteditor/lrscripteditor.cpp +++ b/limereport/scripteditor/lrscripteditor.cpp @@ -20,7 +20,11 @@ ScriptEditor::ScriptEditor(QWidget *parent) : setFocusProxy(ui->textEdit); m_completer = new ReportStructureCompleater(this); ui->textEdit->setCompleter(m_completer); - ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0")*m_tabIndention); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + ui->textEdit->setTabStopDistance(ui->textEdit->fontMetrics().horizontalAdvance("0") * m_tabIndention); +#else + ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0") * m_tabIndention); +#endif connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SIGNAL(splitterMoved(int,int))); connect(ui->textEdit, SIGNAL(textChanged()), this, SIGNAL(textChanged())); } @@ -86,7 +90,11 @@ void ScriptEditor::setPageBand(BandDesignIntf* band) void ScriptEditor::setTabIndention(int charCount) { if (m_tabIndention != charCount){ - ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("W")*charCount); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) + ui->textEdit->setTabStopDistance(ui->textEdit->fontMetrics().horizontalAdvance("W") * charCount); +#else + ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("W") * charCount); +#endif m_tabIndention = charCount; } }