From e34023931f3f20997214e2ffebb242a2caf8e9b7 Mon Sep 17 00:00:00 2001 From: Youssef BEDDAD Date: Fri, 20 May 2022 12:21:41 +0100 Subject: [PATCH 01/30] Update: - Added -USE_QT6 in order to choose what to build instead of the default behaviour. --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ba0f51..bf9c49a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,13 @@ set(LIMEREPORT_VERSION_RELEASE 6) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) +option(USE_QT6 "Use Qt6" OFF) -find_package( - QT NAMES Qt6 Qt5 - COMPONENTS Core Widgets Sql Network Xml Svg Qml PrintSupport REQUIRED - ) +if(USE_QT6) + find_package(QT NAMES Qt6) +else() + find_package(QT NAMES Qt5) +endif(USE_QT6) find_package( Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets Sql Network Xml Svg Qml PrintSupport REQUIRED From c622a5a0094b9dfa452ebe3fcfbe6b057a6e290f Mon Sep 17 00:00:00 2001 From: Youssef BEDDAD Date: Fri, 20 May 2022 12:28:08 +0100 Subject: [PATCH 02/30] Update: - Adding an ifdef condition to discard Q_DECLARE_METATYPE(QLocale::Language) from compilation on Qt6 --- limereport/translationeditor/languageselectdialog.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/limereport/translationeditor/languageselectdialog.h b/limereport/translationeditor/languageselectdialog.h index 0402327..48d53b4 100644 --- a/limereport/translationeditor/languageselectdialog.h +++ b/limereport/translationeditor/languageselectdialog.h @@ -8,18 +8,20 @@ namespace Ui { class LanguageSelectDialog; } -class LanguageSelectDialog : public QDialog -{ +class LanguageSelectDialog : public QDialog { Q_OBJECT -public: + public: explicit LanguageSelectDialog(QWidget *parent = 0); ~LanguageSelectDialog(); QLocale::Language getSelectedLanguage(); -private: + + private: Ui::LanguageSelectDialog *ui; }; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_DECLARE_METATYPE(QLocale::Language) +#endif #endif // LANGUAGESELECTDIALOG_H From 747346b4138eee61ad5178cdd44a63cd31d2ec46 Mon Sep 17 00:00:00 2001 From: Youssef BEDDAD Date: Fri, 20 May 2022 12:32:47 +0100 Subject: [PATCH 03/30] Update: - setResizeMode is no longer available on Qt6 ( I think the setSectionResizeMode from Qt5 was reintroduced in Qt6 LTS ) --- limereport/databrowser/lrsqleditdialog.cpp | 274 +++++++++------------ 1 file changed, 122 insertions(+), 152 deletions(-) diff --git a/limereport/databrowser/lrsqleditdialog.cpp b/limereport/databrowser/lrsqleditdialog.cpp index 7fe874f..92e5b3a 100644 --- a/limereport/databrowser/lrsqleditdialog.cpp +++ b/limereport/databrowser/lrsqleditdialog.cpp @@ -28,20 +28,18 @@ * GNU General Public License for more details. * ****************************************************************************/ #include "lrsqleditdialog.h" -#include "ui_lrsqleditdialog.h" #include "lrreportengine_p.h" +#include "ui_lrsqleditdialog.h" #include -#include #include +#include -namespace LimeReport{ +namespace LimeReport { -SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dataSources, SQLDialogMode dialogMode) : - QDialog(parent), - ui(new Ui::SQLEditDialog),m_datasources(dataSources),m_dialogMode(dialogMode), m_oldDatasourceName(""), - m_settings(0), m_ownedSettings(false) -{ +SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dataSources, SQLDialogMode dialogMode) + : QDialog(parent), ui(new Ui::SQLEditDialog), m_datasources(dataSources), m_dialogMode(dialogMode), + m_oldDatasourceName(""), m_settings(0), m_ownedSettings(false) { ui->setupUi(this); m_masterDatasources = new QCompleter(this); ui->leMaster->setCompleter(m_masterDatasources); @@ -54,72 +52,72 @@ SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dat ui->rbSubQuery->setVisible(false); ui->leMaster->setVisible(false); ui->lbMaster->setVisible(false); - ui->fieldsMap->setHorizontalHeaderItem(0,new QTableWidgetItem("master")); - ui->fieldsMap->setHorizontalHeaderItem(1,new QTableWidgetItem("detail")); + ui->fieldsMap->setHorizontalHeaderItem(0, new QTableWidgetItem("master")); + ui->fieldsMap->setHorizontalHeaderItem(1, new QTableWidgetItem("detail")); -#ifdef HAVE_QT5 ui->fieldsMap->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -#else - ui->fieldsMap->horizontalHeader()->setResizeMode(QHeaderView::Stretch); -#endif + ui->pnlChildDatasource->setVisible(false); connect(ui->pbPreview, SIGNAL(pressed()), this, SLOT(slotPreviewData())); connect(ui->pbHidePreview, SIGNAL(pressed()), this, SLOT(slotHidePreview())); } -SQLEditDialog::~SQLEditDialog() -{ +SQLEditDialog::~SQLEditDialog() { delete ui; if (m_settings && m_ownedSettings) delete m_settings; } -QSettings *SQLEditDialog::settings(){ - if (m_settings){ +QSettings *SQLEditDialog::settings() { + if (m_settings) { return m_settings; } else { - m_settings = new QSettings("LimeReport",QCoreApplication::applicationName()); + m_settings = new QSettings("LimeReport", QCoreApplication::applicationName()); m_ownedSettings = true; return m_settings; } } -void SQLEditDialog::setSettings(QSettings *value, bool owned){ - if (m_settings && m_ownedSettings) delete m_settings; +void SQLEditDialog::setSettings(QSettings *value, bool owned) { + if (m_settings && m_ownedSettings) + delete m_settings; m_settings = value; m_ownedSettings = owned; } -void SQLEditDialog::accept() -{ +void SQLEditDialog::accept() { SQLEditResult result; - if (ui->tabWidget->currentIndex() == 1){ + if (ui->tabWidget->currentIndex() == 1) { result.resultMode = SQLEditResult::CSVText; - } else if (!ui->cbSubdetail->isChecked()){ - result.resultMode=SQLEditResult::Query; + } else if (!ui->cbSubdetail->isChecked()) { + result.resultMode = SQLEditResult::Query; } else { - if (ui->rbSubQuery->isChecked()) result.resultMode = SQLEditResult::SubQuery; - else result.resultMode=SQLEditResult::SubProxy; + if (ui->rbSubQuery->isChecked()) + result.resultMode = SQLEditResult::SubQuery; + else + result.resultMode = SQLEditResult::SubProxy; } result.connectionName = ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()); - result.datasourceName=ui->leDatasourceName->text(); + result.datasourceName = ui->leDatasourceName->text(); result.sql = ui->sqlText->toPlainText(); result.csv = ui->csvText->toPlainText(); result.dialogMode = m_dialogMode; result.oldDatasourceName = m_oldDatasourceName; result.subdetail = ui->cbSubdetail->isChecked(); - result.masterDatasource=ui->leMaster->text(); - result.childDataSource=ui->leChild->text(); + result.masterDatasource = ui->leMaster->text(); + result.childDataSource = ui->leChild->text(); result.separator = ui->leSeparator->text(); result.firstRowIsHeader = ui->cbUseFirstRowAsHeader->isChecked(); - if (ui->fieldsMap->rowCount() > 0){ - for(int i=0; i< ui->fieldsMap->rowCount(); ++i){ + if (ui->fieldsMap->rowCount() > 0) { + for (int i = 0; i < ui->fieldsMap->rowCount(); ++i) { LimeReport::FieldsCorrelation fieldsCorrelation; - fieldsCorrelation.master = ui->fieldsMap->item(i,0) ? ui->fieldsMap->item(i,0)->data(Qt::DisplayRole).toString() : ""; - fieldsCorrelation.detail = ui->fieldsMap->item(i,1) ? ui->fieldsMap->item(i,1)->data(Qt::DisplayRole).toString() : ""; + fieldsCorrelation.master = + ui->fieldsMap->item(i, 0) ? ui->fieldsMap->item(i, 0)->data(Qt::DisplayRole).toString() : ""; + fieldsCorrelation.detail = + ui->fieldsMap->item(i, 1) ? ui->fieldsMap->item(i, 1)->data(Qt::DisplayRole).toString() : ""; result.fieldMap.append(fieldsCorrelation); } } @@ -128,87 +126,83 @@ void SQLEditDialog::accept() check(); emit signalSqlEditingFinished(result); QDialog::accept(); - }catch(LimeReport::ReportError &exception){ - QMessageBox::critical(this,tr("Error"),exception.what()); + } catch (LimeReport::ReportError &exception) { + QMessageBox::critical(this, tr("Error"), exception.what()); } } -void SQLEditDialog::showEvent(QShowEvent *) -{ +void SQLEditDialog::showEvent(QShowEvent *) { ui->lblInfo->setVisible(false); initConnections(); readSettings(); } -void SQLEditDialog::closeEvent(QCloseEvent *) -{ - writeSetting(); -} +void SQLEditDialog::closeEvent(QCloseEvent *) { writeSetting(); } -void SQLEditDialog::hideEvent(QHideEvent *) -{ - writeSetting(); -} +void SQLEditDialog::hideEvent(QHideEvent *) { writeSetting(); } -void SQLEditDialog::check() -{ - if (ui->leDatasourceName->text().isEmpty()) throw LimeReport::ReportError(tr("Datasource Name is empty!")); - if (ui->sqlText->toPlainText().isEmpty() && (!ui->rbProxy) ) throw LimeReport::ReportError(tr("SQL is empty!")); - if (m_dialogMode==AddMode){ - if (m_datasources->containsDatasource(ui->leDatasourceName->text())){ - throw LimeReport::ReportError(QString(tr("Datasource with name: \"%1\" already exists!")).arg(ui->leDatasourceName->text())); +void SQLEditDialog::check() { + if (ui->leDatasourceName->text().isEmpty()) + throw LimeReport::ReportError(tr("Datasource Name is empty!")); + if (ui->sqlText->toPlainText().isEmpty() && (!ui->rbProxy)) + throw LimeReport::ReportError(tr("SQL is empty!")); + if (m_dialogMode == AddMode) { + if (m_datasources->containsDatasource(ui->leDatasourceName->text())) { + throw LimeReport::ReportError( + QString(tr("Datasource with name: \"%1\" already exists!")).arg(ui->leDatasourceName->text())); } } } -void SQLEditDialog::initConnections() -{ - foreach(QString connectionName, QSqlDatabase::connectionNames()){ - ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-connect.png"),ConnectionDesc::connectionNameForUser(connectionName)); +void SQLEditDialog::initConnections() { + foreach (QString connectionName, QSqlDatabase::connectionNames()) { + ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-connect.png"), + ConnectionDesc::connectionNameForUser(connectionName)); } - foreach(QString connectionName, m_datasources->connectionNames()){ - connectionName = (connectionName.compare(QSqlDatabase::defaultConnection)==0) ? - tr("defaultConnection") : connectionName; - if (ui->cbbConnection->findText(connectionName,Qt::MatchExactly )==-1) - ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-disconnect.png"),ConnectionDesc::connectionNameForUser(connectionName)); + foreach (QString connectionName, m_datasources->connectionNames()) { + connectionName = + (connectionName.compare(QSqlDatabase::defaultConnection) == 0) ? tr("defaultConnection") : connectionName; + if (ui->cbbConnection->findText(connectionName, Qt::MatchExactly) == -1) + ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-disconnect.png"), + ConnectionDesc::connectionNameForUser(connectionName)); } ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(m_defaultConnection)); - if (!m_oldDatasourceName.isEmpty()){ - ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(ConnectionDesc::connectionNameForUser(m_datasources->connectionName(m_oldDatasourceName)))); + if (!m_oldDatasourceName.isEmpty()) { + ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText( + ConnectionDesc::connectionNameForUser(m_datasources->connectionName(m_oldDatasourceName)))); } } -void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, QString datasourceName) -{ - m_datasources=dataSources; - if (!datasourceName.isEmpty()){ +void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, QString datasourceName) { + m_datasources = dataSources; + if (!datasourceName.isEmpty()) { ui->cbSubdetail->setEnabled(true); - m_oldDatasourceName=datasourceName; + m_oldDatasourceName = datasourceName; ui->leDatasourceName->setText(datasourceName); ui->sqlText->setText(dataSources->queryText(datasourceName)); - if (dataSources->isQuery(datasourceName)){ + if (dataSources->isQuery(datasourceName)) { initQueryMode(); } - if (dataSources->isSubQuery(datasourceName)){ + if (dataSources->isSubQuery(datasourceName)) { initSubQueryMode(); ui->leMaster->setText(dataSources->subQueryByName(datasourceName)->master()); } - if (dataSources->isProxy(datasourceName)){ + if (dataSources->isProxy(datasourceName)) { initProxyMode(); - LimeReport::ProxyDesc* proxyDesc = dataSources->proxyByName(datasourceName); + LimeReport::ProxyDesc *proxyDesc = dataSources->proxyByName(datasourceName); ui->leChild->setText(proxyDesc->child()); ui->leMaster->setText(proxyDesc->master()); - int curIndex=0; - foreach(LimeReport::FieldMapDesc* fields, *proxyDesc->fieldsMap()){ - ui->fieldsMap->setRowCount(curIndex+1); - ui->fieldsMap->setItem(curIndex,0,new QTableWidgetItem(fields->master())); - ui->fieldsMap->setItem(curIndex,1,new QTableWidgetItem(fields->detail())); + int curIndex = 0; + foreach (LimeReport::FieldMapDesc *fields, *proxyDesc->fieldsMap()) { + ui->fieldsMap->setRowCount(curIndex + 1); + ui->fieldsMap->setItem(curIndex, 0, new QTableWidgetItem(fields->master())); + ui->fieldsMap->setItem(curIndex, 1, new QTableWidgetItem(fields->detail())); curIndex++; } } - if (dataSources->isCSV(datasourceName)){ + if (dataSources->isCSV(datasourceName)) { ui->csvText->setPlainText(dataSources->csvByName(datasourceName)->csvText()); ui->leSeparator->setText(dataSources->csvByName(datasourceName)->separator()); ui->cbUseFirstRowAsHeader->setChecked(dataSources->csvByName(datasourceName)->firstRowIsHeader()); @@ -217,59 +211,55 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q } } -void SQLEditDialog::setDefaultConnection(QString defaultConnection) -{ +void SQLEditDialog::setDefaultConnection(QString defaultConnection) { m_defaultConnection = ConnectionDesc::connectionNameForUser(defaultConnection); } -void SQLEditDialog::slotDataSourceNameEditing() -{ - if (m_dialogMode==AddMode){ - QPalette palette=ui->leDatasourceName->palette(); - if (m_datasources->containsDatasource(ui->leDatasourceName->text())){ - palette.setColor(QPalette::Text,Qt::red); +void SQLEditDialog::slotDataSourceNameEditing() { + if (m_dialogMode == AddMode) { + QPalette palette = ui->leDatasourceName->palette(); + if (m_datasources->containsDatasource(ui->leDatasourceName->text())) { + palette.setColor(QPalette::Text, Qt::red); ui->leDatasourceName->setPalette(palette); - ui->lblInfo->setText(QString(tr("Datasource with name %1 already exist")).arg(ui->leDatasourceName->text())); + ui->lblInfo->setText( + QString(tr("Datasource with name %1 already exist")).arg(ui->leDatasourceName->text())); ui->lblInfo->setVisible(true); } else { - palette.setColor(QPalette::Text,QApplication::palette().text().color()); + palette.setColor(QPalette::Text, QApplication::palette().text().color()); ui->leDatasourceName->setPalette(palette); ui->lblInfo->setVisible(false); } } } -void SQLEditDialog::on_cbSubdetail_clicked(bool checked) -{ - if (checked){ - m_masterDatasources->setModel(new QStringListModel(m_datasources->dataSourceNames(),m_datasources)); +void SQLEditDialog::on_cbSubdetail_clicked(bool checked) { + if (checked) { + m_masterDatasources->setModel(new QStringListModel(m_datasources->dataSourceNames(), m_datasources)); } ui->leMaster->setEnabled(checked); ui->rbProxy->setEnabled(checked); ui->rbSubQuery->setEnabled(checked); - if ((checked)&&(ui->rbProxy->isChecked())) initProxyMode(); - if ((checked)&&(ui->rbSubQuery->isChecked())) initSubQueryMode(); - if (!checked) initQueryMode(); + if ((checked) && (ui->rbProxy->isChecked())) + initProxyMode(); + if ((checked) && (ui->rbSubQuery->isChecked())) + initSubQueryMode(); + if (!checked) + initQueryMode(); } -void SQLEditDialog::on_rbProxy_clicked(bool checked) -{ - if (checked) initProxyMode(); +void SQLEditDialog::on_rbProxy_clicked(bool checked) { + if (checked) + initProxyMode(); } -void SQLEditDialog::on_rbSubQuery_clicked(bool checked) -{ - if (checked) initSubQueryMode(); +void SQLEditDialog::on_rbSubQuery_clicked(bool checked) { + if (checked) + initSubQueryMode(); } -void SQLEditDialog::on_pbAddField_clicked() -{ - ui->fieldsMap->setRowCount(ui->fieldsMap->rowCount()+1); -} +void SQLEditDialog::on_pbAddField_clicked() { ui->fieldsMap->setRowCount(ui->fieldsMap->rowCount() + 1); } - -void SQLEditDialog::initQueryMode() -{ +void SQLEditDialog::initQueryMode() { ui->gbSQL->setVisible(true); ui->gbFieldsMap->setVisible(false); ui->pnlChildDatasource->setVisible(false); @@ -278,12 +268,11 @@ void SQLEditDialog::initQueryMode() ui->cbSubdetail->setChecked(false); ui->leMaster->setVisible(false); ui->lbMaster->setVisible(false); - //ui->tabWidget->removeTab(1); + // ui->tabWidget->removeTab(1); ui->tabWidget->addTab(ui->csvTab, tr("CSV")); } -void SQLEditDialog::initSubQueryMode() -{ +void SQLEditDialog::initSubQueryMode() { ui->gbSQL->setVisible(true); ui->gbFieldsMap->setVisible(false); ui->pnlChildDatasource->setVisible(false); @@ -297,8 +286,7 @@ void SQLEditDialog::initSubQueryMode() ui->tabWidget->removeTab(1); } -void SQLEditDialog::initProxyMode() -{ +void SQLEditDialog::initProxyMode() { ui->gbSQL->setVisible(false); ui->gbFieldsMap->setVisible(true); ui->pnlChildDatasource->setVisible(true); @@ -313,23 +301,17 @@ void SQLEditDialog::initProxyMode() ui->tabWidget->removeTab(1); } -void SQLEditDialog::initCSVMode() -{ - ui->tabWidget->setCurrentWidget(ui->csvTab); -} +void SQLEditDialog::initCSVMode() { ui->tabWidget->setCurrentWidget(ui->csvTab); } -void SQLEditDialog::slotPreviewData() -{ - if (ui->cbbConnection->currentText().isEmpty()){ - QMessageBox::critical(this,tr("Attention"),tr("Connection is not specified")); +void SQLEditDialog::slotPreviewData() { + if (ui->cbbConnection->currentText().isEmpty()) { + QMessageBox::critical(this, tr("Attention"), tr("Connection is not specified")); return; } - m_previewModel = m_datasources->previewSQL( - ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()), - ui->sqlText->toPlainText(), - ui->leMaster->text() - ); - if (m_previewModel){ + m_previewModel = + m_datasources->previewSQL(ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()), + ui->sqlText->toPlainText(), ui->leMaster->text()); + if (m_previewModel) { ui->tvPreview->setModel(m_previewModel.data()); ui->gbDataPreview->setVisible(true); ui->pbPreview->setText(tr("Refresh")); @@ -337,49 +319,37 @@ void SQLEditDialog::slotPreviewData() } else { if (ui->gbDataPreview->isVisible()) hidePreview(); - QMessageBox::critical(this,tr("Attention"),m_datasources->lastError()); + QMessageBox::critical(this, tr("Attention"), m_datasources->lastError()); } } -void SQLEditDialog::slotHidePreview() -{ - hidePreview(); -} +void SQLEditDialog::slotHidePreview() { hidePreview(); } -void SQLEditDialog::writeSetting() -{ - if (settings()!=0){ +void SQLEditDialog::writeSetting() { + if (settings() != 0) { settings()->beginGroup("SQLEditor"); - settings()->setValue("Geometry",saveGeometry()); + settings()->setValue("Geometry", saveGeometry()); settings()->endGroup(); } } -void SQLEditDialog::readSettings() -{ - if (settings()==0) return; +void SQLEditDialog::readSettings() { + if (settings() == 0) + return; settings()->beginGroup("SQLEditor"); QVariant v = settings()->value("Geometry"); - if (v.isValid()){ + if (v.isValid()) { restoreGeometry(v.toByteArray()); } settings()->endGroup(); } -void SQLEditDialog::hidePreview() -{ +void SQLEditDialog::hidePreview() { ui->gbDataPreview->setVisible(false); ui->pbPreview->setText(tr("Preview")); ui->pbHidePreview->setVisible(false); } -void SQLEditDialog::on_pbDelField_clicked() -{ - ui->fieldsMap->removeRow(ui->fieldsMap->currentRow()); -} +void SQLEditDialog::on_pbDelField_clicked() { ui->fieldsMap->removeRow(ui->fieldsMap->currentRow()); } } // namespace LimeReport - - - - From 593112ccb1fbf3db84bd297f2d8a1b60d1712a29 Mon Sep 17 00:00:00 2001 From: Youssef BEDDAD Date: Fri, 20 May 2022 12:41:09 +0100 Subject: [PATCH 04/30] Update: - add -qt{QT_MAJOR_VERSION} at the end of the created library --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf9c49a..6257b8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,6 +342,8 @@ set(GLOBAL_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/config.h ) +set(PROJECT_NAME ${PROJECT_NAME}-qt${QT_VERSION_MAJOR}) + if (LIMEREPORT_STATIC) message(STATUS "STATIC LIBRARY") add_library(${PROJECT_NAME} STATIC ${EXTRA_FILES} ${LIMEREPORT_SOURCES}) From f561bfa8f3d83f69855b0081cf91bdee355cfd96 Mon Sep 17 00:00:00 2001 From: Youssef BEDDAD Date: Sat, 21 May 2022 14:49:23 +0100 Subject: [PATCH 05/30] Update: - Fixed LRDesigner build complaining about PrintSupport and Qml --- designer/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer/CMakeLists.txt b/designer/CMakeLists.txt index 3f3ffe4..cad7b86 100644 --- a/designer/CMakeLists.txt +++ b/designer/CMakeLists.txt @@ -14,5 +14,7 @@ target_include_directories(LRDesigner PUBLIC ${PROJECT_SOURCE_DIR}/include) target_link_libraries(LRDesigner PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::PrintSupport + Qt${QT_VERSION_MAJOR}::Qml ${PROJECT_NAME} ) From 8575dd25d33aff37d155f0724f69e0adfa84d42e Mon Sep 17 00:00:00 2001 From: Youssef BEDDAD Date: Sat, 21 May 2022 20:30:14 +0100 Subject: [PATCH 06/30] Update: - added missing lrchartaxiseditor to CMakeLists.txt to fix LRDesigner and demo_r1 builds - added -qt${QT_VERSION_MAJOR} to demo_r1 and LRDesigner CMakeLists.txt project files --- CMakeLists.txt | 3 +++ demo_r1/CMakeLists.txt | 2 +- designer/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6257b8c..9874801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ ${PROJECT_NAME}/items/editors/lrtextalignmenteditorwidget.cpp ${PROJECT_NAME}/items/lrabstractlayout.cpp ${PROJECT_NAME}/items/lralignpropitem.cpp ${PROJECT_NAME}/items/lrchartitem.cpp +${PROJECT_NAME}/items/lrchartaxiseditor.cpp ${PROJECT_NAME}/items/lrchartitemeditor.cpp ${PROJECT_NAME}/items/lrhorizontallayout.cpp ${PROJECT_NAME}/items/lrimageitem.cpp @@ -191,6 +192,7 @@ ${PROJECT_NAME}/items/editors/lrtextalignmenteditorwidget.h ${PROJECT_NAME}/items/lrabstractlayout.h ${PROJECT_NAME}/items/lralignpropitem.h ${PROJECT_NAME}/items/lrchartitem.h +${PROJECT_NAME}/items/lrchartaxiseditor.h ${PROJECT_NAME}/items/lrchartitemeditor.h ${PROJECT_NAME}/items/lreditableimageitemintf.h ${PROJECT_NAME}/items/lrhorizontallayout.h @@ -287,6 +289,7 @@ ${PROJECT_NAME}/databrowser/lrsqleditdialog.ui ${PROJECT_NAME}/databrowser/lrvariabledialog.ui ${PROJECT_NAME}/dialogdesigner/templates/Dialog.ui ${PROJECT_NAME}/items/lrchartitemeditor.ui +${PROJECT_NAME}/items/lrchartaxiseditor.ui ${PROJECT_NAME}/items/lrimageitemeditor.ui ${PROJECT_NAME}/items/lrtextitemeditor.ui ${PROJECT_NAME}/lraboutdialog.ui diff --git a/demo_r1/CMakeLists.txt b/demo_r1/CMakeLists.txt index a694da1..da749ac 100644 --- a/demo_r1/CMakeLists.txt +++ b/demo_r1/CMakeLists.txt @@ -18,6 +18,6 @@ target_link_libraries(demo_r1 PRIVATE Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Sql - ${PROJECT_NAME} + ${PROJECT_NAME}-qt${QT_VERSION_MAJOR} ) diff --git a/designer/CMakeLists.txt b/designer/CMakeLists.txt index cad7b86..d63ea0b 100644 --- a/designer/CMakeLists.txt +++ b/designer/CMakeLists.txt @@ -16,5 +16,5 @@ target_link_libraries(LRDesigner PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Qml - ${PROJECT_NAME} + ${PROJECT_NAME}-qt${QT_VERSION_MAJOR} ) From a2c3f6bf5a2d985c363de7573ccb328633eebbb3 Mon Sep 17 00:00:00 2001 From: liufeijin <1290689371@qq.com> Date: Wed, 13 Jul 2022 11:54:00 +0800 Subject: [PATCH 07/30] Update lrfactoryinitializer.cpp lose barcode item when use static build fixed --- limereport/lrfactoryinitializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/limereport/lrfactoryinitializer.cpp b/limereport/lrfactoryinitializer.cpp index ccfc024..2a7225e 100644 --- a/limereport/lrfactoryinitializer.cpp +++ b/limereport/lrfactoryinitializer.cpp @@ -165,7 +165,7 @@ void initReportItems(){ #ifdef HAVE_SVG DesignElementsFactory::instance().registerCreator( - "BarcodeItem", + "SVGItem", LimeReport::ItemAttribs(QObject::tr("SVG Item"),"Item"), createSVGItem ); From 64193a18d023f20dc976ac560d5b3a41ac12db67 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Sat, 16 Jul 2022 02:33:39 +0300 Subject: [PATCH 08/30] QRegularExpression usage has been fixed Qt6 drag&drop has been fixed --- CMakeLists.txt | 2 +- common.pri | 2 +- include/lrglobal.h | 10 ++++ limereport/databrowser/lrdatabrowsertree.cpp | 4 ++ limereport/databrowser/lrdatabrowsertree.h | 6 +- limereport/items/lrtextitem.cpp | 2 +- limereport/lrbanddesignintf.h | 1 - limereport/lrdatasourcemanager.cpp | 15 +++-- limereport/lrglobal.cpp | 51 ++++++++++++++++- limereport/lrglobal.h | 10 ++++ limereport/lrgroupfunctions.cpp | 10 ++-- limereport/lrpagedesignintf.cpp | 5 +- limereport/lrreportrender.cpp | 58 ++++---------------- limereport/lrscriptenginemanager.cpp | 19 +++---- limereport/lrscriptenginemanager.h | 6 +- 15 files changed, 121 insertions(+), 80 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9874801..fb10889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) set(LIMEREPORT_VERSION_MAJOR 1) set(LIMEREPORT_VERSION_MINOR 6) -set(LIMEREPORT_VERSION_RELEASE 6) +set(LIMEREPORT_VERSION_RELEASE 7) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) diff --git a/common.pri b/common.pri index ebf1c89..bbdb45d 100644 --- a/common.pri +++ b/common.pri @@ -141,7 +141,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 6 -LIMEREPORT_VERSION_RELEASE = 0 +LIMEREPORT_VERSION_RELEASE = 7 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/include/lrglobal.h b/include/lrglobal.h index ed0254a..1286a0d 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -157,6 +157,16 @@ namespace Const{ #else typedef QStyleOptionViewItem StyleOptionViewItem; #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression getRegEx(QString expression); + QRegularExpression getVariableRegEx(); + QRegularExpression getFieldRegEx(); + QRegularExpression getScriptRegEx(); + QRegularExpression getGroupFunctionRegEx(QString functionName); + QRegularExpression getGroupFunctionNameRegEx(QString functionName); + QRegularExpression getNamedVariableRegEx(QString variableName); +#endif + class Enums { diff --git a/limereport/databrowser/lrdatabrowsertree.cpp b/limereport/databrowser/lrdatabrowsertree.cpp index 2625602..53934f3 100644 --- a/limereport/databrowser/lrdatabrowsertree.cpp +++ b/limereport/databrowser/lrdatabrowsertree.cpp @@ -36,7 +36,11 @@ namespace LimeReport { DataBrowserTree::DataBrowserTree(QWidget *parent) : QTreeWidget(parent){} +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +QMimeData *DataBrowserTree::mimeData(const QList &items) const +#else QMimeData *DataBrowserTree::mimeData(const QList items) const +#endif { QMimeData* result = QTreeWidget::mimeData(items); if (items.at(0)->type()==Row){ diff --git a/limereport/databrowser/lrdatabrowsertree.h b/limereport/databrowser/lrdatabrowsertree.h index 3cbcdff..eb03791 100644 --- a/limereport/databrowser/lrdatabrowsertree.h +++ b/limereport/databrowser/lrdatabrowsertree.h @@ -42,7 +42,11 @@ public: enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable}; explicit DataBrowserTree(QWidget *parent = 0); protected: - QMimeData* mimeData(const QList items) const; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + virtual QMimeData *mimeData(const QList &items) const; +#else + virtual QMimeData *mimeData(const QList items) const; +#endif public slots: diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 086adca..4ef3db9 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -827,7 +827,7 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); #else - QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); + QRegularExpression rx = getNamedVariableRegEx(variableName); #endif if (context.contains(rx) && pass == FirstPass){ backupContent(); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 71d02e1..8960eeb 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -261,7 +261,6 @@ public: void setAlternateBackgroundColor(const QColor &alternateBackgroundColor); bool useAlternateBackgroundColor() const; void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor); - void replaceGroupsFunction(BandDesignIntf *band); qreal bottomSpace() const; void setBackgroundModeProperty(BGMode value); void setBackgroundOpacity(int value); diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index b3e3738..fa5e355 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -423,8 +423,8 @@ QString DataSourceManager::extractField(QString source) } QString DataSourceManager::replaceVariables(QString value){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(Const::VARIABLE_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getVariableRegEx(); QRegularExpressionMatchIterator iter = rx.globalMatch(value); qsizetype pos = 0; QString result; @@ -468,8 +468,8 @@ QString DataSourceManager::replaceVariables(QString value){ QString DataSourceManager::replaceVariables(QString query, QMap &aliasesToParam) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(Const::VARIABLE_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getVariableRegEx(); int curentAliasIndex = 0; if (query.contains(rx)){ int pos = -1; @@ -553,9 +553,8 @@ QString DataSourceManager::replaceVariables(QString query, QMap QString DataSourceManager::replaceFields(QString query, QMap &aliasesToParam, QString masterDatasource) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - - QRegularExpression rx(Const::FIELD_RX); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getFieldRegEx(); int curentAliasIndex = 0; if (query.contains(rx)){ int pos = -1; @@ -1498,7 +1497,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); #else - QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName)); + QRegularExpression rx = getNamedVariableRegEx(variableName); #endif if (holder->queryText().contains(rx)){ holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE); diff --git a/limereport/lrglobal.cpp b/limereport/lrglobal.cpp index cd2b6c0..ac78588 100644 --- a/limereport/lrglobal.cpp +++ b/limereport/lrglobal.cpp @@ -67,7 +67,7 @@ QString replaceHTMLSymbols(const QString &value) return result; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) QVector normalizeCaptures(const QRegularExpressionMatch& reg){ #else QVector normalizeCaptures(const QRegExp& reg){ @@ -93,4 +93,53 @@ ReportError::ReportError(const QString& message):std::runtime_error(message.toSt IExternalPainter::~IExternalPainter(){} IPainterProxy::~IPainterProxy(){} + +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) +QRegularExpression getRegEx(QString expression){ + return QRegularExpression(expression, QRegularExpression::DotMatchesEverythingOption); +} +QRegularExpression getVariableRegEx(){ + return QRegularExpression( + Const::VARIABLE_RX, + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::CaseInsensitiveOption + ); +} +QRegularExpression getFieldRegEx(){ + return QRegularExpression( + Const::FIELD_RX, + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::CaseInsensitiveOption + ); +} +QRegularExpression getScriptRegEx(){ + return QRegularExpression( + Const::SCRIPT_RX, + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::CaseInsensitiveOption + ); +} +QRegularExpression getGroupFunctionRegEx(QString functionName){ + return QRegularExpression( + QString(Const::GROUP_FUNCTION_RX).arg(functionName), + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::InvertedGreedinessOption + ); +} +QRegularExpression getGroupFunctionNameRegEx(QString functionName){ + return QRegularExpression( + QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName), + QRegularExpression::DotMatchesEverythingOption | + QRegularExpression::InvertedGreedinessOption + ); +} +QRegularExpression getNamedVariableRegEx(QString variableName){ + return QRegularExpression( + QString(Const::NAMED_VARIABLE_RX).arg(variableName), + QRegularExpression::DotMatchesEverythingOption + ); +} +#endif + + } //namespace LimeReport diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index ed0254a..1286a0d 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -157,6 +157,16 @@ namespace Const{ #else typedef QStyleOptionViewItem StyleOptionViewItem; #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression getRegEx(QString expression); + QRegularExpression getVariableRegEx(); + QRegularExpression getFieldRegEx(); + QRegularExpression getScriptRegEx(); + QRegularExpression getGroupFunctionRegEx(QString functionName); + QRegularExpression getGroupFunctionNameRegEx(QString functionName); + QRegularExpression getNamedVariableRegEx(QString variableName); +#endif + class Enums { diff --git a/limereport/lrgroupfunctions.cpp b/limereport/lrgroupfunctions.cpp index 3130832..f893d12 100644 --- a/limereport/lrgroupfunctions.cpp +++ b/limereport/lrgroupfunctions.cpp @@ -48,8 +48,8 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band) QRegExp rxField(Const::FIELD_RX); QRegExp rxVar(Const::VARIABLE_RX); #else - QRegularExpression rxField(Const::FIELD_RX); - QRegularExpression rxVar(Const::VARIABLE_RX); + QRegularExpression rxField = getFieldRegEx(); + QRegularExpression rxVar = getVariableRegEx(); #endif switch (m_dataType){ @@ -154,9 +154,9 @@ GroupFunction::GroupFunction(const QString &expression, const QString &dataBandN QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive); QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive); #else - QRegularExpression rxField(Const::FIELD_RX, QRegularExpression::CaseInsensitiveOption); - QRegularExpression rxVariable(Const::VARIABLE_RX, QRegularExpression::CaseInsensitiveOption); - QRegularExpression rxScript(Const::SCRIPT_RX, QRegularExpression::CaseInsensitiveOption); + QRegularExpression rxField = getFieldRegEx(); + QRegularExpression rxVariable = getVariableRegEx(); + QRegularExpression rxScript = getScriptRegEx(); #endif #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) if (rxScript.indexIn(expression) != -1){ diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 6e7477b..659244d 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -726,7 +726,6 @@ ReportEnginePrivate *PageDesignIntf::reportEditor() void PageDesignIntf::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { - if (!event->mimeData()->text().isEmpty()){ event->setDropAction(Qt::CopyAction); event->accept(); @@ -755,7 +754,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) if (isVar) data = data.remove(QRegExp(" \\[.*\\]")); #else - if (isVar) data = data.remove(QRegularExpression(" \\[.*\\]")); + if (isVar) data = data.remove(QRegularExpression(" \\[.*\\]", QRegularExpression::DotMatchesEverythingOption)); #endif ti->setContent(data); if (!isVar){ @@ -767,7 +766,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event) parentBand->setProperty("datasource",dataSource.cap(1)); } #else - QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})"); + QRegularExpression dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})", QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatch match = dataSource.match(data); if(match.hasMatch()){ parentBand->setProperty("datasource", match.captured(1)); diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 917bf04..d412b19 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -196,13 +196,11 @@ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignInt QString content = contentItem->content(); QVector functions; foreach(const QString &functionName, m_datasources->groupFunctionNames()){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getGroupFunctionRegEx(functionName); if(content.indexOf(rx)>=0){ functions.append(functionName); } - // TODO: Qt6 port - done #else QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); rx.setMinimal(true); @@ -368,13 +366,11 @@ void ReportRender::clearPageMap() bool checkContentItem(ContentItemDesignIntf* item, DataSourceManager* datasources){ QString content = item->content(); foreach(QString functionName, datasources->groupFunctionNames()){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getGroupFunctionRegEx(functionName); if(content.indexOf(rx)>=0){ return true; } - // TODO: Qt6 port - done #else QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); if (rx.indexIn(content)>=0){ @@ -400,16 +396,14 @@ bool ReportRender::containsGroupFunctions(BaseDesignIntf *container){ } void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - - if ( contentItem && contentItem->content().contains(QRegularExpression("\\$S\\s*\\{.*\\}"))){ +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + if ( contentItem && contentItem->content().contains(getScriptRegEx())){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){ - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); - QRegularExpression rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName)); - rxName.setPatternOptions(rx.InvertedGreedinessOption); + QRegularExpression rx = getGroupFunctionRegEx(functionName); + QRegularExpression rxName = getGroupFunctionNameRegEx(functionName); QRegularExpressionMatch match = rx.match(contentItem->content()); + if (match.hasMatch()){ QRegularExpressionMatchIterator iter = rx.globalMatch(contentItem->content()); @@ -437,31 +431,7 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt } } } -// int pos = 0; -// while ( (pos = match.capturedStart()) != -1){ -// QVector captures = normalizeCaptures(match); -// if (captures.size() >= 3){ -// int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX; -// BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex)); -// if (dataBand){ -// GroupFunction* gf = datasources()->addGroupFunction( -// functionName, captures.at(Const::VALUE_INDEX), band->objectName(), dataBand->objectName() -// ); -// if (gf){ -// connect(dataBand, SIGNAL(bandRendered(BandDesignIntf*)), -// gf, SLOT(slotBandRendered(BandDesignIntf*))); -// connect(dataBand, SIGNAL(bandReRendered(BandDesignIntf*, BandDesignIntf*)), -// gf, SLOT(slotBandReRendered(BandDesignIntf*, BandDesignIntf*))); -// } -// } else { -// GroupFunction* gf = datasources()->addGroupFunction( -// functionName, captures.at(Const::VALUE_INDEX), band->objectName(), captures.at(dsIndex) -// ); -// gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex))); -// } -// } -// match = rx.match(contentItem->content(), pos + match.capturedLength()); -// } + } else if (contentItem->content().indexOf(rxName)>=0){ match = rxName.match(contentItem->content()); GroupFunction* gf = datasources()->addGroupFunction(functionName, match.captured(1), band->objectName(), ""); @@ -470,7 +440,6 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt } } - // TODO: Qt6 port - done #else if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){ foreach(const QString &functionName, m_datasources->groupFunctionNames()){ @@ -529,10 +498,8 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte if (m_groupfunctionItems.contains(contentItem->patternName())){ QString content = contentItem->content(); foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) - - QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); - rx.setPatternOptions(rx.InvertedGreedinessOption); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) + QRegularExpression rx = getGroupFunctionRegEx(functionName); QRegularExpressionMatch match = rx.match(content); if (match.capturedStart() != -1){ @@ -556,7 +523,6 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte match = rx.match(content, pos + match.capturedLength()); } } - // TODO: Qt6 port - done #else QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); rx.setMinimal(true); diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 2abc084..952c8e2 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -398,7 +398,7 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* } return context; #else - QRegularExpression rx(Const::VARIABLE_RX); + QRegularExpression rx = getVariableRegEx(); if (context.contains(rx)){ int pos = 0; QRegularExpressionMatch match = rx.match(context, pos); @@ -504,8 +504,7 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand return context; #else - QRegularExpression rx(Const::FIELD_RX); - + QRegularExpression rx = getFieldRegEx(); if (context.contains(rx)){ QRegularExpressionMatch match = rx.match(context); while (match.hasMatch()){ @@ -567,8 +566,7 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, if (context.contains(rx)){ #else - QRegularExpression rx(Const::SCRIPT_RX, QRegularExpression::DotMatchesEverythingOption); - + QRegularExpression rx = getScriptRegEx(); if(context.contains(rx)){ #endif @@ -636,8 +634,8 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){ QVariant varValue; if (script.contains(rx)){ -#else - QRegularExpression rx(Const::SCRIPT_RX); +#else + QRegularExpression rx = getScriptRegEx(); QVariant varValue; if (script.contains(rx)){ @@ -1110,7 +1108,7 @@ bool ScriptExtractor::parse() bool ScriptExtractor::parse(int &curPos, const State& state, ScriptNode::Ptr scriptNode) { - while (curPosisValid()){ return gf->calculate(pageItem); - }else{ + } else{ return gf->error(); } - } - else { + } else { return QString(QObject::tr("Function %1 not found or have wrong arguments").arg(name)); } } else { diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 7c3bccd..59979ae 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -401,7 +401,11 @@ private: class ScriptNode{ public: typedef QSharedPointer Ptr; - QString body(){return m_body;} + QString body(){ + if (m_body.isEmpty() && m_children.count() > 0) + return m_children.at(0)->body(); + return m_body; + } void setBody(const QString& body){ m_body = body;} void setStartLex(const QString startLex){ m_startLex = startLex;} QString script(){return m_startLex + m_body + '}';} From 1b1c0d52bcaf74b7ac0d8589feac11477bec3714 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Mon, 18 Jul 2022 18:45:09 +0300 Subject: [PATCH 09/30] TextItem: Value trimming behavior has been fixed --- limereport/items/lrtextitem.cpp | 39 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 4ef3db9..73b9dfd 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -276,10 +276,6 @@ void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, Q BaseDesignIntf::paint(painter, style, widget); } -QString TextItem::content() const{ - return m_strText; -} - void TextItem::Init() { m_autoWidth = NoneAutoWidth; @@ -299,14 +295,8 @@ void TextItem::setContent(const QString &value) { if (m_strText.compare(value)!=0){ QString oldValue = m_strText; - if (m_trimValue) - m_strText=value.trimmed(); - else - m_strText=value; -// if (itemMode() == DesignMode && (autoHeight())){ -// initTextSizes(); -// } + m_strText = value; if (!isLoading()){ if (autoHeight() || autoWidth() || hasFollower()) @@ -317,6 +307,10 @@ void TextItem::setContent(const QString &value) } } +QString TextItem::content() const{ + return m_strText; +} + void TextItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { @@ -494,28 +488,30 @@ QString TextItem::formatFieldValue() } switch (value.type()) { - case QVariant::Date: - case QVariant::DateTime: - return formatDateTime(value.toDateTime()); - case QVariant::Double: - return formatNumber(value.toDouble()); - default: - return value.toString(); + case QVariant::Date: + case QVariant::DateTime: + return formatDateTime(value.toDateTime()); + case QVariant::Double: + return formatNumber(value.toDouble()); + default: + return value.toString(); } + } TextItem::TextPtr TextItem::textDocument() const { TextPtr text(new QTextDocument); + QString content = m_trimValue ? m_strText.trimmed() : m_strText; if (allowHTML()) if (isReplaceCarriageReturns()){ - text->setHtml(replaceReturns(m_strText)); + text->setHtml(replaceReturns(content)); } else { - text->setHtml(m_strText); + text->setHtml(content); } else - text->setPlainText(m_strText); + text->setPlainText(content); QTextOption to; to.setAlignment(m_alignment); @@ -785,6 +781,7 @@ void TextItem::setTrimValue(bool value) { bool oldValue = m_trimValue; m_trimValue = value; + update(); notify("trimValue",oldValue,value); } From a865e92a2328343f0c97c73e6c4e40be4cf84588 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Tue, 19 Jul 2022 00:43:54 +0300 Subject: [PATCH 10/30] Fixed some deprecation warnings --- CMakeLists.txt | 4 +-- common.pri | 2 +- limereport/items/lrimageitem.cpp | 22 ++++++++++-- limereport/items/lrsvgitem.cpp | 15 ++++++-- limereport/items/lrtextitem.cpp | 12 +++++++ limereport/lrbasedesignintf.cpp | 19 +++++++--- limereport/lrdatadesignintf.cpp | 5 +++ limereport/lrdatasourcemanager.cpp | 9 +++-- limereport/lrscriptenginemanager.cpp | 35 +++++++++++++------ .../editors/lrcomboboxeditor.cpp | 7 +++- .../propertyItems/lrrectproptem.cpp | 12 +++++++ limereport/serializators/lrxmlwriter.cpp | 22 ++++++++++-- .../translationeditor/translationeditor.cpp | 7 +++- .../translationeditor/translationeditor.h | 1 + 14 files changed, 141 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb10889..00f0869 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) set(LIMEREPORT_VERSION_MAJOR 1) set(LIMEREPORT_VERSION_MINOR 6) -set(LIMEREPORT_VERSION_RELEASE 7) +set(LIMEREPORT_VERSION_RELEASE 8) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) @@ -38,7 +38,7 @@ endif() add_subdirectory(3rdparty) add_subdirectory(designer EXCLUDE_FROM_ALL) -add_subdirectory(demo_r1 EXCLUDE_FROM_ALL) +add_subdirectory(demo_r1 EXCLUDE_FROM_ALL) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) diff --git a/common.pri b/common.pri index bbdb45d..160fdce 100644 --- a/common.pri +++ b/common.pri @@ -141,7 +141,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 6 -LIMEREPORT_VERSION_RELEASE = 7 +LIMEREPORT_VERSION_RELEASE = 8 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 02f7daa..8fc3975 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -61,8 +61,13 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par } void ImageItem::loadPictureFromVariant(QVariant& data){ + //TODO: Migrate to QMetaType if (data.isValid()){ - if (data.type()==QVariant::Image){ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + if (data.typeId() == QMetaType::QImage){ +#else + if (data.type() == QVariant::Image){ +#endif m_picture = data.value(); } else { switch (m_format) { @@ -178,11 +183,22 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager); m_picture = QImage(m_resourcePath); } else if (!m_variable.isEmpty()){ + //TODO: Migrate to QMetaType QVariant data = dataManager->variable(m_variable); +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + if (data.typeId() == QMetaType::QString){ +#else if (data.type() == QVariant::String){ +#endif m_picture = QImage(data.toString()); - } else if (data.type() == QVariant::Image){ - loadPictureFromVariant(data); + } else { +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + if (data.typeId() == QMetaType::QImage){ +#else + if (data.type() == QVariant::Image){ +#endif + loadPictureFromVariant(data); + } } } } diff --git a/limereport/items/lrsvgitem.cpp b/limereport/items/lrsvgitem.cpp index fe3c1a1..9bf1ea6 100644 --- a/limereport/items/lrsvgitem.cpp +++ b/limereport/items/lrsvgitem.cpp @@ -107,11 +107,22 @@ void SVGItem::updateItemSize(DataSourceManager *dataManager, RenderPass pass, in m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager); m_image = imageFromResource(m_resourcePath); } else if (!m_variable.isEmpty()){ + //TODO: Migrate to QMetaType QVariant data = dataManager->variable(m_variable); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (data.typeId() == QMetaType::QString){ +#else if (data.type() == QVariant::String){ +#endif m_image = imageFromResource(data.toString()); - } else if (data.type() == QVariant::ByteArray) { - m_image = data.value() ; + } else { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (data.typeId() == QMetaType::QByteArray) { +#else + if (data.type() == QVariant::ByteArray) { +#endif + m_image = data.value() ; + } } } } diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 73b9dfd..fb14eb6 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -487,6 +487,7 @@ QString TextItem::formatFieldValue() } } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) switch (value.type()) { case QVariant::Date: case QVariant::DateTime: @@ -496,6 +497,17 @@ QString TextItem::formatFieldValue() default: return value.toString(); } +#else + switch (value.typeId()) { + case QMetaType::QDate: + case QMetaType::QDateTime: + return formatDateTime(value.toDateTime()); + case QMetaType::Double: + return formatNumber(value.toDouble()); + default: + return value.toString(); + } +#endif } diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 9b93395..bc1328a 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -1349,18 +1349,27 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QAction* lockGeometryAction = menu.addAction(tr("Lock item geometry")); lockGeometryAction->setCheckable(true); - lockGeometryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); + lockGeometryAction->setChecked(isGeometryLocked()); menu.addSeparator(); QAction* copyAction = menu.addAction(QIcon(":/report/images/copy"), tr("Copy")); - copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); - QAction* cutAction = menu.addAction(QIcon(":/report/images/cut"), tr("Cut")); - cutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); + QAction* cutAction = menu.addAction(QIcon(":/report/images/cut"), tr("Cut")); QAction* pasteAction = menu.addAction(QIcon(":/report/images/paste"), tr("Paste")); - pasteAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V)); pasteAction->setEnabled(false); +#if QT_VERSION >=QT_VERSION_CHECK(5,0,0) + lockGeometryAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_L)); + copyAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_C)); + cutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_X)); + pasteAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_V)); +#else + lockGeometryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); + copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); + cutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); + pasteAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V)); +#endif + QClipboard *clipboard = QApplication::clipboard(); ItemsReaderIntf::Ptr reader = StringXMLreader::create(clipboard->text()); if (reader->first() && reader->itemType() == "Object"){ diff --git a/limereport/lrdatadesignintf.cpp b/limereport/lrdatadesignintf.cpp index f970c86..0315c27 100644 --- a/limereport/lrdatadesignintf.cpp +++ b/limereport/lrdatadesignintf.cpp @@ -85,7 +85,12 @@ bool QueryHolder::runQuery(IDataSource::DatasourceMode mode) query.exec(); QSqlQueryModel *model = new QSqlQueryModel; + +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + model->setQuery(std::move(query)); +#else model->setQuery(query); +#endif while (model->canFetchMore()) model->fetchMore(); diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index fa5e355..91f1189 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -392,7 +392,13 @@ QSharedPointerDataSourceManager::previewSQL(const QString &c } query.exec(); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + model->setQuery(std::move(query)); +#else model->setQuery(query); +#endif + m_lastError = model->lastError().text(); putError(m_lastError); if (model->query().isActive()) @@ -443,7 +449,6 @@ QString DataSourceManager::replaceVariables(QString value){ } result += value.mid(pos); return result; - // TODO: Qt6 port - done #else QRegExp rx(Const::VARIABLE_RX); @@ -508,7 +513,6 @@ QString DataSourceManager::replaceVariables(QString query, QMap match = rx.match(query); } } - // TODO: Qt6 port - done #else QRegExp rx(Const::VARIABLE_RX); int curentAliasIndex = 0; @@ -582,7 +586,6 @@ QString DataSourceManager::replaceFields(QString query, QMap &a match = rx.match(query); } } - // TODO: Qt6 port - done #else QRegExp rx(Const::FIELD_RX); if (query.contains(rx)){ diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 952c8e2..05e8cde 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -519,17 +519,32 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand 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; + //TODO: Migrate to QMetaType +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + switch (dataManager()->fieldData(field).typeId()) { + case QMetaType::QChar: + case QMetaType::QString: + case QMetaType::QStringList: + case QMetaType::QDate: + case QMetaType::QDateTime: + fieldValue = "\""+fieldValue+"\""; + break; + default: + break; } +#else + 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; + } +#endif } } else { if (expandType == ReplaceHTMLSymbols) diff --git a/limereport/objectinspector/editors/lrcomboboxeditor.cpp b/limereport/objectinspector/editors/lrcomboboxeditor.cpp index d034c50..3a4748a 100644 --- a/limereport/objectinspector/editors/lrcomboboxeditor.cpp +++ b/limereport/objectinspector/editors/lrcomboboxeditor.cpp @@ -56,7 +56,12 @@ ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) : connect(m_buttonClear,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked())); } - connect(m_comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotCurrentIndexChanged(QString))); +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + connect(m_comboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString))); +#else + connect(m_comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString))); +#endif + m_comboBox->installEventFilter(this); QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(m_comboBox); diff --git a/limereport/objectinspector/propertyItems/lrrectproptem.cpp b/limereport/objectinspector/propertyItems/lrrectproptem.cpp index 20c2b56..d95e487 100644 --- a/limereport/objectinspector/propertyItems/lrrectproptem.cpp +++ b/limereport/objectinspector/propertyItems/lrrectproptem.cpp @@ -85,6 +85,17 @@ LimeReport::RectPropItem::RectPropItem(QObject *object, ObjectsList* objects, co QString LimeReport::RectPropItem::displayValue() const { + //TODO: Migrate to QMetaType +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + switch(propertyValue().typeId()){ + case QMetaType::QRect: + return rectToString(propertyValue().toRect()); + case QMetaType::QRectF: + return rectToString(propertyValue().toRect()); + default : + return ObjectPropItem::displayValue(); + } +#else switch(propertyValue().type()){ case QVariant::Rect: return rectToString(propertyValue().toRect()); @@ -93,6 +104,7 @@ QString LimeReport::RectPropItem::displayValue() const default : return ObjectPropItem::displayValue(); } +#endif } LimeReport::RectUnitPropItem::RectUnitPropItem(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool /*readonly*/): diff --git a/limereport/serializators/lrxmlwriter.cpp b/limereport/serializators/lrxmlwriter.cpp index 7da6046..fdae62c 100644 --- a/limereport/serializators/lrxmlwriter.cpp +++ b/limereport/serializators/lrxmlwriter.cpp @@ -193,13 +193,23 @@ bool XMLWriter::enumOrFlag(QString name, QObject *item) bool XMLWriter::isCollection(QString propertyName, QObject* item) { QMetaProperty prop=item->metaObject()->property(item->metaObject()->indexOfProperty(propertyName.toLatin1())); - return QMetaType::type(prop.typeName())==COLLECTION_TYPE_ID; + //TODO: Migrate to QMetaType +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QMetaType::fromName(prop.typeName()).id() == COLLECTION_TYPE_ID; +#else + return QMetaType::type(prop.typeName()) == COLLECTION_TYPE_ID; +#endif } bool XMLWriter::isTranslation(QString propertyName, QObject* item) { QMetaProperty prop=item->metaObject()->property(item->metaObject()->indexOfProperty(propertyName.toLatin1())); - return QMetaType::type(prop.typeName())==TRANSLATION_TYPE_ID; + //TODO: Migrate to QMetaType +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QMetaType::fromName(prop.typeName()).id() == TRANSLATION_TYPE_ID; +#else + return QMetaType::type(prop.typeName()) == TRANSLATION_TYPE_ID; +#endif } void XMLWriter::saveCollection(QString propertyName, QObject *item, QDomElement *node) @@ -254,7 +264,13 @@ void XMLWriter::saveTranslation(QString propertyName, QObject* item, QDomElement bool XMLWriter::isQObject(QString propertyName, QObject *item) { QMetaProperty prop=item->metaObject()->property(item->metaObject()->indexOfProperty(propertyName.toLatin1())); - return QMetaType::type(prop.typeName())==QMetaType::QObjectStar; + //TODO: Migrate to QMetaType +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QMetaType::fromName(prop.typeName()).id() == QMetaType::QObjectStar; +#else + return QMetaType::type(prop.typeName()) == QMetaType::QObjectStar; +#endif + } bool XMLWriter::replaceNode(QDomElement node, QObject* item) diff --git a/limereport/translationeditor/translationeditor.cpp b/limereport/translationeditor/translationeditor.cpp index 8006c3b..a2e693e 100644 --- a/limereport/translationeditor/translationeditor.cpp +++ b/limereport/translationeditor/translationeditor.cpp @@ -29,7 +29,11 @@ TranslationEditor::TranslationEditor(QWidget *parent) : ui->tbStrings->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("Report Item"))); ui->tbStrings->setHorizontalHeaderItem(2,new QTableWidgetItem(tr("Property"))); ui->tbStrings->setHorizontalHeaderItem(3,new QTableWidgetItem(tr("Source text"))); - new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(slotItemChecked())); +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + m_clrReturn = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Return), this, SLOT(slotItemChecked())); +#else + m_clrReturn = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(slotItemChecked())); +#endif //ui->tbStrings->setSortingEnabled(true); } @@ -50,6 +54,7 @@ void TranslationEditor::setReportEngine(ITranslationContainer* translationContai TranslationEditor::~TranslationEditor() { delete ui; + delete m_clrReturn; } QLocale::Language TranslationEditor::getLanguageByName(const QString& languageName){ diff --git a/limereport/translationeditor/translationeditor.h b/limereport/translationeditor/translationeditor.h index 48fbb0b..954bf34 100644 --- a/limereport/translationeditor/translationeditor.h +++ b/limereport/translationeditor/translationeditor.h @@ -46,6 +46,7 @@ private: PageTranslation* m_currentPageTranslation; PropertyTranslation* m_currentPropertyTranslation; bool m_translationChanging; + QShortcut* m_clrReturn; }; } //namespace LimeReport From b6839a509ac08e8cd4db70d7cdad3a33ac7294e7 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Tue, 23 Aug 2022 01:31:12 +0300 Subject: [PATCH 11/30] build has been fixed --- include/lrglobal.h | 2 +- limereport/items/lrimageitem.cpp | 6 +++--- limereport/lrglobal.h | 2 +- limereport/translationeditor/translationeditor.h | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/lrglobal.h b/include/lrglobal.h index 1286a0d..b2fe56c 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -104,7 +104,7 @@ namespace Const{ QString extractClassName(QString className); QString escapeSimbols(const QString& value); QString replaceHTMLSymbols(const QString &value); -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) QVector normalizeCaptures(const QRegularExpressionMatch ®); #else QVector normalizeCaptures(const QRegExp ®); diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 8fc3975..0459b67 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -63,7 +63,7 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par void ImageItem::loadPictureFromVariant(QVariant& data){ //TODO: Migrate to QMetaType if (data.isValid()){ -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (data.typeId() == QMetaType::QImage){ #else if (data.type() == QVariant::Image){ @@ -185,14 +185,14 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, } else if (!m_variable.isEmpty()){ //TODO: Migrate to QMetaType QVariant data = dataManager->variable(m_variable); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (data.typeId() == QMetaType::QString){ #else if (data.type() == QVariant::String){ #endif m_picture = QImage(data.toString()); } else { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) if (data.typeId() == QMetaType::QImage){ #else if (data.type() == QVariant::Image){ diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index 1286a0d..b2fe56c 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -104,7 +104,7 @@ namespace Const{ QString extractClassName(QString className); QString escapeSimbols(const QString& value); QString replaceHTMLSymbols(const QString &value); -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) QVector normalizeCaptures(const QRegularExpressionMatch ®); #else QVector normalizeCaptures(const QRegExp ®); diff --git a/limereport/translationeditor/translationeditor.h b/limereport/translationeditor/translationeditor.h index 954bf34..2288b25 100644 --- a/limereport/translationeditor/translationeditor.h +++ b/limereport/translationeditor/translationeditor.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "lrreporttranslation.h" namespace LimeReport { From 0944aa15bd857e0888c0fb3aae823aafedacb5be Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 17 Sep 2022 07:53:58 +0000 Subject: [PATCH 12/30] Create github actions pipeline --- .github/workflows/cmake.yml | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..57437ed --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,47 @@ +name: CMake + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-${{ matrix.ubuntu_version }} + name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} + strategy: + fail-fast: false + matrix: + ubuntu_version: [20.04, 22.04] + qt_version: [5.12.12, 5.15.2, 6.3.0] + static: [ON, OFF] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_version }} + cache: 'true' + cache-key-prefix: ${{ runner.os }}-Qt-Cache-${{ matrix.qt_version }} + dir: ${{ github.workspace }}/Qt + + - name: Configure CMake for Qt5 + if: "startsWith(matrix.qt_version, '5.')" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + + - name: Configure CMake for Qt6 + if: "startsWith(matrix.qt_version, '6.')" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + From 3361113946332cd770fe373c84019d598c7932b8 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Wed, 12 Oct 2022 18:27:39 +0300 Subject: [PATCH 13/30] Update README.md cmake bage added --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f03702b..6fab887 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # LimeReport v1.5.87 [![Build Status](https://app.travis-ci.com/fralx/LimeReport.svg?branch=master)](https://app.travis-ci.com/fralx/LimeReport) [![Build status](https://ci.appveyor.com/api/projects/status/wna5429pix7ilcmo/branch/master?svg=true)](https://ci.appveyor.com/project/fralx/limereport/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) +https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From 6f588477857786b7c50001b3dce6c9043bf04b87 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Wed, 12 Oct 2022 18:31:07 +0300 Subject: [PATCH 14/30] Update README.md cmake badge added --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fab887..fd1dcbe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LimeReport v1.5.87 [![Build Status](https://app.travis-ci.com/fralx/LimeReport.svg?branch=master)](https://app.travis-ci.com/fralx/LimeReport) [![Build status](https://ci.appveyor.com/api/projects/status/wna5429pix7ilcmo/branch/master?svg=true)](https://ci.appveyor.com/project/fralx/limereport/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) -https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg +[!Cmake Build Status](https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From 9c5a219ceb855f1e5566d62d0fb27b4e239ced69 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Wed, 12 Oct 2022 18:33:07 +0300 Subject: [PATCH 15/30] Update README.md cmake badge added --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index fd1dcbe..3e80b4c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -# LimeReport v1.5.87 [![Build Status](https://app.travis-ci.com/fralx/LimeReport.svg?branch=master)](https://app.travis-ci.com/fralx/LimeReport) [![Build status](https://ci.appveyor.com/api/projects/status/wna5429pix7ilcmo/branch/master?svg=true)](https://ci.appveyor.com/project/fralx/limereport/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) -[!Cmake Build Status](https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg) +# LimeReport v1.5.87 [![Build Status](https://app.travis-ci.com/fralx/LimeReport.svg?branch=master)](https://app.travis-ci.com/fralx/LimeReport) [![Build status](https://ci.appveyor.com/api/projects/status/wna5429pix7ilcmo/branch/master?svg=true)](https://ci.appveyor.com/project/fralx/limereport/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) ![Cmake Build Status](https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From adc74053e38d5685270a36595e01a638e54a5f54 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Wed, 12 Oct 2022 18:46:15 +0300 Subject: [PATCH 16/30] Update README.md travis badge removed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e80b4c..78ff6ac 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# LimeReport v1.5.87 [![Build Status](https://app.travis-ci.com/fralx/LimeReport.svg?branch=master)](https://app.travis-ci.com/fralx/LimeReport) [![Build status](https://ci.appveyor.com/api/projects/status/wna5429pix7ilcmo/branch/master?svg=true)](https://ci.appveyor.com/project/fralx/limereport/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) ![Cmake Build Status](https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg) +# LimeReport v1.5.87 [![Build status](https://ci.appveyor.com/api/projects/status/wna5429pix7ilcmo/branch/master?svg=true)](https://ci.appveyor.com/project/fralx/limereport/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) ![Cmake Build Status](https://github.com/fralx/limereport/actions/workflows/cmake.yml/badge.svg) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From 2059a2a16437528e80736cc51445c7adb13cd484 Mon Sep 17 00:00:00 2001 From: Dmitry Zagorodnev Date: Thu, 20 Oct 2022 14:25:53 +0300 Subject: [PATCH 17/30] Fix: ImageItem added isEmpty --- limereport/items/lrimageitem.cpp | 11 ++++++++--- limereport/items/lrimageitem.h | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 0459b67..00ed897 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -111,14 +111,14 @@ void ImageItem::processPopUpAction(QAction *action) ItemDesignIntf::processPopUpAction(action); } -QImage getFileByResourcePath(QString resourcePath){ +QImage getFileByResourcePath(QString resourcePath) { QFileInfo resourceFile(resourcePath); if (resourceFile.exists()) return QImage(resourcePath); return QImage(); } -QImage ImageItem::drawImage() +QImage ImageItem::drawImage() const { if (image().isNull()) return getFileByResourcePath(m_resourcePath); @@ -410,7 +410,7 @@ void ImageItem::setImage(QImage value) } } -QImage ImageItem::image(){ +QImage ImageItem::image() const{ return m_picture; } @@ -439,3 +439,8 @@ void ImageItem::setFormat(Format format) } } + +bool LimeReport::ImageItem::isEmpty() const +{ + return drawImage().isNull(); +} diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index 5640e8a..7d6127d 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -67,7 +67,7 @@ public: ImageItem(QObject *owner, QGraphicsItem *parent); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setImage(QImage value); - QImage image(); + QImage image() const; void setResourcePath(const QString &value); QString resourcePath() const; QString datasource() const; @@ -108,7 +108,7 @@ protected: void loadPictureFromVariant(QVariant& data); void preparePopUpMenu(QMenu &menu); void processPopUpAction(QAction *action); - QImage drawImage(); + QImage drawImage() const; private: QImage m_picture; bool m_useExternalPainter; @@ -121,8 +121,12 @@ private: bool m_keepAspectRatio; bool m_center; Format m_format; - QString m_variable; + QString m_variable; + + // BaseDesignIntf interface + public: + bool isEmpty() const override; }; } From 4903abc40808c7f2eb7b1109b192cb7e3d61514d Mon Sep 17 00:00:00 2001 From: Dmitry Zagorodnev Date: Mon, 24 Oct 2022 13:07:25 +0300 Subject: [PATCH 18/30] + --- limereport/items/lrtextitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index fb14eb6..4677892 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -389,6 +389,7 @@ void TextItem::setTextFont(TextPtr text, const QFont& value) const { void TextItem::adaptFontSize(TextPtr text) const{ QFont _font = transformToSceneFont(font()); do{ +// qApp->processEvents(); setTextFont(text,_font); if (_font.pixelSize()>2) _font.setPixelSize(_font.pixelSize()-1); From 2c5ed82376fc0d0a5137d2cded7f3bd4c4150509 Mon Sep 17 00:00:00 2001 From: Dmitry Zagorodnev Date: Mon, 24 Oct 2022 14:57:31 +0300 Subject: [PATCH 19/30] Fix: ImageItem::paint --- limereport/items/lrimageitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 00ed897..4958807 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -364,7 +364,7 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, } if (shiftHeight > 0){ - point.setY(point.x()+shiftHeight/2); + point.setY(point.y()+shiftHeight/2); } else { cutY = fabs(shiftHeight/2); cutHeigth += shiftHeight; From f00f72efa98ce27aeaa1e5ecd8dee2ba9791acf0 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 30 Oct 2022 12:26:13 +0300 Subject: [PATCH 20/30] Github actions: add support msvc, mingw, macos --- .github/workflows/cmake.yml | 129 +++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 57437ed..be1b89b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: ubuntu_version: [20.04, 22.04] - qt_version: [5.12.12, 5.15.2, 6.3.0] + qt_version: [5.15.2, 6.4.0] static: [ON, OFF] steps: @@ -45,3 +45,130 @@ jobs: - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + MSVC: + name: windows-${{ matrix.win_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} + runs-on: windows-${{ matrix.win_version }} + strategy: + fail-fast: false + matrix: + win_version: [2019, 2022] + qt_version: [5.15.2, 6.4.0] + static: [ON, OFF] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_version }} + cache: 'true' + cache-key-prefix: ${{ runner.os }}-Qt-Cache-${{ matrix.qt_version }} + dir: ${{ github.workspace }}/Qt + + - name: Configure CMake for Qt5 + if: "startsWith(matrix.qt_version, '5.')" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + + - name: Configure CMake for Qt6 + if: "startsWith(matrix.qt_version, '6.')" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + MinGW-w64: + runs-on: windows-2022 + name: msys2-${{ matrix.msystem }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} + strategy: + fail-fast: false + matrix: + qt_version: [5, 6] + msystem: [UCRT64, CLANG64] + static: [ON, OFF] + defaults: + run: + shell: msys2 {0} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install MinGW-w64 packages Qt5 + if: "startsWith(matrix.qt_version, '5')" + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} + release: false + update: true + pacboy: >- + cc:p + cmake:p + ninja:p + qt${{ matrix.qt_version }}-base:p + qt${{ matrix.qt_version }}-svg:p + qt${{ matrix.qt_version }}-tools:p + qt${{ matrix.qt_version }}-quickcontrols:p + + - name: Install MinGW-w64 packages Qt6 + if: "startsWith(matrix.qt_version, '6')" + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.msystem }} + release: false + update: true + pacboy: >- + cc:p + cmake:p + ninja:p + qt${{ matrix.qt_version }}-base:p + qt${{ matrix.qt_version }}-svg:p + qt${{ matrix.qt_version }}-tools:p + qt${{ matrix.qt_version }}-declarative:p + + - name: Configure CMake for Qt5 + if: "startsWith(matrix.qt_version, '5')" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + + - name: Configure CMake for Qt6 + if: "startsWith(matrix.qt_version, '6')" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + - name: Build + run: cmake --build '${{github.workspace}}/build' --config ${{env.BUILD_TYPE}} + macos: + runs-on: macos-${{ matrix.macos_version }} + name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} + strategy: + fail-fast: false + matrix: + macos_version: [11, 12] + qt_version: [5.15.2, 6.4.0] + static: [ON, OFF] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_version }} + cache: 'true' + cache-key-prefix: ${{ runner.os }}-Qt-Cache-${{ matrix.qt_version }} + dir: ${{ github.workspace }}/Qt + + - name: Configure CMake for Qt5 + if: "startsWith(matrix.qt_version, '5.')" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + + - name: Configure CMake for Qt6 + if: "startsWith(matrix.qt_version, '6.')" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} \ No newline at end of file From e6ead26d31385cc62e969339623ce9d45717b0f8 Mon Sep 17 00:00:00 2001 From: Jihadist Date: Sun, 30 Oct 2022 20:44:59 +0300 Subject: [PATCH 21/30] Cmake fixes: non exported symbols, missing files, shared import, rewrite cmake for demo and designer --- .github/workflows/cmake.yml | 16 ++++++------ CMakeLists.txt | 27 +++++++++++++++---- demo_r1/CMakeLists.txt | 9 ++++--- designer/CMakeLists.txt | 10 +++---- limereport/items/lrbordereditor.h | 2 +- limereport/items/lrpageeditor.cpp | 33 +++++++++++++----------- limereport/items/lrpageeditor.h | 2 +- limereport/lrbasedesignintf.h | 8 +++--- limereport/lrcollection.h | 6 ++--- limereport/lrglobal.h | 10 +++---- limereport/lritemscontainerdesignitf.h | 12 ++++----- limereport/lrpageitemdesignintf.h | 2 +- limereport/serializators/lrstorageintf.h | 7 ++--- 13 files changed, 83 insertions(+), 61 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index be1b89b..1233e7a 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -35,12 +35,12 @@ jobs: - name: Configure CMake for Qt5 if: "startsWith(matrix.qt_version, '5.')" - run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Configure CMake for Qt6 if: "startsWith(matrix.qt_version, '6.')" - run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} @@ -69,12 +69,12 @@ jobs: - name: Configure CMake for Qt5 if: "startsWith(matrix.qt_version, '5.')" - run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Configure CMake for Qt6 if: "startsWith(matrix.qt_version, '6.')" - run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} @@ -130,12 +130,12 @@ jobs: - name: Configure CMake for Qt5 if: "startsWith(matrix.qt_version, '5')" - run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Configure CMake for Qt6 if: "startsWith(matrix.qt_version, '6')" - run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Build run: cmake --build '${{github.workspace}}/build' --config ${{env.BUILD_TYPE}} @@ -163,12 +163,12 @@ jobs: - name: Configure CMake for Qt5 if: "startsWith(matrix.qt_version, '5.')" - run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Configure CMake for Qt6 if: "startsWith(matrix.qt_version, '6.')" - run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -B "${{github.workspace}}/build" + run: cmake -DUSE_QT6=ON -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build" - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 00f0869..64ce1b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ set(LIMEREPORT_VERSION_RELEASE 8) option(ENABLE_ZINT "Enable libzint build for barcode support" OFF) option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF) +option(LIMEREPORT_DEMO "Build LimeReport demos" OFF) option(USE_QT6 "Use Qt6" OFF) if(USE_QT6) @@ -37,8 +38,11 @@ if (Qt${QT_VERSION_MAJOR}Widgets_FOUND) endif() add_subdirectory(3rdparty) -add_subdirectory(designer EXCLUDE_FROM_ALL) -add_subdirectory(demo_r1 EXCLUDE_FROM_ALL) + +if (LIMEREPORT_DEMO) + add_subdirectory(designer) + add_subdirectory(demo_r1) +endif() set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) @@ -79,6 +83,8 @@ ${PROJECT_NAME}/items/editors/lritemsborderseditorwidget.cpp ${PROJECT_NAME}/items/editors/lrtextalignmenteditorwidget.cpp ${PROJECT_NAME}/items/lrabstractlayout.cpp ${PROJECT_NAME}/items/lralignpropitem.cpp +${PROJECT_NAME}/items/borderframeeditor.cpp +${PROJECT_NAME}/items/lrbordereditor.cpp ${PROJECT_NAME}/items/lrchartitem.cpp ${PROJECT_NAME}/items/lrchartaxiseditor.cpp ${PROJECT_NAME}/items/lrchartitemeditor.cpp @@ -86,6 +92,7 @@ ${PROJECT_NAME}/items/lrhorizontallayout.cpp ${PROJECT_NAME}/items/lrimageitem.cpp ${PROJECT_NAME}/items/lrimageitemeditor.cpp ${PROJECT_NAME}/items/lrlayoutmarker.cpp +${PROJECT_NAME}/items/lrpageeditor.cpp ${PROJECT_NAME}/items/lrshapeitem.cpp ${PROJECT_NAME}/items/lrsubitemparentpropitem.cpp ${PROJECT_NAME}/items/lrsvgitem.cpp @@ -191,6 +198,8 @@ ${PROJECT_NAME}/items/editors/lritemsborderseditorwidget.h ${PROJECT_NAME}/items/editors/lrtextalignmenteditorwidget.h ${PROJECT_NAME}/items/lrabstractlayout.h ${PROJECT_NAME}/items/lralignpropitem.h +${PROJECT_NAME}/items/borderframeeditor.h +${PROJECT_NAME}/items/lrbordereditor.h ${PROJECT_NAME}/items/lrchartitem.h ${PROJECT_NAME}/items/lrchartaxiseditor.h ${PROJECT_NAME}/items/lrchartitemeditor.h @@ -199,6 +208,7 @@ ${PROJECT_NAME}/items/lrhorizontallayout.h ${PROJECT_NAME}/items/lrimageitem.h ${PROJECT_NAME}/items/lrimageitemeditor.h ${PROJECT_NAME}/items/lrlayoutmarker.h +${PROJECT_NAME}/items/lrpageeditor.h ${PROJECT_NAME}/items/lrshapeitem.h ${PROJECT_NAME}/items/lrsubitemparentpropitem.h ${PROJECT_NAME}/items/lrsvgitem.h @@ -288,9 +298,12 @@ ${PROJECT_NAME}/databrowser/lrdatabrowser.ui ${PROJECT_NAME}/databrowser/lrsqleditdialog.ui ${PROJECT_NAME}/databrowser/lrvariabledialog.ui ${PROJECT_NAME}/dialogdesigner/templates/Dialog.ui +${PROJECT_NAME}/items/borderframeeditor.ui +${PROJECT_NAME}/items/lrbordereditor.ui ${PROJECT_NAME}/items/lrchartitemeditor.ui ${PROJECT_NAME}/items/lrchartaxiseditor.ui ${PROJECT_NAME}/items/lrimageitemeditor.ui +${PROJECT_NAME}/items/lrpageeditor.ui ${PROJECT_NAME}/items/lrtextitemeditor.ui ${PROJECT_NAME}/lraboutdialog.ui ${PROJECT_NAME}/lrpreviewreportwidget.ui @@ -348,12 +361,13 @@ set(GLOBAL_HEADERS set(PROJECT_NAME ${PROJECT_NAME}-qt${QT_VERSION_MAJOR}) if (LIMEREPORT_STATIC) - message(STATUS "STATIC LIBRARY") - add_library(${PROJECT_NAME} STATIC ${EXTRA_FILES} ${LIMEREPORT_SOURCES}) + message(STATUS "STATIC LIBRARY") + add_library(${PROJECT_NAME} STATIC ${EXTRA_FILES} ${LIMEREPORT_SOURCES}) target_compile_definitions( ${PROJECT_NAME} PUBLIC -DHAVE_STATIC_BUILD) else() add_library(${PROJECT_NAME} SHARED ${EXTRA_FILES} ${LIMEREPORT_SOURCES}) - target_compile_definitions( ${PROJECT_NAME} PUBLIC -DLIMEREPORT_EXPORTS) + target_compile_definitions( ${PROJECT_NAME} PRIVATE -DLIMEREPORT_EXPORTS) + target_compile_definitions( ${PROJECT_NAME} INTERFACE -DLIMEREPORT_IMPORTS) endif() target_compile_definitions(${PROJECT_NAME} PUBLIC -DCMAKE_CONFIG) @@ -392,6 +406,9 @@ target_include_directories( ${PROJECT_NAME} PRIVATE limereport/serializators limereport/scripteditor ) +target_include_directories( ${PROJECT_NAME} INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/include) + install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib diff --git a/demo_r1/CMakeLists.txt b/demo_r1/CMakeLists.txt index da749ac..4f68d4a 100644 --- a/demo_r1/CMakeLists.txt +++ b/demo_r1/CMakeLists.txt @@ -1,3 +1,5 @@ +project(demo_r1) + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) @@ -9,15 +11,14 @@ set(PROJECT_SOURCES mainwindow.ui ) -add_executable(demo_r1 main.cpp ${PROJECT_SOURCES}) +add_executable(${PROJECT_NAME} main.cpp ${PROJECT_SOURCES}) -target_include_directories( demo_r1 PRIVATE ../include/ ) -target_link_libraries(demo_r1 PRIVATE +target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Sql - ${PROJECT_NAME}-qt${QT_VERSION_MAJOR} + limereport-qt${QT_VERSION_MAJOR} ) diff --git a/designer/CMakeLists.txt b/designer/CMakeLists.txt index d63ea0b..9ae1a39 100644 --- a/designer/CMakeLists.txt +++ b/designer/CMakeLists.txt @@ -1,3 +1,5 @@ +project(LRDesigner) + set(CMAKE_AUTOMOC ON) set(LRDESIGNER_FILES @@ -7,14 +9,12 @@ set(LRDESIGNER_FILES mainicon.rc ) -add_executable(LRDesigner ${LRDESIGNER_FILES}) +add_executable(${PROJECT_NAME} ${LRDESIGNER_FILES}) -target_include_directories(LRDesigner PUBLIC ${PROJECT_SOURCE_DIR}/include) - -target_link_libraries(LRDesigner PUBLIC +target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Qml - ${PROJECT_NAME}-qt${QT_VERSION_MAJOR} + limereport-qt${QT_VERSION_MAJOR} ) diff --git a/limereport/items/lrbordereditor.h b/limereport/items/lrbordereditor.h index 5c2c9ba..3158b48 100644 --- a/limereport/items/lrbordereditor.h +++ b/limereport/items/lrbordereditor.h @@ -7,7 +7,7 @@ namespace Ui { class lrbordereditor; } -class lrbordereditor : public QDialog +class LIMEREPORT_EXPORT lrbordereditor : public QDialog { Q_OBJECT diff --git a/limereport/items/lrpageeditor.cpp b/limereport/items/lrpageeditor.cpp index d0c2f46..0efe6f2 100644 --- a/limereport/items/lrpageeditor.cpp +++ b/limereport/items/lrpageeditor.cpp @@ -1,9 +1,12 @@ #include "lrpageeditor.h" #include "ui_lrpageeditor.h" -#include "lrpagedesignintf.h" +#include "lrpageitemdesignintf.h" #include #include -lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) : + +using namespace LimeReport; + +lrpageeditor::lrpageeditor(QWidget *parent, PageItemDesignIntf *page) : QDialog(parent), ui(new Ui::lrpageeditor) { @@ -16,10 +19,10 @@ lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page ui->format->addItem(pageSizes.key(i)); } ui->format->setCurrentIndex(m_page->pageSize()); - ui->width->setValue(m_page->width() / LimeReport::Const::mmFACTOR); - ui->height->setValue(m_page->height() / LimeReport::Const::mmFACTOR); - ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait); - ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape); + ui->width->setValue(m_page->width() / Const::mmFACTOR); + ui->height->setValue(m_page->height() / Const::mmFACTOR); + ui->portrait->setChecked(m_page->pageOrientation() == PageItemDesignIntf::Portrait); + ui->landscape->setChecked(m_page->pageOrientation() == PageItemDesignIntf::Landscape); //Margins ui->marginTop->setValue(m_page->topMargin()); ui->marginRight->setValue(m_page->rightMargin()); @@ -40,10 +43,10 @@ lrpageeditor::~lrpageeditor() void lrpageeditor::applyChanges() { - m_page->setPageSize(static_cast(ui->format->currentIndex())); - m_page->setWidth(ui->width->value()* LimeReport::Const::mmFACTOR); - m_page->setHeight(ui->height->value()* LimeReport::Const::mmFACTOR); - m_page->setPageOrientation(ui->portrait->isChecked()?LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape); + m_page->setPageSize(static_cast(ui->format->currentIndex())); + m_page->setWidth(ui->width->value()* Const::mmFACTOR); + m_page->setHeight(ui->height->value()* Const::mmFACTOR); + m_page->setPageOrientation(ui->portrait->isChecked()?PageItemDesignIntf::Portrait : PageItemDesignIntf::Landscape); m_page->setTopMargin(ui->marginTop->value()); m_page->setBottomMargin(ui->marginBottom->value()); @@ -61,9 +64,9 @@ void lrpageeditor::on_buttonBox_accepted() } -QSizeF lrpageeditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageSize& size) +QSizeF lrpageeditor::getRectByPageSize(const PageItemDesignIntf::PageSize& size) { - if (size != LimeReport::PageItemDesignIntf::Custom) { + if (size != PageItemDesignIntf::Custom) { QPrinter printer; printer.setOutputFormat(QPrinter::PdfFormat); #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) @@ -76,8 +79,8 @@ QSizeF lrpageeditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::Pag QPageSize pageSize = QPageSize((QPageSize::PageSizeId)size); qreal width = pageSize.size(QPageSize::Millimeter).width() * 10; qreal height = pageSize.size(QPageSize::Millimeter).height() * 10; - return QSizeF(pageOrientation() == Portrait ? width : height, - pageOrientation() == Portrait ? height : width); + return QSizeF(m_page->pageOrientation() == PageItemDesignIntf::Portrait ? width : height, + m_page->pageOrientation() == PageItemDesignIntf::Orientation::Portrait ? height : width); // printer.setPageOrientation((QPageLayout::Orientation)pageOrientation()); // printer.setPageSize(QPageSize((QPageSize::PageSizeId)size)); @@ -95,7 +98,7 @@ void lrpageeditor::on_format_currentIndexChanged(int index) QPageSize ps = *new QPageSize(); if(ui->format->currentText() != "Custom") { - QSizeF pageSize = getRectByPageSize(static_cast(index)); + QSizeF pageSize = getRectByPageSize(static_cast(index)); ui->width->setValue(pageSize.width()/10); ui->height->setValue(pageSize.height()/10); } diff --git a/limereport/items/lrpageeditor.h b/limereport/items/lrpageeditor.h index 545ca3e..d1ed8d5 100644 --- a/limereport/items/lrpageeditor.h +++ b/limereport/items/lrpageeditor.h @@ -8,7 +8,7 @@ namespace Ui { class lrpageeditor; } -class lrpageeditor : public QDialog +class LIMEREPORT_EXPORT lrpageeditor : public QDialog { Q_OBJECT diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index adf7d21..44267c0 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -49,7 +49,7 @@ class ReportEnginePrivate; class PageDesignIntf; class BaseDesignIntf; -class Marker : public QGraphicsItem{ +class LIMEREPORT_EXPORT Marker : public QGraphicsItem{ public: Marker(QGraphicsItem* parent = 0, BaseDesignIntf* owner = 0): QGraphicsItem(parent), m_owner(owner){} QRectF boundingRect() const; @@ -65,7 +65,7 @@ private: BaseDesignIntf* m_owner; }; -class SelectionMarker : public Marker{ +class LIMEREPORT_EXPORT SelectionMarker : public Marker{ public: SelectionMarker(QGraphicsItem* parent=0, BaseDesignIntf* owner = 0); QColor color() const; @@ -80,7 +80,7 @@ protected: class DataSourceManager; class ReportRender; -class BaseDesignIntf : +class LIMEREPORT_EXPORT BaseDesignIntf : public QObject, public QGraphicsItem, public ICollectionContainer, public ObjectLoadingStateIntf { Q_OBJECT Q_INTERFACES(QGraphicsItem) @@ -515,7 +515,7 @@ signals: void afterRender(); }; -class BookmarkContainerDesignIntf: public BaseDesignIntf{ +class LIMEREPORT_EXPORT BookmarkContainerDesignIntf: public BaseDesignIntf{ Q_OBJECT public: BookmarkContainerDesignIntf(const QString& storageTypeName, QObject* owner = 0, QGraphicsItem* parent = 0) diff --git a/limereport/lrcollection.h b/limereport/lrcollection.h index 4e3aded..e66d1b9 100644 --- a/limereport/lrcollection.h +++ b/limereport/lrcollection.h @@ -35,7 +35,7 @@ #include "lrglobal.h" -class ACollectionProperty{ +class LIMEREPORT_EXPORT ACollectionProperty{ public: ACollectionProperty(){} ACollectionProperty(const ACollectionProperty& ){} @@ -45,8 +45,8 @@ Q_DECLARE_METATYPE(ACollectionProperty) namespace LimeReport{ -const int COLLECTION_TYPE_ID = qMetaTypeId(); -class ICollectionContainer{ +const int inline COLLECTION_TYPE_ID = qMetaTypeId(); +class LIMEREPORT_EXPORT ICollectionContainer{ public: virtual QObject* createElement(const QString& collectionName,const QString& elementType)=0; virtual int elementsCount(const QString& collectionName)=0; diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index b2fe56c..95f9801 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -125,12 +125,12 @@ namespace Const{ Q_DECLARE_FLAGS(PreviewHints, PreviewHint) Q_FLAGS(PreviewHints) - class ReportError : public std::runtime_error{ + class LIMEREPORT_EXPORT ReportError : public std::runtime_error{ public: ReportError(const QString& message); }; - class ReportSettings{ + class LIMEREPORT_EXPORT ReportSettings{ public: ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false){} void setDefaultValues(){m_suppressAbsentFieldsAndVarsWarnings = false;} @@ -140,13 +140,13 @@ namespace Const{ bool m_suppressAbsentFieldsAndVarsWarnings; }; - class IExternalPainter{ + class LIMEREPORT_EXPORT IExternalPainter{ public: virtual void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options) = 0; virtual ~IExternalPainter(); }; - class IPainterProxy{ + class LIMEREPORT_EXPORT IPainterProxy{ public: virtual void setExternalPainter(IExternalPainter* externalPainter) = 0; virtual ~IPainterProxy(); @@ -168,7 +168,7 @@ namespace Const{ #endif - class Enums + class LIMEREPORT_EXPORT Enums { public: enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; diff --git a/limereport/lritemscontainerdesignitf.h b/limereport/lritemscontainerdesignitf.h index 483bf95..5a87532 100644 --- a/limereport/lritemscontainerdesignitf.h +++ b/limereport/lritemscontainerdesignitf.h @@ -5,7 +5,7 @@ namespace LimeReport{ -class Segment{ +class LIMEREPORT_EXPORT Segment{ public: Segment(qreal segmentStart,qreal segmentEnd):m_begin(segmentStart),m_end(segmentEnd){} bool intersect(Segment value); @@ -15,17 +15,17 @@ private: qreal m_end; }; -class VSegment : public Segment{ +class LIMEREPORT_EXPORT VSegment : public Segment{ public: VSegment(QRectF rect):Segment(rect.top(),rect.bottom()){} }; -struct HSegment :public Segment{ +struct LIMEREPORT_EXPORT HSegment :public Segment{ public: HSegment(QRectF rect):Segment(rect.left(),rect.right()){} }; -struct ItemSortContainer { +struct LIMEREPORT_EXPORT ItemSortContainer { QRectF m_rect; BaseDesignIntf * m_item; ItemSortContainer(BaseDesignIntf *item){ @@ -35,9 +35,9 @@ struct ItemSortContainer { }; typedef QSharedPointer< ItemSortContainer > PItemSortContainer; -bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2); +bool LIMEREPORT_EXPORT itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2); -class ItemsContainerDesignInft : public BookmarkContainerDesignIntf{ +class LIMEREPORT_EXPORT ItemsContainerDesignInft : public BookmarkContainerDesignIntf{ Q_OBJECT public: ItemsContainerDesignInft(const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0): diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 365c87d..1170a8f 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -39,7 +39,7 @@ namespace LimeReport{ class ReportRender; -class PageItemDesignIntf : public ItemsContainerDesignInft +class LIMEREPORT_EXPORT PageItemDesignIntf : public ItemsContainerDesignInft { Q_OBJECT Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin) diff --git a/limereport/serializators/lrstorageintf.h b/limereport/serializators/lrstorageintf.h index e0ec406..c178bd2 100644 --- a/limereport/serializators/lrstorageintf.h +++ b/limereport/serializators/lrstorageintf.h @@ -30,6 +30,7 @@ #ifndef LRSTORAGEINTF_H #define LRSTORAGEINTF_H +#include "lrglobal.h" #include class QString; @@ -37,14 +38,14 @@ class QObject; namespace LimeReport{ -class ObjectLoadingStateIntf{ +class LIMEREPORT_EXPORT ObjectLoadingStateIntf{ public: virtual bool isLoading() = 0; virtual void objectLoadStarted() = 0; virtual void objectLoadFinished() = 0; }; -class ItemsWriterIntf +class LIMEREPORT_EXPORT ItemsWriterIntf { public: virtual void putItem(QObject* item) = 0; @@ -55,7 +56,7 @@ public: virtual ~ItemsWriterIntf(){} }; -class ItemsReaderIntf +class LIMEREPORT_EXPORT ItemsReaderIntf { public: typedef QSharedPointer Ptr; From 7bf0ce51e6ddf1450fcedf264b916103213043a4 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Mon, 31 Oct 2022 21:20:24 +0300 Subject: [PATCH 22/30] Border editor refactoring --- limereport/images/border_settings.png | Bin 0 -> 5843 bytes limereport/items/borderframeeditor.cpp | 287 ------------------ .../editors/lritemsborderseditorwidget.cpp | 54 ++-- .../editors/lritemsborderseditorwidget.h | 6 +- limereport/items/images/border_settings.png | Bin 0 -> 5788 bytes limereport/items/lrbordereditor.cpp | 206 ++++++------- limereport/items/lrbordereditor.h | 53 ++-- limereport/items/lrbordereditor.ui | 68 +++-- limereport/items/lrborderframeeditor.cpp | 181 +++++++++++ ...derframeeditor.h => lrborderframeeditor.h} | 20 +- ...rframeeditor.ui => lrborderframeeditor.ui} | 4 +- limereport/items/lrpageeditor.cpp | 77 ++--- limereport/items/lrpageeditor.h | 9 +- limereport/items/lrpageeditor.ui | 16 +- limereport/limereport.pri | 6 +- limereport/lrbasedesignintf.cpp | 22 +- limereport/lrbasedesignintf.h | 2 +- limereport/lrpagedesignintf.cpp | 14 + limereport/lrpagedesignintf.h | 5 + limereport/lrpageitemdesignintf.cpp | 34 +-- limereport/lrreportdesignwidget.cpp | 10 + limereport/lrreportdesignwidget.h | 2 + limereport/report.qrc | 1 + 23 files changed, 487 insertions(+), 590 deletions(-) create mode 100644 limereport/images/border_settings.png delete mode 100644 limereport/items/borderframeeditor.cpp create mode 100644 limereport/items/images/border_settings.png create mode 100644 limereport/items/lrborderframeeditor.cpp rename limereport/items/{borderframeeditor.h => lrborderframeeditor.h} (61%) rename limereport/items/{borderframeeditor.ui => lrborderframeeditor.ui} (94%) diff --git a/limereport/images/border_settings.png b/limereport/images/border_settings.png new file mode 100644 index 0000000000000000000000000000000000000000..3bae2c8c8626033ef5c59aed46123ad2a09cae81 GIT binary patch literal 5843 zcmeHLX;f3!7QP9fGK!#}pb{d344DHNOb`tzLNjSwATdC+p(jJe*pilF74CoGxFD;!uNJ20?~j z_f5$veKywNZBxLDL2GJxBNt@+d?S6u*=5zs@AxFFRbAaU8(%P2WIrML&7Y5yJ?CnI zzus$qe_OZbXivpm>j}qR{cw7F!^6(k6{F65cVoSk!|KgtuM*##^D6jtV{lx_UE=)1 zd%tAe^=?a zaE4xFr*$oL+&3t8AX0cO%EKyiNItZHy5&fw|0-GdjkJ4?80akZMPGMe5s-5H6;S;^A*!D2*7fRcJ zf}u3>@3oU5Mx0B1MZ0%#N#b3R=JsA~W96+je%UF*gALtbFXM(LtV|cGs~0%aYgdZf z_9T=~NZhugK2AhWeNKs3M%gi!iw398?6`+0T3$cxDG8aj_eocB6Wb7SSG<&YG`j;IDVX$#P#&o2^?t=P?V`HG>`Krx|+WoE7 z8-Bm|SNg;8Ph=%Ux0m&N$MYqcnbp{co!ucAXyQ6`tKQQ@7EvD5NtMx9w)5 z?VO+N1iW*x+%V?aW{;(9c;Q*3V_Uh=bJb28mzVLkqkpP@;q6;Js&sEnW6c_`E60a& zyKh|eJ~@=;%lN(hS<$tnPmDX+Ke$zJao+P5$=&pnS&$ z)O7W^^qyGzE9B7J;*x{R5tEq>9*vte{G4rd`>C)1PiXKcTDPWL-d%rkrfL@U*~1;b z?GmKL1QMrR-@SbDsGJvB=T01>QZ6KU?ZUfm4_mc=!8D`Gfi8cS>jwABFKrHoUmu*l zIP1=xzfxA+&dtfGPANKWc>PPusjYi`cj&CFb}c+8;}L zhhZF~(4B>gFE_i~t8+-XaFxp`JiX*`aJRO2`3#ndTs6kIi6UeyVl2!E6)t-gma}km z#M+nZ4HI|TyNuVQYF;kWw#Z0L4)@l!adH+WkIg;MR=xL!pxV}2cxqh0&2{=@%temkP>^muW#}xi`Y*c&TCA`Wku(!GOZt0nTfzNMZzX{oStUWBoYqo>_NTJop zkyt7J(u}maV z8E;U-(kxVmlb{)LB^Upw@+=-FN4WSYAwsfH%|kQgQ3V<_p&&*qEy$9x5d8QsJC1=3 z02HVW#u*gZN-f*K#hY>2KsT95c%0cqm&L^=3q?4dN`vC)L^_d7;2Y$*RD75nj-x?j z?D&YU`XE4$i_g^Q)NB$dFE5XnM(?8&T;{CpMvor7#3fU1Vsos>HAcBiG z#b+ZbsT^UORT@pgK#|Z;f`m>ECD2*0lmLg2sRWh`rqWRfgA&4o`#}kmS{ttX8I0JGeqRP{L91_bFXo3zl@kt2{4P{X%Oa_g`pfl+qADxm= zjTY=h6DoyFq*2WyriEdHasaikX{Q1JvmI2!=4nt^r_zX3s%$RaloZZ1^TV(Z94G|V z!4a?y1)yXql}#bDsZ24M$|lpGgDLI6} zAjnWEoj{k$5CS;uFhK&Y8I%meG=|hd>j!kLN~X($HRyy4z$4%aY)~^-xUqdp74T^` zd6}qb9ROtn3YqYcG8&%LS1ieNW4y1HL;5d1IA(`_R}7eEv4N`#+=QeLS79GtAlHBL z)3*-)WC$GYOOVgv_X}NL==v-MKFj&b?)pO4XEE?u&R=%d|BWuYk1tcG68s002VRv5 zJ7Vj>EAdlNw3u&x;erCZAXS1D%?~r$9ZHMDQhXtH5G3MYQ}~$TG#e}y8W)TaactCL z8zLTKV-3ZyFo*z~6$445pl~7-)pRi|#w0y+?FixP-M zmp4j*sG8-#A6U@KX%+#_7E55hpY(F73fHvh~62JsT&;=4%6Aq98Y=05dOyr&AOguBr)SepGrqO)`)+AOutmk^vQg(m+bU#}vBS6tuUu_sw(GQn2b6 zU3^Re6mGl*e*J|olF5+~&_bJ0QJ`b1j+&~4AbVHS7Xy92emF1=)Cq+Afkrz|cWdv* zj<3ssX_6pff_Qjq(TZwE2sg-T)XwQYm%kz5_{(N5>c;!q$UC?A`&@Z2EPY6H$?}j? z%)FA>_$s&iiM5LlTCaF~(fjGBY3;@pgaJ)C^K4z?#tx?(Xx#@;Apt)oV*kYSlK%jW C$=tdC literal 0 HcmV?d00001 diff --git a/limereport/items/borderframeeditor.cpp b/limereport/items/borderframeeditor.cpp deleted file mode 100644 index a864550..0000000 --- a/limereport/items/borderframeeditor.cpp +++ /dev/null @@ -1,287 +0,0 @@ -#include "borderframeeditor.h" -#include "ui_borderframeeditor.h" -#include -#include -#include -#include -#include "lrbasedesignintf.h" -#include "lrbordereditor.h" -using namespace LimeReport; -BorderFrameEditor::BorderFrameEditor(QWidget *parent) - : QWidget(parent) - , ui(new Ui::BorderFrameEditor) -{ - ui->setupUi(this); - scene = new QGraphicsScene(ui->graphicsView); - - QRect vRect = rect(); - - //Draw corder lines - //topLeft - scene->addLine(10,5, 10,10,QPen(Qt::gray)); - scene->addLine(5,10, 10,10,QPen(Qt::gray)); - //bottomLeft - scene->addLine(10,vRect.bottom() -5, 10,vRect.bottom()-10,QPen(Qt::gray)); - scene->addLine(5,vRect.bottom()-10,10,vRect.bottom()-10,QPen(Qt::gray)); - //bottomRight - scene->addLine(vRect.right()-10,vRect.bottom() -5,vRect.right()- 10,vRect.bottom()-10,QPen(Qt::gray)); - scene->addLine(vRect.right()-5,vRect.bottom()-10,vRect.right()-10,vRect.bottom()-10,QPen(Qt::gray)); - //topRight - scene->addLine(vRect.width()-10,5,vRect.width()- 10,10,QPen(Qt::gray)); - scene->addLine(vRect.width()-5,10, vRect.width()-10,10,QPen(Qt::gray)); - scene->setSceneRect(vRect); - ui->graphicsView->setScene(scene); - QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem(); - io->setAcceptedMouseButtons(Qt::LeftButton); - io->setPos(scene->sceneRect().center()); - io->setText(tr("Text")); - scene->addItem(io); - - QRectF bR = io->sceneBoundingRect(); - io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 ); - connect(this,SIGNAL(borderSideClicked(int, bool)),this,SLOT(SlotBorderSideClicked(int,bool))); - -} - -BorderFrameEditor::~BorderFrameEditor() -{ - delete ui; -} - -void BorderFrameEditor::setPen(QPen pen) -{ - m_pen = pen; - updateBorders(); - -} - -QPen BorderFrameEditor::pen() -{ - return m_pen; -} - -void BorderFrameEditor::setAllLines() -{ - - topLine = scene->addLine(QLineF(10,10,rect().width() - 10,10),m_pen); - - - leftLine = scene->addLine(QLineF(10,10,10,rect().height() - 10),m_pen); - - bottomLine = scene->addLine(QLineF(10,rect().bottom() -10,rect().width() - 10 - ,rect().bottom() - 10),m_pen); - - - - rightLine = scene->addLine(QLineF(rect().width() - 10,10 - ,rect().width() - 10,rect().height() - 10),m_pen); - - -} - -void BorderFrameEditor::unSetAllLines() -{ - if(topLine) - { - scene->removeItem(topLine); - - } - if(leftLine) - { - scene->removeItem(leftLine); - - } - if(bottomLine) - { - scene->removeItem(bottomLine); - - - - } - if(rightLine) - { - scene->removeItem(rightLine); - - } - -} - -void BorderFrameEditor::mousePressEvent(QMouseEvent *event) -{ - - if(event->x() >= 10 && event->y() <30)//Draw top border - { - - if(!topLine) - { - - emit borderSideClicked(1,true); - - } - else - { - - emit borderSideClicked(1,false); - } - } - - if((event->x() >= 10 && event->x() < 30) && (event->y() > 10)) //Draw border left - { - if(!leftLine) - { - - emit borderSideClicked(4,true); - - } - else - { - - emit borderSideClicked(4,false); - - } - } - - if(event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom())) //Draw bottom border - { - if(!bottomLine) - { - - emit borderSideClicked(2,true); - } - - else - { - - emit borderSideClicked(2,false); - - } - } - - if((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10) //Draw border right - { - if(!rightLine) - { - - emit borderSideClicked(8,true); - - } - else - { - - emit borderSideClicked(8,false); - - } - - } - - -} - -void BorderFrameEditor::SlotBorderSideClicked(int side, bool show) -{ - - switch(side) - { - case BaseDesignIntf::BorderSide::TopLine: - { - if(show) - { - topLine = scene->addLine(QLineF(10,10,rect().width() - 10,10),m_pen); - - - } - else - { - scene->removeItem(topLine); - topLine = NULL; - - } - }break; - case BaseDesignIntf::LeftLine: - { - if(show) - { - leftLine = scene->addLine(QLineF(10,10,10,rect().height() - 10),m_pen); - - - } - else - { - scene->removeItem(leftLine); - leftLine = NULL; - - - } - }break; - case BaseDesignIntf::BottomLine: - { - if(show) - { - bottomLine = scene->addLine(QLineF(10,rect().bottom() -10,rect().width() - 10 - ,rect().bottom() - 10),m_pen); - - } - - else - { - scene->removeItem(bottomLine); - bottomLine = NULL; - - - } - }break; - case BaseDesignIntf::RightLine: - { - if(show) - { - rightLine = scene->addLine(QLineF(rect().width() - 10,10 - ,rect().width() - 10,rect().height() - 10),m_pen); - - } - else - { - scene->removeItem(rightLine); - rightLine = NULL; - - } - - } - - } - updateBorders(); -} - -void BorderFrameEditor::updateBorders() -{ - //if a line is set we redraw it - if(topLine) - { - scene->removeItem(topLine); - topLine = scene->addLine(QLineF(10,10,rect().width() - 10,10),m_pen); - - } - if(leftLine) - { - scene->removeItem(leftLine); - leftLine = scene->addLine(QLineF(10,10,10,rect().height() - 10),m_pen); - - } - if(bottomLine) - { - scene->removeItem(bottomLine); - - bottomLine = scene->addLine(QLineF(10,rect().bottom() -10,rect().width() - 10 - ,rect().bottom() - 10),m_pen); - - } - if(rightLine) - { - scene->removeItem(rightLine); - - rightLine = scene->addLine(QLineF(rect().width() - 10,10 - ,rect().width() - 10,rect().height() - 10),m_pen); - - } - -} - diff --git a/limereport/items/editors/lritemsborderseditorwidget.cpp b/limereport/items/editors/lritemsborderseditorwidget.cpp index 7b4853a..a49aef2 100644 --- a/limereport/items/editors/lritemsborderseditorwidget.cpp +++ b/limereport/items/editors/lritemsborderseditorwidget.cpp @@ -44,7 +44,7 @@ void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item) updateValues((BaseDesignIntf::BorderLines)borders.toInt()); setEnabled(true); } - itm = item; + m_item = item; } void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, const QVariant& oldValue, const QVariant& newValue) @@ -72,21 +72,18 @@ void ItemsBordersEditorWidget::allBordesClicked() updateValues((BaseDesignIntf::BorderLines)borders); } -void ItemsBordersEditorWidget::buttonClicked(bool) -{ - -} +void ItemsBordersEditorWidget::buttonClicked(bool){} void ItemsBordersEditorWidget::editBorderClicked() { - lrbordereditor be; - be.loadItem(itm); - if(be.exec() == QDialog::Rejected)return; + BorderEditor be; + be.loadItem(m_item); + if ( be.exec() == QDialog::Rejected ) return; updateValues(be.borderSides()); - itm->setBorderLinesFlags(be.borderSides()); - itm->setBorderLineSize(be.border_width()); - itm->setBorderStyle((LimeReport::BaseDesignIntf::BorderStyle)be.border_style()); - itm->setBorderColor(be.borderColor()); + m_item->setBorderLinesFlags(be.borderSides()); + m_item->setBorderLineSize(be.borderWidth()); + m_item->setBorderStyle((LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle()); + m_item->setBorderColor(be.borderColor()); } void ItemsBordersEditorWidget::initEditor() @@ -129,7 +126,7 @@ void ItemsBordersEditorWidget::initEditor() addAction(m_allLines); addSeparator(); m_BorderEditor = new QAction(tr("Edit border"),this); - m_BorderEditor->setIcon(QIcon(":/report/images/allLines")); + m_BorderEditor->setIcon(QIcon(":/report/images/borderEditor")); connect(m_BorderEditor,SIGNAL(triggered()),this,SLOT(editBorderClicked())); addAction(m_BorderEditor); @@ -140,20 +137,20 @@ void ItemsBordersEditorWidget::initEditor() void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders) { m_changing = true; - m_topLine->setChecked(borders&BaseDesignIntf::TopLine); - m_bottomLine->setChecked(borders&BaseDesignIntf::BottomLine); - m_leftLine->setChecked(borders&BaseDesignIntf::LeftLine); - m_rightLine->setChecked(borders&BaseDesignIntf::RightLine); + m_topLine->setChecked(borders & BaseDesignIntf::TopLine); + m_bottomLine->setChecked(borders & BaseDesignIntf::BottomLine); + m_leftLine->setChecked(borders & BaseDesignIntf::LeftLine); + m_rightLine->setChecked(borders & BaseDesignIntf::RightLine); m_changing = false; } BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders() { int borders = 0; - borders += (m_topLine->isChecked())?BaseDesignIntf::TopLine:0; - borders += (m_bottomLine->isChecked())?BaseDesignIntf::BottomLine:0; - borders += (m_leftLine->isChecked())?BaseDesignIntf::LeftLine:0; - borders += (m_rightLine->isChecked())?BaseDesignIntf::RightLine:0; + borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine:0; + borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine:0; + borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine:0; + borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine:0; return (BaseDesignIntf::BorderLines)borders; } @@ -180,6 +177,21 @@ void ItemsBordersEditorWidgetForDesigner::allBordesClicked() ItemsBordersEditorWidget::allBordesClicked(); m_reportEditor->setBorders(createBorders()); } + +void ItemsBordersEditorWidgetForDesigner::editBorderClicked() +{ + BorderEditor be; + be.loadItem(m_item); + if ( be.exec() == QDialog::Rejected ) return; + + m_reportEditor->setBordersExt( + be.borderSides(), + be.borderWidth(), + (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), + be.borderColor() + ); +} + #endif } //namespace LimeReport diff --git a/limereport/items/editors/lritemsborderseditorwidget.h b/limereport/items/editors/lritemsborderseditorwidget.h index 2538258..ef83dbc 100644 --- a/limereport/items/editors/lritemsborderseditorwidget.h +++ b/limereport/items/editors/lritemsborderseditorwidget.h @@ -49,11 +49,12 @@ protected slots: virtual void noBordesClicked(); virtual void allBordesClicked(); virtual void buttonClicked(bool); - void editBorderClicked(); + virtual void editBorderClicked(); protected: void setItemEvent(BaseDesignIntf *item); void properyChangedEvent(const QString &property, const QVariant &oldValue, const QVariant &newValue); BaseDesignIntf::BorderLines createBorders(); + BaseDesignIntf *m_item; private: void initEditor(); void updateValues(BaseDesignIntf::BorderLines borders); @@ -66,7 +67,7 @@ private: QAction* m_BorderEditor; bool m_changing; int m_borders; - BaseDesignIntf *itm; + }; #ifdef HAVE_REPORT_DESIGNER @@ -79,6 +80,7 @@ protected slots: void buttonClicked(bool); void noBordesClicked(); void allBordesClicked(); + void editBorderClicked(); private: ReportDesignWidget* m_reportEditor; diff --git a/limereport/items/images/border_settings.png b/limereport/items/images/border_settings.png new file mode 100644 index 0000000000000000000000000000000000000000..a74087414c9377b8499b89525b322e1246f61ed2 GIT binary patch literal 5788 zcmeHLcT`hZ6MqRH3J8b|5g~*k2&s@jLXaTD5HJ`ZG^LpG0)aG=00CVE6~zuJYhzUe zY`eOOD=T7wrCE?-U&Xd67A&}^*!gY}L_FV~^BvFm_CIrO9&_i-{AT8N=ibN5GENwC zq=}6Q1VJNN!9fw=uch`o+yGo%F&2>!WOzJ>8>^1sWuX*GxkxO5QR-|3jDj^{5d>+j z?Td-4y0_c>L-N?;hE9Zn`*W74a*X9~Cz-WwX;ntwKmO{8U{Sth-ZZ4-TK}h~UH0)U z#x5pK`9vG06-F>}?k`(4GD z=GlzI5?j0b`#K9xCc{TRiG{mrnqsQ`CGiD`$Nab6{P{H{xdmMV#VqyPqndJP*l~lv zm8F-US-IzOts~ao4LdS6JfU{h;YPb7rq28W=TC=M%=qb=hv`_ly3>rw-DrAt%-*1| zc$c}d&Wn_gwNp$I&z9d9;eVjrmi#BbD`k0+dqDAsrj&-pEP3w@^W$r{sLFReV-*C8 zWP_$TvSX#grtg;TdiUsd@BHJ#enk%Z*zrC^Jxu zTJjnSL=LO9S+T%7+)~M&zNGIPSNLI+Qwn;#meMp~0H8b7R!SJy*7e zN3H8>U>!(#Hzs1n=7=*B1ftm1hd-4T_SP-6eb&=8oJo5b%)}1g_SbS;X~PcZ;`r*2 z#&_X?tD@5OR)+_=lCI1%#gL_Y?yu%_^N)6)SZY`E`eN^*!|ZNcpLcB8Ih&a~m+BgQR$7HW}W@nDtJmXm$0m)e>2pTbVN_AkJ1 z^2fg5iu(v^2wl$=S(S5i)TKpmMu}`KOix@ z%}2j_(ri#;!=4?ky z>DE@o^$AOx%8oaSpXDVYZrmN2oozI6?q11d;~HGd<#nmHcB0=dr+?~mAGbr;{XBD0 z@9%L7T-H~MEHP6EF^61zLQ6*PuJlmbo%HGpA#dq^=ANn$M?BxZZDUH_Y(_)rw&TL5O^DU?7JT82I@h1IJg%4@G{# z^>o|Dq}de_Q_RPW$~eWzIEadF2;UoPXj-waeea^v6-n*o4y^R_G4ZD6^F5*`#g}Ac zD8?GrSy(bBPiBmFd$E93%2;XK{85wjJiX7nhdgBl;iwCOL3+idxd>H1FYF(SFcUy` z3zoOETRmzti*LT-N1JziMUO|HYQgG6iX30-XxT>%H10-H1OiW-EM8ki0wMo7`NwQZ1>g= z`E|#RuI-|p8`W@dvEf=vROu4p6#S^tDCb7{^49|FCx`3XoHhjQCt6d+aq^KJuNU># zJ(sPTrar?mY07;z{_HzzqYpLoL$bJA%|BkEA?CH!7GHZEGqLu`x&Ln1K zXU$BO_iq)y>N7Cdsl20Fm=p`1IGJMbWQk?ZpbF$tEKexs!&r?}0iHY%MDy1uc!D%o zjpD<}VwoTMdCf^QN-Xq4$B@`~wjvNt5eMfe;mDjYt{^8(KoO$-r<%|-Q~)4_)jX6& zDv_zE8b7oSmkMO98iz*dOw?(9=vX!f6)0E2C@-uR7LQ?Q#F<3&R1*|UDHKs7f~F5Z zfSDgUMXgp)ak#9kENqr1R<2CO5hxT24o}1pi5OskQDw{2JPk&sa@0cTF@j)~Kq*$J z#c~-+i^=25Gt_=)G`NrYoS#&|W)H&4R0AvkK5!bI0!P5&aZ)L6sE10;$OIq*3H_so ziVGglxCmG!&rk|rMkXv%I}U{q3I_cZ8A^$+9H9UQOJFH5Re`94uR=0eY|fyEmV#ul zRH5?%WPfF;7K^@+^;K@#JGyd)CIZ|Calf+uT)WN~Sh3mEAh{qzn;t9353P+)70Lx- zAyp?5JVhctnTN*^d1Nn)7apt$pO5#!P{<^*CyzuX;6Lc#E1z9)v{MZ}9Ju&0oM=M90FsT6~*Jz<9x40*nuVNYdiLB5yuSCh+vx2nE#Xa;209mQyU{CBry{ELj&rOE@)v!}3ED zvG^|*4V$`j~IQ1LQhp)OB=rN1Re;mML=aDEIl>}S3BADV&WKD+1^z zktgUUPXdNS;t9QcU?PD6>ziQ^T_qQ(vv^84AQ|uoxB?BT;|k?EuvBheXOoozYu7>B zsRYorgOricxPfAE+7sh*wKUv+@j=rW3^`(epI!%!E^rd!29Lr4zCf=3=4W6X{>>05 z)b}9Y#P4^yzSH$h41AOE_wM>m*EccnO~&85>;FcV$(NTYSO)$B$^x%S3qsc(0I$S< zb7pWEP|sZO#^q)Y$s-LsT@ZHTp(G}f;0#gSAr1{0&p<3lGD0FDUk?O_W~AU6VbKU9 zLnw@b5VDYIVUQpgqGKUA+{GZ*#?ScIz{_HYL1ze zl@%I|X4Bo`L)?gKJTw=SUUU&vl7C z6&`(RW?&sH?o=ebisGE=031c<=719N3d zMgs#x0oVA`(Et-D!4wQ;Jslte*r9_}KP~ViZQ2Q6?e&=NfS{WK1pNqU2n2%u3Jkyi zvVN*Jm|E!#a0c!50?+`xq)i0U284jBK{B8sP#Q=H*l0u7X@mCn_g@nniUUiIP)CGC zLiDby;Fnwo!4G8yK?O#Wg27~jA~;S3L8ha%Uj($d#2P4#)hsr{xXWbXIFb|dji3Uk zn5>`xuJr}MoLXpvE98`m4qcl&omL4Ij<)z?_}CY7a?72!I(V%QFu+3V&5Rbld1I;0 tn-M=N7isf?zPNst>+sWybIeCV(5o89+M?-aw*yFs#Rv=9KW)y!{{YaLv+4i< literal 0 HcmV?d00001 diff --git a/limereport/items/lrbordereditor.cpp b/limereport/items/lrbordereditor.cpp index e8e2af3..63d8b88 100644 --- a/limereport/items/lrbordereditor.cpp +++ b/limereport/items/lrbordereditor.cpp @@ -2,181 +2,155 @@ #include "ui_lrbordereditor.h" #include #include "lrbasedesignintf.h" -lrbordereditor::lrbordereditor(QWidget *parent) : + +namespace LimeReport{ + +BorderEditor::BorderEditor(QWidget *parent) : QDialog(parent), - ui(new Ui::lrbordereditor) + ui(new Ui::BorderEditor), + m_borderStyle(1), + m_borderWidth(1) { ui->setupUi(this); - - connect(ui->borderFrame,SIGNAL(borderSideClicked(int, bool)), this, SLOT(checkToolButtons(int, bool))); + connect( + ui->borderFrame, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), + this, SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool)) + ); } -void lrbordereditor::loadItem(LimeReport::BaseDesignIntf *i) +void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item) { - item = i; - if(item->borderLines() & LimeReport::BaseDesignIntf::TopLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,true); + m_item = item; + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, + item->borderLines() & LimeReport::BaseDesignIntf::TopLine); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, + item->borderLines() & LimeReport::BaseDesignIntf::LeftLine); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, + item->borderLines() & LimeReport::BaseDesignIntf::RightLine); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, + item->borderLines() & LimeReport::BaseDesignIntf::BottomLine); - } - if(item->borderLines() & LimeReport::BaseDesignIntf::LeftLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,true); - - } - if(item->borderLines() & LimeReport::BaseDesignIntf::RightLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,true); - - } - if(item->borderLines() & LimeReport::BaseDesignIntf::BottomLine) - { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,true); - } QPen pen; pen.setWidthF(item->borderLineSize()); pen.setColor(item->borderColor()); pen.setStyle((Qt::PenStyle)item->borderStyle()); ui->borderFrame->setPen(pen); - border_color = item->borderColor().name(); + m_borderColor = item->borderColor().name(); ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle()); ui->comboBox->setCurrentText(QString::number(item->borderLineSize())); - borderWidth = ui->comboBox->currentText().toDouble(); - borderStyle =ui->listWidget->currentRow(); - ui->pushButton->setStyleSheet(QString("#pushButton{background-color:%1;}").arg(border_color)); + m_borderWidth = ui->comboBox->currentText().toDouble(); + m_borderStyle =ui->listWidget->currentRow(); + ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor)); } -LimeReport::BaseDesignIntf::BorderLines lrbordereditor::borderSides() +LimeReport::BaseDesignIntf::BorderLines BorderEditor::borderSides() { int borders = 0; - borders += (ui->topLine->isChecked())?LimeReport::BaseDesignIntf::TopLine:0; - borders += (ui->bottomLine->isChecked())?LimeReport::BaseDesignIntf::BottomLine:0; - borders += (ui->leftLine->isChecked())?LimeReport::BaseDesignIntf::LeftLine:0; - borders += (ui->rightLine->isChecked())?LimeReport::BaseDesignIntf::RightLine:0; - return (LimeReport::BaseDesignIntf::BorderLines)borders; + borders += (ui->topLine->isChecked()) ? LimeReport::BaseDesignIntf::TopLine : 0; + borders += (ui->bottomLine->isChecked()) ? LimeReport::BaseDesignIntf::BottomLine : 0; + borders += (ui->leftLine->isChecked()) ? LimeReport::BaseDesignIntf::LeftLine : 0; + borders += (ui->rightLine->isChecked()) ? LimeReport::BaseDesignIntf::RightLine : 0; + return (LimeReport::BaseDesignIntf::BorderLines) borders; } -LimeReport::BaseDesignIntf::BorderStyle lrbordereditor::border_style() +LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle() { - return (LimeReport::BaseDesignIntf::BorderStyle)borderStyle; + return (LimeReport::BaseDesignIntf::BorderStyle) m_borderStyle; } -QString lrbordereditor::borderColor() +QString BorderEditor::borderColor() { - return border_color; + return m_borderColor; } -double lrbordereditor::border_width() +double BorderEditor::borderWidth() { - return borderWidth; + return m_borderWidth; } -lrbordereditor::~lrbordereditor() +BorderEditor::~BorderEditor() { delete ui; } -void lrbordereditor::on_listWidget_currentRowChanged(int currentRow) +void BorderEditor::on_listWidget_currentRowChanged(int currentRow) { QPen pen = ui->borderFrame->pen(); pen.setStyle((Qt::PenStyle)currentRow); - borderStyle = currentRow; + m_borderStyle = currentRow; ui->borderFrame->setPen(pen); - - } - -void lrbordereditor::on_comboBox_currentTextChanged(const QString &arg1) +void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1) { QPen pen = ui->borderFrame->pen(); pen.setWidthF(arg1.toDouble()); ui->borderFrame->setPen(pen); - borderWidth = arg1.toDouble(); + m_borderWidth = arg1.toDouble(); } - -void lrbordereditor::on_pushButton_clicked() +void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check) { - QColorDialog cd(this); - if(cd.exec() == QDialog::Rejected)return; - QPen pen = ui->borderFrame->pen(); - pen.setColor(cd.selectedColor().name()); - border_color = pen.color().name(); - - ui->pushButton->setStyleSheet(QString("#pushButton{background-color:%1;}").arg(border_color)); - ui->borderFrame->setPen(pen); -} - - -void lrbordereditor::on_toolButton_4_clicked() -{ - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,true); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,true); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,true); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,true); - QPen pen = ui->borderFrame->pen(); - - ui->borderFrame->setPen(pen); -} - - -void lrbordereditor::on_noLines_clicked() -{ - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,false); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,false); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,false); - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,false); - -} - - -void lrbordereditor::on_topLine_clicked() -{ - - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,ui->topLine->isChecked()); - -} - -void lrbordereditor::checkToolButtons(int side, bool check) -{ - switch(side) { - case LimeReport::BaseDesignIntf::BorderSide::TopLine: - { - ui->topLine->setChecked(check); - }break; - case LimeReport::BaseDesignIntf::BorderSide::BottomLine: - { - ui->bottomLine->setChecked(check); - }break; - case LimeReport::BaseDesignIntf::BorderSide::LeftLine: - { - ui->leftLine->setChecked(check); - }break; - case LimeReport::BaseDesignIntf::BorderSide::RightLine: - { - ui->rightLine->setChecked(check); - }break; + case BaseDesignIntf::BorderSide::TopLine: + ui->topLine->setChecked(check); + break; + case BaseDesignIntf::BorderSide::BottomLine: + ui->bottomLine->setChecked(check); + break; + case BaseDesignIntf::BorderSide::LeftLine: + ui->leftLine->setChecked(check); + break; + case BaseDesignIntf::BorderSide::RightLine: + ui->rightLine->setChecked(check); + break; } } +void BorderEditor::on_topLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, checked); +} -void lrbordereditor::on_bottomLine_clicked() -{ - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,ui->bottomLine->isChecked()); +void BorderEditor::on_bottomLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, checked); +} + +void BorderEditor::on_leftLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, checked); +} + +void BorderEditor::on_rightLine_clicked(bool checked){ + emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::RightLine, checked); } -void lrbordereditor::on_leftLine_clicked() +void BorderEditor::on_allLines_clicked() { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,ui->leftLine->isChecked()); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, true); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, true); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, true); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, true); +} + +void BorderEditor::on_noLines_clicked() +{ + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, false); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, false); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, false); + emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, false); } -void lrbordereditor::on_toolButton_3_clicked() +void BorderEditor::on_selectColor_clicked() { - emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,ui->rightLine->isChecked()); + QColorDialog cd(this); + if(cd.exec() == QDialog::Rejected) return; + QPen pen = ui->borderFrame->pen(); + pen.setColor(cd.selectedColor().name()); + m_borderColor = pen.color().name(); + ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor)); + ui->borderFrame->setPen(pen); } +} // namespace LimeReport diff --git a/limereport/items/lrbordereditor.h b/limereport/items/lrbordereditor.h index 5c2c9ba..443cb63 100644 --- a/limereport/items/lrbordereditor.h +++ b/limereport/items/lrbordereditor.h @@ -3,54 +3,45 @@ #include #include "lrbasedesignintf.h" +namespace LimeReport{ + namespace Ui { -class lrbordereditor; +class BorderEditor; } -class lrbordereditor : public QDialog +class BorderEditor : public QDialog { Q_OBJECT public: - explicit lrbordereditor(QWidget *parent = nullptr); - void loadItem(LimeReport::BaseDesignIntf *i); + explicit BorderEditor(QWidget *parent = nullptr); + void loadItem(LimeReport::BaseDesignIntf *item); LimeReport::BaseDesignIntf::BorderLines borderSides(); - LimeReport::BaseDesignIntf::BorderStyle border_style(); + LimeReport::BaseDesignIntf::BorderStyle borderStyle(); QString borderColor(); - double border_width(); - - - ~lrbordereditor(); + double borderWidth(); + ~BorderEditor(); private slots: void on_listWidget_currentRowChanged(int currentRow); - void on_comboBox_currentTextChanged(const QString &arg1); - - void on_pushButton_clicked(); - - void on_toolButton_4_clicked(); - void on_noLines_clicked(); - - void on_topLine_clicked(); - void checkToolButtons(int side, bool check); - - void on_bottomLine_clicked(); - - void on_leftLine_clicked(); - - void on_toolButton_3_clicked(); + void on_topLine_clicked(bool checked); + void on_bottomLine_clicked(bool checked); + void on_leftLine_clicked(bool checked); + void on_rightLine_clicked(bool checked); + void on_allLines_clicked(); + void checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check); + void on_selectColor_clicked(); private: - Ui::lrbordereditor *ui; - LimeReport::BaseDesignIntf *item; - QString border_color; - int borderStyle = 1; - double borderWidth = 1; - - + Ui::BorderEditor *ui; + LimeReport::BaseDesignIntf *m_item; + QString m_borderColor; + int m_borderStyle; + double m_borderWidth; }; +} // namespace LimeReport #endif // LRBORDEREDITOR_H diff --git a/limereport/items/lrbordereditor.ui b/limereport/items/lrbordereditor.ui index 7cd7a39..00c4108 100644 --- a/limereport/items/lrbordereditor.ui +++ b/limereport/items/lrbordereditor.ui @@ -1,13 +1,13 @@ - lrbordereditor - + LimeReport::BorderEditor + 0 0 381 - 311 + 352 @@ -46,7 +46,7 @@ - + Outline @@ -119,7 +119,7 @@ - + @@ -319,14 +319,34 @@ - - - #pushButton{background-color: black;} - - - Select... - - + + + + + + 20 + 20 + + + + + 10 + 10 + + + + background-color: rgb(0, 0, 0); + + + + + + + Select + + + + @@ -342,7 +362,7 @@ - BorderFrameEditor + LimeReport::BorderFrameEditor QWidget
borderframeeditor.h
1 @@ -356,32 +376,32 @@ buttonBox accepted() - lrbordereditor + LimeReport::BorderEditor accept() - 253 - 255 + 119 + 322 - 219 - 275 + 377 + 309 buttonBox rejected() - lrbordereditor + LimeReport::BorderEditor reject() - 316 - 258 + 48 + 334 - 345 - 277 + 66 + 348 diff --git a/limereport/items/lrborderframeeditor.cpp b/limereport/items/lrborderframeeditor.cpp new file mode 100644 index 0000000..46fd9b9 --- /dev/null +++ b/limereport/items/lrborderframeeditor.cpp @@ -0,0 +1,181 @@ +#include "lrborderframeeditor.h" +#include "ui_lrborderframeeditor.h" +#include +#include +#include +#include +#include "lrbasedesignintf.h" +#include "lrbordereditor.h" + +namespace LimeReport{ + +BorderFrameEditor::BorderFrameEditor(QWidget *parent) + : QWidget(parent) + , ui(new Ui::BorderFrameEditor) +{ + ui->setupUi(this); + scene = new QGraphicsScene(ui->graphicsView); + + QRect vRect = rect(); + + //Draw corder lines + //topLeft + scene->addLine(10, 5, 10, 10, QPen(Qt::gray)); + scene->addLine(5, 10, 10, 10, QPen(Qt::gray)); + //bottomLeft + scene->addLine(10,vRect.bottom() -5, 10, vRect.bottom()-10, QPen(Qt::gray)); + scene->addLine(5,vRect.bottom()-10, 10, vRect.bottom()-10, QPen(Qt::gray)); + //bottomRight + scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right()- 10, vRect.bottom() - 10, QPen(Qt::gray)); + scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10, QPen(Qt::gray)); + //topRight + scene->addLine(vRect.width() - 10, 5, vRect.width() - 10, 10, QPen(Qt::gray)); + scene->addLine(vRect.width() - 5, 10, vRect.width() - 10, 10, QPen(Qt::gray)); + scene->setSceneRect(vRect); + ui->graphicsView->setScene(scene); + QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem(); + io->setAcceptedMouseButtons(Qt::LeftButton); + io->setPos(scene->sceneRect().center()); + io->setText(tr("Text")); + scene->addItem(io); + + QRectF bR = io->sceneBoundingRect(); + io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 ); + connect( + this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), + this, SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)) + ); + +} + +BorderFrameEditor::~BorderFrameEditor() +{ + delete ui; +} + +void BorderFrameEditor::setPen(QPen pen) +{ + m_pen = pen; + updateBorders(); +} + +QPen BorderFrameEditor::pen() +{ + return m_pen; +} + +void BorderFrameEditor::setAllLines() +{ + if (!topLine) + topLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::TopLine); + if (!leftLine) + leftLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::LeftLine); + if (!bottomLine) + bottomLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::BottomLine); + if (!rightLine) + rightLine = createSideLine(LimeReport::BaseDesignIntf::BorderSide::RightLine); +} + +void BorderFrameEditor::unSetAllLines() +{ + if (topLine){ + scene->removeItem(topLine); + topLine = NULL; + } + if (leftLine){ + scene->removeItem(leftLine); + leftLine = NULL; + } + if (bottomLine){ + scene->removeItem(bottomLine); + bottomLine = NULL; + } + if (rightLine){ + scene->removeItem(rightLine); + rightLine = NULL; + } + +} + +void BorderFrameEditor::mousePressEvent(QMouseEvent *event) +{ + if (event->x() >= 10 && event->y() <30) + emit borderSideClicked(BaseDesignIntf::BorderSide::TopLine, !topLine); + + if ((event->x() >= 10 && event->x() < 30) && (event->y() > 10)) + emit borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, !leftLine); + + if (event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom())) + emit borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, !bottomLine); + + if ((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10) + emit borderSideClicked(BaseDesignIntf::BorderSide::RightLine, !rightLine); +} + +void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, bool show) +{ + + switch(side){ + + case BaseDesignIntf::BorderSide::TopLine: + if (show){ + if (!topLine) topLine = createSideLine(side); + } else { + if (topLine) scene->removeItem(topLine); + topLine = NULL; + } + break; + + case BaseDesignIntf::LeftLine: + if (show){ + if (!leftLine) leftLine = createSideLine(side); + } else { + if (leftLine) scene->removeItem(leftLine); + leftLine = NULL; + } + break; + + case BaseDesignIntf::BottomLine: + if (show){ + if (!bottomLine) bottomLine = createSideLine(side); + } else { + if (bottomLine) scene->removeItem(bottomLine); + bottomLine = NULL; + } + break; + + case BaseDesignIntf::RightLine: + if (show){ + if (!rightLine) rightLine = createSideLine(side); + } else { + if(rightLine) scene->removeItem(rightLine); + rightLine = NULL; + } + + } + updateBorders(); +} + +QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side) +{ + switch(side){ + case BaseDesignIntf::BorderSide::TopLine: + return scene->addLine(QLineF(10, 10, rect().width() - 10, 10), m_pen); + case BaseDesignIntf::BorderSide::LeftLine: + return scene->addLine(QLineF(10, 10, 10, rect().height() - 10), m_pen); + case BaseDesignIntf::BorderSide::RightLine: + return scene->addLine(QLineF(rect().width() - 10, 10 ,rect().width() - 10, rect().height() - 10), m_pen); + case BaseDesignIntf::BorderSide::BottomLine: + return scene->addLine(QLineF(10, rect().bottom() - 10, rect().width() - 10, rect().bottom() - 10), m_pen); + } +} + +void BorderFrameEditor::updateBorders() +{ + if (topLine) topLine->setPen(m_pen); + if (leftLine) leftLine->setPen(m_pen); + if (bottomLine) bottomLine->setPen(m_pen); + if (rightLine) rightLine->setPen(m_pen); +} + +} //namespace LimeReport diff --git a/limereport/items/borderframeeditor.h b/limereport/items/lrborderframeeditor.h similarity index 61% rename from limereport/items/borderframeeditor.h rename to limereport/items/lrborderframeeditor.h index f0beae8..9333677 100644 --- a/limereport/items/borderframeeditor.h +++ b/limereport/items/lrborderframeeditor.h @@ -5,9 +5,9 @@ #include #include #include "lrbasedesignintf.h" -QT_BEGIN_NAMESPACE +namespace LimeReport{ + namespace Ui { class BorderFrameEditor; } -QT_END_NAMESPACE class BorderFrameEditor : public QWidget { @@ -23,20 +23,24 @@ public: protected: void mousePressEvent(QMouseEvent *event); signals: - void borderSideClicked(int side,bool show); + void borderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); private slots: - void SlotBorderSideClicked(int side, bool show); + void slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); +private: + QGraphicsLineItem *createSideLine(LimeReport::BaseDesignIntf::BorderSide side); + void updateBorders(); private: Ui::BorderFrameEditor *ui; - QGraphicsScene *scene; - QGraphicsLineItem *topLine = NULL + QGraphicsScene *scene; + QGraphicsLineItem *topLine = NULL ,*bottomLine = NULL ,*leftLine = NULL ,*rightLine = NULL; - QPen m_pen; - void updateBorders(); + QPen m_pen; + }; +} // namespace LimeReport #endif // WIDGET diff --git a/limereport/items/borderframeeditor.ui b/limereport/items/lrborderframeeditor.ui similarity index 94% rename from limereport/items/borderframeeditor.ui rename to limereport/items/lrborderframeeditor.ui index 3324d90..3f70f12 100644 --- a/limereport/items/borderframeeditor.ui +++ b/limereport/items/lrborderframeeditor.ui @@ -1,7 +1,7 @@ - BorderFrameEditor - + LimeReport::BorderFrameEditor + 0 diff --git a/limereport/items/lrpageeditor.cpp b/limereport/items/lrpageeditor.cpp index d0c2f46..6f4c4e3 100644 --- a/limereport/items/lrpageeditor.cpp +++ b/limereport/items/lrpageeditor.cpp @@ -1,9 +1,11 @@ #include "lrpageeditor.h" #include "ui_lrpageeditor.h" #include "lrpagedesignintf.h" +#include "lrpageitemdesignintf.h" #include #include -lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) : + +PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) : QDialog(parent), ui(new Ui::lrpageeditor) { @@ -16,8 +18,8 @@ lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page ui->format->addItem(pageSizes.key(i)); } ui->format->setCurrentIndex(m_page->pageSize()); - ui->width->setValue(m_page->width() / LimeReport::Const::mmFACTOR); - ui->height->setValue(m_page->height() / LimeReport::Const::mmFACTOR); + ui->width->setValue(m_page->width() / m_page->unitFactor()); + ui->height->setValue(m_page->height() / m_page->unitFactor()); ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait); ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape); //Margins @@ -33,18 +35,17 @@ lrpageeditor::lrpageeditor(QWidget *parent, LimeReport::PageItemDesignIntf *page ui->fullPage->setChecked(m_page->fullPage()); } -lrpageeditor::~lrpageeditor() +PageEditor::~PageEditor() { delete ui; } -void lrpageeditor::applyChanges() +void PageEditor::applyChanges() { m_page->setPageSize(static_cast(ui->format->currentIndex())); - m_page->setWidth(ui->width->value()* LimeReport::Const::mmFACTOR); - m_page->setHeight(ui->height->value()* LimeReport::Const::mmFACTOR); - m_page->setPageOrientation(ui->portrait->isChecked()?LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape); - + m_page->setWidth(ui->width->value() * LimeReport::Const::mmFACTOR); + m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR); + m_page->setPageOrientation(ui->portrait->isChecked()? LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape); m_page->setTopMargin(ui->marginTop->value()); m_page->setBottomMargin(ui->marginBottom->value()); m_page->setRightMargin(ui->marginRight->value()); @@ -52,53 +53,55 @@ void lrpageeditor::applyChanges() m_page->setDropPrinterMargins(ui->dropPrinterMargins->isChecked()); ui->endlessHeight->setChecked(ui->endlessHeight->isChecked()); m_page->setExtendedHeight(ui->extendedHeight->value()); + ui->width->setValue(m_page->getItemWidth()); + ui->height->setValue(m_page->getItemHeight()); } -void lrpageeditor::on_buttonBox_accepted() -{ - applyChanges(); - accept(); - -} - -QSizeF lrpageeditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageSize& size) +QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageSize& size) { if (size != LimeReport::PageItemDesignIntf::Custom) { QPrinter printer; printer.setOutputFormat(QPrinter::PdfFormat); #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) - printer.setOrientation(ui->portrait->isChecked()?QPrinter::Portrait : QPrinter::Landscape); + printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait : QPrinter::Landscape); printer.setPaperSize((QPrinter::PageSize)size); - return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10, - printer.paperSize(QPrinter::Millimeter).height() * 10); + return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * m_page->unitFactor(), + printer.paperSize(QPrinter::Millimeter).height() * m_page->unitFactor()); #else - QPageSize pageSize = QPageSize((QPageSize::PageSizeId)size); - qreal width = pageSize.size(QPageSize::Millimeter).width() * 10; - qreal height = pageSize.size(QPageSize::Millimeter).height() * 10; - return QSizeF(pageOrientation() == Portrait ? width : height, - pageOrientation() == Portrait ? height : width); - -// printer.setPageOrientation((QPageLayout::Orientation)pageOrientation()); -// printer.setPageSize(QPageSize((QPageSize::PageSizeId)size)); -// return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * 10, -// printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * 10); + printer.setPageOrientation((QPageLayout::Orientation)m_page->pageOrientation()); + printer.setPageSize(QPageSize((QPageSize::PageSizeId)size)); + return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * m_page->unitFactor(), + printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * m_page->unitFactor()); #endif - } - - else { - return QSizeF(width(),height()); + } else { + return QSizeF(m_page->getItemWidth(), m_page->getItemHeight()); } } -void lrpageeditor::on_format_currentIndexChanged(int index) +void PageEditor::on_format_currentIndexChanged(int index) { QPageSize ps = *new QPageSize(); if(ui->format->currentText() != "Custom") { QSizeF pageSize = getRectByPageSize(static_cast(index)); - ui->width->setValue(pageSize.width()/10); - ui->height->setValue(pageSize.height()/10); + ui->width->setValue(pageSize.width() / m_page->unitFactor()); + ui->height->setValue(pageSize.height() / m_page->unitFactor()); } } + +void PageEditor::on_buttonBox_clicked(QAbstractButton *button) +{ + switch(ui->buttonBox->buttonRole(button)){ + case QDialogButtonBox::ApplyRole: + applyChanges(); + break; + case QDialogButtonBox::AcceptRole: + applyChanges(); + accept(); + } + + +} + diff --git a/limereport/items/lrpageeditor.h b/limereport/items/lrpageeditor.h index 545ca3e..1adf97b 100644 --- a/limereport/items/lrpageeditor.h +++ b/limereport/items/lrpageeditor.h @@ -8,17 +8,18 @@ namespace Ui { class lrpageeditor; } -class lrpageeditor : public QDialog +class PageEditor : public QDialog { Q_OBJECT public: - explicit lrpageeditor(QWidget *parent = nullptr,LimeReport::PageItemDesignIntf *page = nullptr); - ~lrpageeditor(); + explicit PageEditor(QWidget *parent = nullptr,LimeReport::PageItemDesignIntf *page = nullptr); + ~PageEditor(); private slots: - void on_buttonBox_accepted(); +// void on_buttonBox_accepted(); void on_format_currentIndexChanged(int index); + void on_buttonBox_clicked(QAbstractButton *button); private: Ui::lrpageeditor *ui; diff --git a/limereport/items/lrpageeditor.ui b/limereport/items/lrpageeditor.ui index 70ca440..af2f735 100644 --- a/limereport/items/lrpageeditor.ui +++ b/limereport/items/lrpageeditor.ui @@ -7,7 +7,7 @@ 0 0 306 - 322 + 350 @@ -297,7 +297,7 @@ Qt::Horizontal - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Ok @@ -312,8 +312,8 @@ reject() - 325 - 312 + 296 + 340 286 @@ -328,12 +328,12 @@ setEnabled(bool) - 60 - 50 + 72 + 81 - 130 - 85 + 131 + 134 diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 524d3d8..c86b575 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -80,7 +80,7 @@ SOURCES += \ $$REPORT_PATH/lraxisdata.cpp \ $$REPORT_PATH/lrpreparedpages.cpp \ $$REPORT_PATH/items/lrpageeditor.cpp \ - $$REPORT_PATH/items/borderframeeditor.cpp \ + $$REPORT_PATH/items/lrborderframeeditor.cpp \ $$REPORT_PATH/items/lrbordereditor.cpp CONFIG(staticlib) { @@ -181,7 +181,7 @@ HEADERS += \ $$REPORT_PATH/lraxisdata.h \ $$REPORT_PATH/lrpreparedpagesintf.h \ $$REPORT_PATH/items/lrpageeditor.h \ - $$REPORT_PATH/items/borderframeeditor.h \ + $$REPORT_PATH/items/lrborderframeeditor.h \ $$REPORT_PATH/items/lrbordereditor.h CONFIG(staticlib) { @@ -207,7 +207,7 @@ FORMS += \ $$REPORT_PATH/items/lrimageitemeditor.ui \ $$REPORT_PATH/scripteditor/lrscripteditor.ui \ $$REPORT_PATH/items/lrpageeditor.ui \ - $$REPORT_PATH/items/borderframeeditor.ui \ + $$REPORT_PATH/items/lrborderframeeditor.ui \ $$REPORT_PATH/items/lrbordereditor.ui RESOURCES += \ diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index d31165f..d66efeb 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -431,7 +431,7 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o setupPainter(ppainter); drawBorder(ppainter, rect()); if(m_shadow) - drawShadow(ppainter, rect()); + drawShadow(ppainter, rect(), 6); // if (m_joinMarkerOn) { drawMarker(ppainter, Const::JOIN_COLOR);} // if (isSelected() && !m_joinMarkerOn) {drawMarker(ppainter, Const::SELECTION_COLOR);} drawResizeZone(ppainter); @@ -1145,10 +1145,9 @@ void BaseDesignIntf::drawBorder(QPainter *painter, QRectF rect) const painter->restore(); } -void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect) const +void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect, qreal shadowSize) const { - - qreal shWidth = rect.width()/100; + qreal shWidth = shadowSize; QRectF rshadow(rect.topRight() + QPointF(0, shWidth), rect.bottomRight() + QPointF(shWidth, 0)); QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight()); @@ -1167,8 +1166,6 @@ void BaseDesignIntf::drawShadow(QPainter *painter, QRectF rect) const cgrad.setColorAt(0.0, QColor(0,0,0,255)); cgrad.setColorAt(1.0, QColor(0,0,0,0)); painter->fillRect(cshadow, QBrush(cgrad)); - - } void BaseDesignIntf::setGeometry(QRectF rect) @@ -1486,7 +1483,7 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) menu.addSeparator(); QAction* noBordersAction = menu.addAction(QIcon(":/report/images/noLines"), tr("No borders")); QAction* allBordersAction = menu.addAction(QIcon(":/report/images/allLines"), tr("All borders")); - QAction* editBorderAction = menu.addAction(QIcon(":/report/images/allLines"), tr("Edit borders...")); + QAction* editBorderAction = menu.addAction(QIcon(":/report/images/borderEditor"), tr("Edit borders...")); preparePopUpMenu(menu); QAction* a = menu.exec(event->screenPos()); if (a){ @@ -1507,15 +1504,12 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) page->setBorders(BaseDesignIntf::NoLine); if (a == allBordersAction) page->setBorders(BaseDesignIntf::AllLines); - if(a == editBorderAction) + if (a == editBorderAction) { - lrbordereditor be; + BorderEditor be; be.loadItem(this); - if(be.exec() == QDialog::Rejected)return; - setBorderLinesFlags(be.borderSides()); - setBorderLineSize(be.border_width()); - setBorderStyle((LimeReport::BaseDesignIntf::BorderStyle)be.border_style()); - setBorderColor(be.borderColor()); + if (be.exec() == QDialog::Rejected) return; + page->setBordersExt(be.borderSides(), be.borderWidth(), (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), be.borderColor()); } if (a == createHLayout) page->addHLayout(); diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index adf7d21..89f68d2 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -389,7 +389,7 @@ protected: void drawBorder(QPainter* painter, QRectF rect) const; - void drawShadow(QPainter* painter, QRectF rect) const; + void drawShadow(QPainter* painter, QRectF rect, qreal shadowSize) const; void drawDesignModeBorder(QPainter* painter, QRectF rect) const; void drawRenderModeBorder(QPainter *painter, QRectF rect) const; void drawResizeZone(QPainter*); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 55907b4..bd0e583 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1826,6 +1826,20 @@ void PageDesignIntf::setBorders(const BaseDesignIntf::BorderLines& border) changeSelectedGroupProperty("borders", (int)border); } +void PageDesignIntf::setBordersExt( + const BaseDesignIntf::BorderLines& border, + const double borderWidth, + const LimeReport::BaseDesignIntf::BorderStyle style, + const QString color + +) +{ + changeSelectedGroupProperty("borders", (int)border); + changeSelectedGroupProperty("borderLineSize", borderWidth); + changeSelectedGroupProperty("borderStyle", style); + changeSelectedGroupProperty("borderColor", color); +} + void PageDesignIntf::lockSelectedItems() { foreach(QGraphicsItem* graphicItem, selectedItems()){ diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index 0a49b4d..c64b501 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -254,6 +254,11 @@ namespace LimeReport { void setFont(const QFont &font); void setTextAlign(const Qt::Alignment& alignment); void setBorders(const BaseDesignIntf::BorderLines& border); + void setBordersExt(const BaseDesignIntf::BorderLines &border, + const double borderWidth, + const BaseDesignIntf::BorderStyle style, + const QString color + ); void lockSelectedItems(); void unlockSelectedItems(); void selectOneLevelItems(); diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 0311707..57f05ae 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -98,38 +98,10 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte paintGrid(ppainter, rect); ppainter->setPen(gridColor()); ppainter->drawRect(boundingRect()); - //Draw shadow - qreal shWidth = boundingRect().width()/100; - QRectF rshadow(boundingRect().topRight() + QPointF(0, shWidth), - boundingRect().bottomRight() + QPointF(shWidth, 0)); - QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight()); - rgrad.setColorAt(0.0, QColor(0,0,0,255)); - rgrad.setColorAt(1.0, QColor(0,0,0,0)); - ppainter->fillRect(rshadow, QBrush(rgrad)); - QRectF bshadow(boundingRect().bottomLeft() + QPointF(shWidth, 0), - boundingRect().bottomRight() + QPointF(0, shWidth)); - QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft()); - bgrad.setColorAt(0.0, QColor(0,0,0,255)); - bgrad.setColorAt(1.0, QColor(0,0,0,0)); - ppainter->fillRect(bshadow, QBrush(bgrad)); - QRectF cshadow(boundingRect().bottomRight(), - boundingRect().bottomRight() + QPointF(shWidth, shWidth)); - QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft()); - cgrad.setColorAt(0.0, QColor(0,0,0,255)); - cgrad.setColorAt(1.0, QColor(0,0,0,0)); - ppainter->fillRect(cshadow, QBrush(cgrad)); - if (m_isExtendedInDesignMode){ - QPen pen; - pen.setColor(Qt::red); - pen.setStyle(Qt::DashLine); - pen.setWidth(2); - ppainter->setPen(pen); - ppainter->drawLine(pageRect().bottomLeft(),pageRect().bottomRight()); - } + drawShadow(ppainter, boundingRect(), 10); ppainter->restore(); } - if (itemMode() & PreviewMode) { ppainter->save(); ppainter->fillRect(rect(), Qt::white); @@ -145,8 +117,6 @@ void PageItemDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsIte BaseDesignIntf::paint(ppainter,option,widget); } - - } BaseDesignIntf *PageItemDesignIntf::createSameTypeItem(QObject *owner, QGraphicsItem *parent) @@ -828,7 +798,7 @@ void PageItemDesignIntf::processPopUpAction(QAction *action) } if(action->text() == tr("Edit")) { - lrpageeditor pageEdit(NULL,this); + PageEditor pageEdit(NULL,this); pageEdit.exec(); } diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 19c3a3e..58570bc 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -704,6 +704,16 @@ void ReportDesignWidget::setBorders(const BaseDesignIntf::BorderLines& borders) activePage()->setBorders(borders); } +void ReportDesignWidget::setBordersExt( + const BaseDesignIntf::BorderLines& border, + const double borderWidth, + const LimeReport::BaseDesignIntf::BorderStyle style, + const QString color +){ + if (activePage()) + activePage()->setBordersExt(border, borderWidth, style, color); +} + void ReportDesignWidget::prepareReport() { m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 8057f13..9a5a68a 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -194,6 +194,8 @@ public slots: void setFont(const QFont &font); void setTextAlign(const bool &horizontalAlign, const Qt::AlignmentFlag &alignment); void setBorders(const BaseDesignIntf::BorderLines& borders); + void setBordersExt(const BaseDesignIntf::BorderLines &border, const double borderWidth, + const LimeReport::BaseDesignIntf::BorderStyle style, const QString color); void editSetting(); void setUseGrid(bool value); void previewReport(); diff --git a/limereport/report.qrc b/limereport/report.qrc index 89999d9..dc59710 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -186,5 +186,6 @@ images/designer.png images/lock.png images/unlock.png + images/border_settings.png From 934e31ec1c8063f7151f686ef684b83451d96d67 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Tue, 1 Nov 2022 13:22:20 +0300 Subject: [PATCH 23/30] Cmake fixed --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64ce1b6..481370e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ ${PROJECT_NAME}/items/editors/lritemsborderseditorwidget.cpp ${PROJECT_NAME}/items/editors/lrtextalignmenteditorwidget.cpp ${PROJECT_NAME}/items/lrabstractlayout.cpp ${PROJECT_NAME}/items/lralignpropitem.cpp -${PROJECT_NAME}/items/borderframeeditor.cpp +${PROJECT_NAME}/items/lrborderframeeditor.cpp ${PROJECT_NAME}/items/lrbordereditor.cpp ${PROJECT_NAME}/items/lrchartitem.cpp ${PROJECT_NAME}/items/lrchartaxiseditor.cpp @@ -198,7 +198,7 @@ ${PROJECT_NAME}/items/editors/lritemsborderseditorwidget.h ${PROJECT_NAME}/items/editors/lrtextalignmenteditorwidget.h ${PROJECT_NAME}/items/lrabstractlayout.h ${PROJECT_NAME}/items/lralignpropitem.h -${PROJECT_NAME}/items/borderframeeditor.h +${PROJECT_NAME}/items/lrborderframeeditor.h ${PROJECT_NAME}/items/lrbordereditor.h ${PROJECT_NAME}/items/lrchartitem.h ${PROJECT_NAME}/items/lrchartaxiseditor.h From 2aaf467dc10eb8caa5cc821f61d7cedf8838b8fa Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Tue, 1 Nov 2022 13:29:52 +0300 Subject: [PATCH 24/30] Cmake fixed --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 481370e..482d337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,7 +298,7 @@ ${PROJECT_NAME}/databrowser/lrdatabrowser.ui ${PROJECT_NAME}/databrowser/lrsqleditdialog.ui ${PROJECT_NAME}/databrowser/lrvariabledialog.ui ${PROJECT_NAME}/dialogdesigner/templates/Dialog.ui -${PROJECT_NAME}/items/borderframeeditor.ui +${PROJECT_NAME}/items/lrborderframeeditor.ui ${PROJECT_NAME}/items/lrbordereditor.ui ${PROJECT_NAME}/items/lrchartitemeditor.ui ${PROJECT_NAME}/items/lrchartaxiseditor.ui From 288afc44e4b8f8cdfd4b9167f8ebe7ea2aa49697 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 9 Nov 2022 09:33:42 +0000 Subject: [PATCH 25/30] Update readme for cmake --- README.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 78ff6ac..0bafa82 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,37 @@ ### How to use it -1. Build limereport.pro. It will create a limereport shared library -2. In your project connect the limereport library then in source code add: +#### QMake + +- Build limereport.pro. It will create a limereport shared library +- In your project connect the limereport library + +#### CMake + +To use in your application without installation + +There are 2 possible ways: + +- Use cmake subdirectory in your CMakeLists.txt: + +```cmake +add_subdirectory(LimeReport) +target_link_libraries(myapp PRIVATE limereport-qt${QT_VERSION_MAJOR}) +``` +- Use cmake FetchContent in your CMakeLists.txt: + +```cmake +include(FetchContent) +FetchContent_Declare( + LimeReport + GIT_REPOSITORY https://github.com/fralx/LimeReport.git + GIT_TAG sha-of-the-commit +) +FetchContent_MakeAvailable(LimeReport) +target_link_libraries(myapp PRIVATE limereport-qt${QT_VERSION_MAJOR}) +``` + +- Then in source code add: ```cpp #include "lrreportengine.h" to add report engine From 706eefba7c1582f2637ea376bf27e249b0f561b8 Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 5 Jan 2023 00:22:53 +0000 Subject: [PATCH 26/30] Fix cmake_minimum_required https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html Call the cmake_minimum_required() command at the beginning of the top-level CMakeLists.txt file even before calling the project() command. It is important to establish version and policy settings before invoking other commands whose behavior they may affect. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 482d337..930fa33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -project(limereport) cmake_minimum_required(VERSION 3.14) +project(limereport) set(LIMEREPORT_VERSION_MAJOR 1) set(LIMEREPORT_VERSION_MINOR 6) From 920037d387826659508ae49408378542d861ff21 Mon Sep 17 00:00:00 2001 From: yanis60 <30592254+yanis60@users.noreply.github.com> Date: Mon, 9 Jan 2023 09:42:19 +0000 Subject: [PATCH 27/30] Page free space calculation has been updated --- limereport/lrscriptenginemanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 0b80203..9cb87ed 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -707,14 +707,13 @@ int ScriptEngineManager::getPageFreeSpace(PageItemDesignIntf* page){ if (page){ int height = 0; foreach(BandDesignIntf* band, page->bands()){ - if(band->type() == BandDesignIntf::Data) { height += band->geometry().height() * m_dataManager->dataSource(band->datasourceName())->model()->rowCount(); } else height += band->height(); } - return page->height() - height; + return page->height() - height - (page->pageFooter()?page->pageFooter()->height() : 0); } else return -1; } From b0d0fd526b90cbeb125616a9fc32cc332e371abe Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 5 Jan 2023 00:37:27 +0000 Subject: [PATCH 28/30] fix cmake install dirs and public headers --- CMakeLists.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 930fa33..fbab265 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,16 +409,13 @@ target_include_directories( ${PROJECT_NAME} PRIVATE target_include_directories( ${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) +list (APPEND GLOBAL_HEADERS ${EXTRA_FILES}) +set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${GLOBAL_HEADERS}") + install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + RUNTIME DESTINATION bin + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/limereport) -install(FILES - ${EXTRA_FILES} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}") - -install(FILES - ${GLOBAL_HEADERS} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}") From 266b6795daf79178f0abd74585593358975336f3 Mon Sep 17 00:00:00 2001 From: Jihadist Date: Wed, 11 Jan 2023 20:47:11 +0300 Subject: [PATCH 29/30] fix build without UiTools --- limereport/lrscriptenginemanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 9cb87ed..31220d3 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -1443,6 +1443,8 @@ DialogDescriber* ScriptEngineContext::findDialogContainer(const QString& dialogN return 0; } +#endif + TableOfContents* ScriptEngineContext::tableOfContents() const { return m_tableOfContents; @@ -1474,6 +1476,8 @@ void ScriptEngineContext::setCurrentBand(BandDesignIntf* currentBand) m_currentBand = currentBand; } +#ifdef HAVE_UI_LOADER + QDialog* ScriptEngineContext::getDialog(const QString& dialogName) { QDialog* dialog = findDialog(dialogName); From 3a7f4fef28ad39e79dfe9d564e77aee6b6c8f7a0 Mon Sep 17 00:00:00 2001 From: Jihadist Date: Wed, 11 Jan 2023 21:55:01 +0300 Subject: [PATCH 30/30] remove local CMakeLists.txt.user --- CMakeLists.txt.user | 576 -------------------------------------------- 1 file changed, 576 deletions(-) delete mode 100644 CMakeLists.txt.user diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user deleted file mode 100644 index 4934a44..0000000 --- a/CMakeLists.txt.user +++ /dev/null @@ -1,576 +0,0 @@ - - - - - - EnvironmentId - {33389db1-1b8e-4833-9ab8-a0816539f586} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - false - true - false - 0 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - - 0 - true - - -fno-delayed-template-parsing - - true - Builtin.BuildSystem - - true - true - Builtin.DefaultTidyAndClazy - 2 - - - - true - - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop Qt 5.12.3 MinGW 64-bit - Desktop Qt 5.12.3 MinGW 64-bit - qt.qt5.5123.win64_mingw73_kit - 0 - 0 - 1 - - Debug - -GNinja --DCMAG=Debug --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:/Work/C++/Projects/build-LimeReport-Desktop_Qt_5_12_3_MinGW_64_bit-Debug - - - - all - - true - Build - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - Build - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - Release - -GNinja --DCMAKE_BUILD_TYPE:STRING=Release --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_12_3_MinGW_64_bit-Release - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - CMakeProjectManager.CMakeBuildConfiguration - - - RelWithDebInfo - -GNinja --DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_12_3_MinGW_64_bit-RelWithDebInfo - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release with Debug Information - CMakeProjectManager.CMakeBuildConfiguration - - - MinSizeRel - -GNinja --DCMAKE_BUILD_TYPE:STRING=MinSizeRel --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_12_3_MinGW_64_bit-MinSizeRel - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Minimum Size Release - CMakeProjectManager.CMakeBuildConfiguration - - 4 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - LRDesigner - CMakeProjectManager.CMakeRunConfiguration.LRDesigner - LRDesigner - false - true - true - false - true - - - true - true - true - - 2 - - demo_r1 - CMakeProjectManager.CMakeRunConfiguration.demo_r1 - demo_r1 - false - true - true - false - true - - 2 - - - - ProjectExplorer.Project.Target.1 - - Desktop - Desktop Qt 5.15.1 MSVC2019 64bit - Desktop Qt 5.15.1 MSVC2019 64bit - qt.qt5.5151.win64_msvc2019_64_kit - 0 - 0 - 0 - - Debug - -GNinja --DCMAKE_BUILD_TYPE:STRING=Debug --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_15_1_MSVC2019_64bit-Debug - - - - all - - true - Build - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - Build - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - Release - -GNinja --DCMAKE_BUILD_TYPE:STRING=Release --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_15_1_MSVC2019_64bit-Release - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - CMakeProjectManager.CMakeBuildConfiguration - - - RelWithDebInfo - -GNinja --DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_15_1_MSVC2019_64bit-RelWithDebInfo - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release with Debug Information - CMakeProjectManager.CMakeBuildConfiguration - - - MinSizeRel - -GNinja --DCMAKE_BUILD_TYPE:STRING=MinSizeRel --DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - D:\Work\C++\Projects\build-LimeReport-Desktop_Qt_5_15_1_MSVC2019_64bit-MinSizeRel - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Minimum Size Release - CMakeProjectManager.CMakeBuildConfiguration - - 4 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - LRDesigner - CMakeProjectManager.CMakeRunConfiguration.LRDesigner - LRDesigner - false - true - true - false - true - - - true - true - true - - 2 - - demo_r1 - CMakeProjectManager.CMakeRunConfiguration.demo_r1 - demo_r1 - false - true - true - false - true - - 2 - - - - ProjectExplorer.Project.TargetCount - 2 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - -