0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

Qt6 support added

This commit is contained in:
fralx 2021-01-20 14:47:05 +03:00
parent e3356a3d00
commit 81f27782be
39 changed files with 759 additions and 204 deletions

View File

@ -17,6 +17,7 @@
#include "qzint.h"
#include <stdio.h>
#include <QPainterPath>
namespace Zint {

View File

@ -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

View File

@ -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,27 +60,17 @@ unix:{
}
win32 {
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
DESTDIR = $$DEST_DIR
RC_FILE += mainicon.rc
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){
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) {
@ -76,4 +79,14 @@ message($$LIBS)
LIBS += -lQtZint
}
}
}
LIBS += -L$${DEST_LIBS}
CONFIG(debug, debug|release) {
LIBS += -llimereportd
} else {
LIBS += -llimereport
}
}

View File

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF8"?>
<Report>
<object Type="Object" ClassName="LimeReport::ReportEnginePrivate">
<object ClassName="LimeReport::ReportEnginePrivate" Type="Object">
<objectName Type="QString"></objectName>
<pages Type="Collection">
<item Type="Object" ClassName="LimeReport::PageDesignIntf">
<item ClassName="LimeReport::PageDesignIntf" Type="Object">
<objectName Type="QString">page1</objectName>
<sceneRect Type="QRect" x="-50" y="-50" width="2200" height="3070"/>
<sceneRect Type="QRect" width="2200" x="-50" y="-50" height="3070"/>
<bspTreeDepth Value="5" Type="int"/>
<font underline="0" Type="QFont" italic="0" family="MS Shell Dlg 2" weight="50" pointSize="8" stylename=""/>
<font stylename="" Type="QFont" pointSize="8" underline="0" family="MS Shell Dlg 2" weight="50" italic="0"/>
<sortCacheEnabled Value="0" Type="bool"/>
<stickyFocus Value="0" Type="bool"/>
<minimumRenderSize Value="0" Type="qreal"/>
<pageItem Type="Object" ClassName="PageItem">
<pageItem ClassName="PageItem" Type="Object">
<objectName Type="QString">ReportPage1</objectName>
<geometry Type="QRect" x="0" y="0" width="2100" height="2970"/>
<geometry Type="QRect" width="2100" x="0" y="0" height="2970"/>
<children Type="Collection">
<item Type="Object" ClassName="Data">
<item ClassName="Data" Type="Object">
<objectName Type="QString">DataBand1</objectName>
<geometry Type="QRect" x="50" y="306" width="2000" height="110"/>
<geometry Type="QRect" width="2000" x="50" y="306" height="110"/>
<children Type="Collection">
<item Type="Object" ClassName="TextItem">
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem2</objectName>
<geometry Type="QRect" x="38" y="32" width="814" height="50"/>
<geometry Type="QRect" width="814" x="38" y="32" height="50"/>
<children Type="Collection"/>
<zOrder Value="0" Type="qreal"/>
<borders Value="0" Type="enumAndFlags"/>
@ -51,7 +51,7 @@ if ($D{customers.CustomerID}=="ANTON"){
<alignment Value="33" Type="enumAndFlags"/>
<autoWidth Value="0" Type="enumAndFlags"/>
<autoHeight Value="0" Type="bool"/>
<font underline="0" Type="QFont" italic="0" family="Arial" weight="50" pointSize="10" stylename=""/>
<font stylename="" Type="QFont" pointSize="10" underline="0" family="Arial" weight="50" italic="0"/>
<backgroundOpacity Value="100" Type="int"/>
<backgroundMode Value="1" Type="enumAndFlags"/>
<backgroundColor Value="#ffffff" Type="QColor"/>
@ -65,13 +65,6 @@ if ($D{customers.CustomerID}=="ANTON"){
<underlineLineSize Value="1" Type="int"/>
<allowHTML Value="1" Type="bool"/>
<allowHTMLInFields Value="0" Type="bool"/>
<format Type="QString"></format>
<valueType Value="0" Type="enumAndFlags"/>
<followTo Type="QString"></followTo>
<backgroundBrushStyle Value="1" Type="enumAndFlags"/>
<textIndent Value="0" Type="qreal"/>
<textLayoutDirection Value="2" Type="enumAndFlags"/>
<fillInSecondPass Value="0" Type="bool"/>
</item>
</children>
<zOrder Value="0" Type="qreal"/>
@ -85,7 +78,6 @@ if ($D{customers.CustomerID}=="ANTON"){
<keepBottomSpace Value="0" Type="bool"/>
<parentBand Type="QString"></parentBand>
<backgroundColor Value="#ffffff" Type="QColor"/>
<backgroundBrushStyle Value="1" Type="enumAndFlags"/>
<printIfEmpty Value="0" Type="bool"/>
<datasource Type="QString">customers</datasource>
<keepSubdetailTogether Value="0" Type="bool"/>
@ -96,16 +88,14 @@ if ($D{customers.CustomerID}=="ANTON"){
<columnsFillDirection Value="0" Type="enumAndFlags"/>
<startNewPage Value="0" Type="bool"/>
<startFromNewPage Value="0" Type="bool"/>
<alternateBackgroundColor Value="#ffffff" Type="QColor"/>
<useAlternateBackgroundColor Value="0" Type="bool"/>
</item>
<item Type="Object" ClassName="ReportHeader">
<item ClassName="ReportHeader" Type="Object">
<objectName Type="QString">ReportHeader1</objectName>
<geometry Type="QRect" x="50" y="50" width="2000" height="252"/>
<geometry Type="QRect" width="2000" x="50" y="50" height="252"/>
<children Type="Collection">
<item Type="Object" ClassName="TextItem">
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem1</objectName>
<geometry Type="QRect" x="6" y="12" width="816" height="222"/>
<geometry Type="QRect" width="816" x="6" y="12" height="222"/>
<children Type="Collection"/>
<zOrder Value="0" Type="qreal"/>
<borders Value="0" Type="enumAndFlags"/>
@ -117,10 +107,10 @@ if ($D{customers.CustomerID}=="ANTON"){
<stretchToMaxHeight Value="0" Type="bool"/>
<itemAlign Value="4" Type="enumAndFlags"/>
<content Type="QString">$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'}</content>
@ -128,7 +118,7 @@ THIS.font = font;
<alignment Value="33" Type="enumAndFlags"/>
<autoWidth Value="0" Type="enumAndFlags"/>
<autoHeight Value="0" Type="bool"/>
<font underline="0" Type="QFont" italic="0" family="Times New Roman" weight="50" pointSize="10" stylename=""/>
<font stylename="" Type="QFont" pointSize="10" underline="0" family="Times New Roman" weight="50" italic="0"/>
<backgroundOpacity Value="100" Type="int"/>
<backgroundMode Value="1" Type="enumAndFlags"/>
<backgroundColor Value="#ffffff" Type="QColor"/>
@ -142,17 +132,10 @@ THIS.font = font;
<underlineLineSize Value="1" Type="int"/>
<allowHTML Value="0" Type="bool"/>
<allowHTMLInFields Value="0" Type="bool"/>
<format Type="QString"></format>
<valueType Value="0" Type="enumAndFlags"/>
<followTo Type="QString"></followTo>
<backgroundBrushStyle Value="1" Type="enumAndFlags"/>
<textIndent Value="0" Type="qreal"/>
<textLayoutDirection Value="2" Type="enumAndFlags"/>
<fillInSecondPass Value="0" Type="bool"/>
</item>
<item Type="Object" ClassName="TextItem">
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem3</objectName>
<geometry Type="QRect" x="878" y="44" width="408" height="86"/>
<geometry Type="QRect" width="408" x="878" y="44" height="86"/>
<children Type="Collection"/>
<zOrder Value="0" Type="qreal"/>
<borders Value="0" Type="enumAndFlags"/>
@ -168,7 +151,7 @@ THIS.font = font;
<alignment Value="33" Type="enumAndFlags"/>
<autoWidth Value="0" Type="enumAndFlags"/>
<autoHeight Value="0" Type="bool"/>
<font underline="0" Type="QFont" italic="0" family="Arial" weight="50" pointSize="10" stylename=""/>
<font stylename="" Type="QFont" pointSize="10" underline="0" family="Arial" weight="50" italic="0"/>
<backgroundOpacity Value="100" Type="int"/>
<backgroundMode Value="1" Type="enumAndFlags"/>
<backgroundColor Value="#ffffff" Type="QColor"/>
@ -182,13 +165,6 @@ THIS.font = font;
<underlineLineSize Value="1" Type="int"/>
<allowHTML Value="1" Type="bool"/>
<allowHTMLInFields Value="0" Type="bool"/>
<format Type="QString"></format>
<valueType Value="0" Type="enumAndFlags"/>
<followTo Type="QString"></followTo>
<backgroundBrushStyle Value="1" Type="enumAndFlags"/>
<textIndent Value="0" Type="qreal"/>
<textLayoutDirection Value="2" Type="enumAndFlags"/>
<fillInSecondPass Value="0" Type="bool"/>
</item>
</children>
<zOrder Value="0" Type="qreal"/>
@ -202,10 +178,8 @@ THIS.font = font;
<keepBottomSpace Value="0" Type="bool"/>
<parentBand Type="QString"></parentBand>
<backgroundColor Value="#ffffff" Type="QColor"/>
<backgroundBrushStyle Value="1" Type="enumAndFlags"/>
<printIfEmpty Value="0" Type="bool"/>
<splittable Value="0" Type="bool"/>
<printBeforePageHeader Value="0" Type="bool"/>
</item>
</children>
<zOrder Value="0" Type="qreal"/>
@ -223,19 +197,13 @@ THIS.font = font;
<gridStep Value="2" Type="int"/>
<fullPage Value="0" Type="bool"/>
<oldPrintMode Value="0" Type="bool"/>
<resetPageNumber Value="0" Type="bool"/>
<isExtendedInDesignMode Value="0" Type="bool"/>
<extendedHeight Value="1000" Type="int"/>
<pageIsTOC Value="0" Type="bool"/>
<setPageSizeToPrinter Value="0" Type="bool"/>
<endlessHeight Value="0" Type="bool"/>
</pageItem>
</item>
</pages>
<datasourcesManager Type="Object" ClassName="LimeReport::DataSourceManager">
<datasourcesManager ClassName="LimeReport::DataSourceManager" Type="Object">
<objectName Type="QString">datasources</objectName>
<connections Type="Collection">
<item Type="Object" ClassName="LimeReport::ConnectionDesc">
<item ClassName="LimeReport::ConnectionDesc" Type="Object">
<objectName Type="QString"></objectName>
<name Type="QString">test</name>
<driver Type="QString">QSQLITE</driver>
@ -244,11 +212,10 @@ THIS.font = font;
<password Value="" Type="QString"/>
<host Type="QString"></host>
<autoconnect Value="0" Type="bool"/>
<keepDBCredentials Value="1" Type="bool"/>
</item>
</connections>
<queries Type="Collection">
<item Type="Object" ClassName="LimeReport::QueryDesc">
<item ClassName="LimeReport::QueryDesc" Type="Object">
<objectName Type="QString"></objectName>
<queryName Type="QString">customers</queryName>
<queryText Type="QString">Select * from customers limit 5</queryText>
@ -258,21 +225,18 @@ THIS.font = font;
<subqueries Type="Collection"/>
<subproxies Type="Collection"/>
<variables Type="Collection">
<item Type="Object" ClassName="LimeReport::VarDesc">
<item ClassName="LimeReport::VarDesc" Type="Object">
<objectName Type="QString"></objectName>
<name Type="QString">TestName</name>
<value Type="QString">TestValue</value>
<isMandatory Value="0" Type="bool"/>
<dataType Value="0" Type="int"/>
</item>
</variables>
</datasourcesManager>
<scriptContext Type="Object" ClassName="LimeReport::ScriptEngineContext">
<scriptContext ClassName="LimeReport::ScriptEngineContext" Type="Object">
<objectName Type="QString"></objectName>
<dialogs Type="Collection"/>
<initScript Type="QString"></initScript>
</scriptContext>
<suppressFieldAndVarError Value="0" Type="bool"/>
<translation Type="Translation"/>
</object>
</Report>

Binary file not shown.

View File

@ -1 +1 @@
IDI_ICON1 ICON "main.ico"
DI_ICON1 ICON "main.ico"

View File

@ -37,15 +37,8 @@
#include <LRCallbackDS>
#include <QDebug>
#include <QStringListModel>
#include <QPrinter>
#ifdef BUILD_WITH_EASY_PROFILER
#include "easy/profiler.h"
#else
# define EASY_BLOCK(...)
# define EASY_END_BLOCK
# define EASY_PROFILER_ENABLE
#endif
#include <QSqlError>
#include <QSqlDriver>
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<QString, QPrinter*> 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);
m_progressDialog->setWindowModality(Qt::WindowModal);
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
QApplication::processEvents();
m_progressDialog->show();
}
QApplication::processEvents();
}
void MainWindow::renderPageFinished(int renderedPageCount)
@ -274,3 +244,26 @@ void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
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&)));
}

View File

@ -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:

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>192</height>
<width>426</width>
<height>214</height>
</rect>
</property>
<property name="font">
@ -185,6 +185,43 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Load from Database</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -3,7 +3,12 @@
#include <QSqlDatabase>
#include <QDir>
#include <QDebug>
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
#include <QDesktopWidget>
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
#include <QScreen>
#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;

View File

@ -34,6 +34,7 @@
#include <QString>
#include <QStyleOptionViewItem>
#include <QtGlobal>
#include <QRegExp>
#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

View File

@ -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);
}

View File

@ -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<SizeHandleRect::Direction>(i), this);

View File

@ -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;

View File

@ -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<fm.horizontalAdvance(label))
maxWidth = fm.horizontalAdvance(label)+10;
#else
if (maxWidth<fm.width(label))
maxWidth = fm.width(label)+10;
#endif
}
} else {
foreach(QString label, m_designLabels){
cw += fm.height();
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
if (maxWidth<fm.horizontalAdvance(label))
maxWidth = fm.horizontalAdvance(label)+10;
#else
if (maxWidth<fm.width(label))
maxWidth = fm.width(label)+10;
#endif
}
}
cw += fm.height();

View File

@ -63,7 +63,11 @@ void FontEditorWidget::initEditor()
m_fontSizeEditor = new QComboBox(this);
m_fontSizeEditor->setModel(&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();

View File

@ -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 (maxWidth<fm.horizontalAdvance(series->name()))
maxWidth = fm.horizontalAdvance(series->name())+10;
}
} else {
foreach(QString label, m_designLabels){
cw += fm.height();
if (maxWidth<fm.horizontalAdvance(label))
maxWidth = fm.horizontalAdvance(label)+10;
}
}
#else
if (!m_chartItem->series().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 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<QFontMetricsF> 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<QFontMetricsF> 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

View File

@ -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);

View File

@ -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 <QMenu>
@ -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<PageItemDesignIntf*>(parent);
BaseDesignIntf* parentItem = dynamic_cast<BaseDesignIntf*>(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))){
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;

View File

@ -232,6 +232,7 @@ private:
Qt::LayoutDirection m_textLayoutDirection;
bool m_hideIfEmpty;
int m_fontLetterSpacing;
QFont mutable *m_adaptedFont;
};
}

View File

@ -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 \

View File

@ -260,7 +260,11 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
QFontMetrics fontMetrics(font);
QVector<QRectF> 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();
}

View File

@ -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<QString,QString> &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<QString,QString>
}
}
}
#endif
return query;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &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<QString,QString> &aliasesToParam, QString masterDatasource)
{
QRegExp rx(Const::FIELD_RX);
@ -511,6 +607,7 @@ QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &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<QueryHolder*>(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<QueryHolder*>(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();

View File

@ -34,6 +34,7 @@
#include <QString>
#include <QStyleOptionViewItem>
#include <QtGlobal>
#include <QRegExp>
#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

View File

@ -53,12 +53,21 @@ bool GraphicsViewZoomer::eventFilter(QObject *object, QEvent *event) {
} else if (event->type() == QEvent::Wheel) {
QWheelEvent* wheel_event = static_cast<QWheelEvent*>(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)

View File

@ -770,7 +770,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
BaseDesignIntf* item = addReportItem("TextItem",event->scenePos(),QSize(250, 50));
TextItem* ti = dynamic_cast<TextItem*>(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<BandDesignIntf*>(ti->parentItem());

View File

@ -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);
}

View File

@ -41,7 +41,9 @@
#include <QPrintDialog>
#include <QFileDialog>
#include <QScrollBar>
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
#include <QDesktopWidget>
#endif
#include <QLabel>
#include <QMessageBox>
#include <QToolButton>
@ -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<int>(screenWidth*0.1);
int y = static_cast<int>(screenHeight*0.1);

View File

@ -1058,8 +1058,13 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
if (event->type() == QEvent::Wheel){
QWheelEvent* we = dynamic_cast<QWheelEvent*>(event);
if (QApplication::keyboardModifiers()==Qt::ControlModifier){
if(we->delta()<0) scale(1.2,1.2);
#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;

View File

@ -39,7 +39,9 @@
#include <QMenuBar>
#include <QCheckBox>
#include <QVBoxLayout>
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
#include <QDesktopWidget>
#endif
#include <QSortFilterProxyModel>
#include <QLineEdit>
#include <QPushButton>
@ -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

View File

@ -32,7 +32,9 @@
#include <QPrinterInfo>
#include <QMessageBox>
#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
#include <QDesktopWidget>
#endif
#include <QFileSystemWatcher>
#include <QPluginLoader>
#include <QFileDialog>

View File

@ -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);

View File

@ -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)){

View File

@ -34,7 +34,11 @@
#include <QFocusEvent>
#include <QApplication>
#include <QStyle>
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
#include <QScreen>
#else
#include <QDesktopWidget>
#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()));

View File

@ -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)

View File

@ -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);
}

View File

@ -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));

View File

@ -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);

View File

@ -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;
}
}