diff --git a/common.pri b/common.pri index 018c3f7..339bd2e 100644 --- a/common.pri +++ b/common.pri @@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 45 +LIMEREPORT_VERSION_RELEASE = 46 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 5a366bb..5d1ca0e 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -129,7 +129,8 @@ void SeriesItem::setPreferredType(const SeriesItemPreferredType& type) ChartItem::ChartItem(QObject *owner, QGraphicsItem *parent) : ItemDesignIntf(xmlTag, owner, parent), m_legendBorder(true), m_legendAlign(LegendAlignCenter), m_titleAlign(TitleAlignCenter), - m_chartType(Pie), m_labelsField("") + m_chartType(Pie), m_labelsField(""), m_isEmpty(true), + m_showLegend(true) { m_labels<<"First"<<"Second"<<"Thrid"; m_chart = new PieChart(this); @@ -176,12 +177,15 @@ void ChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, (maxTitleHeight)):0; QRectF titleRect = QRectF(borderMargin,borderMargin,rect().width()-borderMargin*2,titleOffset); - QRectF legendRect = m_chart->calcChartLegendRect(painter->font(), rect(), false, borderMargin, titleOffset); + QRectF legendRect = QRectF(0,0,0,0); + if (m_showLegend) + legendRect = m_chart->calcChartLegendRect(painter->font(), rect(), false, borderMargin, titleOffset); QRectF diagramRect = rect().adjusted(borderMargin,titleOffset+borderMargin, -(legendRect.width()+borderMargin*2),-borderMargin); paintChartTitle(painter, titleRect); - m_chart->paintChartLegend(painter,legendRect); + if (m_showLegend) + m_chart->paintChartLegend(painter,legendRect); m_chart->paintChart(painter,diagramRect); painter->restore(); @@ -224,11 +228,15 @@ QObject *ChartItem::elementAt(const QString &collectionName, int index) void ChartItem::updateItemSize(DataSourceManager *dataManager, RenderPass , int ) { + + m_isEmpty = false; if (dataManager && dataManager->dataSource(m_datasource)){ IDataSource* ds = dataManager->dataSource(m_datasource); foreach (SeriesItem* series, m_series) { - series->setLabelsColumn(m_labelsField); - series->fillSeriesData(ds); + if (series->isEmpty()){ + series->setLabelsColumn(m_labelsField); + series->fillSeriesData(ds); + } } fillLabels(ds); } @@ -258,7 +266,22 @@ QWidget *ChartItem::defaultEditor() bool ChartItem::isNeedUpdateSize(RenderPass pass) const { - return pass == FirstPass; + return pass == FirstPass && m_isEmpty; +} + +bool ChartItem::showLegend() const +{ + return m_showLegend; +} + +void ChartItem::setShowLegend(bool showLegend) +{ + if (m_showLegend != showLegend){ + m_showLegend = showLegend; + notify("showLegend", !m_showLegend, m_showLegend); + update(); + } + m_showLegend = showLegend; } QList ChartItem::labels() const diff --git a/limereport/items/lrchartitem.h b/limereport/items/lrchartitem.h index 2197b8d..3db73ca 100644 --- a/limereport/items/lrchartitem.h +++ b/limereport/items/lrchartitem.h @@ -52,6 +52,7 @@ public: void setColor(const QColor &color); SeriesItemPreferredType preferredType() const; void setPreferredType(const SeriesItemPreferredType& preferredType); + bool isEmpty(){ return m_data.values().isEmpty();} private: QString m_name; QString m_valuesColumn; @@ -127,6 +128,7 @@ class ChartItem : public LimeReport::ItemDesignIntf Q_PROPERTY(TitleAlign titleAlign READ titleAlign WRITE setTitleAlign) Q_PROPERTY(ChartType chartType READ chartType WRITE setChartType) Q_PROPERTY(QString labelsField READ labelsField WRITE setLabelsField) + Q_PROPERTY(bool showLegend READ showLegend WRITE setShowLegend) friend class AbstractChart; public: @@ -176,6 +178,9 @@ public: void setLabels(const QList &labels); QWidget* defaultEditor(); + bool showLegend() const; + void setShowLegend(bool showLegend); + protected: void paintChartTitle(QPainter* painter, QRectF titleRect); virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); @@ -200,6 +205,8 @@ private: ChartType m_chartType; QString m_labelsField; QList m_labels; + bool m_isEmpty; + bool m_showLegend; }; } //namespace LimeReport diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index d62d667..d88d7bd 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -609,6 +609,8 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) while(!bandDatasource->eof() && !m_renderCanceled){ + datasources()->updateChildrenData(dataBand->datasourceName()); + BandDesignIntf* rawData = renderData(dataBand); if (!rawData->isEmpty() || dataBand->printIfEmpty()){ @@ -624,7 +626,6 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) if (dataBand->keepFooterTogether() && !bandDatasource->hasNext()) openFooterGroup(dataBand); - datasources()->updateChildrenData(dataBand->datasourceName()); m_lastDataBand = dataBand; if (header && !firstTime && header->repeatOnEachRow())