From 634a0c7eaa940959f96f146a8dcd8817a8e2597c Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 11 Dec 2019 15:01:02 +0300 Subject: [PATCH 01/23] Default file name to save preview has been added --- common.pri | 2 +- limereport/lrpreviewreportwidget.cpp | 4 ++-- limereport/lrreportengine.cpp | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common.pri b/common.pri index 62c871f..cff835e 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 22 +LIMEREPORT_VERSION_RELEASE = 23 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 87a3bab..636bcb9 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -124,9 +124,9 @@ bool PreviewReportWidget::exportReport(QString exporterName, const QMapm_report); - + QString defaultFileName = d_ptr->m_report->reportName().split(".")[0]; QString filter = QString("%1 (*.%2)").arg(e->exporterName()).arg(e->exporterFileExt()); - QString fileName = QFileDialog::getSaveFileName(this,tr("%1 file name").arg(e->exporterName()),"",filter); + QString fileName = QFileDialog::getSaveFileName(this,tr("%1 file name").arg(e->exporterName()), defaultFileName, filter); if (!fileName.isEmpty()){ QFileInfo fi(fileName); if (fi.suffix().isEmpty()) diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 1717f3f..8d25064 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -470,8 +470,9 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file if (ExportersFactory::instance().map().contains(exporterName)){ ReportExporterInterface* e = ExportersFactory::instance().objectCreator(exporterName)(this); if (fn.isEmpty()){ + QString defaultFileName = reportName().split(".")[0]; QString filter = QString("%1 (*.%2)").arg(e->exporterName()).arg(e->exporterFileExt()); - QString fn = QFileDialog::getSaveFileName(0,tr("%1 file name").arg(e->exporterName()),"",filter); + QString fn = QFileDialog::getSaveFileName(0, tr("%1 file name").arg(e->exporterName()), defaultFileName, filter); } if (!fn.isEmpty()){ QFileInfo fi(fn); From 8d6cf97a4813dc3c6b198efa63e7828584836fd0 Mon Sep 17 00:00:00 2001 From: wartime Date: Sun, 15 Dec 2019 14:23:27 +0800 Subject: [PATCH 02/23] Increase line number for every group header --- limereport/lrreportrender.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index c17973d..f0a4c5a 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1,4 +1,4 @@ -/*************************************************************************** +/*************************************************************************** * This file is part of the Lime Report project * * Copyright (C) 2015 by Alexander Arin * * arin_a@bk.ru * @@ -636,10 +636,23 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) bandDatasource->next(); datasources()->setReportVariable(varName,datasources()->variable(varName).toInt()+1); - foreach (BandDesignIntf* band, dataBand->childrenByType(BandDesignIntf::GroupHeader)){ - QString groupLineVar = QLatin1String("line_")+band->objectName().toLower(); - if (datasources()->containsVariable(groupLineVar)) - datasources()->setReportVariable(groupLineVar,datasources()->variable(groupLineVar).toInt()+1); + + QList bandList; + QList childList; + + bandList = dataBand->childrenByType(BandDesignIntf::GroupHeader); + while (bandList.size() > 0) + { + childList.clear(); + foreach (BandDesignIntf* band, bandList) + { + childList.append(band->childrenByType(BandDesignIntf::GroupHeader)); + + QString groupLineVar = QLatin1String("line_")+band->objectName().toLower(); + if (datasources()->containsVariable(groupLineVar)) + datasources()->setReportVariable(groupLineVar,datasources()->variable(groupLineVar).toInt()+1); + } + bandList = childList; } renderGroupHeader(dataBand, bandDatasource, false); From 464e0275ba30efd589e766b599f6a9eadd9181bc Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Mon, 16 Dec 2019 14:37:44 +0300 Subject: [PATCH 03/23] Increased border size --- common.pri | 2 +- limereport/lrbanddesignintf.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.pri b/common.pri index cff835e..6439752 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 23 +LIMEREPORT_VERSION_RELEASE = 24 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 30661bd..20c0dfe 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -1123,7 +1123,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p if (keepBottomSpace()) spaceBorder = bottomSpace(); spaceBorder = spaceBorder > 0 ? spaceBorder : 0; if (borderLines() != 0){ - spaceBorder += borderLineSize(); + spaceBorder += borderLineSize() + 2; } spaceBorder += m_bottomSpace; From 8328e0146b057cd713fca8ca509dfaa5d0c46ee8 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Wed, 18 Dec 2019 23:13:33 +0300 Subject: [PATCH 04/23] ChartItem has been fixed --- common.pri | 2 +- limereport/items/lrchartitem.cpp | 8 +++++--- limereport/items/lrchartitem.h | 4 ++-- limereport/lrreportrender.cpp | 7 ++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/common.pri b/common.pri index 6439752..a37bc09 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 24 +LIMEREPORT_VERSION_RELEASE = 25 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index 73565d4..df86704 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -85,6 +85,8 @@ SeriesItem *SeriesItem::clone() void SeriesItem::fillSeriesData(IDataSource *dataSource) { + m_data.clear(); + if (dataSource){ dataSource->first(); int currentColorIndex = 0; @@ -724,7 +726,7 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect) } barSeriesCount = (m_chartItem->itemMode()==DesignMode) ? seriesCount() : barSeriesCount; - + if (barSeriesCount < 1) return; painter->save(); painter->setRenderHint(QPainter::Antialiasing,false); @@ -770,7 +772,7 @@ void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect) qreal hStep = (barsRect.width() / valuesCount()); qreal topShift = (delta - (maxValue()-minValue())) * vStep +barsRect.top(); - if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ + if (!m_chartItem->series().isEmpty()){ foreach (SeriesItem* series, m_chartItem->series()) { if (series->preferredType() == SeriesItem::Line){ QPen pen(series->color()); @@ -859,7 +861,7 @@ qreal AbstractSeriesChart::minValue() int AbstractSeriesChart::valuesCount() { if (m_chartItem->itemMode()==DesignMode) return 3; - return (m_chartItem->series().isEmpty())?(0):(m_chartItem->series().at(0)->data()->labels().count()); + return (m_chartItem->series().isEmpty())?(0):(m_chartItem->series().at(0)->data()->values().count()); } int AbstractSeriesChart::seriesCount() diff --git a/limereport/items/lrchartitem.h b/limereport/items/lrchartitem.h index 5af5213..ee38f6b 100644 --- a/limereport/items/lrchartitem.h +++ b/limereport/items/lrchartitem.h @@ -16,6 +16,7 @@ public: QList& values(){ return m_values;} QList& labels(){ return m_labels;} QList& colors() { return m_colors;} + void clear(){ m_values.clear(); m_labels.clear(); m_colors.clear(); } private: QList m_values; QList m_labels; @@ -189,7 +190,7 @@ protected: void paintChartTitle(QPainter* painter, QRectF titleRect); virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); //ICollectionContainer - QObject* createElement(const QString& collectionName,const QString& elementType); + QObject* createElement(const QString& collectionName, const QString& elementType); int elementsCount(const QString& collectionName); QObject* elementAt(const QString& collectionName,int index); void collectionLoadFinished(const QString& collectionName){Q_UNUSED(collectionName)} @@ -199,7 +200,6 @@ protected: bool isNeedUpdateSize(RenderPass pass) const; private: QList m_series; -// QList< QPointer > m_series; QString m_datasource; QPixmap m_chartImage; QString m_title; diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index f0a4c5a..49af8cc 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1183,7 +1183,7 @@ void ReportRender::updateTOC(BaseDesignIntf* item, int pageNumber){ void ReportRender::secondRenderPass(ReportPages renderedPages) { if (!m_scriptEngineContext->tableOfContents()->isEmpty()){ - for(int i=0; ichildBaseItems()){ @@ -1192,12 +1192,13 @@ void ReportRender::secondRenderPass(ReportPages renderedPages) } } - for(int i=0; isetReportVariable("#PAGE",m_pagesRanges.findPageNumber(i)); m_datasources->setReportVariable("#PAGE_COUNT",m_pagesRanges.findLastPageNumber(i)); foreach(BaseDesignIntf* item, page->childBaseItems()){ - item->updateItemSize(m_datasources, SecondPass); + if (item->isNeedUpdateSize(SecondPass)) + item->updateItemSize(m_datasources, SecondPass); } } } From 6a7180346c5c938bb7bb93eee827a387fe890315 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Thu, 19 Dec 2019 23:40:32 +0300 Subject: [PATCH 05/23] Crash on selection "use default connection" has been fixed --- common.pri | 2 +- limereport/databrowser/lrdatabrowser.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common.pri b/common.pri index a37bc09..53f06b0 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 25 +LIMEREPORT_VERSION_RELEASE = 26 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/databrowser/lrdatabrowser.cpp b/limereport/databrowser/lrdatabrowser.cpp index 2deebd6..d475826 100644 --- a/limereport/databrowser/lrdatabrowser.cpp +++ b/limereport/databrowser/lrdatabrowser.cpp @@ -723,7 +723,8 @@ void DataBrowser::addDatasource(SQLEditResult result) void DataBrowser::activateItem(const QString& name, DataBrowserTree::NodeType type){ QTreeWidgetItem* item = findByNameAndType(name, type); - item->treeWidget()->setCurrentItem(item); + if (item) + item->treeWidget()->setCurrentItem(item); } void DataBrowser::addConnectionDesc(ConnectionDesc *connection) From ca965db02ab64129a3a88158da20036576592621 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Fri, 27 Dec 2019 20:19:58 +0300 Subject: [PATCH 06/23] Second pass has been fixed --- common.pri | 2 +- limereport/lrbanddesignintf.cpp | 7 +++++++ limereport/lrbanddesignintf.h | 3 ++- limereport/lrbasedesignintf.cpp | 2 +- limereport/lrbasedesignintf.h | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common.pri b/common.pri index 53f06b0..ab447f6 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 26 +LIMEREPORT_VERSION_RELEASE = 27 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 20c0dfe..8b1c341 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -241,6 +241,13 @@ void BandDesignIntf::setBackgroundOpacity(int value) } } +bool BandDesignIntf::isNeedUpdateSize(RenderPass pass) const{ + foreach(BaseDesignIntf* item, childBaseItems()){ + if (item->isNeedUpdateSize(pass)) return true; + } + return false; +} + void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { prepareRect(painter, option, widget); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 7f1d3f0..8984518 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -263,7 +263,8 @@ public: void setBootomSpace(int bootomSpace); void updateBandMarkerGeometry(); int shiftItems() const; - void setShiftItems(int shiftItems); + void setShiftItems(int shiftItems); + bool isNeedUpdateSize(RenderPass) const; signals: void bandRendered(BandDesignIntf* band); diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 1555aaf..91fa79c 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -1569,7 +1569,7 @@ void BaseDesignIntf::objectLoadFinished() void BaseDesignIntf::parentObjectLoadFinished() {} -QList BaseDesignIntf::childBaseItems() +QList BaseDesignIntf::childBaseItems() const { QList resList; foreach(QGraphicsItem * item, childItems()) { diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index b7fbbbb..6887ca3 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -244,7 +244,7 @@ public: virtual void parentObjectLoadFinished(); virtual void beforeDelete(); - QList childBaseItems(); + QList childBaseItems() const; QList allChildBaseItems(); BaseDesignIntf* childByName(const QString& name); From e9e98292f2e7eb4824bed2912dae420c26ff29d9 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 9 Jan 2020 21:22:58 +0300 Subject: [PATCH 07/23] Showing the report designer from a console application has been fixed --- common.pri | 2 +- designer/main.cpp | 1 + include/lrreportengine.h | 4 ++++ limereport/lrreportengine.cpp | 20 +++++++++++++++----- limereport/lrreportengine.h | 4 ++++ limereport/lrreportengine_p.h | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/common.pri b/common.pri index ab447f6..17f5c7c 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 27 +LIMEREPORT_VERSION_RELEASE = 28 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/designer/main.cpp b/designer/main.cpp index 8d06579..57a32c1 100644 --- a/designer/main.cpp +++ b/designer/main.cpp @@ -47,6 +47,7 @@ int main(int argc, char *argv[]) QObject::connect(&report, SIGNAL(currentDefaultDesignerLanguageChanged(QLocale::Language)), &manager, SLOT(currentDefaultLanguageChanged(QLocale::Language))); + report.setShowDesignerModal(false); report.designReport(); return a.exec(); } diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 8ef7ff0..6509302 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -208,6 +208,9 @@ public: bool showPreparedPages(PreviewHints hints = PreviewBarsUserSetting); bool prepareReportPages(); bool printPreparedPages(); + bool showDesignerModal() const; + void setShowDesignerModal(bool showDesignerModal); + signals: void cleared(); void renderStarted(); @@ -241,6 +244,7 @@ protected: private: Q_DECLARE_PRIVATE(ReportEngine) static QSettings* m_settings; + bool m_showDesignerModal; }; } // namespace LimeReport diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 8d25064..81657c5 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -738,7 +738,7 @@ QGraphicsScene* ReportEngine::createPreviewScene(QObject* parent){ return d->createPreviewScene(parent); } -void ReportEnginePrivate::designReport() +void ReportEnginePrivate::designReport(bool showModal) { ReportDesignWindowInterface* designerWindow = getDesignerWindow(); if (designerWindow){ @@ -747,7 +747,7 @@ void ReportEnginePrivate::designReport() #ifdef Q_OS_WIN designerWindow->setWindowModality(Qt::ApplicationModal); #endif - if (QApplication::activeWindow()==0){ + if (!showModal){ designerWindow->show();; } else { designerWindow->showModal(); @@ -1373,7 +1373,7 @@ QString ReportEnginePrivate::lastError() } ReportEngine::ReportEngine(QObject *parent) - : QObject(parent), d_ptr(new ReportEnginePrivate()) + : QObject(parent), d_ptr(new ReportEnginePrivate()), m_showDesignerModal(true) { Q_D(ReportEngine); d->q_ptr=this; @@ -1469,7 +1469,7 @@ void ReportEngine::designReport() Q_D(ReportEngine); if (m_settings) d->setSettings(m_settings); - d->designReport(); + d->designReport(showDesignerModal()); } ReportDesignWindowInterface* ReportEngine::getDesignerWindow() @@ -1760,7 +1760,7 @@ void ReportEngine::cancelPrinting() } ReportEngine::ReportEngine(ReportEnginePrivate &dd, QObject *parent) - :QObject(parent),d_ptr(&dd) + :QObject(parent), d_ptr(&dd), m_showDesignerModal(true) { Q_D(ReportEngine); d->q_ptr=this; @@ -1770,6 +1770,16 @@ ReportEngine::ReportEngine(ReportEnginePrivate &dd, QObject *parent) connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished())); } +bool ReportEngine::showDesignerModal() const +{ + return m_showDesignerModal; +} + +void ReportEngine::setShowDesignerModal(bool showDesignerModal) +{ + m_showDesignerModal = showDesignerModal; +} + ScriptEngineManager*LimeReport::ReportEnginePrivate::scriptManager(){ ScriptEngineManager::instance().setContext(scriptContext()); ScriptEngineManager::instance().setDataManager(dataManager()); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 8ef7ff0..6509302 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -208,6 +208,9 @@ public: bool showPreparedPages(PreviewHints hints = PreviewBarsUserSetting); bool prepareReportPages(); bool printPreparedPages(); + bool showDesignerModal() const; + void setShowDesignerModal(bool showDesignerModal); + signals: void cleared(); void renderStarted(); @@ -241,6 +244,7 @@ protected: private: Q_DECLARE_PRIVATE(ReportEngine) static QSettings* m_settings; + bool m_showDesignerModal; }; } // namespace LimeReport diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 3196f4e..2453b90 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -179,7 +179,7 @@ public: void previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting); ReportDesignWindowInterface* getDesignerWindow(); - void designReport(); + void designReport(bool showModal); void setSettings(QSettings* value); void setShowProgressDialog(bool value){m_showProgressDialog = value;} bool isShowProgressDialog() const {return m_showProgressDialog;} From 6eb30918e5aa0ada7ed877fc84cef9295e72d9f3 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 9 Jan 2020 21:26:25 +0300 Subject: [PATCH 08/23] ChartItem: from now chart labels will rotate only if not enough space to draw them horizontally --- limereport/items/lrchartitem.cpp | 36 ++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index df86704..abeb2e4 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -800,22 +800,36 @@ void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect) painter->restore(); } - - void VerticalBarChart::paintLabels(QPainter *painter, QRectF labelsRect) { painter->save(); qreal hStep = (labelsRect.width() / valuesCount()); - - if (!m_chartItem->labels().isEmpty()){ - painter->rotate(270); - painter->translate(-(labelsRect.top()+labelsRect.height()),labelsRect.left()); - foreach (QString label, m_chartItem->labels()) { - painter->drawText(QRectF(QPoint(0,0), - QSize(labelsRect.height()-4,hStep)),Qt::AlignVCenter|Qt::AlignRight,label); - painter->translate(0,hStep); + bool rotateLabels = false; + QFontMetrics fm = painter->fontMetrics(); + foreach(QString label, m_chartItem->labels()){ + if (fm.width(label) > hStep){ + rotateLabels = true; + break; + } + } + if (!m_chartItem->labels().isEmpty()){ + if (rotateLabels){ + painter->rotate(270); + painter->translate( -(labelsRect.top()+labelsRect.height()), labelsRect.left() ); + foreach (QString label, m_chartItem->labels()) { + painter->drawText(QRectF(QPoint(0,0), + QSize(labelsRect.height()-4, hStep)), Qt::AlignVCenter | Qt::AlignRight, label); + painter->translate(0,hStep); + } + painter->rotate(-270); + } else { + painter->translate( labelsRect.left(), labelsRect.top() ); + foreach (QString label, m_chartItem->labels()) { + painter->drawText(QRectF(QPoint(0, 4), + QSize(hStep, labelsRect.height()-4)), Qt::AlignHCenter | Qt::AlignTop, label); + painter->translate(hStep, 0); + } } - painter->rotate(-270); } painter->restore(); } From 919173870a88066e6160e619ebb0cfe283e0c515 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 11 Jan 2020 02:11:55 +0300 Subject: [PATCH 09/23] ChartItem has been refactored --- common.pri | 2 +- .../items/charts/lrhorizontalbarchart.cpp | 64 ++ .../items/charts/lrhorizontalbarchart.h | 17 + limereport/items/charts/lrlineschart.cpp | 97 +++ limereport/items/charts/lrlineschart.h | 17 + limereport/items/charts/lrpiechart.cpp | 172 +++++ limereport/items/charts/lrpiechart.h | 19 + .../items/charts/lrverticalbarchart.cpp | 123 +++ limereport/items/charts/lrverticalbarchart.h | 19 + limereport/items/lrchartitem.cpp | 717 +++++------------- limereport/items/lrchartitem.h | 56 +- limereport/limereport.pri | 21 +- 12 files changed, 753 insertions(+), 571 deletions(-) create mode 100644 limereport/items/charts/lrhorizontalbarchart.cpp create mode 100644 limereport/items/charts/lrhorizontalbarchart.h create mode 100644 limereport/items/charts/lrlineschart.cpp create mode 100644 limereport/items/charts/lrlineschart.h create mode 100644 limereport/items/charts/lrpiechart.cpp create mode 100644 limereport/items/charts/lrpiechart.h create mode 100644 limereport/items/charts/lrverticalbarchart.cpp create mode 100644 limereport/items/charts/lrverticalbarchart.h diff --git a/common.pri b/common.pri index 17f5c7c..84e603c 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 28 +LIMEREPORT_VERSION_RELEASE = 29 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/items/charts/lrhorizontalbarchart.cpp b/limereport/items/charts/lrhorizontalbarchart.cpp new file mode 100644 index 0000000..e2713dd --- /dev/null +++ b/limereport/items/charts/lrhorizontalbarchart.cpp @@ -0,0 +1,64 @@ +#include "lrhorizontalbarchart.h" + +namespace LimeReport{ + +void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect) +{ + QRectF calcRect = verticalLabelsRect(painter, chartRect.adjusted( + hPadding(chartRect), + vPadding(chartRect) * 2, + -(chartRect.width() * 0.9), + -(vPadding(chartRect) * 2 + valuesVMargin(painter)) + )); + + qreal barsShift = calcRect.width(); + + paintHorizontalGrid(painter, chartRect.adjusted( + hPadding(chartRect) + barsShift, + vPadding(chartRect), + -(hPadding(chartRect)),-vPadding(chartRect))); + paintHorizontalBars(painter, chartRect.adjusted( + hPadding(chartRect) + barsShift, + vPadding(chartRect) * 2, + -(hPadding(chartRect)), + -(vPadding(chartRect) * 2) )); + + paintVerticalLabels(painter, calcRect); +} + +void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect) +{ + painter->save(); + painter->setRenderHint(QPainter::Antialiasing,false); + int delta = int(maxValue()-minValue()); + delta = genNextValue(delta); + + qreal vStep = (barsRect.height()-painter->fontMetrics().height()) / valuesCount() / seriesCount(); + qreal hStep = (barsRect.width()-painter->fontMetrics().width(QString::number(maxValue()))) / delta; + + if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){ + int curSeries = 0; + foreach (SeriesItem* series, m_chartItem->series()) { + qreal curVOffset = curSeries*vStep+barsRect.top(); + painter->setBrush(series->color()); + foreach (qreal value, series->data()->values()) { + painter->drawRect(QRectF((-minValue()*hStep)+barsRect.left(), curVOffset, value*hStep, vStep)); + curVOffset+=vStep*seriesCount(); + } + curSeries++; + } + } else { + qreal curVOffset = barsRect.top(); + int curColor = 0; + for (int i=0; i<9; ++i){ + if (curColor==3) curColor=0; + painter->setBrush(color_map[curColor]); + painter->drawRect(QRectF(barsRect.left(), curVOffset, designValues()[i]*hStep, vStep)); + curVOffset+=vStep; + curColor++; + } + } + painter->restore(); +} + +} diff --git a/limereport/items/charts/lrhorizontalbarchart.h b/limereport/items/charts/lrhorizontalbarchart.h new file mode 100644 index 0000000..af478dc --- /dev/null +++ b/limereport/items/charts/lrhorizontalbarchart.h @@ -0,0 +1,17 @@ +#ifndef HORIZONTALBARCHART_H +#define HORIZONTALBARCHART_H + +#include "lrchartitem.h" + +namespace LimeReport{ + +class HorizontalBarChart: public AbstractBarChart{ +public: + HorizontalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){} + void paintChart(QPainter *painter, QRectF chartRect); + void paintHorizontalBars(QPainter *painter, QRectF barsRect); +}; + +} // namespace LimeReport + +#endif // HORIZONTALBARCHART_H diff --git a/limereport/items/charts/lrlineschart.cpp b/limereport/items/charts/lrlineschart.cpp new file mode 100644 index 0000000..30f2949 --- /dev/null +++ b/limereport/items/charts/lrlineschart.cpp @@ -0,0 +1,97 @@ +#include "lrlineschart.h" + +namespace LimeReport { + +void LinesChart::paintChart(QPainter *painter, QRectF chartRect) +{ + QRectF calcRect = horizontalLabelsRect( + painter, + chartRect.adjusted( + hPadding(chartRect) * 2 + valuesHMargin(painter), + chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect)*2), + -(hPadding(chartRect) * 2), + -vPadding(chartRect) + ) + ); + qreal barsShift = calcRect.height(); + paintVerticalGrid( + painter, + chartRect.adjusted( + hPadding(chartRect), + vPadding(chartRect) + valuesVMargin(painter), + -hPadding(chartRect), + -(vPadding(chartRect) + barsShift) + ) + ); + paintSerialLines( + painter, + chartRect.adjusted( + hPadding(chartRect) * 2 + valuesHMargin(painter), + vPadding(chartRect) + valuesVMargin(painter), + -(hPadding(chartRect) * 2), + -(vPadding(chartRect)+barsShift) + ) + ); + paintHorizontalLabels(painter, calcRect); +} + +void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect){ + for (int i = 0; i < valuesCount()-1; ++i){ + QPoint startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - designValues()[i] * vStep + ); + QPoint endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - designValues()[i+1] * vStep + ); + drawSegment(painter, startPoint, endPoint, color_map[0]); + + startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - designValues()[i+3] * vStep + ); + endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - designValues()[i+3+1] * vStep + ); + drawSegment(painter, startPoint, endPoint, color_map[1]); + + startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - designValues()[i+6] * vStep + ); + endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - designValues()[i+6+1] * vStep + ); + drawSegment(painter, startPoint, endPoint, color_map[2]); + } +} + +void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) +{ + painter->save(); + painter->setRenderHint(QPainter::Antialiasing,true); + int delta = int(maxValue() - minValue()); + delta = genNextValue(delta); + + qreal vStep = barsRect.height() / delta; + qreal hStep = barsRect.width() / valuesCount(); + qreal topShift = (delta - (maxValue() - minValue())) * vStep +barsRect.top(); + + if (m_chartItem->itemMode() != DesignMode){ + foreach (SeriesItem* series, m_chartItem->series()) { + QPen pen(series->color()); + pen.setWidth(4); + painter->setPen(pen); + for (int i = 0; i < series->data()->values().count()-1; ++i ){ + QPoint startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2, + (maxValue()*vStep+topShift) - series->data()->values().at(i) * vStep); + QPoint endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2, + (maxValue() * vStep+topShift) - series->data()->values().at(i+1) * vStep); + drawSegment(painter, startPoint, endPoint, series->color()); + } + } + } else { + drawDesignMode(painter, hStep, vStep, topShift, barsRect); + } + painter->restore(); +} + +} //namespace LimeReport + diff --git a/limereport/items/charts/lrlineschart.h b/limereport/items/charts/lrlineschart.h new file mode 100644 index 0000000..6e10cf4 --- /dev/null +++ b/limereport/items/charts/lrlineschart.h @@ -0,0 +1,17 @@ +#ifndef LINESCHART_H +#define LINESCHART_H + +#include "lrchartitem.h" + +namespace LimeReport { +class LinesChart: public AbstractBarChart{ +public: + LinesChart(ChartItem* chartItem):AbstractBarChart(chartItem){} + void paintChart(QPainter *painter, QRectF chartRect); +private: + void paintSerialLines(QPainter *painter, QRectF barsRect); + void drawDesignMode(QPainter *painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect); +}; +} + +#endif // LINESCHART_H diff --git a/limereport/items/charts/lrpiechart.cpp b/limereport/items/charts/lrpiechart.cpp new file mode 100644 index 0000000..f54e62d --- /dev/null +++ b/limereport/items/charts/lrpiechart.cpp @@ -0,0 +1,172 @@ +#include "lrpiechart.h" + +namespace LimeReport{ + +void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle) +{ + painter->save(); + + QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2); + qreal percent = angle/3.6; +#ifdef HAVE_QT4 + qreal radAngle = (angle/2+startAngle)*(M_PI/180); +#endif +#ifdef HAVE_QT5 + qreal radAngle = qDegreesToRadians(angle/2+startAngle); +#endif + qreal radius = painter->fontMetrics().width("99,9%"); + qreal border = chartRect.height()*0.02; + qreal length = (chartRect.height())/2-(radius/2+border); + qreal x,y; + x = length*qCos(radAngle); + y = length*qSin(radAngle); + QPointF endPoint(center.x()+x,center.y()-y); + painter->setPen(Qt::white); + QRectF textRect(endPoint.x()-(radius/2),endPoint.y()-(radius/2),radius,radius); + + qreal arcLength = 3.14 * length * angle / 180; + if (arcLength >= radius) + painter->drawText(textRect,Qt::AlignCenter,QString::number(percent,'f',1)+"%"); + painter->restore(); + +} + +void PieChart::paintChart(QPainter *painter, QRectF chartRect) +{ + painter->save(); + QPen pen(Qt::white); + pen.setWidthF(2); + painter->setPen(pen); + + QBrush brush(Qt::transparent); + painter->setBrush(brush); + painter->setBackground(QBrush(Qt::NoBrush)); + + QRectF tmpRect = chartRect; + if (chartRect.height()>chartRect.width()){ + tmpRect.setHeight(chartRect.width()); + tmpRect.adjust(0,(chartRect.bottom()-tmpRect.bottom())/2, + 0,(chartRect.bottom()-tmpRect.bottom())/2); + } else { + tmpRect.setWidth(chartRect.height()); + } + + chartRect = tmpRect; + painter->drawRect(chartRect); + + if (!m_chartItem->series().isEmpty()&&!m_chartItem->series().at(0)->data()->values().isEmpty()){ + SeriesItem* si = m_chartItem->series().at(0); + qreal sum = 0; + foreach(qreal value, si->data()->values()){ + sum+=value; + } + qreal onePercent = sum / 100; + qreal currentDegree = 0; + for(int i=0; idata()->values().count(); ++i){ + qreal value = si->data()->values().at(i); + qreal sectorDegree = (value/onePercent)*3.6; + painter->setBrush(si->data()->colors().at(i)); + painter->drawPie(chartRect,currentDegree*16,sectorDegree*16); + drawPercent(painter, chartRect, currentDegree, sectorDegree); + currentDegree += sectorDegree; + } + } else { + painter->setBrush(color_map[0]); + painter->drawPie(chartRect,0,260*16); + drawPercent(painter, chartRect, 0, 260); + painter->setBrush(color_map[1]); + painter->drawPie(chartRect,260*16,40*16); + drawPercent(painter, chartRect, 260, 40); + painter->setBrush(color_map[2]); + painter->drawPie(chartRect,300*16,60*16); + drawPercent(painter, chartRect, 300, 60); + } + + pen.setWidthF(1); + pen.setColor(Qt::gray); + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawEllipse(chartRect); + painter->restore(); +} + +void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect) +{ + prepareLegendToPaint(legendRect, painter); + + int indicatorSize = painter->fontMetrics().height()/2; + painter->setRenderHint(QPainter::Antialiasing,false); + + if (m_chartItem->drawLegendBorder()) + painter->drawRect(legendRect); + + painter->setRenderHint(QPainter::Antialiasing,true); + QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height()/2,painter->fontMetrics().height()/2,0,0); + + if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ + qreal cw = 0; + SeriesItem* si = m_chartItem->series().at(0); + for (int i=0;idata()->labels().count();++i){ + QString label = si->data()->labels().at(i); + painter->setPen(Qt::black); + painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label); + painter->setPen(si->data()->colors().at(i)); + painter->setBrush(si->data()->colors().at(i)); + painter->drawEllipse( + indicatorsRect.adjusted( + 0, + cw+indicatorSize/2, + -(indicatorsRect.width()-indicatorSize), + -(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2)) + ) + ); + cw += painter->fontMetrics().height(); + } + } else { + qreal cw = 0; + for (int i=0;isetPen(Qt::black); + painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label); + painter->setBrush(color_map[i]); + painter->setPen(color_map[i]); + painter->drawEllipse( + indicatorsRect.adjusted( + 0, + cw+indicatorSize/2, + -(indicatorsRect.width()-indicatorSize), + -(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2)) + ) + ); + cw += painter->fontMetrics().height(); + } + + } +} + +QSizeF PieChart::calcChartLegendSize(const QFont &font) +{ + QFontMetrics fm(font); + + qreal cw = 0; + qreal maxWidth = 0; + + if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ + SeriesItem* si = m_chartItem->series().at(0); + foreach(QString label, si->data()->labels()){ + cw += fm.height(); + if (maxWidthfontMetrics().height() + vPadding(chartRect) * 2), + -(hPadding(chartRect) * 2), + -vPadding(chartRect) + ) + ); + qreal barsShift = calcRect.height(); + paintVerticalGrid( + painter, + chartRect.adjusted( + hPadding(chartRect), + vPadding(chartRect) + valuesVMargin(painter), + -hPadding(chartRect), + -(vPadding(chartRect) + barsShift) + ) + ); + paintVerticalBars( + painter, + chartRect.adjusted( + hPadding(chartRect) * 2 + valuesHMargin(painter), + vPadding(chartRect) + valuesVMargin(painter), + -hPadding(chartRect) * 2, + -(vPadding(chartRect) + barsShift) + ) + ); + paintSerialLines( + painter, + chartRect.adjusted( + hPadding(chartRect) * 2 + valuesHMargin(painter), + vPadding(chartRect) + valuesVMargin(painter), + -hPadding(chartRect) * 2, + -(vPadding(chartRect) + barsShift) + ) + ); + paintHorizontalLabels(painter, calcRect); +} + +void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect) +{ + + int delta = int(maxValue() - minValue()); + delta = genNextValue(delta); + + int barSeriesCount = 0; + foreach(SeriesItem* series, m_chartItem->series()){ + if (series->preferredType() == SeriesItem::Bar) barSeriesCount++; + } + + barSeriesCount = (m_chartItem->itemMode() == DesignMode) ? seriesCount() : barSeriesCount; + if (barSeriesCount < 1) return; + painter->save(); + painter->setRenderHint(QPainter::Antialiasing,false); + + qreal vStep = barsRect.height() / delta; + qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount); + qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top(); + + if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){ + int curSeries = 0; + foreach (SeriesItem* series, m_chartItem->series()) { + if (series->preferredType() == SeriesItem::Bar){ + qreal curHOffset = curSeries * hStep + barsRect.left(); + painter->setBrush(series->color()); + foreach (qreal value, series->data()->values()) { + painter->drawRect(QRectF(curHOffset, maxValue() * vStep + topShift, hStep, -value * vStep)); + curHOffset += hStep * barSeriesCount; + } + curSeries++; + } + } + } else { + qreal curHOffset = barsRect.left(); + int curColor = 0; + for (int i = 0; i < 9; ++i){ + if (curColor == 3) curColor = 0; + painter->setBrush(color_map[curColor]); + painter->drawRect(QRectF(curHOffset, maxValue() * vStep + barsRect.top(), hStep, -designValues()[i] * vStep)); + curHOffset += hStep; + curColor++; + } + } + painter->restore(); +} + +void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect) +{ + painter->save(); + painter->setRenderHint(QPainter::Antialiasing,true); + int delta = int(maxValue() - minValue()); + delta = genNextValue(delta); + + qreal vStep = barsRect.height() / delta; + qreal hStep = (barsRect.width() / valuesCount()); + qreal topShift = (delta - (maxValue()-minValue())) * vStep + barsRect.top(); + + if (!m_chartItem->series().isEmpty()){ + foreach (SeriesItem* series, m_chartItem->series()) { + if (series->preferredType() == SeriesItem::Line){ + for (int i = 0; i < series->data()->values().count()-1; ++i ){ + QPoint startPoint = QPoint((i+1)*hStep + barsRect.left()-hStep/2, + (maxValue() * vStep+topShift) - series->data()->values().at(i) * vStep + ); + QPoint endPoint = QPoint((i+2)*hStep + barsRect.left()-hStep/2, + (maxValue() * vStep+topShift) - series->data()->values().at(i+1) * vStep + ); + drawSegment(painter, startPoint, endPoint, series->color()); + } + } + } + } + painter->restore(); +} + +} // namespace LimeReport diff --git a/limereport/items/charts/lrverticalbarchart.h b/limereport/items/charts/lrverticalbarchart.h new file mode 100644 index 0000000..9cfe8f8 --- /dev/null +++ b/limereport/items/charts/lrverticalbarchart.h @@ -0,0 +1,19 @@ +#ifndef VERTICALBARCHART_H +#define VERTICALBARCHART_H + +#include "lrchartitem.h" + +namespace LimeReport{ + +class VerticalBarChart: public AbstractBarChart{ +public: + VerticalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){} + void paintChart(QPainter *painter, QRectF chartRect); +// void paintVerticalGrid(QPainter *painter, QRectF gridRect); + void paintVerticalBars(QPainter *painter, QRectF barsRect); + void paintSerialLines(QPainter *painter, QRectF barsRect); +}; + +} //namespace LimeReport + +#endif // VERTICALBARCHART_H diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index abeb2e4..b80e700 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -9,6 +9,11 @@ #include "lrreportengine_p.h" #include "lrdatadesignintf.h" +#include "charts/lrpiechart.h" +#include "charts/lrverticalbarchart.h" +#include "charts/lrhorizontalbarchart.h" +#include "charts/lrlineschart.h" + namespace{ const QString xmlTag = "ChartItem"; @@ -32,15 +37,15 @@ QColor generateColor() } QColor color_map[39] = { - QColor(51,102,204), QColor(220,57,18), QColor(225, 153, 0), QColor(16, 150, 24), QColor(153,0,153), - QColor(0,153,198), QColor(221, 68, 119), - QColor(255,0,0), QColor(0,0,139), QColor(0,205,0), QColor(233,30,99), QColor(255,255,0), QColor(244,67,54), - QColor(156,39,176), QColor(103,58,183), QColor(63,81,181), QColor(33,153,243), - QColor(0,150,136), QColor(78,175,80), QColor(139,195,74), QColor(205,228,57), - QColor(0,139,0), QColor(0,0,255), QColor(255,235,59), QColor(255,193,7), - QColor(255,152,0), QColor(255,87,34), QColor(121,85,72), QColor(158,158,158), - QColor(96,125,139), QColor(241,153,185), QColor(64,64,64), - QColor(188,229,218), QColor(139,0,0), QColor(139,139,0), QColor(171, 130, 255), + QColor(51,102,204), QColor(220,57,18), QColor(225, 153, 0), QColor(16, 150, 24), + QColor(153,0,153), QColor(0,153,198), QColor(221, 68, 119), QColor(255,0,0), + QColor(0,0,139), QColor(0,205,0), QColor(233,30,99), QColor(255,255,0), + QColor(244,67,54), QColor(156,39,176), QColor(103,58,183), QColor(63,81,181), + QColor(33,153,243), QColor(0,150,136), QColor(78,175,80), QColor(139,195,74), + QColor(205,228,57), QColor(0,139,0), QColor(0,0,255), QColor(255,235,59), + QColor(255,193,7), QColor(255,152,0), QColor(255,87,34), QColor(121,85,72), + QColor(158,158,158), QColor(96,125,139), QColor(241,153,185), QColor(64,64,64), + QColor(188,229,218), QColor(139,0,0), QColor(139,139,0), QColor(171, 130, 255), QColor(139, 123, 139), QColor(255, 0, 255), QColor(139, 69, 19) }; @@ -297,6 +302,8 @@ void ChartItem::setChartType(const ChartType &chartType) case HorizontalBar: m_chart = new HorizontalBarChart(this); break; + case Lines: + m_chart = new LinesChart(this); } notify("chartType",oldValue,m_chartType); update(); @@ -462,378 +469,14 @@ void AbstractChart::prepareLegendToPaint(QRectF &legendRect, QPainter *painter) } } -void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle) -{ - painter->save(); - - QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2); - qreal percent = angle/3.6; -#ifdef HAVE_QT4 - qreal radAngle = (angle/2+startAngle)*(M_PI/180); -#endif -#ifdef HAVE_QT5 - qreal radAngle = qDegreesToRadians(angle/2+startAngle); -#endif - qreal radius = painter->fontMetrics().width("99,9%"); - qreal border = chartRect.height()*0.02; - qreal length = (chartRect.height())/2-(radius/2+border); - qreal x,y; - x = length*qCos(radAngle); - y = length*qSin(radAngle); - QPointF endPoint(center.x()+x,center.y()-y); - painter->setPen(Qt::white); - QRectF textRect(endPoint.x()-(radius/2),endPoint.y()-(radius/2),radius,radius); - - qreal arcLength = 3.14 * length * angle / 180; - if (arcLength >= radius) - painter->drawText(textRect,Qt::AlignCenter,QString::number(percent,'f',1)+"%"); - painter->restore(); - -} - -void PieChart::paintChart(QPainter *painter, QRectF chartRect) -{ - painter->save(); - QPen pen(Qt::white); - pen.setWidthF(2); - painter->setPen(pen); - - QBrush brush(Qt::transparent); - painter->setBrush(brush); - painter->setBackground(QBrush(Qt::NoBrush)); - - QRectF tmpRect = chartRect; - if (chartRect.height()>chartRect.width()){ - tmpRect.setHeight(chartRect.width()); - tmpRect.adjust(0,(chartRect.bottom()-tmpRect.bottom())/2, - 0,(chartRect.bottom()-tmpRect.bottom())/2); - } else { - tmpRect.setWidth(chartRect.height()); - } - - chartRect = tmpRect; - painter->drawRect(chartRect); - - if (!m_chartItem->series().isEmpty()&&!m_chartItem->series().at(0)->data()->values().isEmpty()){ - SeriesItem* si = m_chartItem->series().at(0); - qreal sum = 0; - foreach(qreal value, si->data()->values()){ - sum+=value; - } - qreal onePercent = sum / 100; - qreal currentDegree = 0; - for(int i=0; idata()->values().count(); ++i){ - qreal value = si->data()->values().at(i); - qreal sectorDegree = (value/onePercent)*3.6; - painter->setBrush(si->data()->colors().at(i)); - painter->drawPie(chartRect,currentDegree*16,sectorDegree*16); - drawPercent(painter, chartRect, currentDegree, sectorDegree); - currentDegree += sectorDegree; - } - } else { - painter->setBrush(color_map[0]); - painter->drawPie(chartRect,0,260*16); - drawPercent(painter, chartRect, 0, 260); - painter->setBrush(color_map[1]); - painter->drawPie(chartRect,260*16,40*16); - drawPercent(painter, chartRect, 260, 40); - painter->setBrush(color_map[2]); - painter->drawPie(chartRect,300*16,60*16); - drawPercent(painter, chartRect, 300, 60); - } - - pen.setWidthF(1); - pen.setColor(Qt::gray); - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - painter->drawEllipse(chartRect); - painter->restore(); -} - -void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect) -{ - prepareLegendToPaint(legendRect, painter); - - int indicatorSize = painter->fontMetrics().height()/2; - painter->setRenderHint(QPainter::Antialiasing,false); - - if (m_chartItem->drawLegendBorder()) - painter->drawRect(legendRect); - - painter->setRenderHint(QPainter::Antialiasing,true); - QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height()/2,painter->fontMetrics().height()/2,0,0); - - if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ - qreal cw = 0; - SeriesItem* si = m_chartItem->series().at(0); - for (int i=0;idata()->labels().count();++i){ - QString label = si->data()->labels().at(i); - painter->setPen(Qt::black); - painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label); - painter->setPen(si->data()->colors().at(i)); - painter->setBrush(si->data()->colors().at(i)); - painter->drawEllipse( - indicatorsRect.adjusted( - 0, - cw+indicatorSize/2, - -(indicatorsRect.width()-indicatorSize), - -(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2)) - ) - ); - cw += painter->fontMetrics().height(); - } - } else { - qreal cw = 0; - for (int i=0;isetPen(Qt::black); - painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label); - painter->setBrush(color_map[i]); - painter->setPen(color_map[i]); - painter->drawEllipse( - indicatorsRect.adjusted( - 0, - cw+indicatorSize/2, - -(indicatorsRect.width()-indicatorSize), - -(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2)) - ) - ); - cw += painter->fontMetrics().height(); - } - - } -} - -QSizeF PieChart::calcChartLegendSize(const QFont &font) -{ - QFontMetrics fm(font); - - qreal cw = 0; - qreal maxWidth = 0; - - if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ - SeriesItem* si = m_chartItem->series().at(0); - foreach(QString label, si->data()->labels()){ - cw += fm.height(); - if (maxWidthfontMetrics().width(QString::number(delta))+4; -} - -qreal VerticalBarChart::valuesVMargin(QPainter *painter) -{ - return painter->fontMetrics().height(); -} - -QRectF VerticalBarChart::labelsRect(QPainter *painter, QRectF labelsRect) -{ - qreal maxWidth = 0; - - foreach (QString label, m_chartItem->labels()) { - if (painter->fontMetrics().width(label)>maxWidth) - maxWidth = painter->fontMetrics().width(label); - } - - if (maxWidth+vPadding(m_chartItem->rect())> labelsRect.height()) - return labelsRect; - else - return labelsRect.adjusted(0,(labelsRect.height()-(maxWidth+vPadding(m_chartItem->rect()))),0,0); -} - -void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect) -{ - QRectF calcRect = labelsRect(painter, chartRect.adjusted( - hPadding(chartRect)*2+valuesHMargin(painter), - chartRect.height()*0.5, - -(hPadding(chartRect)*2), - -vPadding(chartRect) - )); - - qreal barsShift = calcRect.height(); - paintVerticalGrid(painter, chartRect.adjusted( - hPadding(chartRect), - vPadding(chartRect)+valuesVMargin(painter), - -hPadding(chartRect),-(vPadding(chartRect)+barsShift) )); - - paintVerticalBars(painter, chartRect.adjusted( - hPadding(chartRect)*2+valuesHMargin(painter), - vPadding(chartRect)+valuesVMargin(painter), - -(hPadding(chartRect)*2), - -(vPadding(chartRect)+barsShift) )); - paintSerialLines(painter, chartRect.adjusted( - hPadding(chartRect)*2+valuesHMargin(painter), - vPadding(chartRect)+valuesVMargin(painter), - -(hPadding(chartRect)*2), - -(vPadding(chartRect)+barsShift) )); - paintLabels(painter,calcRect); -} - - -void VerticalBarChart::paintVerticalGrid(QPainter *painter, QRectF gridRect) -{ - int delta = int(maxValue()-minValue()); - delta = genNextValue(delta); - - painter->setRenderHint(QPainter::Antialiasing,false); - qreal vStep = gridRect.height() / 4; - - for (int i=0;i<5;i++){ - painter->drawText(QRectF(gridRect.bottomLeft()-QPointF(0,vStep*i+painter->fontMetrics().height()), - QSizeF(valuesHMargin(painter),painter->fontMetrics().height())), - QString::number(minValue()+i*delta/4)); - painter->drawLine(gridRect.bottomLeft()-QPointF(-valuesHMargin(painter),vStep*i), - gridRect.bottomRight()-QPointF(0,vStep*i)); - } - - painter->setRenderHint(QPainter::Antialiasing,true); -} - - - -void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect) -{ - - int delta = int(maxValue()-minValue()); - delta = genNextValue(delta); - - int barSeriesCount = 0; - foreach(SeriesItem* series, m_chartItem->series()){ - if (series->preferredType() == SeriesItem::Bar) barSeriesCount++; - } - - barSeriesCount = (m_chartItem->itemMode()==DesignMode) ? seriesCount() : barSeriesCount; - if (barSeriesCount < 1) return; - painter->save(); - painter->setRenderHint(QPainter::Antialiasing,false); - - qreal vStep = barsRect.height() / delta; - qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount); - qreal topShift = (delta - (maxValue()-minValue())) * vStep +barsRect.top(); - - if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ - int curSeries = 0; - foreach (SeriesItem* series, m_chartItem->series()) { - if (series->preferredType() == SeriesItem::Bar){ - qreal curHOffset = curSeries*hStep+barsRect.left(); - painter->setBrush(series->color()); - foreach (qreal value, series->data()->values()) { - painter->drawRect(QRectF(curHOffset, maxValue()*vStep+topShift, hStep, -value*vStep)); - curHOffset+=hStep*barSeriesCount; - } - curSeries++; - } - } - } else { - qreal curHOffset = barsRect.left(); - int curColor = 0; - for (int i=0; i<9; ++i){ - if (curColor==3) curColor=0; - painter->setBrush(color_map[curColor]); - painter->drawRect(QRectF(curHOffset, maxValue()*vStep+barsRect.top(), hStep, -designValues()[i]*vStep)); - curHOffset+=hStep; - curColor++; - } - } - painter->restore(); -} - -void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect) -{ - painter->save(); - painter->setRenderHint(QPainter::Antialiasing,true); - int delta = int(maxValue()-minValue()); - delta = genNextValue(delta); - - qreal vStep = barsRect.height() / delta; - qreal hStep = (barsRect.width() / valuesCount()); - qreal topShift = (delta - (maxValue()-minValue())) * vStep +barsRect.top(); - - if (!m_chartItem->series().isEmpty()){ - foreach (SeriesItem* series, m_chartItem->series()) { - if (series->preferredType() == SeriesItem::Line){ - QPen pen(series->color()); - pen.setWidth(4); - painter->setPen(pen); - for (int i = 0; i < series->data()->values().count()-1; ++i ){ - QPoint startPoint = QPoint((i+1)*hStep + barsRect.left()-hStep/2, - (maxValue()*vStep+topShift) - series->data()->values().at(i)*vStep - ); - QPoint endPoint = QPoint((i+2)*hStep + barsRect.left()-hStep/2, - (maxValue()*vStep+topShift) - series->data()->values().at(i+1)*vStep - ); - painter->drawLine(startPoint, endPoint); - QRect startPointRect(startPoint,startPoint); - QRect endPointRect(endPoint,endPoint); - int radius = 4; - painter->setBrush(series->color()); - painter->drawEllipse(startPointRect.adjusted(radius,radius,-radius,-radius)); - painter->drawEllipse(endPointRect.adjusted(radius,radius,-radius,-radius)); - - } - } - } - } - painter->restore(); -} - -void VerticalBarChart::paintLabels(QPainter *painter, QRectF labelsRect) -{ - painter->save(); - qreal hStep = (labelsRect.width() / valuesCount()); - bool rotateLabels = false; - QFontMetrics fm = painter->fontMetrics(); - foreach(QString label, m_chartItem->labels()){ - if (fm.width(label) > hStep){ - rotateLabels = true; - break; - } - } - if (!m_chartItem->labels().isEmpty()){ - if (rotateLabels){ - painter->rotate(270); - painter->translate( -(labelsRect.top()+labelsRect.height()), labelsRect.left() ); - foreach (QString label, m_chartItem->labels()) { - painter->drawText(QRectF(QPoint(0,0), - QSize(labelsRect.height()-4, hStep)), Qt::AlignVCenter | Qt::AlignRight, label); - painter->translate(0,hStep); - } - painter->rotate(-270); - } else { - painter->translate( labelsRect.left(), labelsRect.top() ); - foreach (QString label, m_chartItem->labels()) { - painter->drawText(QRectF(QPoint(0, 4), - QSize(hStep, labelsRect.height()-4)), Qt::AlignHCenter | Qt::AlignTop, label); - painter->translate(hStep, 0); - } - } - } - painter->restore(); -} - AbstractSeriesChart::AbstractSeriesChart(ChartItem *chartItem) :AbstractChart(chartItem) { @@ -850,7 +493,7 @@ AbstractSeriesChart::AbstractSeriesChart(ChartItem *chartItem) qreal AbstractSeriesChart::maxValue() { - if (m_chartItem->itemMode()==DesignMode) return 40; + if (m_chartItem->itemMode() == DesignMode) return 40; qreal maxValue = 0; foreach(SeriesItem* series, m_chartItem->series()){ foreach(qreal value, series->data()->values()){ @@ -862,7 +505,7 @@ qreal AbstractSeriesChart::maxValue() qreal AbstractSeriesChart::minValue() { - if (m_chartItem->itemMode()==DesignMode) return 0; + if (m_chartItem->itemMode() == DesignMode) return 0; qreal minValue = 0; foreach(SeriesItem* series, m_chartItem->series()){ foreach(qreal value, series->data()->values()){ @@ -872,15 +515,25 @@ qreal AbstractSeriesChart::minValue() return minValue; } +qreal AbstractSeriesChart::hPadding(QRectF chartRect) +{ + return (chartRect.width() * 0.02); +} + +qreal AbstractSeriesChart::vPadding(QRectF chartRect) +{ + return (chartRect.height() * 0.02); +} + int AbstractSeriesChart::valuesCount() { - if (m_chartItem->itemMode()==DesignMode) return 3; - return (m_chartItem->series().isEmpty())?(0):(m_chartItem->series().at(0)->data()->values().count()); + if (m_chartItem->itemMode() == DesignMode) return 3; + return (m_chartItem->series().isEmpty()) ? 0 : m_chartItem->series().at(0)->data()->values().count(); } int AbstractSeriesChart::seriesCount() { - if (m_chartItem->itemMode()==DesignMode) return 3; + if (m_chartItem->itemMode() == DesignMode) return 3; return m_chartItem->series().count(); } @@ -908,154 +561,48 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font) return QSizeF(maxWidth+fm.height()*2,cw); } -qreal HorizontalBarChart::valuesHMargin(QPainter *painter) -{ - int delta = int(maxValue()-minValue()); - delta = genNextValue(delta); - return painter->fontMetrics().width(QString::number(delta))+4; -} - -qreal HorizontalBarChart::valuesVMargin(QPainter *painter) -{ - return painter->fontMetrics().height(); -} - -void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect) -{ - QRectF calcRect = labelsRect(painter, chartRect.adjusted( - hPadding(chartRect), - vPadding(chartRect)*2, - -(chartRect.width()*0.5), - -(vPadding(chartRect)*2+valuesVMargin(painter)) - )); - - qreal barsShift = calcRect.width(); - - paintHorizontalGrid(painter, chartRect.adjusted( - hPadding(chartRect)+barsShift, - vPadding(chartRect), - -(hPadding(chartRect)),-vPadding(chartRect))); - paintHorizontalBars(painter, chartRect.adjusted( - hPadding(chartRect)+barsShift, - vPadding(chartRect)*2, - -(hPadding(chartRect)), - -(vPadding(chartRect)*2) )); - - paintLabels(painter,calcRect); -} - -void HorizontalBarChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect) -{ - painter->save(); - int delta = int(maxValue()-minValue()); - delta = genNextValue(delta); - - painter->setRenderHint(QPainter::Antialiasing,false); - qreal hStep = (gridRect.width()-painter->fontMetrics().width(QString::number(maxValue()))) / 4; - - painter->setFont(adaptValuesFont(hStep-4,painter->font())); - - for (int i=0;i<5;i++){ - painter->drawText(QRectF(gridRect.left()+4+hStep*i,gridRect.bottom()-painter->fontMetrics().height(), - hStep,painter->fontMetrics().height()), - QString::number(minValue()+i*delta/4)); - painter->drawLine( gridRect.left()+hStep*i, gridRect.bottom(), - gridRect.left()+hStep*i, gridRect.top()); - - } - painter->restore(); -} - -void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect) -{ - painter->save(); - painter->setRenderHint(QPainter::Antialiasing,false); - int delta = int(maxValue()-minValue()); - delta = genNextValue(delta); - - qreal vStep = (barsRect.height()-painter->fontMetrics().height()) / valuesCount() / seriesCount(); - qreal hStep = (barsRect.width()-painter->fontMetrics().width(QString::number(maxValue()))) / delta; - - if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ - int curSeries = 0; - foreach (SeriesItem* series, m_chartItem->series()) { - qreal curVOffset = curSeries*vStep+barsRect.top(); - painter->setBrush(series->color()); - foreach (qreal value, series->data()->values()) { - painter->drawRect(QRectF((-minValue()*hStep)+barsRect.left(), curVOffset, value*hStep, vStep)); - curVOffset+=vStep*seriesCount(); - } - curSeries++; - } - } else { - qreal curVOffset = barsRect.top(); - int curColor = 0; - for (int i=0; i<9; ++i){ - if (curColor==3) curColor=0; - painter->setBrush(color_map[curColor]); - painter->drawRect(QRectF(barsRect.left(), curVOffset, designValues()[i]*hStep, vStep)); - curVOffset+=vStep; - curColor++; - } - } - painter->restore(); -} - -QRectF HorizontalBarChart::labelsRect(QPainter *painter, QRectF labelsRect) -{ - qreal maxWidth = 0; - - foreach (QString label, m_chartItem->labels()) { - if (painter->fontMetrics().width(label)>maxWidth) - maxWidth = painter->fontMetrics().width(label); - } - - if (maxWidth+hPadding(m_chartItem->rect())*2> labelsRect.width()) - return labelsRect; - else - return labelsRect.adjusted(0,0,-(labelsRect.width()-(maxWidth+hPadding(m_chartItem->rect())*2)),0); -} - -QFont HorizontalBarChart::adaptLabelsFont(QRectF rect, QFont font) -{ - QString maxWord; - QFontMetrics fm(font); - +bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect){ + qreal hStep = (labelsRect.width() / valuesCount()); + QFontMetrics fm = painter->fontMetrics(); foreach(QString label, m_chartItem->labels()){ - foreach (QString currentWord, label.split(QRegExp("\\W+"))){ - if (fm.width(maxWord) hStep){ + return true; } } - - qreal curWidth = fm.width(maxWord); - QFont tmpFont = font; - while (curWidth>rect.width() && tmpFont.pixelSize()>1){ - tmpFont.setPixelSize(tmpFont.pixelSize()-1); - QFontMetricsF tmpFM(tmpFont); - curWidth = tmpFM.width(maxWord); - } - return tmpFont; + return false; } -QFont HorizontalBarChart::adaptValuesFont(qreal width, QFont font) -{ - QString strValue = QString::number(maxValue()); - QFont tmpFont = font; - QScopedPointer fm(new QFontMetricsF(tmpFont)); - qreal curWidth = fm->width(strValue); - while (curWidth>width && tmpFont.pixelSize()>1){ - tmpFont.setPixelSize(tmpFont.pixelSize()-1); - fm.reset(new QFontMetricsF(tmpFont)); - curWidth = fm->width(strValue); - } - return tmpFont; -} - -void HorizontalBarChart::paintLabels(QPainter *painter, QRectF labelsRect) +void AbstractSeriesChart::paintHorizontalLabels(QPainter *painter, QRectF labelsRect) { painter->save(); - painter->setFont(adaptLabelsFont(labelsRect.adjusted(0,0,-hPadding(m_chartItem->rect()),0), - painter->font())); + qreal hStep = (labelsRect.width() / valuesCount()); + if (!m_chartItem->labels().isEmpty()){ + if (verticalLabels(painter, labelsRect)){ + painter->rotate(270); + painter->translate( -(labelsRect.top()+labelsRect.height()), labelsRect.left() ); + foreach (QString label, m_chartItem->labels()) { + painter->drawText(QRectF(QPoint(0,0), + QSize(labelsRect.height()-4, hStep)), Qt::AlignVCenter | Qt::AlignRight, label); + painter->translate(0,hStep); + } + painter->rotate(-270); + } else { + painter->translate( labelsRect.left(), labelsRect.top() ); + foreach (QString label, m_chartItem->labels()) { + painter->drawText(QRectF(QPoint(0, 4), + QSize(hStep, labelsRect.height()-4)), Qt::AlignHCenter | Qt::AlignTop, label); + painter->translate(hStep, 0); + } + } + } + painter->restore(); +} + +void AbstractSeriesChart::paintVerticalLabels(QPainter *painter, QRectF labelsRect) +{ + painter->save(); + painter->setFont(adaptLabelsFont(labelsRect.adjusted(0, 0, -hPadding(m_chartItem->rect()), 0), + painter->font())); qreal vStep = (labelsRect.height() / valuesCount()); int curLabel = 0; @@ -1072,14 +619,106 @@ void HorizontalBarChart::paintLabels(QPainter *painter, QRectF labelsRect) painter->restore(); } -qreal AbstractBarChart::hPadding(QRectF chartRect) +void AbstractSeriesChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect) { - return (chartRect.width()*0.02); + painter->save(); + int delta = int(maxValue() - minValue()); + delta = genNextValue(delta); + + painter->setRenderHint(QPainter::Antialiasing,false); + qreal hStep = (gridRect.width() - painter->fontMetrics().width(QString::number(maxValue()))) / 4; + + painter->setFont(adaptValuesFont(hStep-4, painter->font())); + + for (int i=0;i<5;i++){ + painter->drawText(QRectF(gridRect.left() + 4 + hStep * i, gridRect.bottom() - painter->fontMetrics().height(), + hStep, painter->fontMetrics().height()), + QString::number(minValue() + i * delta / 4)); + painter->drawLine( gridRect.left()+hStep*i, gridRect.bottom(), + gridRect.left()+hStep*i, gridRect.top()); + + } + painter->restore(); } -qreal AbstractBarChart::vPadding(QRectF chartRect) +void AbstractSeriesChart::paintVerticalGrid(QPainter *painter, QRectF gridRect) { - return (chartRect.height()*0.02); + int delta = int(maxValue()-minValue()); + delta = genNextValue(delta); + + painter->setRenderHint(QPainter::Antialiasing,false); + qreal vStep = gridRect.height() / 4; + + for (int i=0;i<5;i++){ + painter->drawText(QRectF(gridRect.bottomLeft()-QPointF(0,vStep*i+painter->fontMetrics().height()), + QSizeF(valuesHMargin(painter),painter->fontMetrics().height())), + QString::number(minValue()+i*delta/4)); + painter->drawLine(gridRect.bottomLeft()-QPointF(-valuesHMargin(painter),vStep*i), + gridRect.bottomRight()-QPointF(0,vStep*i)); + } + + painter->setRenderHint(QPainter::Antialiasing,true); +} + +void AbstractSeriesChart::drawSegment(QPainter *painter, QPoint startPoint, QPoint endPoint, QColor color) +{ + int radius = 4; + QPen pen(color); + pen.setWidth(radius); + painter->setPen(pen); + painter->drawLine(startPoint, endPoint); + QRect startPointRect(startPoint,startPoint); + QRect endPointRect(endPoint,endPoint); + painter->setBrush(color); + painter->drawEllipse(startPointRect.adjusted(radius,radius,-radius,-radius)); + painter->drawEllipse(endPointRect.adjusted(radius,radius,-radius,-radius)); +} + +qreal AbstractSeriesChart::valuesHMargin(QPainter *painter) +{ + int delta = int(maxValue()-minValue()); + delta = genNextValue(delta); + return painter->fontMetrics().width(QString::number(delta))+4; +} + +qreal AbstractSeriesChart::valuesVMargin(QPainter *painter) +{ + return painter->fontMetrics().height(); +} + +QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font) +{ + QString maxWord; + QFontMetrics fm(font); + + foreach(QString label, m_chartItem->labels()){ + foreach (QString currentWord, label.split(QRegExp("\\W+"))){ + if (fm.width(maxWord) < fm.width(currentWord)) maxWord = currentWord; + } + } + + qreal curWidth = fm.width(maxWord); + QFont tmpFont = font; + while (curWidth>rect.width() && tmpFont.pixelSize() > 1){ + tmpFont.setPixelSize(tmpFont.pixelSize() - 1); + QFontMetricsF tmpFM(tmpFont); + curWidth = tmpFM.width(maxWord); + } + return tmpFont; +} + +QFont AbstractSeriesChart::adaptValuesFont(qreal width, QFont font) +{ + QString strValue = QString::number(maxValue()); + QFont tmpFont = font; + QScopedPointer fm(new QFontMetricsF(tmpFont)); + qreal curWidth = fm->width(strValue); + while (curWidth > width && tmpFont.pixelSize() > 1){ + tmpFont.setPixelSize(tmpFont.pixelSize() - 1); + fm.reset(new QFontMetricsF(tmpFont)); + curWidth = fm->width(strValue); + } + return tmpFont; } void AbstractBarChart::paintChartLegend(QPainter *painter, QRectF legendRect) @@ -1129,4 +768,34 @@ void AbstractBarChart::paintChartLegend(QPainter *painter, QRectF legendRect) } } +QRectF AbstractBarChart::verticalLabelsRect(QPainter *painter, QRectF labelsRect) +{ + qreal maxWidth = 0; + + foreach (QString label, m_chartItem->labels()) { + if (painter->fontMetrics().width(label)>maxWidth) + maxWidth = painter->fontMetrics().width(label); + } + + if (maxWidth + hPadding(m_chartItem->rect()) * 2 < labelsRect.width()) + return labelsRect; + else + return labelsRect.adjusted(0, 0, -(labelsRect.width() - (maxWidth + hPadding(m_chartItem->rect()) * 2)), 0); +} + +QRectF AbstractBarChart::horizontalLabelsRect(QPainter *painter, QRectF labelsRect) +{ + qreal maxWidth = 0; + + foreach (QString label, m_chartItem->labels()) { + if (painter->fontMetrics().width(label)>maxWidth) + maxWidth = painter->fontMetrics().width(label); + } + + if ((maxWidth + vPadding(m_chartItem->rect()) < labelsRect.height()) || !verticalLabels(painter, labelsRect)) + return labelsRect; + else + return labelsRect.adjusted(0, (labelsRect.height() - maxWidth), 0, 0); +} + } // namespace LimeReport diff --git a/limereport/items/lrchartitem.h b/limereport/items/lrchartitem.h index ee38f6b..bd1ca40 100644 --- a/limereport/items/lrchartitem.h +++ b/limereport/items/lrchartitem.h @@ -81,56 +81,34 @@ protected: qreal minValue(); int valuesCount(); int seriesCount(); + bool verticalLabels(QPainter* painter, QRectF labelsRect); QSizeF calcChartLegendSize(const QFont &font); qreal* designValues(){ return m_designValues;} + virtual qreal hPadding(QRectF chartRect); + virtual qreal vPadding(QRectF chartRect); + virtual void paintHorizontalLabels(QPainter *painter, QRectF labelsRect); + virtual void paintVerticalLabels(QPainter *painter, QRectF labelsRect); + virtual void paintHorizontalGrid(QPainter *painter, QRectF gridRect); + virtual void paintVerticalGrid(QPainter *painter, QRectF gridRect); + virtual void drawSegment(QPainter *painter, QPoint startPoint, QPoint endPoint, QColor color); + virtual qreal valuesHMargin(QPainter *painter); + virtual qreal valuesVMargin(QPainter *painter); + virtual QFont adaptLabelsFont(QRectF rect, QFont font); + virtual QFont adaptValuesFont(qreal width, QFont font); + private: qreal m_designValues [9]; }; -class PieChart : public AbstractChart{ -public: - PieChart(ChartItem* chartItem):AbstractChart(chartItem){} - QSizeF calcChartLegendSize(const QFont &font); - void paintChart(QPainter *painter, QRectF chartRect); - void paintChartLegend(QPainter *painter, QRectF legendRect); -protected: - void drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle); -}; +int genNextValue(int value); class AbstractBarChart: public AbstractSeriesChart{ public: AbstractBarChart(ChartItem* chartItem):AbstractSeriesChart(chartItem){} - qreal hPadding(QRectF chartRect); - qreal vPadding(QRectF chartRect); void paintChartLegend(QPainter *painter, QRectF legendRect); -}; - -class HorizontalBarChart: public AbstractBarChart{ -public: - HorizontalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){} - qreal valuesHMargin(QPainter *painter); - qreal valuesVMargin(QPainter *painter); - void paintChart(QPainter *painter, QRectF chartRect); - void paintHorizontalGrid(QPainter *painter, QRectF gridRect); - void paintHorizontalBars(QPainter *painter, QRectF barsRect); - QRectF labelsRect(QPainter* painter, QRectF labelsRect); - void paintLabels(QPainter *painter, QRectF labelsRect); protected: - QFont adaptLabelsFont(QRectF rect, QFont font); - QFont adaptValuesFont(qreal width, QFont font); -}; - -class VerticalBarChart: public AbstractBarChart{ -public: - VerticalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){} - qreal valuesHMargin(QPainter *painter); - qreal valuesVMargin(QPainter *painter); - QRectF labelsRect(QPainter* painter, QRectF labelsRect); - void paintChart(QPainter *painter, QRectF chartRect); - void paintVerticalGrid(QPainter *painter, QRectF gridRect); - void paintVerticalBars(QPainter *painter, QRectF barsRect); - void paintSerialLines(QPainter *painter, QRectF barsRect); - void paintLabels(QPainter *painter, QRectF labelsRect); + QRectF verticalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect); + virtual QRectF horizontalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect); }; class ChartItem : public LimeReport::ItemDesignIntf @@ -152,7 +130,7 @@ public: enum LegendAlign{LegendAlignTop,LegendAlignCenter,LegendAlignBottom}; enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight}; - enum ChartType{Pie, VerticalBar, HorizontalBar}; + enum ChartType{Pie, VerticalBar, HorizontalBar, Lines}; ChartItem(QObject* owner, QGraphicsItem* parent); ~ChartItem(); diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 0918890..219dbb4 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -43,6 +43,12 @@ SOURCES += \ $$REPORT_PATH/items/lrverticallayout.cpp \ $$REPORT_PATH/items/lrlayoutmarker.cpp \ $$REPORT_PATH/items/lrabstractlayout.cpp \ + $$REPORT_PATH/items/lrchartitem.cpp \ + $$REPORT_PATH/items/lrchartitemeditor.cpp \ + $$REPORT_PATH/items/charts/lrhorizontalbarchart.cpp \ + $$REPORT_PATH/items/charts/lrlineschart.cpp \ + $$REPORT_PATH/items/charts/lrpiechart.cpp \ + $$REPORT_PATH/items/charts/lrverticalbarchart.cpp \ $$REPORT_PATH/lrbanddesignintf.cpp \ $$REPORT_PATH/lrpageitemdesignintf.cpp \ $$REPORT_PATH/lrpagedesignintf.cpp \ @@ -65,8 +71,6 @@ SOURCES += \ $$REPORT_PATH/lrsettingdialog.cpp \ $$REPORT_PATH/lritemscontainerdesignitf.cpp \ $$REPORT_PATH/lrcolorindicator.cpp \ - $$REPORT_PATH/items/lrchartitem.cpp \ - $$REPORT_PATH/items/lrchartitemeditor.cpp \ $$REPORT_PATH/lrreporttranslation.cpp \ $$REPORT_PATH/exporters/lrpdfexporter.cpp \ $$REPORT_PATH/lrpreparedpages.cpp @@ -104,6 +108,8 @@ HEADERS += \ $$REPORT_PATH/scripteditor/lrscripthighlighter.h \ $$REPORT_PATH/items/editors/lritemeditorwidget.h \ $$REPORT_PATH/items/editors/lrfonteditorwidget.h \ + $$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.h \ + $$REPORT_PATH/items/editors/lritemsborderseditorwidget.h \ $$REPORT_PATH/items/lrtextitem.h \ $$REPORT_PATH/items/lrhorizontallayout.h \ $$REPORT_PATH/items/lrtextitemeditor.h \ @@ -114,6 +120,12 @@ HEADERS += \ $$REPORT_PATH/items/lrverticallayout.h \ $$REPORT_PATH/items/lrlayoutmarker.h \ $$REPORT_PATH/items/lrabstractlayout.h \ + $$REPORT_PATH/items/lrchartitem.h \ + $$REPORT_PATH/items/lrchartitemeditor.h \ + $$REPORT_PATH/items/charts/lrhorizontalbarchart.h \ + $$REPORT_PATH/items/charts/lrlineschart.h \ + $$REPORT_PATH/items/charts/lrpiechart.h \ + $$REPORT_PATH/items/charts/lrverticalbarchart.h \ $$REPORT_PATH/lrbanddesignintf.h \ $$REPORT_PATH/lrpageitemdesignintf.h \ $$REPORT_PATH/lrbandsmanager.h \ @@ -145,10 +157,6 @@ HEADERS += \ $$REPORT_PATH/lrpreviewreportwidget_p.h \ $$REPORT_PATH/lritemscontainerdesignitf.h \ $$REPORT_PATH/lrcolorindicator.h \ - $$REPORT_PATH/items/lrchartitem.h \ - $$REPORT_PATH/items/lrchartitemeditor.h \ - $$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.h \ - $$REPORT_PATH/items/editors/lritemsborderseditorwidget.h \ $$REPORT_PATH/lrreporttranslation.h \ $$REPORT_PATH/lrreportdesignwindowintrerface.h \ $$REPORT_PATH/lrexporterintf.h \ @@ -157,7 +165,6 @@ HEADERS += \ $$REPORT_PATH/lrpreparedpages.h \ $$REPORT_PATH/lrpreparedpagesintf.h - contains(CONFIG, staticlib){ HEADERS += $$REPORT_PATH/lrfactoryinitializer.h } From ab118549e1a912ce78bcc17e191a11521d1a81d6 Mon Sep 17 00:00:00 2001 From: Rodrigo Torres Date: Wed, 22 Jan 2020 12:05:16 -0300 Subject: [PATCH 10/23] Update .travis.yml --- .travis.yml | 102 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f879261..e708932 100644 --- a/.travis.yml +++ b/.travis.yml @@ -498,7 +498,7 @@ matrix: - make - make check - - env: Qt5.12.3_Ubuntu_18.04 + - env: Qt5.12.6_Ubuntu_18.04 os: linux dist: bionic language: cpp @@ -507,7 +507,7 @@ matrix: addons: apt: sources: - - sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic' + - sourceline: 'ppa:beineri/opt-qt-5.12.6-bionic' packages: - qt512base - qt512script @@ -521,7 +521,7 @@ matrix: - make - make check - - env: Qt5.12.3_Ubuntu_18.04 + - env: Qt5.12.6_Ubuntu_18.04 os: linux dist: bionic language: cpp @@ -530,7 +530,7 @@ matrix: addons: apt: sources: - - sourceline: 'ppa:beineri/opt-qt-5.12.3-bionic' + - sourceline: 'ppa:beineri/opt-qt-5.12.6-bionic' packages: - qt512base - qt512script @@ -542,7 +542,99 @@ matrix: - source /opt/qt512/bin/qt512-env.sh - /opt/qt512/bin/qmake -r limereport.pro - make - - make check + - make check + + - env: Qt5.13.2_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.13.2-bionic' + packages: + - qt513base + - qt513script + - qt513tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt513/bin/qt513-env.sh + - /opt/qt513/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.13.2_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.13.2-bionic' + packages: + - qt513base + - qt513script + - qt513tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt513/bin/qt513-env.sh + - /opt/qt513/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.14.0_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: gcc + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.14.0-bionic' + packages: + - qt514base + - qt514script + - qt514tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt514/bin/qt514-env.sh + - /opt/qt514/bin/qmake -r limereport.pro + - make + - make check + + - env: Qt5.14.0_Ubuntu_18.04 + os: linux + dist: bionic + language: cpp + compiler: clang + cache: ccache + addons: + apt: + sources: + - sourceline: 'ppa:beineri/opt-qt-5.14.0-bionic' + packages: + - qt514base + - qt514script + - qt514tools + - mesa-common-dev + - libgl1-mesa-dev + + script: + - source /opt/qt514/bin/qt514-env.sh + - /opt/qt514/bin/qmake -r limereport.pro + - make + - make check notifications: email: false \ No newline at end of file From 85b3c940d418841c448e0e6cff348b88d3e99a1c Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 31 Jan 2020 20:00:28 +0300 Subject: [PATCH 11/23] ChartItem: Series property editor has been added --- limereport/base/lrattribsabstractfactory.h | 6 +-- limereport/designer.pri | 2 + limereport/items/lrchartitem.cpp | 2 +- limereport/items/lrchartitem.h | 7 +-- limereport/items/lrchartitemeditor.cpp | 2 +- limereport/items/lrchartitemeditor.h | 4 ++ .../lrobjectinspectorwidget.cpp | 8 ++- .../objectinspector/lrobjectitemmodel.cpp | 10 ++-- .../propertyItems/lrimagepropitem.cpp | 4 +- .../propertyItems/lrseriespropitem.cpp | 51 +++++++++++++++++++ .../propertyItems/lrseriespropitem.h | 41 +++++++++++++++ .../propertyItems/lrstringpropitem.cpp | 2 +- 12 files changed, 121 insertions(+), 18 deletions(-) create mode 100644 limereport/objectinspector/propertyItems/lrseriespropitem.cpp create mode 100644 limereport/objectinspector/propertyItems/lrseriespropitem.h diff --git a/limereport/base/lrattribsabstractfactory.h b/limereport/base/lrattribsabstractfactory.h index d760aa5..3499253 100644 --- a/limereport/base/lrattribsabstractfactory.h +++ b/limereport/base/lrattribsabstractfactory.h @@ -54,11 +54,11 @@ private: friend class Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >; public: bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator){ - return (m_factoryMap.insert(id,creator).value()==creator)&& - (m_attribsMap.insert(id,attribs).value()==attribs); + return (m_factoryMap.insert(id,creator).value() == creator) && + (m_attribsMap.insert(id,attribs).value() == attribs); } bool unregisterCreator(const IdentifierType& id){ - return (m_factoryMap.remove(id)==1)&&(m_attribsMap.remove(id)==1); + return (m_factoryMap.remove(id) == 1) && (m_attribsMap.remove(id) == 1); } ProductCreator objectCreator(const IdentifierType& id){ if (m_factoryMap.contains(id)){ diff --git a/limereport/designer.pri b/limereport/designer.pri index 1c7e279..deef2d8 100644 --- a/limereport/designer.pri +++ b/limereport/designer.pri @@ -28,6 +28,7 @@ SOURCES += \ $$REPORT_PATH/objectinspector/propertyItems/lrgroupfieldpropitem.cpp \ $$REPORT_PATH/objectinspector/propertyItems/lrcontentpropitem.cpp \ $$REPORT_PATH/objectinspector/propertyItems/lrmarginpropitem.cpp \ + $$REPORT_PATH/objectinspector/propertyItems/lrseriespropitem.cpp \ $$REPORT_PATH/objectinspector/editors/lrtextitempropertyeditor.cpp \ $$REPORT_PATH/objectinspector/editors/lrcomboboxeditor.cpp \ $$REPORT_PATH/objectinspector/editors/lrcheckboxeditor.cpp \ @@ -71,6 +72,7 @@ HEADERS += \ $$REPORT_PATH/objectinspector/propertyItems/lrqrealpropitem.h \ $$REPORT_PATH/objectinspector/propertyItems/lrcolorpropitem.h \ $$REPORT_PATH/objectinspector/propertyItems/lrmarginpropitem.h \ + $$REPORT_PATH/objectinspector/propertyItems/lrseriespropitem.h \ $$REPORT_PATH/objectinspector/editors/lrtextitempropertyeditor.h \ $$REPORT_PATH/objectinspector/editors/lrcomboboxeditor.h \ $$REPORT_PATH/objectinspector/editors/lrcheckboxeditor.h \ diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index b80e700..5a366bb 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -251,7 +251,7 @@ QWidget *ChartItem::defaultEditor() QSettings* l_settings = (page()->settings() != 0) ? page()->settings() : (page()->reportEditor()!=0) ? page()->reportEditor()->settings() : 0; - QWidget* editor = new ChartItemEditor(this,page(),l_settings); + QWidget* editor = new ChartItemEditor(this, page(), l_settings); editor->setAttribute(Qt::WA_DeleteOnClose); return editor; } diff --git a/limereport/items/lrchartitem.h b/limereport/items/lrchartitem.h index bd1ca40..8929668 100644 --- a/limereport/items/lrchartitem.h +++ b/limereport/items/lrchartitem.h @@ -117,7 +117,7 @@ class ChartItem : public LimeReport::ItemDesignIntf Q_ENUMS(LegendAlign) Q_ENUMS(TitleAlign) Q_ENUMS(ChartType) - Q_PROPERTY(ACollectionProperty series READ fakeCollectionReader) + Q_PROPERTY(ACollectionProperty series READ fakeCollectionReader WRITE setSeries) Q_PROPERTY(QString datasource READ datasource WRITE setDatasource) Q_PROPERTY(QString chartTitle READ chartTitle WRITE setChartTitle) Q_PROPERTY(bool drawLegendBorder READ drawLegendBorder WRITE setDrawLegendBorder) @@ -163,6 +163,7 @@ public: QList labels() const; void setLabels(const QList &labels); + QWidget* defaultEditor(); protected: void paintChartTitle(QPainter* painter, QRectF titleRect); @@ -173,9 +174,9 @@ protected: QObject* elementAt(const QString& collectionName,int index); void collectionLoadFinished(const QString& collectionName){Q_UNUSED(collectionName)} void updateItemSize(DataSourceManager *dataManager, RenderPass, int); - void fillLabels(IDataSource* dataSource); - QWidget* defaultEditor(); + void fillLabels(IDataSource* dataSource); bool isNeedUpdateSize(RenderPass pass) const; + void setSeries(ACollectionProperty series){Q_UNUSED(series)} private: QList m_series; QString m_datasource; diff --git a/limereport/items/lrchartitemeditor.cpp b/limereport/items/lrchartitemeditor.cpp index f772632..92ea3fb 100644 --- a/limereport/items/lrchartitemeditor.cpp +++ b/limereport/items/lrchartitemeditor.cpp @@ -189,9 +189,9 @@ void ChartItemEditor::on_splitter_splitterMoved(int , int ) #endif } - void ChartItemEditor::on_pbOk_clicked() { + emit editingFinished(); close(); } diff --git a/limereport/items/lrchartitemeditor.h b/limereport/items/lrchartitemeditor.h index a406fc8..f24123f 100644 --- a/limereport/items/lrchartitemeditor.h +++ b/limereport/items/lrchartitemeditor.h @@ -25,6 +25,10 @@ public: protected: void resizeEvent(QResizeEvent *); void moveEvent(QMoveEvent *); + +signals: + void editingFinished(); + private slots: void on_splitter_splitterMoved(int, int); void on_pbOk_clicked(); diff --git a/limereport/objectinspector/lrobjectinspectorwidget.cpp b/limereport/objectinspector/lrobjectinspectorwidget.cpp index 3997e16..1a3be38 100644 --- a/limereport/objectinspector/lrobjectinspectorwidget.cpp +++ b/limereport/objectinspector/lrobjectinspectorwidget.cpp @@ -95,13 +95,17 @@ void ObjectInspectorTreeView::mousePressEvent(QMouseEvent *event) if ((event->button()==Qt::LeftButton)){ QModelIndex index=indexAt(event->pos()); if (index.isValid()){ - if (event->pos().x()pos().x() < indentation()) { if (!nodeFromIndex(index)->isHaveValue()) setExpanded(index,!isExpanded(index)); } else { if ((index.column()==1)&&(!nodeFromIndex(index)->isHaveChildren())) { setCurrentIndex(index); - edit(index); + + Qt::ItemFlags flags = index.model()->flags(index); + if ( !(((flags & Qt::ItemIsEditable) == 0) || ((flags & Qt::ItemIsEnabled) == 0)) ) + edit(index); + return ; } } diff --git a/limereport/objectinspector/lrobjectitemmodel.cpp b/limereport/objectinspector/lrobjectitemmodel.cpp index eb09d92..0f725db 100644 --- a/limereport/objectinspector/lrobjectitemmodel.cpp +++ b/limereport/objectinspector/lrobjectitemmodel.cpp @@ -363,14 +363,14 @@ QModelIndex QObjectPropertyModel::parent(const QModelIndex &child) const Qt::ItemFlags QObjectPropertyModel::flags(const QModelIndex &index) const { - if ((index.column()==1)&&(!nodeFromIndex(index)->isValueReadonly())) return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable; + if ((index.column() == 1) && (!nodeFromIndex(index)->isValueReadonly())) return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable; else return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } CreatePropItem QObjectPropertyModel::propertyItemCreator(QMetaProperty prop) { - CreatePropItem creator=0; - creator=ObjectPropFactory::instance().objectCreator(APropIdent(prop.name(),prop.enclosingMetaObject()->className())); + CreatePropItem creator = 0; + creator = ObjectPropFactory::instance().objectCreator(APropIdent(prop.name(),prop.enclosingMetaObject()->className())); if (!creator){ if (prop.isFlagType()){ creator=ObjectPropFactory::instance().objectCreator(APropIdent("flags","")); @@ -390,7 +390,7 @@ CreatePropItem QObjectPropertyModel::propertyItemCreator(QMetaProperty prop) return 0; } } - creator=ObjectPropFactory::instance().objectCreator(APropIdent(prop.typeName(),"")); + creator = ObjectPropFactory::instance().objectCreator(APropIdent(prop.typeName(),"")); if (!creator) {qDebug()<<"Editor for propperty name = \""<property(prop.name()), parent, - !(prop.isWritable()&&prop.isDesignable()) + !(prop.isWritable() && prop.isDesignable()) ); } else { propertyItem=new ObjectPropItem( diff --git a/limereport/objectinspector/propertyItems/lrimagepropitem.cpp b/limereport/objectinspector/propertyItems/lrimagepropitem.cpp index c6d324b..e44797d 100644 --- a/limereport/objectinspector/propertyItems/lrimagepropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrimagepropitem.cpp @@ -48,12 +48,12 @@ QWidget* ImagePropItem::createProperyEditor(QWidget *parent) const QString ImagePropItem::displayValue() const { - return (propertyValue().isNull())?"":"Picture"; + return (propertyValue().isNull()) ? "" : QObject::tr("image"); } void ImagePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const { - ImageEditor *editor =qobject_cast(propertyEditor); + ImageEditor *editor = qobject_cast(propertyEditor); editor->setImage(propertyValue().value()); } diff --git a/limereport/objectinspector/propertyItems/lrseriespropitem.cpp b/limereport/objectinspector/propertyItems/lrseriespropitem.cpp new file mode 100644 index 0000000..3e5b6eb --- /dev/null +++ b/limereport/objectinspector/propertyItems/lrseriespropitem.cpp @@ -0,0 +1,51 @@ +#include "lrseriespropitem.h" + +#include + +#include +#include +#include + +namespace{ +LimeReport::ObjectPropItem * createSeriesPropItem( + QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly) +{ + return new LimeReport::SeriesPropItem(object, objects, name, displayName, data, parent, readonly); +} +bool VARIABLE_IS_NOT_USED registredSeriesProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("series", "LimeReport::ChartItem"), QObject::tr("series"), createSeriesPropItem); +} + +namespace LimeReport { + +QWidget *SeriesPropItem::createProperyEditor(QWidget *parent) const +{ + return new SeriesPropEditor(qobject_cast(object()), parent); +} + +QString SeriesPropItem::displayValue() const +{ + return QObject::tr("Series"); +} + +SeriesPropEditor::SeriesPropEditor(ChartItem *chart, QWidget *parent) + : QWidget(parent), m_button(new QPushButton(this)), m_chart(chart) +{ + m_button->setText("..."); + QHBoxLayout* layout = new QHBoxLayout(this); + layout->addWidget(m_button); + layout->setSpacing(1); + layout->setContentsMargins(1,0,1,1); + setLayout(layout); + setFocusProxy(m_button); + setAutoFillBackground(true); + connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked())); +} + +void SeriesPropEditor::slotButtonClicked() +{ + m_chart->showEditorDialog(); + emit editingFinished(); +} + + +} diff --git a/limereport/objectinspector/propertyItems/lrseriespropitem.h b/limereport/objectinspector/propertyItems/lrseriespropitem.h new file mode 100644 index 0000000..b7cdb1e --- /dev/null +++ b/limereport/objectinspector/propertyItems/lrseriespropitem.h @@ -0,0 +1,41 @@ +#ifndef SERIESPROPITEM_H +#define SERIESPROPITEM_H + +#include +#include +#include +#include + +namespace LimeReport { + +class SeriesPropEditor : public QWidget +{ + Q_OBJECT +public: + SeriesPropEditor(ChartItem* chart, QWidget *parent = 0); +signals: + void editingFinished(); +private slots: + void slotButtonClicked(); +private: + QPushButton* m_button; + ChartItem* m_chart; +}; + +class SeriesPropItem : public LimeReport::ObjectPropItem{ + Q_OBJECT +public: + SeriesPropItem():ObjectPropItem(){} + SeriesPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly) + :ObjectPropItem(object, objects, name, displayName, value, parent, readonly){} + QWidget* createProperyEditor(QWidget *parent) const; + QString displayValue() const; +}; + +} // namespace LimeReport + + + + + +#endif // SERIESPROPITEM_H diff --git a/limereport/objectinspector/propertyItems/lrstringpropitem.cpp b/limereport/objectinspector/propertyItems/lrstringpropitem.cpp index 8c4c19a..b742c55 100644 --- a/limereport/objectinspector/propertyItems/lrstringpropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrstringpropitem.cpp @@ -54,7 +54,7 @@ QWidget * StringPropItem::createProperyEditor(QWidget *parent) const void StringPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const { - ButtonLineEditor *editor =qobject_cast(propertyEditor); + ButtonLineEditor *editor = qobject_cast(propertyEditor); editor->setText(propertyValue().toString()); } From 36a7529b7658b9bdd32caeeecb29b1904d22617a Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 31 Jan 2020 20:01:11 +0300 Subject: [PATCH 12/23] Russian translation has been updated --- translations/limereport_ru.qm | Bin 124649 -> 124735 bytes translations/limereport_ru.ts | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/translations/limereport_ru.qm b/translations/limereport_ru.qm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v< zYK<5A{bifo*zs(3Hma!OKZ|q6H0!;zms`09Ug<^yDd?X; zb+>^*w&9fCpBv=`Z)5S_r%m0<&UqtqIj`QouR8J~yXMvWjfV?g3FJzy|16+#b Series - Ряд + Ряды данных Add @@ -1952,7 +1952,7 @@ p, li { white-space: pre-wrap; } series - Ряд данных + Ряды данных titleAlign @@ -3225,5 +3225,17 @@ This preview is no longer valid. '' '' + + image + Изображение + + + series + Ряды данных + + + Series + Ряды данных + From ae65a079b010f66e87d32932ae69046d35408781 Mon Sep 17 00:00:00 2001 From: Alexander Arin Date: Sat, 1 Feb 2020 20:11:01 +0300 Subject: [PATCH 13/23] Print range has been fixed --- common.pri | 2 +- limereport/lrreportengine.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common.pri b/common.pri index 84e603c..b334f14 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 29 +LIMEREPORT_VERSION_RELEASE = 31 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 81657c5..7da7d87 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -316,18 +316,17 @@ void ReportEnginePrivate::internalPrintPages(ReportPages pages, QPrinter &printe if ( !m_cancelPrinting && ((printer.printRange() == QPrinter::AllPages) || ( (printer.printRange()==QPrinter::PageRange) && - (currenPage>=printer.fromPage()) && - (currenPage<=printer.toPage()) + (currenPage >= printer.fromPage()) && + (currenPage <= printer.toPage()) )) ) { printProcessors["default"]->printPage(page); - currenPage++; emit pagePrintingFinished(currenPage); QApplication::processEvents(); } - + currenPage++; } emit printingFinished(); } From f73055e347ad468f66de0b91eaf13c9705108fd1 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Mon, 3 Feb 2020 21:50:28 +0300 Subject: [PATCH 14/23] TOC generation has been fixed --- common.pri | 2 +- limereport/lrbasedesignintf.h | 2 +- limereport/lrdatadesignintf.cpp | 35 +++++++++++++++++++---------- limereport/lrdatadesignintf.h | 7 +++--- limereport/lrreportdesignwidget.cpp | 2 ++ limereport/lrreportdesignwindow.cpp | 2 ++ limereport/lrreportengine_p.h | 1 + limereport/lrreportrender.cpp | 10 +++++---- 8 files changed, 40 insertions(+), 21 deletions(-) diff --git a/common.pri b/common.pri index b334f14..c1f54da 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 31 +LIMEREPORT_VERSION_RELEASE = 32 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 6887ca3..597d04a 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -468,7 +468,7 @@ public: QVariant getBookMark(const QString& key); void copyBookmarks(BookmarkContainerDesignIntf* source); private: - QMap m_bookmarks; + QHash m_bookmarks; }; } //namespace LimeReport diff --git a/limereport/lrdatadesignintf.cpp b/limereport/lrdatadesignintf.cpp index 6fa78a5..eb4b564 100644 --- a/limereport/lrdatadesignintf.cpp +++ b/limereport/lrdatadesignintf.cpp @@ -719,24 +719,35 @@ QVariant CallbackDatasource::dataByKeyField(const QString& columnName, const QSt { int backupCurrentRow = m_currentRow; QVariant result = QVariant(); - first(); - if (!checkIfEmpty()){ - int currentRow = 0; - do { - QVariant key = callbackData(keyColumnName, currentRow); + + m_currentRow = m_lastKeyRow; + if (next()){ + for (int i = 0; i < 10; ++i){ + QVariant key = callbackData(keyColumnName, m_currentRow); if (key == keyData){ - result = callbackData(columnName, currentRow); - break; + result = callbackData(columnName, m_currentRow); + m_lastKeyRow = m_currentRow; + m_currentRow = backupCurrentRow; + return result; } - currentRow++; - } while (next()); + if (!next()) break; + } } first(); - if (backupCurrentRow != -1){ - for (int i = 0; i < backupCurrentRow; ++i) - next(); + if (!checkIfEmpty()){ + do { + QVariant key = callbackData(keyColumnName, m_currentRow); + if (key == keyData){ + result = callbackData(columnName, m_currentRow); + m_lastKeyRow = m_currentRow; + m_currentRow = backupCurrentRow; + return result; + } + } while (next()); } + + m_currentRow = backupCurrentRow; return result; } diff --git a/limereport/lrdatadesignintf.h b/limereport/lrdatadesignintf.h index c682fc4..867cbbb 100644 --- a/limereport/lrdatadesignintf.h +++ b/limereport/lrdatadesignintf.h @@ -410,8 +410,8 @@ private: class CallbackDatasource :public ICallbackDatasource, public IDataSource { Q_OBJECT public: - CallbackDatasource(): m_currentRow(-1), m_eof(false), m_columnCount(-1), - m_rowCount(-1), m_getDataFromCache(false){} + CallbackDatasource(): m_currentRow(-1), m_eof(false), m_columnCount(-1), + m_rowCount(-1), m_getDataFromCache(false), m_lastKeyRow(0){} bool next(); bool hasNext(){ if (!m_eof) return checkNextRecord(m_currentRow); else return false;} bool prior(); @@ -431,6 +431,7 @@ public: private: bool checkNextRecord(int recordNum); bool checkIfEmpty(); + QVariant callbackData(const QString& columnName, int row); private: QVector m_headers; int m_currentRow; @@ -439,7 +440,7 @@ private: int m_rowCount; QHash m_valuesCache; bool m_getDataFromCache; - QVariant callbackData(const QString& columnName, int row); + int m_lastKeyRow; }; class CallbackDatasourceHolder :public QObject, public IDataSourceHolder{ diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index a1e8a3b..acd6298 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -722,6 +722,7 @@ void ReportDesignWidget::initThemeIfExist(const QString &themeName, const QStrin void ReportDesignWidget::previewReport() { + if (report()->isBusy()) return; prepareReport(); #ifdef HAVE_QTDESIGNER_INTEGRATION updateDialogs(); @@ -734,6 +735,7 @@ void ReportDesignWidget::previewReport() void ReportDesignWidget::printReport() { + if (report()->isBusy()) return; prepareReport(); #ifdef HAVE_QTDESIGNER_INTEGRATION updateDialogs(); diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 5181c7b..d863ee9 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -1264,7 +1264,9 @@ void ReportDesignWindow::slotPrintReport() void ReportDesignWindow::slotPreviewReport() { + m_previewReportAction->setDisabled(true); m_reportDesignWidget->previewReport(); + m_previewReportAction->setDisabled(false); } void ReportDesignWindow::slotItemActionCliked() diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 2453b90..efb2881 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -113,6 +113,7 @@ public: virtual void cancelRender() = 0; virtual void setShowProgressDialog(bool value) = 0; virtual bool isShowProgressDialog() const = 0; + virtual bool isBusy() = 0; }; class PrintProcessor{ diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 49af8cc..0752a2e 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -261,11 +261,11 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool renderReportHeader(m_patternPageItem, AfterPageHeader); BandDesignIntf* lastRenderedBand = 0; - for (int i=0;idataBandCount() && !m_renderCanceled;i++){ + for (int i=0;idataBandCount() && !m_renderCanceled; i++){ lastRenderedBand = m_patternPageItem->dataBandAt(i); initDatasource(lastRenderedBand->datasourceName()); renderDataBand(lastRenderedBand); - if (idataBandCount()-1) closeFooterGroup(lastRenderedBand); + if (i < m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand); } if (reportFooter) @@ -475,7 +475,7 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign if (bandData){ bandClone = bandData; } else { - bandClone=renderData(patternBand); + bandClone = renderData(patternBand); } if (isLast) bandClone->setBootomSpace(1); @@ -543,8 +543,10 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign savePage(); startNewPage(); if (!bandIsSliced){ + BandDesignIntf* t = renderData(patternBand); + t->copyBookmarks(bandClone); delete bandClone; - bandClone = renderData(patternBand); + bandClone = t; } } if (!registerBand(bandClone)) { From 2ac3f7174bdff8155560fd9fb4a2f82c4184777e Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 4 Feb 2020 11:40:05 +0300 Subject: [PATCH 15/23] Memory leak has been fixed --- common.pri | 2 +- limereport/lrreportengine.cpp | 15 ++++++++------- limereport/lrreportengine_p.h | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common.pri b/common.pri index c1f54da..609d3fa 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 32 +LIMEREPORT_VERSION_RELEASE = 33 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 7da7d87..5f8f7e1 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -1254,6 +1254,11 @@ BaseDesignIntf* ReportEnginePrivate::createWatermark(PageDesignIntf* page, Water } +void ReportEnginePrivate::clearRenderingPages(){ + qDeleteAll(m_renderingPages.begin(), m_renderingPages.end()); + m_renderingPages.clear(); +} + ReportPages ReportEnginePrivate::renderToPages() { int startTOCPage = -1; @@ -1275,7 +1280,7 @@ ReportPages ReportEnginePrivate::renderToPages() m_reportRendering = true; m_reportRender->setDatasources(dataManager()); m_reportRender->setScriptContext(scriptContext()); - m_renderingPages.clear(); + clearRenderingPages(); foreach (PageDesignIntf* page, m_pages) { QVector watermarks; @@ -1349,14 +1354,10 @@ ReportPages ReportEnginePrivate::renderToPages() emit renderFinished(); m_reportRender.clear(); - - //foreach(PageItemDesignIntf* page, m_renderingPages){ - // delete page; - //} - m_renderingPages.clear(); + clearRenderingPages(); } m_reportRendering = false; - //activateLanguage(QLocale::AnyLanguage); + #ifdef USE_QTSCRIPTENGINE ScriptEngineManager::instance().scriptEngine()->popContext(); #endif diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index efb2881..d49743e 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -311,6 +311,7 @@ private: void initReport(); void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options); void dropChanges(){ m_datasources->dropChanges(); m_scriptEngineContext->dropChanges();} + void clearRenderingPages(); private: QList m_pages; QList m_renderingPages; From fa386a1b6e4fbb51746d5b1fae53b9c323685faa Mon Sep 17 00:00:00 2001 From: fralx Date: Tue, 4 Feb 2020 11:47:30 +0300 Subject: [PATCH 16/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b72e356..691c7df 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# LimeReport v1.5.16 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![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) +# LimeReport v1.5.33 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![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) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From 0b422bee3b2a9b4abcbd90454bf03de9a2bb7b4a Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 4 Feb 2020 17:16:48 +0300 Subject: [PATCH 17/23] Memory leak has been fixed --- limereport/lrscriptenginemanager.cpp | 59 ++++++++++++---------------- limereport/lrscriptenginemanager.h | 15 ++++--- 2 files changed, 33 insertions(+), 41 deletions(-) diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 91bc9bc..19d6a83 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -60,14 +60,18 @@ QScriptValue constructColor(QScriptContext *context, QScriptEngine *engine) namespace LimeReport{ +ScriptEngineNode::ScriptEngineNode(const QString &name, const QString &description, + ScriptEngineNode::NodeType type, ScriptEngineNode *parent, const QIcon &icon) + :m_name(name), m_description(description), m_icon(icon), m_type(type), m_parent(parent) +{} + ScriptEngineNode::~ScriptEngineNode() { - for (int i = 0; i it(m_functions); - while(it.hasNext()){ - if (it.next().name.compare(functionsName, Qt::CaseInsensitive)==0){ - it.remove(); - } - } + m_functions.remove(functionsName); } bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber) { + if (m_functions.contains(functionDescriber.name())) return false; ScriptValueType functionManager = scriptEngine()->globalObject().property(functionDescriber.managerName()); #ifdef USE_QJSENGINE if (functionManager.isUndefined()){ @@ -254,7 +255,7 @@ bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber) funct.description = functionDescriber.description(); funct.category = functionDescriber.category(); funct.type = ScriptFunctionDesc::Native; - m_functions.append(funct); + m_functions.insert(funct.name, funct); if (m_model) m_model->updateModel(); return true; @@ -269,15 +270,6 @@ bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber) } -bool ScriptEngineManager::containsFunction(const QString& functionName){ - foreach (ScriptFunctionDesc funct, m_functions) { - if (funct.name.compare(functionName)== 0){ - return true; - } - } - return false; -} - #ifdef USE_QTSCRIPTENGINE #if QT_VERSION > 0x050600 Q_DECL_DEPRECATED @@ -317,7 +309,7 @@ bool ScriptEngineManager::addFunction(const QString& name, const QString& script funct.category = category; funct.description = description; funct.type = ScriptFunctionDesc::Script; - m_functions.append(funct); + m_functions.insert(name, funct); m_model->updateModel(); return true; } else { @@ -328,16 +320,17 @@ bool ScriptEngineManager::addFunction(const QString& name, const QString& script QStringList ScriptEngineManager::functionsNames() { - QStringList res; - foreach(ScriptFunctionDesc func, m_functions){ - res<groupFunctionNames()){ JSFunctionDesc describer( diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 784253d..d3b47ba 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -98,14 +98,15 @@ struct ScriptFunctionDesc{ class ScriptEngineNode { public: - enum NodeType{Root,Category,Function,Dialog,DialogElement}; - ScriptEngineNode(const QString& name="", const QString& description ="", NodeType type=Root, ScriptEngineNode* parent=0, const QIcon& icon=QIcon()) - :m_name(name), m_description(description), m_icon(icon), m_type(type), m_parent(parent){} + enum NodeType{Root, Category, Function, Dialog, DialogElement}; + ScriptEngineNode(const QString& name = "", const QString& description = "", NodeType type = Root, + ScriptEngineNode* parent = 0, const QIcon& icon = QIcon()); virtual ~ScriptEngineNode(); int childCount(){return m_childs.count();} ScriptEngineNode* child(int index){return m_childs[index];} ScriptEngineNode* parent(){return m_parent;} - ScriptEngineNode* addChild(const QString& name="", const QString &description="", NodeType type=Root, const QIcon& icon=QIcon()); + ScriptEngineNode* addChild(const QString& name = "", const QString &description = "", + NodeType type = Root, const QIcon& icon = QIcon()); int row(); QString name(){return m_name;} QString description(){return m_description;} @@ -455,7 +456,7 @@ public: const QString &category="", const QString &description=""); const QString& lastError() const {return m_lastError;} QStringList functionsNames(); - const QList& functionsDescribers(){return m_functions;} + const QHash& functionsDescribers(){return m_functions;} ScriptEngineModel* model(){return m_model;} void setContext(ScriptEngineContext* context){m_context=context;} DataSourceManager* dataManager() const {return m_dataManager;} @@ -473,10 +474,8 @@ public: void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent); void clearTableOfContents(); ScriptValueType moveQObjectToScript(QObject* object, const QString objectName); - protected: void updateModel(); - bool containsFunction(const QString &functionName); private: Q_DISABLE_COPY(ScriptEngineManager) bool createLineFunction(); @@ -503,7 +502,7 @@ private: ScriptEngineManager(); ScriptEngineType* m_scriptEngine; QString m_lastError; - QList m_functions; + QHash m_functions; ScriptEngineModel* m_model; ScriptEngineContext* m_context; DataSourceManager* m_dataManager; From c350d9328ae500cb7a5cbd7f672207f3154fa273 Mon Sep 17 00:00:00 2001 From: fralx Date: Tue, 4 Feb 2020 17:26:57 +0300 Subject: [PATCH 18/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 691c7df..d8341bb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# LimeReport v1.5.33 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![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) +# LimeReport v1.5.34 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![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) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From 2cb39f1f906f23244f9ed26df3450c4878ed134b Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 5 Feb 2020 09:08:54 +0300 Subject: [PATCH 19/23] Building with qtscriptengine has been fixed --- common.pri | 2 +- limereport/lrscriptenginemanager.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common.pri b/common.pri index 609d3fa..1ab4c24 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 33 +LIMEREPORT_VERSION_RELEASE = 35 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 19d6a83..f974c51 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -279,19 +279,19 @@ bool ScriptEngineManager::addFunction(const QString& name, const QString& category, const QString& description) { - if (!containsFunction(name)){ + if (!isFunctionExists(name)){ ScriptFunctionDesc funct; funct.name = name; funct.description = description; funct.category = category; funct.scriptValue = scriptEngine()->newFunction(function); - funct.scriptValue.setProperty("functionName",name); + funct.scriptValue.setProperty("functionName", name); funct.scriptValue.setData(m_scriptEngine->toScriptValue(this)); funct.type = ScriptFunctionDesc::Native; - m_functions.append(funct); + m_functions.insert(name, funct); if (m_model) m_model->updateModel(); - m_scriptEngine->globalObject().setProperty(funct.name,funct.scriptValue); + m_scriptEngine->globalObject().setProperty(funct.name, funct.scriptValue); return true; } else { return false; From 3653ebb859dab59f6ba2000e574434773b5de58d Mon Sep 17 00:00:00 2001 From: fralx Date: Wed, 5 Feb 2020 09:12:31 +0300 Subject: [PATCH 20/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d8341bb..140ffd3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# LimeReport v1.5.34 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![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) +# LimeReport v1.5.35 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![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) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru) From cdab55a5fdd52c5b24d68fb075147760021e2da7 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sun, 16 Feb 2020 16:47:26 +0300 Subject: [PATCH 21/23] TableBuilder has been fixed --- common.pri | 2 +- limereport/lrbanddesignintf.cpp | 2 +- limereport/lrreportrender.cpp | 1 + limereport/lrscriptenginemanager.cpp | 23 ++++++++++++----------- limereport/lrscriptenginemanager.h | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/common.pri b/common.pri index 1ab4c24..0e8d673 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 35 +LIMEREPORT_VERSION_RELEASE = 36 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 8b1c341..fd5c3e8 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -1137,7 +1137,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p restoreLinks(); snapshotItemsLayout(); BandDesignIntf* patternBand = dynamic_cast(patternItem()); - if (patternBand && pass == FirstPass) emit(patternBand->preparedForRender()); + arrangeSubItems(pass, dataManager); if (autoHeight()){ if (!keepTopSpace()) { diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 0752a2e..271f1ec 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1264,6 +1264,7 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand) replaceGroupsFunction(bandClone); } + patternBand->preparedForRender(); bandClone->updateItemSize(m_datasources); //m_scriptEngineContext->baseDesignIntfToScript(bandClone); diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index f974c51..fe2e53c 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -587,8 +587,7 @@ void ScriptEngineManager::clearTableOfContents(){ } ScriptValueType ScriptEngineManager::moveQObjectToScript(QObject* object, const QString objectName) -{ - +{ ScriptValueType obj = scriptEngine()->globalObject().property(objectName); if (!obj.isNull()) delete obj.toQObject(); ScriptValueType result = scriptEngine()->newQObject(object); @@ -1934,7 +1933,7 @@ bool DatasourceFunctions::invalidate(const QString& datasourceName) return false; } -QObject* DatasourceFunctions::createTableBuilder(BaseDesignIntf* horizontalLayout) +QObject* DatasourceFunctions::createTableBuilder(QObject* horizontalLayout) { return new TableBuilder(dynamic_cast(horizontalLayout), dynamic_cast(m_dataManager)); } @@ -1987,14 +1986,16 @@ void TableBuilder::buildTable(const QString& datasourceName) { checkBaseLayout(); m_dataManager->dataSourceHolder(datasourceName)->invalidate(IDataSource::RENDER_MODE); - m_dataManager->dataSource(datasourceName)->first(); - bool firstTime = true; - QObject* row = m_horizontalLayout; - while(!m_dataManager->dataSource(datasourceName)->eof()){ - if (!firstTime) row = addRow(); - else firstTime = false; - fillInRowData(row); - m_dataManager->dataSource(datasourceName)->next(); + IDataSource* ds = m_dataManager->dataSource(datasourceName); + if (ds){ + bool firstTime = true; + QObject* row = m_horizontalLayout; + while(!ds->eof()){ + if (!firstTime) row = addRow(); + else firstTime = false; + fillInRowData(row); + ds->next(); + } } } diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index d3b47ba..7f86a33 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -338,7 +338,7 @@ public: Q_INVOKABLE bool prior(const QString& datasourceName); Q_INVOKABLE bool isEOF(const QString& datasourceName); Q_INVOKABLE bool invalidate(const QString& datasourceName); - Q_INVOKABLE QObject *createTableBuilder(BaseDesignIntf* horizontalLayout); + Q_INVOKABLE QObject *createTableBuilder(QObject *horizontalLayout); private: IDataSourceManager* m_dataManager; }; From c53f46bdb76a45612ade2ad500d524d3b292d1c7 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 18 Feb 2020 02:03:05 +0300 Subject: [PATCH 22/23] Qt4 build fixed --- common.pri | 2 +- limereport/lrreportrender.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.pri b/common.pri index 0e8d673..0c05d0a 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 36 +LIMEREPORT_VERSION_RELEASE = 37 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 271f1ec..a022f41 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1264,7 +1264,7 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand) replaceGroupsFunction(bandClone); } - patternBand->preparedForRender(); + emit(patternBand->preparedForRender()); bandClone->updateItemSize(m_datasources); //m_scriptEngineContext->baseDesignIntfToScript(bandClone); From cb15a263f0d569600a0472f243cd061e782d2e55 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 18 Feb 2020 02:16:03 +0300 Subject: [PATCH 23/23] Qt4 build fixed --- common.pri | 2 +- limereport/lrbanddesignintf.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common.pri b/common.pri index 0c05d0a..6987c1e 100644 --- a/common.pri +++ b/common.pri @@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 37 +LIMEREPORT_VERSION_RELEASE = 38 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 8984518..9a0c350 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -117,6 +117,7 @@ class BandDesignIntf : public ItemsContainerDesignInft Q_ENUMS(BandColumnsLayoutType) friend class BandMarker; friend class BandNameLabel; + friend class ReportRender; public: enum BandsType {