Finish 1.5.46

This commit is contained in:
Arin Alexander 2020-04-06 19:48:25 +03:00
commit e83f739bfd
4 changed files with 39 additions and 8 deletions

View File

@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5 LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 45 LIMEREPORT_VERSION_RELEASE = 46
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -129,7 +129,8 @@ void SeriesItem::setPreferredType(const SeriesItemPreferredType& type)
ChartItem::ChartItem(QObject *owner, QGraphicsItem *parent) ChartItem::ChartItem(QObject *owner, QGraphicsItem *parent)
: ItemDesignIntf(xmlTag, owner, parent), m_legendBorder(true), : ItemDesignIntf(xmlTag, owner, parent), m_legendBorder(true),
m_legendAlign(LegendAlignCenter), m_titleAlign(TitleAlignCenter), 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_labels<<"First"<<"Second"<<"Thrid";
m_chart = new PieChart(this); m_chart = new PieChart(this);
@ -176,12 +177,15 @@ void ChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
(maxTitleHeight)):0; (maxTitleHeight)):0;
QRectF titleRect = QRectF(borderMargin,borderMargin,rect().width()-borderMargin*2,titleOffset); 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, QRectF diagramRect = rect().adjusted(borderMargin,titleOffset+borderMargin,
-(legendRect.width()+borderMargin*2),-borderMargin); -(legendRect.width()+borderMargin*2),-borderMargin);
paintChartTitle(painter, titleRect); paintChartTitle(painter, titleRect);
m_chart->paintChartLegend(painter,legendRect); if (m_showLegend)
m_chart->paintChartLegend(painter,legendRect);
m_chart->paintChart(painter,diagramRect); m_chart->paintChart(painter,diagramRect);
painter->restore(); painter->restore();
@ -224,11 +228,15 @@ QObject *ChartItem::elementAt(const QString &collectionName, int index)
void ChartItem::updateItemSize(DataSourceManager *dataManager, RenderPass , int ) void ChartItem::updateItemSize(DataSourceManager *dataManager, RenderPass , int )
{ {
m_isEmpty = false;
if (dataManager && dataManager->dataSource(m_datasource)){ if (dataManager && dataManager->dataSource(m_datasource)){
IDataSource* ds = dataManager->dataSource(m_datasource); IDataSource* ds = dataManager->dataSource(m_datasource);
foreach (SeriesItem* series, m_series) { foreach (SeriesItem* series, m_series) {
series->setLabelsColumn(m_labelsField); if (series->isEmpty()){
series->fillSeriesData(ds); series->setLabelsColumn(m_labelsField);
series->fillSeriesData(ds);
}
} }
fillLabels(ds); fillLabels(ds);
} }
@ -258,7 +266,22 @@ QWidget *ChartItem::defaultEditor()
bool ChartItem::isNeedUpdateSize(RenderPass pass) const 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<QString> ChartItem::labels() const QList<QString> ChartItem::labels() const

View File

@ -52,6 +52,7 @@ public:
void setColor(const QColor &color); void setColor(const QColor &color);
SeriesItemPreferredType preferredType() const; SeriesItemPreferredType preferredType() const;
void setPreferredType(const SeriesItemPreferredType& preferredType); void setPreferredType(const SeriesItemPreferredType& preferredType);
bool isEmpty(){ return m_data.values().isEmpty();}
private: private:
QString m_name; QString m_name;
QString m_valuesColumn; QString m_valuesColumn;
@ -127,6 +128,7 @@ class ChartItem : public LimeReport::ItemDesignIntf
Q_PROPERTY(TitleAlign titleAlign READ titleAlign WRITE setTitleAlign) Q_PROPERTY(TitleAlign titleAlign READ titleAlign WRITE setTitleAlign)
Q_PROPERTY(ChartType chartType READ chartType WRITE setChartType) Q_PROPERTY(ChartType chartType READ chartType WRITE setChartType)
Q_PROPERTY(QString labelsField READ labelsField WRITE setLabelsField) Q_PROPERTY(QString labelsField READ labelsField WRITE setLabelsField)
Q_PROPERTY(bool showLegend READ showLegend WRITE setShowLegend)
friend class AbstractChart; friend class AbstractChart;
public: public:
@ -176,6 +178,9 @@ public:
void setLabels(const QList<QString> &labels); void setLabels(const QList<QString> &labels);
QWidget* defaultEditor(); QWidget* defaultEditor();
bool showLegend() const;
void setShowLegend(bool showLegend);
protected: protected:
void paintChartTitle(QPainter* painter, QRectF titleRect); void paintChartTitle(QPainter* painter, QRectF titleRect);
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
@ -200,6 +205,8 @@ private:
ChartType m_chartType; ChartType m_chartType;
QString m_labelsField; QString m_labelsField;
QList<QString> m_labels; QList<QString> m_labels;
bool m_isEmpty;
bool m_showLegend;
}; };
} //namespace LimeReport } //namespace LimeReport

View File

@ -609,6 +609,8 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
while(!bandDatasource->eof() && !m_renderCanceled){ while(!bandDatasource->eof() && !m_renderCanceled){
datasources()->updateChildrenData(dataBand->datasourceName());
BandDesignIntf* rawData = renderData(dataBand); BandDesignIntf* rawData = renderData(dataBand);
if (!rawData->isEmpty() || dataBand->printIfEmpty()){ if (!rawData->isEmpty() || dataBand->printIfEmpty()){
@ -624,7 +626,6 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
if (dataBand->keepFooterTogether() && !bandDatasource->hasNext()) if (dataBand->keepFooterTogether() && !bandDatasource->hasNext())
openFooterGroup(dataBand); openFooterGroup(dataBand);
datasources()->updateChildrenData(dataBand->datasourceName());
m_lastDataBand = dataBand; m_lastDataBand = dataBand;
if (header && !firstTime && header->repeatOnEachRow()) if (header && !firstTime && header->repeatOnEachRow())