mirror of
https://github.com/fralx/LimeReport.git
synced 2025-11-25 08:28:06 +03:00
Define code style and format all source file using clang-format-14
except those placed in 3rdparty directories.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "lrgridlineschart.h"
|
||||
|
||||
namespace LimeReport {
|
||||
void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void GridLinesChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
@@ -10,22 +10,18 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
const qreal valuesVMargin = this->valuesVMargin(painter);
|
||||
|
||||
QRectF gridRect = chartRect.adjusted(
|
||||
hPadding,
|
||||
vPadding + valuesVMargin * 2,
|
||||
-hPadding * 3,
|
||||
-vPadding * 3
|
||||
);
|
||||
QRectF gridRect
|
||||
= chartRect.adjusted(hPadding, vPadding + valuesVMargin * 2, -hPadding * 3, -vPadding * 3);
|
||||
|
||||
if (!m_chartItem->horizontalAxisOnTop()) {
|
||||
// If horizontal axis is on the bottom, move grid a little up
|
||||
gridRect.adjust(0, -valuesVMargin, 0 , -valuesVMargin);
|
||||
gridRect.adjust(0, -valuesVMargin, 0, -valuesVMargin);
|
||||
}
|
||||
|
||||
// Adapt font for horizontal axis
|
||||
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter)) / xAxisData().segmentCount() * 0.8,
|
||||
painter->font(),
|
||||
xAxisData()));
|
||||
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter))
|
||||
/ xAxisData().segmentCount() * 0.8,
|
||||
painter->font(), xAxisData()));
|
||||
|
||||
const qreal valuesHMargin = this->valuesHMargin(painter);
|
||||
|
||||
@@ -34,23 +30,21 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
paintGrid(painter, gridRect);
|
||||
|
||||
paintSerialLines(
|
||||
painter,
|
||||
gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0)
|
||||
);
|
||||
paintSerialLines(painter, gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0));
|
||||
}
|
||||
|
||||
void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing,true);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
|
||||
if (m_chartItem->itemMode() == DesignMode){
|
||||
if (m_chartItem->itemMode() == DesignMode) {
|
||||
const qreal hStep = barsRect.width() / valuesCount();
|
||||
const qreal vStep = barsRect.height() / delta;
|
||||
const qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top();
|
||||
@@ -59,7 +53,7 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
return;
|
||||
}
|
||||
|
||||
const AxisData &xAxisData = this->xAxisData();
|
||||
const AxisData& xAxisData = this->xAxisData();
|
||||
const qreal hStep = barsRect.width() / (xAxisData.rangeMax() - xAxisData.rangeMin());
|
||||
|
||||
qreal leftMargin = 0;
|
||||
@@ -70,8 +64,8 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
pen.setWidth(m_chartItem->seriesLineWidth());
|
||||
painter->setPen(pen);
|
||||
|
||||
const QList<qreal> &xAxisValues = series->data()->xAxisValues();
|
||||
const QList<qreal> &values = series->data()->values();
|
||||
const QList<qreal>& xAxisValues = series->data()->xAxisValues();
|
||||
const QList<qreal>& values = series->data()->values();
|
||||
const int xAxisValuesSize = xAxisValues.size();
|
||||
qreal lastXPos = 0;
|
||||
qreal lastYPos = 0;
|
||||
@@ -85,16 +79,16 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
leftMargin = barsRect.left();
|
||||
lastXPos = calculatePos(xAxisData, xAxisValues.first(), barsRect.width());
|
||||
}
|
||||
for (int i = 0; i < values.count() - 1; ++i ) {
|
||||
for (int i = 0; i < values.count() - 1; ++i) {
|
||||
const qreal startY = lastYPos;
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height());
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height());
|
||||
// Record last used Y position to only calculate new one
|
||||
lastYPos = endY;
|
||||
|
||||
qreal startX = lastXPos;
|
||||
qreal endX = 0;
|
||||
if (i + 1 < xAxisValuesSize) {
|
||||
endX = calculatePos(xAxisData, xAxisValues.at(i+1), barsRect.width());
|
||||
endX = calculatePos(xAxisData, xAxisValues.at(i + 1), barsRect.width());
|
||||
} else {
|
||||
endX = startX + hStep;
|
||||
}
|
||||
@@ -109,4 +103,4 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
#include "lrlineschart.h"
|
||||
|
||||
namespace LimeReport {
|
||||
class GridLinesChart : public LinesChart{
|
||||
class GridLinesChart: public LinesChart {
|
||||
public:
|
||||
GridLinesChart(ChartItem* chartItem):LinesChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
GridLinesChart(ChartItem* chartItem): LinesChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
|
||||
private:
|
||||
void paintSerialLines(QPainter *painter, QRectF barsRect);
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // GRIDLINESCHART_H
|
||||
|
||||
@@ -1,52 +1,49 @@
|
||||
#include "lrhorizontalbarchart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void HorizontalBarChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
const qreal valuesVMargin = this->valuesVMargin(painter);
|
||||
|
||||
QRectF calcRect = verticalLabelsRect(painter, chartRect.adjusted(
|
||||
hPadding(chartRect),
|
||||
vPadding(chartRect) * 2,
|
||||
-(chartRect.width() * 0.9),
|
||||
-(vPadding(chartRect) * 2 + valuesVMargin)
|
||||
));
|
||||
QRectF calcRect = verticalLabelsRect(
|
||||
painter,
|
||||
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) * 2, -(chartRect.width() * 0.9),
|
||||
-(vPadding(chartRect) * 2 + valuesVMargin)));
|
||||
|
||||
qreal barsShift = calcRect.width();
|
||||
|
||||
paintHorizontalGrid(painter, chartRect.adjusted(
|
||||
hPadding(chartRect) + barsShift,
|
||||
vPadding(chartRect),
|
||||
-(hPadding(chartRect)),
|
||||
-vPadding(chartRect)));
|
||||
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) ));
|
||||
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)
|
||||
void HorizontalBarChart::paintHorizontalBars(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (seriesCount() == 0) return;
|
||||
if (seriesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
|
||||
const qreal verticalOffset = painter->fontMetrics().height();
|
||||
qreal vStep = (barsRect.height() - verticalOffset) / valuesCount() / seriesCount();
|
||||
qreal hStep = (barsRect.width()-painter->fontMetrics().boundingRect(QString::number(maxValue())).width()) / delta;
|
||||
qreal hStep = (barsRect.width()
|
||||
- painter->fontMetrics().boundingRect(QString::number(maxValue())).width())
|
||||
/ delta;
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)) {
|
||||
qreal curVOffset = barsRect.top();
|
||||
if (m_chartItem->horizontalAxisOnTop()) {
|
||||
curVOffset += verticalOffset;
|
||||
@@ -55,8 +52,9 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
painter->setBrush(series->color());
|
||||
qreal y = curVOffset;
|
||||
foreach (qreal value, series->data()->values()) {
|
||||
painter->drawRect(QRectF((-minValue()*hStep)+barsRect.left(), y, value*hStep, vStep));
|
||||
y+=vStep*seriesCount();
|
||||
painter->drawRect(
|
||||
QRectF((-minValue() * hStep) + barsRect.left(), y, value * hStep, vStep));
|
||||
y += vStep * seriesCount();
|
||||
}
|
||||
curVOffset += vStep;
|
||||
}
|
||||
@@ -66,15 +64,17 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
curVOffset += verticalOffset;
|
||||
}
|
||||
int curColor = 0;
|
||||
for (int i=0; i<9; ++i){
|
||||
if (curColor==3) 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;
|
||||
painter->drawRect(
|
||||
QRectF(barsRect.left(), curVOffset, designValues()[i] * hStep, vStep));
|
||||
curVOffset += vStep;
|
||||
curColor++;
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class HorizontalBarChart: public AbstractBarChart{
|
||||
class HorizontalBarChart: public AbstractBarChart {
|
||||
public:
|
||||
HorizontalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
void paintHorizontalBars(QPainter *painter, QRectF barsRect);
|
||||
HorizontalBarChart(ChartItem* chartItem): AbstractBarChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
void paintHorizontalBars(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void LinesChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
@@ -11,64 +11,47 @@ void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
QRectF calcRect = horizontalLabelsRect(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect)*2),
|
||||
-(hPadding(chartRect) * 2),
|
||||
-vPadding(chartRect)
|
||||
)
|
||||
);
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
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,
|
||||
-hPadding(chartRect),
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintSerialLines(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-(hPadding(chartRect) * 2),
|
||||
-(vPadding(chartRect)+barsShift)
|
||||
)
|
||||
);
|
||||
paintVerticalGrid(painter,
|
||||
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
|
||||
paintSerialLines(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-(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
|
||||
);
|
||||
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
|
||||
);
|
||||
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
|
||||
);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize) const
|
||||
qreal LinesChart::calculatePos(const AxisData& data, qreal value, qreal rectSize) const
|
||||
{
|
||||
if (data.type() == AxisData::XAxis || (data.reverseDirection() && data.rangeMin() >= 0)) {
|
||||
// Not flipping for minimum less than 0 because lower number is at the bottom.
|
||||
@@ -78,10 +61,10 @@ qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize
|
||||
}
|
||||
}
|
||||
|
||||
void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect)
|
||||
void LinesChart::paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect)
|
||||
{
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData &xAxisData = this->xAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const AxisData& xAxisData = this->xAxisData();
|
||||
|
||||
const qreal xAxisDiff = std::max(1.0, xAxisData.maxValue() - xAxisData.minValue());
|
||||
const qreal hStep = barsRect.width() / xAxisDiff;
|
||||
@@ -91,17 +74,17 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
|
||||
pen.setWidth(4);
|
||||
painter->setPen(pen);
|
||||
|
||||
const QList<qreal> &values = series->data()->values();
|
||||
const QList<qreal>& values = series->data()->values();
|
||||
|
||||
qreal lastYValue = 0;
|
||||
qreal lastXValue = barsRect.left() + hStep/2;
|
||||
qreal lastXValue = barsRect.left() + hStep / 2;
|
||||
if (!values.isEmpty()) {
|
||||
// Calculate first point position on plot before loop
|
||||
lastYValue = calculatePos(yAxisData, values.first(), barsRect.height());
|
||||
}
|
||||
for (int i = 0; i < values.count()-1; ++i ){
|
||||
for (int i = 0; i < values.count() - 1; ++i) {
|
||||
const qreal startY = lastYValue;
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height());
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height());
|
||||
// Record last used Y position to only calculate new one
|
||||
lastYValue = endY;
|
||||
|
||||
@@ -118,13 +101,14 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
|
||||
|
||||
void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing,true);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
if (m_chartItem->itemMode() == DesignMode){
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
if (m_chartItem->itemMode() == DesignMode) {
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
const qreal hStep = barsRect.width() / valuesCount();
|
||||
const qreal vStep = barsRect.height() / delta;
|
||||
@@ -134,12 +118,11 @@ void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
return;
|
||||
}
|
||||
|
||||
for (SeriesItem *series : m_chartItem->series()) {
|
||||
for (SeriesItem* series : m_chartItem->series()) {
|
||||
paintSeries(painter, series, barsRect);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -4,18 +4,20 @@
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace LimeReport {
|
||||
class LinesChart: public AbstractBarChart{
|
||||
class LinesChart: public AbstractBarChart {
|
||||
public:
|
||||
LinesChart(ChartItem* chartItem):AbstractBarChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
LinesChart(ChartItem* chartItem): AbstractBarChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
|
||||
protected:
|
||||
void drawDesignMode(QPainter *painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect);
|
||||
qreal calculatePos(const AxisData &data, qreal value, qreal rectSize) const;
|
||||
void paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect);
|
||||
void drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift,
|
||||
QRectF barsRect);
|
||||
qreal calculatePos(const AxisData& data, qreal value, qreal rectSize) const;
|
||||
void paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect);
|
||||
|
||||
private:
|
||||
void paintSerialLines(QPainter *painter, QRectF barsRect);
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LINESCHART_H
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
#include "lrpiechart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle)
|
||||
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;
|
||||
QPointF center(chartRect.left() + chartRect.width() / 2,
|
||||
chartRect.top() + chartRect.height() / 2);
|
||||
qreal percent = angle / 3.6;
|
||||
#if QT_VERSION < 0x050000
|
||||
qreal radAngle = (angle/2+startAngle)*(M_PI/180);
|
||||
qreal radAngle = (angle / 2 + startAngle) * (M_PI / 180);
|
||||
#else
|
||||
qreal radAngle = qDegreesToRadians(angle/2+startAngle);
|
||||
qreal radAngle = qDegreesToRadians(angle / 2 + startAngle);
|
||||
#endif
|
||||
qreal radius = painter->fontMetrics().boundingRect("99,9%").width();
|
||||
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);
|
||||
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);
|
||||
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->drawText(textRect, Qt::AlignCenter, QString::number(percent, 'f', 1) + "%");
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void PieChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
painter->save();
|
||||
QPen pen(Qt::white);
|
||||
@@ -42,10 +42,10 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
painter->setBackground(QBrush(Qt::NoBrush));
|
||||
|
||||
QRectF tmpRect = chartRect;
|
||||
if (chartRect.height()>chartRect.width()){
|
||||
if (chartRect.height() > chartRect.width()) {
|
||||
tmpRect.setHeight(chartRect.width());
|
||||
tmpRect.adjust(0,(chartRect.bottom()-tmpRect.bottom())/2,
|
||||
0,(chartRect.bottom()-tmpRect.bottom())/2);
|
||||
tmpRect.adjust(0, (chartRect.bottom() - tmpRect.bottom()) / 2, 0,
|
||||
(chartRect.bottom() - tmpRect.bottom()) / 2);
|
||||
} else {
|
||||
tmpRect.setWidth(chartRect.height());
|
||||
}
|
||||
@@ -53,31 +53,32 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
chartRect = tmpRect;
|
||||
painter->drawRect(chartRect);
|
||||
|
||||
if (!m_chartItem->series().isEmpty()&&!m_chartItem->series().at(0)->data()->values().isEmpty()){
|
||||
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;
|
||||
foreach (qreal value, si->data()->values()) {
|
||||
sum += value;
|
||||
}
|
||||
qreal onePercent = sum / 100;
|
||||
qreal currentDegree = 0;
|
||||
for(int i=0; i<si->data()->values().count(); ++i){
|
||||
for (int i = 0; i < si->data()->values().count(); ++i) {
|
||||
qreal value = si->data()->values().at(i);
|
||||
qreal sectorDegree = (value/onePercent)*3.6;
|
||||
qreal sectorDegree = (value / onePercent) * 3.6;
|
||||
painter->setBrush(si->data()->colors().at(i));
|
||||
painter->drawPie(chartRect,currentDegree*16,sectorDegree*16);
|
||||
painter->drawPie(chartRect, currentDegree * 16, sectorDegree * 16);
|
||||
drawPercent(painter, chartRect, currentDegree, sectorDegree);
|
||||
currentDegree += sectorDegree;
|
||||
}
|
||||
} else if (m_chartItem->itemMode() == DesignMode){
|
||||
} else if (m_chartItem->itemMode() == DesignMode) {
|
||||
painter->setBrush(color_map[0]);
|
||||
painter->drawPie(chartRect,0,260*16);
|
||||
painter->drawPie(chartRect, 0, 260 * 16);
|
||||
drawPercent(painter, chartRect, 0, 260);
|
||||
painter->setBrush(color_map[1]);
|
||||
painter->drawPie(chartRect,260*16,40*16);
|
||||
painter->drawPie(chartRect, 260 * 16, 40 * 16);
|
||||
drawPercent(painter, chartRect, 260, 40);
|
||||
painter->setBrush(color_map[2]);
|
||||
painter->drawPie(chartRect,300*16,60*16);
|
||||
painter->drawPie(chartRect, 300 * 16, 60 * 16);
|
||||
drawPercent(painter, chartRect, 300, 60);
|
||||
}
|
||||
|
||||
@@ -89,83 +90,77 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
|
||||
void PieChart::paintChartLegend(QPainter* painter, QRectF legendRect)
|
||||
{
|
||||
prepareLegendToPaint(legendRect, painter);
|
||||
|
||||
int indicatorSize = painter->fontMetrics().height()/2;
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
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);
|
||||
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()){
|
||||
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;i<si->data()->labels().count();++i){
|
||||
for (int i = 0; i < si->data()->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->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))
|
||||
)
|
||||
);
|
||||
painter->drawEllipse(indicatorsRect.adjusted(
|
||||
0, cw + indicatorSize / 2, -(indicatorsRect.width() - indicatorSize),
|
||||
-(indicatorsRect.height() - (cw + indicatorSize + indicatorSize / 2))));
|
||||
cw += painter->fontMetrics().height();
|
||||
}
|
||||
} else if (m_chartItem->itemMode() == DesignMode){
|
||||
} else if (m_chartItem->itemMode() == DesignMode) {
|
||||
qreal cw = 0;
|
||||
for (int i=0;i<m_designLabels.size();++i){
|
||||
for (int i = 0; i < m_designLabels.size(); ++i) {
|
||||
QString label = m_designLabels.at(i);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label);
|
||||
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))
|
||||
)
|
||||
);
|
||||
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, qreal)
|
||||
QSizeF PieChart::calcChartLegendSize(const QFont& font, qreal)
|
||||
{
|
||||
QFontMetrics fm(font);
|
||||
|
||||
qreal cw = 0;
|
||||
qreal maxWidth = 0;
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){
|
||||
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()){
|
||||
foreach (QString label, si->data()->labels()) {
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
if (maxWidth < fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width() + 10;
|
||||
}
|
||||
} else {
|
||||
foreach(QString label, m_designLabels){
|
||||
foreach (QString label, m_designLabels) {
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
if (maxWidth < fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width() + 10;
|
||||
}
|
||||
}
|
||||
cw += fm.height();
|
||||
return QSizeF(maxWidth+fm.height()*2,cw);
|
||||
return QSizeF(maxWidth + fm.height() * 2, cw);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -3,16 +3,17 @@
|
||||
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class PieChart : public AbstractChart{
|
||||
class PieChart: public AbstractChart {
|
||||
public:
|
||||
PieChart(ChartItem* chartItem):AbstractChart(chartItem){}
|
||||
QSizeF calcChartLegendSize(const QFont &font, qreal maxWidth = 0);
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
void paintChartLegend(QPainter *painter, QRectF legendRect);
|
||||
PieChart(ChartItem* chartItem): AbstractChart(chartItem) { }
|
||||
QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0);
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
void paintChartLegend(QPainter* painter, QRectF legendRect);
|
||||
|
||||
protected:
|
||||
void drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle);
|
||||
void drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "lrverticalbarchart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void VerticalBarChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
@@ -11,74 +11,61 @@ void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
QRectF calcRect = horizontalLabelsRect(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect) * 2),
|
||||
-(hPadding(chartRect) * 2),
|
||||
-vPadding(chartRect)
|
||||
)
|
||||
);
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
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,
|
||||
-hPadding(chartRect),
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintVerticalBars(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect) * 2,
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintSerialLines(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect) * 2,
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintVerticalGrid(painter,
|
||||
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
|
||||
paintVerticalBars(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect) * 2,
|
||||
-(vPadding(chartRect) + barsShift)));
|
||||
paintSerialLines(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect) * 2,
|
||||
-(vPadding(chartRect) + barsShift)));
|
||||
paintHorizontalLabels(painter, calcRect);
|
||||
}
|
||||
|
||||
void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
void VerticalBarChart::paintVerticalBars(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
|
||||
int barSeriesCount = 0;
|
||||
foreach(SeriesItem* series, m_chartItem->series()){
|
||||
if (series->preferredType() == SeriesItem::Bar) barSeriesCount++;
|
||||
foreach (SeriesItem* series, m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Bar)
|
||||
barSeriesCount++;
|
||||
}
|
||||
|
||||
barSeriesCount = (m_chartItem->itemMode() == DesignMode) ? seriesCount() : barSeriesCount;
|
||||
if (barSeriesCount < 1) return;
|
||||
if (barSeriesCount < 1)
|
||||
return;
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
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)){
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)) {
|
||||
int curSeries = 0;
|
||||
foreach (SeriesItem* series, m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Bar){
|
||||
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));
|
||||
painter->drawRect(
|
||||
QRectF(curHOffset, maxValue() * vStep + topShift, hStep, -value * vStep));
|
||||
curHOffset += hStep * barSeriesCount;
|
||||
}
|
||||
curSeries++;
|
||||
@@ -87,10 +74,12 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
} else {
|
||||
qreal curHOffset = barsRect.left();
|
||||
int curColor = 0;
|
||||
for (int i = 0; i < 9; ++i){
|
||||
if (curColor == 3) 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));
|
||||
painter->drawRect(QRectF(curHOffset, maxValue() * vStep + barsRect.top(), hStep,
|
||||
-designValues()[i] * vStep));
|
||||
curHOffset += hStep;
|
||||
curColor++;
|
||||
}
|
||||
@@ -100,13 +89,14 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
|
||||
void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (valuesCount() == 0 || m_chartItem->series().isEmpty() ) return;
|
||||
if (valuesCount() == 0 || m_chartItem->series().isEmpty())
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing,true);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
for (SeriesItem *series : m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Line){
|
||||
for (SeriesItem* series : m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Line) {
|
||||
paintSeries(painter, series, barsRect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
|
||||
#include "lrlineschart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class VerticalBarChart: public LinesChart{
|
||||
class VerticalBarChart: public LinesChart {
|
||||
public:
|
||||
VerticalBarChart(ChartItem* chartItem):LinesChart(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);
|
||||
VerticalBarChart(ChartItem* chartItem): LinesChart(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
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // VERTICALBARCHART_H
|
||||
|
||||
@@ -29,10 +29,11 @@
|
||||
****************************************************************************/
|
||||
#include "lrfonteditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent)
|
||||
:ItemEditorWidget(title, parent), m_ignoreSlots(false)
|
||||
FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_ignoreSlots(false)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
@@ -40,91 +41,107 @@ FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent)
|
||||
void FontEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
{
|
||||
|
||||
QVariant font=item->property("font");
|
||||
if (font.isValid()){
|
||||
QVariant font = item->property("font");
|
||||
if (font.isValid()) {
|
||||
updateValues(font.value<QFont>());
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FontEditorWidget::initEditor()
|
||||
{
|
||||
setIconSize(QSize(24,24));
|
||||
setIconSize(QSize(24, 24));
|
||||
setAllowedAreas(Qt::TopToolBarArea);
|
||||
setFloatable(false);
|
||||
|
||||
m_fontNameEditor = new QFontComboBox(this);
|
||||
m_fontNameEditor->setFontFilters(QFontComboBox::AllFonts);
|
||||
connect(m_fontNameEditor,SIGNAL(currentFontChanged(QFont)),this,SLOT(slotFontChanged(QFont)));
|
||||
connect(m_fontNameEditor, SIGNAL(currentFontChanged(QFont)), this,
|
||||
SLOT(slotFontChanged(QFont)));
|
||||
addWidget(m_fontNameEditor);
|
||||
|
||||
m_fontSizeModel.setStringList(QStringList()<<"6"<<"7"<<"8"<<"9"<<"10"<<"11"<<"12"<<"14"<<"16"<<"18"<<"20"<<"24"<<"28"<<"30"<<"36"<<"48"<<"64"<<"72");
|
||||
m_fontSizeModel.setStringList(QStringList() << "6"
|
||||
<< "7"
|
||||
<< "8"
|
||||
<< "9"
|
||||
<< "10"
|
||||
<< "11"
|
||||
<< "12"
|
||||
<< "14"
|
||||
<< "16"
|
||||
<< "18"
|
||||
<< "20"
|
||||
<< "24"
|
||||
<< "28"
|
||||
<< "30"
|
||||
<< "36"
|
||||
<< "48"
|
||||
<< "64"
|
||||
<< "72");
|
||||
m_fontSizeEditor = new QComboBox(this);
|
||||
m_fontSizeEditor->setModel(&m_fontSizeModel);
|
||||
m_fontSizeEditor->setEditable(true);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_fontSizeEditor,SIGNAL(currentTextChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
connect(m_fontSizeEditor, SIGNAL(currentTextChanged(QString)), this,
|
||||
SLOT(slotFontSizeChanged(QString)));
|
||||
#else
|
||||
connect(m_fontSizeEditor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
connect(m_fontSizeEditor, SIGNAL(currentIndexChanged(QString)), this,
|
||||
SLOT(slotFontSizeChanged(QString)));
|
||||
#endif
|
||||
addWidget(m_fontSizeEditor);
|
||||
|
||||
addSeparator();
|
||||
setEnabled(false);
|
||||
|
||||
m_fontBold = new QAction(tr("Font bold"),this);
|
||||
m_fontBold = new QAction(tr("Font bold"), this);
|
||||
m_fontBold->setIcon(QIcon(":/report/images/textBold"));
|
||||
m_fontBold->setCheckable(true);
|
||||
connect(m_fontBold,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool)));
|
||||
connect(m_fontBold, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontBold);
|
||||
|
||||
m_fontItalic = new QAction(tr("Font Italic"),this);
|
||||
m_fontItalic = new QAction(tr("Font Italic"), this);
|
||||
m_fontItalic->setIcon(QIcon(":/report/images/textItalic"));
|
||||
m_fontItalic->setCheckable(true);
|
||||
connect(m_fontItalic,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool)));
|
||||
connect(m_fontItalic, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontItalic);
|
||||
|
||||
m_fontUnderline = new QAction(tr("Font Underline"),this);
|
||||
m_fontUnderline = new QAction(tr("Font Underline"), this);
|
||||
m_fontUnderline->setIcon(QIcon(":/report/images/textUnderline"));
|
||||
m_fontUnderline->setCheckable(true);
|
||||
connect(m_fontUnderline,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool)));
|
||||
connect(m_fontUnderline, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontUnderline);
|
||||
|
||||
}
|
||||
|
||||
void FontEditorWidget::updateValues(const QFont& font)
|
||||
{
|
||||
m_ignoreSlots=true;
|
||||
m_ignoreSlots = true;
|
||||
m_fontNameEditor->setCurrentFont(font);
|
||||
m_fontSizeEditor->setEditText(QString::number(font.pointSize()));
|
||||
m_fontBold->setChecked(font.bold());
|
||||
m_fontItalic->setChecked(font.italic());
|
||||
m_fontUnderline->setChecked(font.underline());
|
||||
m_ignoreSlots=false;
|
||||
}
|
||||
|
||||
bool FontEditorWidget::ignoreSlots() const
|
||||
{
|
||||
return m_ignoreSlots;
|
||||
m_ignoreSlots = false;
|
||||
}
|
||||
|
||||
bool FontEditorWidget::ignoreSlots() const { return m_ignoreSlots; }
|
||||
|
||||
void FontEditorWidget::slotFontChanged(const QFont& /*font*/)
|
||||
{
|
||||
//if (page()) page()->setFont(font);
|
||||
// if (page()) page()->setFont(font);
|
||||
}
|
||||
|
||||
void FontEditorWidget::slotFontSizeChanged(const QString &value)
|
||||
void FontEditorWidget::slotFontSizeChanged(const QString& value)
|
||||
{
|
||||
if (m_ignoreSlots) return;
|
||||
if (m_ignoreSlots)
|
||||
return;
|
||||
m_resFont = fontNameEditor()->currentFont();
|
||||
m_resFont.setPointSize(value.toInt());
|
||||
}
|
||||
|
||||
void FontEditorWidget::slotFontAttribsChanged(bool)
|
||||
{
|
||||
if (m_ignoreSlots) return;
|
||||
if (m_ignoreSlots)
|
||||
return;
|
||||
m_resFont = m_fontNameEditor->currentFont();
|
||||
m_resFont.setPointSize(m_fontSizeEditor->currentText().toInt());
|
||||
m_resFont.setBold(m_fontBold->isChecked());
|
||||
@@ -132,16 +149,16 @@ void FontEditorWidget::slotFontAttribsChanged(bool)
|
||||
m_resFont.setUnderline(m_fontUnderline->isChecked());
|
||||
}
|
||||
|
||||
void FontEditorWidget::slotPropertyChanged(const QString &objectName, const QString &property, const QVariant& oldValue, const QVariant& newValue)
|
||||
void FontEditorWidget::slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
Q_UNUSED(newValue)
|
||||
if (item()&&(item()->objectName()==objectName)&&(property=="font")){
|
||||
if (item() && (item()->objectName() == objectName) && (property == "font")) {
|
||||
updateValues(item()->property("font").value<QFont>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FontEditorWidgetForPage::slotFontChanged(const QFont& font)
|
||||
{
|
||||
if (!ignoreSlots())
|
||||
@@ -150,7 +167,7 @@ void FontEditorWidgetForPage::slotFontChanged(const QFont& font)
|
||||
|
||||
void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontSizeChanged(value);
|
||||
m_page->setFont(resFont());
|
||||
}
|
||||
@@ -158,7 +175,7 @@ void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value)
|
||||
|
||||
void FontEditorWidgetForPage::slotFontAttribsChanged(bool value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontAttribsChanged(value);
|
||||
m_page->setFont(resFont());
|
||||
}
|
||||
@@ -167,18 +184,19 @@ void FontEditorWidgetForPage::slotFontAttribsChanged(bool value)
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
void FontEditorWidgetForDesigner::initEditor()
|
||||
{
|
||||
connect(m_reportEditor,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant)));
|
||||
connect(m_reportEditor, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
|
||||
}
|
||||
|
||||
void FontEditorWidgetForDesigner::slotFontChanged(const QFont& font)
|
||||
{
|
||||
if (!ignoreSlots()) m_reportEditor->setFont(font);
|
||||
if (!ignoreSlots())
|
||||
m_reportEditor->setFont(font);
|
||||
}
|
||||
|
||||
void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontSizeChanged(value);
|
||||
m_reportEditor->setFont(resFont());
|
||||
}
|
||||
@@ -186,7 +204,7 @@ void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value)
|
||||
|
||||
void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontAttribsChanged(value);
|
||||
m_reportEditor->setFont(resFont());
|
||||
}
|
||||
@@ -194,5 +212,4 @@ void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#ifndef LRFONTEDITORWIDGET_H
|
||||
#define LRFONTEDITORWIDGET_H
|
||||
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QFontComboBox>
|
||||
#include <QStringListModel>
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
#include "lrreportdesignwidget.h"
|
||||
@@ -41,27 +41,30 @@
|
||||
|
||||
#include "lritemeditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class FontEditorWidget :public ItemEditorWidget{
|
||||
class FontEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditorWidget(const QString &title, QWidget *parent = 0);
|
||||
explicit FontEditorWidget(const QString& title, QWidget* parent = 0);
|
||||
bool ignoreSlots() const;
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf *item);
|
||||
QFontComboBox* fontNameEditor(){return m_fontNameEditor;}
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
QFontComboBox* fontNameEditor() { return m_fontNameEditor; }
|
||||
void initEditor();
|
||||
protected slots:
|
||||
virtual void slotFontChanged(const QFont&);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool);
|
||||
void slotPropertyChanged(const QString& objectName, const QString& property, const QVariant &oldValue, const QVariant &newValue);
|
||||
protected:
|
||||
QFont resFont(){return m_resFont;}
|
||||
private:
|
||||
void slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
void updateValues(const QFont &font);
|
||||
protected:
|
||||
QFont resFont() { return m_resFont; }
|
||||
|
||||
private:
|
||||
void updateValues(const QFont& font);
|
||||
|
||||
QFontComboBox* m_fontNameEditor;
|
||||
QComboBox* m_fontSizeEditor;
|
||||
@@ -73,28 +76,37 @@ private:
|
||||
|
||||
bool m_ignoreSlots;
|
||||
QFont m_resFont;
|
||||
|
||||
};
|
||||
|
||||
class FontEditorWidgetForPage : public FontEditorWidget{
|
||||
class FontEditorWidgetForPage: public FontEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditorWidgetForPage(PageDesignIntf* page, const QString &title, QWidget *parent = 0)
|
||||
: FontEditorWidget(title, parent), m_page(page){}
|
||||
explicit FontEditorWidgetForPage(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
FontEditorWidget(title, parent),
|
||||
m_page(page)
|
||||
{
|
||||
}
|
||||
protected slots:
|
||||
virtual void slotFontChanged(const QFont& font);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
PageDesignIntf* m_page;
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class FontEditorWidgetForDesigner : public FontEditorWidget{
|
||||
class FontEditorWidgetForDesigner: public FontEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0)
|
||||
: FontEditorWidget(title, parent), m_reportEditor(reportEditor){initEditor();}
|
||||
explicit FontEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
FontEditorWidget(title, parent),
|
||||
m_reportEditor(reportEditor)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
protected:
|
||||
void initEditor();
|
||||
@@ -102,11 +114,12 @@ protected slots:
|
||||
virtual void slotFontChanged(const QFont& font);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
};
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRFONTEDITORWIDGET_H
|
||||
|
||||
@@ -29,22 +29,24 @@
|
||||
****************************************************************************/
|
||||
#include "lritemeditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void ItemEditorWidget::setItem(BaseDesignIntf* item)
|
||||
{
|
||||
if (m_item!=item){
|
||||
if (m_item) m_item->disconnect(this);
|
||||
m_item=item;
|
||||
connect(m_item,SIGNAL(destroyed(QObject*)),this,SLOT(slotItemDestroyed(QObject*)));
|
||||
connect(m_item,SIGNAL(propertyChanged(QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QVariant,QVariant)));
|
||||
if (m_item != item) {
|
||||
if (m_item)
|
||||
m_item->disconnect(this);
|
||||
m_item = item;
|
||||
connect(m_item, SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDestroyed(QObject*)));
|
||||
connect(m_item, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QVariant, QVariant)));
|
||||
setEnabled(false);
|
||||
setItemEvent(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVariant& oldValue, const QVariant& newValue)
|
||||
void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(propertName)
|
||||
Q_UNUSED(oldValue)
|
||||
@@ -53,19 +55,16 @@ void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVa
|
||||
|
||||
void ItemEditorWidget::slotItemDestroyed(QObject* item)
|
||||
{
|
||||
if (item==m_item) {
|
||||
if (item == m_item) {
|
||||
m_item = 0;
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue, const QVariant& newValue)
|
||||
void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
properyChangedEvent(propertName,oldValue,newValue);
|
||||
properyChangedEvent(propertName, oldValue, newValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -39,20 +39,26 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ItemEditorWidget : public QToolBar
|
||||
{
|
||||
class ItemEditorWidget: public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemEditorWidget(const QString &title, QWidget *parent = 0)
|
||||
: QToolBar(title, parent), m_item(0){}
|
||||
void setItem(BaseDesignIntf *item);
|
||||
explicit ItemEditorWidget(const QString& title, QWidget* parent = 0):
|
||||
QToolBar(title, parent),
|
||||
m_item(0)
|
||||
{
|
||||
}
|
||||
void setItem(BaseDesignIntf* item);
|
||||
|
||||
protected:
|
||||
virtual void setItemEvent(BaseDesignIntf*){}
|
||||
virtual void properyChangedEvent(const QString& propertName, const QVariant& oldValue, const QVariant& newValue);
|
||||
BaseDesignIntf* item(){return m_item;}
|
||||
virtual void setItemEvent(BaseDesignIntf*) { }
|
||||
virtual void properyChangedEvent(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
BaseDesignIntf* item() { return m_item; }
|
||||
private slots:
|
||||
void slotItemDestroyed(QObject* item);
|
||||
void slotPropertyChanged(const QString& propertName, const QVariant& oldValue, const QVariant& newValue);
|
||||
void slotPropertyChanged(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* m_item;
|
||||
};
|
||||
|
||||
@@ -29,143 +29,174 @@
|
||||
****************************************************************************/
|
||||
#include "lritemsaligneditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(LimeReport::ReportDesignWidget* reportEditor, const QString& title, QWidget* parent)
|
||||
:QToolBar(title,parent), m_reportEditor(reportEditor), m_page(0)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(LimeReport::ReportDesignWidget* reportEditor,
|
||||
const QString& title, QWidget* parent):
|
||||
QToolBar(title, parent),
|
||||
m_reportEditor(reportEditor),
|
||||
m_page(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent)
|
||||
:QToolBar(parent), m_reportEditor(reportEditor), m_page(0)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor,
|
||||
QWidget* parent):
|
||||
QToolBar(parent),
|
||||
m_reportEditor(reportEditor),
|
||||
m_page(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title, QWidget* parent)
|
||||
:QToolBar(title,parent), m_reportEditor(0), m_page(page)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent):
|
||||
QToolBar(title, parent),
|
||||
m_reportEditor(0),
|
||||
m_page(page)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent)
|
||||
:QToolBar(parent), m_reportEditor(0), m_page(page)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent):
|
||||
QToolBar(parent),
|
||||
m_reportEditor(0),
|
||||
m_page(page)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotBringToFront()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->bringToFront();
|
||||
if (m_page) m_page->bringToFront();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->bringToFront();
|
||||
if (m_page)
|
||||
m_page->bringToFront();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotSendToBack()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->sendToBack();
|
||||
if (m_page) m_page->sendToBack();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->sendToBack();
|
||||
if (m_page)
|
||||
m_page->sendToBack();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToLeft()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToLeft();
|
||||
if (m_page) m_page->alignToLeft();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToLeft();
|
||||
if (m_page)
|
||||
m_page->alignToLeft();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToRight()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToRight();
|
||||
if (m_page) m_page->alignToRigth();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToRight();
|
||||
if (m_page)
|
||||
m_page->alignToRigth();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToVCenter()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToVCenter();
|
||||
if (m_page) m_page->alignToVCenter();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToVCenter();
|
||||
if (m_page)
|
||||
m_page->alignToVCenter();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToTop()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToTop();
|
||||
if (m_page) m_page->alignToTop();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToTop();
|
||||
if (m_page)
|
||||
m_page->alignToTop();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToBottom()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToBottom();
|
||||
if (m_page) m_page->alignToBottom();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToBottom();
|
||||
if (m_page)
|
||||
m_page->alignToBottom();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToHCenter()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToHCenter();
|
||||
if (m_page) m_page->alignToHCenter();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToHCenter();
|
||||
if (m_page)
|
||||
m_page->alignToHCenter();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotSameHeight()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->sameHeight();
|
||||
if (m_page) m_page->sameHeight();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->sameHeight();
|
||||
if (m_page)
|
||||
m_page->sameHeight();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotSameWidth()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->sameWidth();
|
||||
if (m_page) m_page->sameWidth();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->sameWidth();
|
||||
if (m_page)
|
||||
m_page->sameWidth();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::initEditor()
|
||||
{
|
||||
m_bringToFront = new QAction(tr("Bring to top"),this);
|
||||
m_bringToFront = new QAction(tr("Bring to top"), this);
|
||||
m_bringToFront->setIcon(QIcon(":/report/images/bringToTop"));
|
||||
connect(m_bringToFront,SIGNAL(triggered()),this,SLOT(slotBringToFront()));
|
||||
connect(m_bringToFront, SIGNAL(triggered()), this, SLOT(slotBringToFront()));
|
||||
addAction(m_bringToFront);
|
||||
|
||||
m_sendToBack = new QAction(tr("Send to back"),this);
|
||||
m_sendToBack = new QAction(tr("Send to back"), this);
|
||||
m_sendToBack->setIcon(QIcon(":/report/images/sendToBack"));
|
||||
connect(m_sendToBack,SIGNAL(triggered()),this,SLOT(slotSendToBack()));
|
||||
connect(m_sendToBack, SIGNAL(triggered()), this, SLOT(slotSendToBack()));
|
||||
addAction(m_sendToBack);
|
||||
|
||||
m_alignToLeft = new QAction(tr("Align to left"),this);
|
||||
m_alignToLeft = new QAction(tr("Align to left"), this);
|
||||
m_alignToLeft->setIcon(QIcon(":/report/images/alignToLeft"));
|
||||
connect(m_alignToLeft,SIGNAL(triggered()),this,SLOT(slotAlignToLeft()));
|
||||
connect(m_alignToLeft, SIGNAL(triggered()), this, SLOT(slotAlignToLeft()));
|
||||
addAction(m_alignToLeft);
|
||||
|
||||
m_alignToRight = new QAction(tr("Align to right"),this);
|
||||
m_alignToRight = new QAction(tr("Align to right"), this);
|
||||
m_alignToRight->setIcon(QIcon(":/report/images/alignToRight"));
|
||||
connect(m_alignToRight,SIGNAL(triggered()),this,SLOT(slotAlignToRight()));
|
||||
connect(m_alignToRight, SIGNAL(triggered()), this, SLOT(slotAlignToRight()));
|
||||
addAction(m_alignToRight);
|
||||
|
||||
m_alignToVCenter = new QAction(tr("Align to vertical center"),this);
|
||||
m_alignToVCenter = new QAction(tr("Align to vertical center"), this);
|
||||
m_alignToVCenter->setIcon(QIcon(":/report/images/alignToVCenter"));
|
||||
connect(m_alignToVCenter,SIGNAL(triggered()),this,SLOT(slotAlignToVCenter()));
|
||||
connect(m_alignToVCenter, SIGNAL(triggered()), this, SLOT(slotAlignToVCenter()));
|
||||
addAction(m_alignToVCenter);
|
||||
|
||||
m_alignToTop = new QAction(tr("Align to top"),this);
|
||||
m_alignToTop = new QAction(tr("Align to top"), this);
|
||||
m_alignToTop->setIcon(QIcon(":/report/images/alignToTop"));
|
||||
connect(m_alignToTop,SIGNAL(triggered()),this,SLOT(slotAlignToTop()));
|
||||
connect(m_alignToTop, SIGNAL(triggered()), this, SLOT(slotAlignToTop()));
|
||||
addAction(m_alignToTop);
|
||||
|
||||
m_alignToBottom = new QAction(tr("Align to bottom"),this);
|
||||
m_alignToBottom = new QAction(tr("Align to bottom"), this);
|
||||
m_alignToBottom->setIcon(QIcon(":/report/images/alignToBottom"));
|
||||
connect(m_alignToBottom,SIGNAL(triggered()),this,SLOT(slotAlignToBottom()));
|
||||
connect(m_alignToBottom, SIGNAL(triggered()), this, SLOT(slotAlignToBottom()));
|
||||
addAction(m_alignToBottom);
|
||||
|
||||
m_alignToHCenter = new QAction(tr("Align to horizontal center"),this);
|
||||
m_alignToHCenter = new QAction(tr("Align to horizontal center"), this);
|
||||
m_alignToHCenter->setIcon(QIcon(":/report/images/alignToHCenter"));
|
||||
connect(m_alignToHCenter,SIGNAL(triggered()),this,SLOT(slotAlignToHCenter()));
|
||||
connect(m_alignToHCenter, SIGNAL(triggered()), this, SLOT(slotAlignToHCenter()));
|
||||
addAction(m_alignToHCenter);
|
||||
|
||||
m_sameHeight = new QAction(tr("Set same height"),this);
|
||||
m_sameHeight = new QAction(tr("Set same height"), this);
|
||||
m_sameHeight->setIcon(QIcon(":/report/images/sameHeight"));
|
||||
connect(m_sameHeight,SIGNAL(triggered()),this,SLOT(slotSameHeight()));
|
||||
connect(m_sameHeight, SIGNAL(triggered()), this, SLOT(slotSameHeight()));
|
||||
addAction(m_sameHeight);
|
||||
|
||||
m_sameWidth = new QAction(tr("Set same width"),this);
|
||||
m_sameWidth = new QAction(tr("Set same width"), this);
|
||||
m_sameWidth->setIcon(QIcon(":/report/images/sameWidth"));
|
||||
connect(m_sameWidth,SIGNAL(triggered()),this,SLOT(slotSameWidth()));
|
||||
connect(m_sameWidth, SIGNAL(triggered()), this, SLOT(slotSameWidth()));
|
||||
addAction(m_sameWidth);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,19 +31,21 @@
|
||||
#define LRITEMSALIGNEDITORWIDGET_H
|
||||
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include <QToolBar>
|
||||
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ItemsAlignmentEditorWidget : public QToolBar
|
||||
{
|
||||
class ItemsAlignmentEditorWidget: public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString &title, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, const QString& title,
|
||||
QWidget* parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent = 0);
|
||||
private slots:
|
||||
void slotBringToFront();
|
||||
void slotSendToBack();
|
||||
@@ -55,6 +57,7 @@ private slots:
|
||||
void slotAlignToHCenter();
|
||||
void slotSameHeight();
|
||||
void slotSameWidth();
|
||||
|
||||
private:
|
||||
void initEditor();
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
@@ -72,6 +75,6 @@ private:
|
||||
QAction* m_sameWidth;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRITEMSALIGNEDITORWIDGET_H
|
||||
|
||||
@@ -28,57 +28,56 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lritemsborderseditorwidget.h"
|
||||
#include <QAction>
|
||||
|
||||
#include "lrbordereditor.h"
|
||||
namespace LimeReport{
|
||||
|
||||
#include <QAction>
|
||||
namespace LimeReport {
|
||||
|
||||
void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
{
|
||||
if(QString(item->metaObject()->className()) == "LimeReport::ShapeItem")
|
||||
{
|
||||
if (QString(item->metaObject()->className()) == "LimeReport::ShapeItem") {
|
||||
setDisabled(true);
|
||||
return;
|
||||
}
|
||||
QVariant borders=item->property("borders");
|
||||
if (borders.isValid()){
|
||||
QVariant borders = item->property("borders");
|
||||
if (borders.isValid()) {
|
||||
updateValues((BaseDesignIntf::BorderLines)borders.toInt());
|
||||
setEnabled(true);
|
||||
}
|
||||
m_item = item;
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, const QVariant& oldValue, const QVariant& newValue)
|
||||
void ItemsBordersEditorWidget::properyChangedEvent(const QString& property,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
if (property == "borders"){
|
||||
if (property == "borders") {
|
||||
m_changing = true;
|
||||
updateValues((BaseDesignIntf::BorderLines)newValue.toInt());
|
||||
m_changing = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::noBordesClicked()
|
||||
{
|
||||
updateValues({});
|
||||
}
|
||||
void ItemsBordersEditorWidget::noBordesClicked() { updateValues({}); }
|
||||
|
||||
void ItemsBordersEditorWidget::allBordesClicked()
|
||||
{
|
||||
int borders = BaseDesignIntf::LeftLine |
|
||||
BaseDesignIntf::RightLine |
|
||||
BaseDesignIntf::TopLine |
|
||||
BaseDesignIntf::BottomLine;
|
||||
int borders = BaseDesignIntf::LeftLine | BaseDesignIntf::RightLine | BaseDesignIntf::TopLine
|
||||
| BaseDesignIntf::BottomLine;
|
||||
|
||||
updateValues((BaseDesignIntf::BorderLines)borders);
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::buttonClicked(bool){}
|
||||
void ItemsBordersEditorWidget::buttonClicked(bool) { }
|
||||
|
||||
void ItemsBordersEditorWidget::editBorderClicked()
|
||||
{
|
||||
BorderEditor be;
|
||||
be.loadItem(m_item);
|
||||
if ( be.exec() == QDialog::Rejected ) return;
|
||||
if (be.exec() == QDialog::Rejected)
|
||||
return;
|
||||
updateValues(be.borderSides());
|
||||
m_item->setBorderLinesFlags(be.borderSides());
|
||||
m_item->setBorderLineSize(be.borderWidth());
|
||||
@@ -89,49 +88,48 @@ void ItemsBordersEditorWidget::editBorderClicked()
|
||||
void ItemsBordersEditorWidget::initEditor()
|
||||
{
|
||||
|
||||
m_topLine = new QAction(tr("Top line"),this);
|
||||
m_topLine = new QAction(tr("Top line"), this);
|
||||
m_topLine->setIcon(QIcon(":/report/images/topLine"));
|
||||
m_topLine->setCheckable(true);
|
||||
connect(m_topLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_topLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_topLine);
|
||||
|
||||
m_bottomLine = new QAction(tr("Bottom line"),this);
|
||||
m_bottomLine = new QAction(tr("Bottom line"), this);
|
||||
m_bottomLine->setIcon(QIcon(":/report/images/bottomLine"));
|
||||
m_bottomLine->setCheckable(true);
|
||||
connect(m_bottomLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_bottomLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_bottomLine);
|
||||
|
||||
m_leftLine = new QAction(tr("Left line"),this);
|
||||
m_leftLine = new QAction(tr("Left line"), this);
|
||||
m_leftLine->setIcon(QIcon(":/report/images/leftLine"));
|
||||
m_leftLine->setCheckable(true);
|
||||
connect(m_leftLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_leftLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_leftLine);
|
||||
|
||||
m_rightLine = new QAction(tr("Right line"),this);
|
||||
m_rightLine = new QAction(tr("Right line"), this);
|
||||
m_rightLine->setIcon(QIcon(":/report/images/rightLine"));
|
||||
m_rightLine->setCheckable(true);
|
||||
connect(m_rightLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_rightLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_rightLine);
|
||||
|
||||
addSeparator();
|
||||
|
||||
m_noLines = new QAction(tr("No borders"),this);
|
||||
m_noLines = new QAction(tr("No borders"), this);
|
||||
m_noLines->setIcon(QIcon(":/report/images/noLines"));
|
||||
connect(m_noLines,SIGNAL(triggered()),this,SLOT(noBordesClicked()));
|
||||
connect(m_noLines, SIGNAL(triggered()), this, SLOT(noBordesClicked()));
|
||||
addAction(m_noLines);
|
||||
|
||||
m_allLines = new QAction(tr("All borders"),this);
|
||||
m_allLines = new QAction(tr("All borders"), this);
|
||||
m_allLines->setIcon(QIcon(":/report/images/allLines"));
|
||||
connect(m_allLines,SIGNAL(triggered()),this,SLOT(allBordesClicked()));
|
||||
connect(m_allLines, SIGNAL(triggered()), this, SLOT(allBordesClicked()));
|
||||
addAction(m_allLines);
|
||||
addSeparator();
|
||||
m_BorderEditor = new QAction(tr("Edit border"),this);
|
||||
m_BorderEditor = new QAction(tr("Edit border"), this);
|
||||
m_BorderEditor->setIcon(QIcon(":/report/images/borderEditor"));
|
||||
connect(m_BorderEditor,SIGNAL(triggered()),this,SLOT(editBorderClicked()));
|
||||
connect(m_BorderEditor, SIGNAL(triggered()), this, SLOT(editBorderClicked()));
|
||||
addAction(m_BorderEditor);
|
||||
|
||||
setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders)
|
||||
@@ -147,17 +145,14 @@ void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders)
|
||||
BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders()
|
||||
{
|
||||
int borders = 0;
|
||||
borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine:0;
|
||||
borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine:0;
|
||||
borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine:0;
|
||||
borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine:0;
|
||||
borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine : 0;
|
||||
borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine : 0;
|
||||
borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine : 0;
|
||||
borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine : 0;
|
||||
return (BaseDesignIntf::BorderLines)borders;
|
||||
}
|
||||
|
||||
bool ItemsBordersEditorWidget::changing() const
|
||||
{
|
||||
return m_changing;
|
||||
}
|
||||
bool ItemsBordersEditorWidget::changing() const { return m_changing; }
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
void ItemsBordersEditorWidgetForDesigner::buttonClicked(bool)
|
||||
@@ -182,16 +177,14 @@ void ItemsBordersEditorWidgetForDesigner::editBorderClicked()
|
||||
{
|
||||
BorderEditor be;
|
||||
be.loadItem(m_item);
|
||||
if ( be.exec() == QDialog::Rejected ) return;
|
||||
if (be.exec() == QDialog::Rejected)
|
||||
return;
|
||||
|
||||
m_reportEditor->setBordersExt(
|
||||
be.borderSides(),
|
||||
be.borderWidth(),
|
||||
(LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(),
|
||||
be.borderColor()
|
||||
);
|
||||
m_reportEditor->setBordersExt(be.borderSides(), be.borderWidth(),
|
||||
(LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(),
|
||||
be.borderColor());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,18 +30,21 @@
|
||||
#ifndef LRITEMSBORDERSEDITORWIDGET_H
|
||||
#define LRITEMSBORDERSEDITORWIDGET_H
|
||||
|
||||
#include <QToolBar>
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lritemeditorwidget.h"
|
||||
#include "lrreportdesignwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QToolBar>
|
||||
|
||||
class ItemsBordersEditorWidget : public ItemEditorWidget
|
||||
{
|
||||
namespace LimeReport {
|
||||
|
||||
class ItemsBordersEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemsBordersEditorWidget(const QString &title, QWidget *parent = 0)
|
||||
: ItemEditorWidget(title, parent), m_changing(false), m_borders(0){
|
||||
explicit ItemsBordersEditorWidget(const QString& title, QWidget* parent = 0):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_changing(false),
|
||||
m_borders(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
bool changing() const;
|
||||
@@ -50,11 +53,14 @@ protected slots:
|
||||
virtual void allBordesClicked();
|
||||
virtual void buttonClicked(bool);
|
||||
virtual void editBorderClicked();
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf *item);
|
||||
void properyChangedEvent(const QString &property, const QVariant &oldValue, const QVariant &newValue);
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
void properyChangedEvent(const QString& property, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
BaseDesignIntf::BorderLines createBorders();
|
||||
BaseDesignIntf *m_item;
|
||||
BaseDesignIntf* m_item;
|
||||
|
||||
private:
|
||||
void initEditor();
|
||||
void updateValues(BaseDesignIntf::BorderLines borders);
|
||||
@@ -67,26 +73,29 @@ private:
|
||||
QAction* m_BorderEditor;
|
||||
bool m_changing;
|
||||
int m_borders;
|
||||
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class ItemsBordersEditorWidgetForDesigner : public ItemsBordersEditorWidget{
|
||||
class ItemsBordersEditorWidgetForDesigner: public ItemsBordersEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemsBordersEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title="", QWidget *parent = 0)
|
||||
: ItemsBordersEditorWidget(title,parent), m_reportEditor(reportEditor){}
|
||||
explicit ItemsBordersEditorWidgetForDesigner(ReportDesignWidget* reportEditor,
|
||||
const QString& title = "", QWidget* parent = 0):
|
||||
ItemsBordersEditorWidget(title, parent),
|
||||
m_reportEditor(reportEditor)
|
||||
{
|
||||
}
|
||||
protected slots:
|
||||
void buttonClicked(bool);
|
||||
void noBordesClicked();
|
||||
void allBordesClicked();
|
||||
void editBorderClicked();
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
}//namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRITEMSBORDERSEDITORWIDGET_H
|
||||
|
||||
@@ -29,17 +29,19 @@
|
||||
****************************************************************************/
|
||||
#include "lrtextalignmenteditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent)
|
||||
:ItemEditorWidget(title, parent), m_textAttibutesIsChanging(false), m_flag(0)
|
||||
namespace LimeReport {
|
||||
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_textAttibutesIsChanging(false),
|
||||
m_flag(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf *item)
|
||||
void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
{
|
||||
QVariant align=item->property("alignment");
|
||||
if (align.isValid()){
|
||||
QVariant align = item->property("alignment");
|
||||
if (align.isValid()) {
|
||||
updateValues(Qt::Alignment(align.value<int>()));
|
||||
setEnabled(true);
|
||||
}
|
||||
@@ -47,178 +49,197 @@ void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf *item)
|
||||
|
||||
void TextAlignmentEditorWidget::initEditor()
|
||||
{
|
||||
m_textAliginLeft = new QAction(tr("Text align left"),this);
|
||||
m_textAliginLeft = new QAction(tr("Text align left"), this);
|
||||
m_textAliginLeft->setIcon(QIcon(":/report/images/textAlignHLeft"));
|
||||
m_textAliginLeft->setCheckable(true);
|
||||
connect(m_textAliginLeft,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginLeft, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginLeft);
|
||||
|
||||
m_textAliginHCenter = new QAction(tr("Text align center"),this);
|
||||
m_textAliginHCenter = new QAction(tr("Text align center"), this);
|
||||
m_textAliginHCenter->setIcon(QIcon(":/report/images/textAlignHCenter"));
|
||||
m_textAliginHCenter->setCheckable(true);
|
||||
connect(m_textAliginHCenter,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginHCenter, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginHCenter);
|
||||
|
||||
m_textAliginRight = new QAction(tr("Text align right"),this);
|
||||
m_textAliginRight = new QAction(tr("Text align right"), this);
|
||||
m_textAliginRight->setIcon(QIcon(":/report/images/textAlignHRight"));
|
||||
m_textAliginRight->setCheckable(true);
|
||||
connect(m_textAliginRight,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginRight, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginRight);
|
||||
|
||||
m_textAliginJustify = new QAction(tr("Text align justify"),this);
|
||||
m_textAliginJustify = new QAction(tr("Text align justify"), this);
|
||||
m_textAliginJustify->setIcon(QIcon(":/report/images/textAlignHJustify"));
|
||||
m_textAliginJustify->setCheckable(true);
|
||||
connect(m_textAliginJustify,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginJustify, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginJustify);
|
||||
|
||||
addSeparator();
|
||||
|
||||
m_textAliginTop = new QAction(tr("Text align top"),this);
|
||||
m_textAliginTop = new QAction(tr("Text align top"), this);
|
||||
m_textAliginTop->setIcon(QIcon(":/report/images/textAlignVTop"));
|
||||
m_textAliginTop->setCheckable(true);
|
||||
connect(m_textAliginTop,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool)));
|
||||
connect(m_textAliginTop, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool)));
|
||||
addAction(m_textAliginTop);
|
||||
|
||||
m_textAliginVCenter = new QAction(tr("Text align center"),this);
|
||||
m_textAliginVCenter = new QAction(tr("Text align center"), this);
|
||||
m_textAliginVCenter->setIcon(QIcon(":/report/images/textAlignVCenter"));
|
||||
m_textAliginVCenter->setCheckable(true);
|
||||
connect(m_textAliginVCenter,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool)));
|
||||
connect(m_textAliginVCenter, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool)));
|
||||
addAction(m_textAliginVCenter);
|
||||
|
||||
m_textAliginBottom = new QAction(tr("Text align bottom"),this);
|
||||
m_textAliginBottom = new QAction(tr("Text align bottom"), this);
|
||||
m_textAliginBottom->setIcon(QIcon(":/report/images/textAlignVBottom"));
|
||||
m_textAliginBottom->setCheckable(true);
|
||||
connect(m_textAliginBottom,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool)));
|
||||
connect(m_textAliginBottom, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool)));
|
||||
addAction(m_textAliginBottom);
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
|
||||
void TextAlignmentEditorWidget::updateValues(const Qt::Alignment& align)
|
||||
{
|
||||
m_textAttibutesIsChanging=true;
|
||||
m_textAliginLeft->setChecked((align & Qt::AlignLeft)==Qt::AlignLeft);
|
||||
m_textAliginRight->setChecked((align & Qt::AlignRight)==Qt::AlignRight);
|
||||
m_textAliginHCenter->setChecked((align & Qt::AlignHCenter)==Qt::AlignHCenter);
|
||||
m_textAliginJustify->setChecked((align & Qt::AlignJustify)==Qt::AlignJustify);
|
||||
m_textAliginTop->setChecked((align & Qt::AlignTop)==Qt::AlignTop);
|
||||
m_textAliginVCenter->setChecked((align & Qt::AlignVCenter)==Qt::AlignVCenter);
|
||||
m_textAliginBottom->setChecked((align & Qt::AlignBottom)==Qt::AlignBottom);
|
||||
m_textAttibutesIsChanging=false;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_textAliginLeft->setChecked((align & Qt::AlignLeft) == Qt::AlignLeft);
|
||||
m_textAliginRight->setChecked((align & Qt::AlignRight) == Qt::AlignRight);
|
||||
m_textAliginHCenter->setChecked((align & Qt::AlignHCenter) == Qt::AlignHCenter);
|
||||
m_textAliginJustify->setChecked((align & Qt::AlignJustify) == Qt::AlignJustify);
|
||||
m_textAliginTop->setChecked((align & Qt::AlignTop) == Qt::AlignTop);
|
||||
m_textAliginVCenter->setChecked((align & Qt::AlignVCenter) == Qt::AlignVCenter);
|
||||
m_textAliginBottom->setChecked((align & Qt::AlignBottom) == Qt::AlignBottom);
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
Qt::Alignment TextAlignmentEditorWidget::createAlignment()
|
||||
{
|
||||
Qt::Alignment align = Qt::Alignment();
|
||||
if (m_textAliginLeft->isChecked()) align |= Qt::AlignLeft;
|
||||
if (m_textAliginHCenter->isChecked()) align |= Qt::AlignHCenter;
|
||||
if (m_textAliginRight->isChecked()) align |= Qt::AlignRight;
|
||||
if (m_textAliginJustify->isChecked()) align |= Qt::AlignJustify;
|
||||
if (m_textAliginTop->isChecked()) align |= Qt::AlignTop;
|
||||
if (m_textAliginVCenter->isChecked()) align |= Qt::AlignVCenter;
|
||||
if (m_textAliginBottom->isChecked()) align |= Qt::AlignBottom;
|
||||
if (m_textAliginLeft->isChecked())
|
||||
align |= Qt::AlignLeft;
|
||||
if (m_textAliginHCenter->isChecked())
|
||||
align |= Qt::AlignHCenter;
|
||||
if (m_textAliginRight->isChecked())
|
||||
align |= Qt::AlignRight;
|
||||
if (m_textAliginJustify->isChecked())
|
||||
align |= Qt::AlignJustify;
|
||||
if (m_textAliginTop->isChecked())
|
||||
align |= Qt::AlignTop;
|
||||
if (m_textAliginVCenter->isChecked())
|
||||
align |= Qt::AlignVCenter;
|
||||
if (m_textAliginBottom->isChecked())
|
||||
align |= Qt::AlignBottom;
|
||||
return align;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::slotTextHAttribsChanged(bool)
|
||||
{
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
|
||||
m_textAliginLeft->setChecked(sender()==m_textAliginLeft);
|
||||
m_textAliginHCenter->setChecked(sender()==m_textAliginHCenter);
|
||||
m_textAliginRight->setChecked(sender()==m_textAliginRight);
|
||||
m_textAliginJustify->setChecked(sender()==m_textAliginJustify);
|
||||
m_textAliginLeft->setChecked(sender() == m_textAliginLeft);
|
||||
m_textAliginHCenter->setChecked(sender() == m_textAliginHCenter);
|
||||
m_textAliginRight->setChecked(sender() == m_textAliginRight);
|
||||
m_textAliginJustify->setChecked(sender() == m_textAliginJustify);
|
||||
|
||||
m_flag = 0;
|
||||
if (sender()==m_textAliginLeft) m_flag |= Qt::AlignLeft;
|
||||
if (sender()==m_textAliginHCenter) m_flag |= Qt::AlignHCenter;
|
||||
if (sender()==m_textAliginRight) m_flag |= Qt::AlignRight;
|
||||
if (sender()==m_textAliginJustify) m_flag |= Qt::AlignJustify;
|
||||
if (sender() == m_textAliginLeft)
|
||||
m_flag |= Qt::AlignLeft;
|
||||
if (sender() == m_textAliginHCenter)
|
||||
m_flag |= Qt::AlignHCenter;
|
||||
if (sender() == m_textAliginRight)
|
||||
m_flag |= Qt::AlignRight;
|
||||
if (sender() == m_textAliginJustify)
|
||||
m_flag |= Qt::AlignJustify;
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::slotTextVAttribsChanged(bool)
|
||||
{
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
|
||||
m_textAliginTop->setChecked(sender()==m_textAliginTop);
|
||||
m_textAliginVCenter->setChecked(sender()==m_textAliginVCenter);
|
||||
m_textAliginBottom->setChecked(sender()==m_textAliginBottom);
|
||||
m_textAliginTop->setChecked(sender() == m_textAliginTop);
|
||||
m_textAliginVCenter->setChecked(sender() == m_textAliginVCenter);
|
||||
m_textAliginBottom->setChecked(sender() == m_textAliginBottom);
|
||||
|
||||
m_flag = 0;
|
||||
if (sender()==m_textAliginTop) m_flag |= Qt::AlignTop;
|
||||
if (sender()==m_textAliginVCenter) m_flag |= Qt::AlignVCenter;
|
||||
if (sender()==m_textAliginBottom) m_flag |= Qt::AlignBottom;
|
||||
if (sender() == m_textAliginTop)
|
||||
m_flag |= Qt::AlignTop;
|
||||
if (sender() == m_textAliginVCenter)
|
||||
m_flag |= Qt::AlignVCenter;
|
||||
if (sender() == m_textAliginBottom)
|
||||
m_flag |= Qt::AlignBottom;
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::slotPropertyChanged(const QString &objectName, const QString &property, const QVariant &oldValue, const QVariant &newValue)
|
||||
void TextAlignmentEditorWidget::slotPropertyChanged(const QString& objectName,
|
||||
const QString& property,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
Q_UNUSED(newValue)
|
||||
|
||||
if (item()&&(item()->objectName()==objectName)&&(property=="alignment")){
|
||||
if (item() && (item()->objectName() == objectName) && (property == "alignment")) {
|
||||
updateValues(Qt::Alignment(item()->property("alignment").value<int>()));
|
||||
}
|
||||
}
|
||||
|
||||
int TextAlignmentEditorWidget::flag() const
|
||||
{
|
||||
return m_flag;
|
||||
}
|
||||
int TextAlignmentEditorWidget::flag() const { return m_flag; }
|
||||
|
||||
void TextAlignmentEditorWidgetForPage::initEditor()
|
||||
{
|
||||
TextAlignmentEditorWidget::initEditor();
|
||||
connect(m_page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant)));
|
||||
connect(m_page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidgetForPage::slotTextHAttribsChanged(bool value)
|
||||
{
|
||||
|
||||
TextAlignmentEditorWidget::slotTextHAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_page->changeSelectedGrpoupTextAlignPropperty(true,Qt::AlignmentFlag(flag()));
|
||||
m_page->changeSelectedGrpoupTextAlignPropperty(true, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidgetForPage::slotTextVAttribsChanged(bool value)
|
||||
{
|
||||
TextAlignmentEditorWidget::slotTextVAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_page->changeSelectedGrpoupTextAlignPropperty(false,Qt::AlignmentFlag(flag()) );
|
||||
m_page->changeSelectedGrpoupTextAlignPropperty(false, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
void TextAlignmentEditorWidgetForDesigner::initEditor()
|
||||
{
|
||||
connect(m_reportEditor,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant)));
|
||||
|
||||
connect(m_reportEditor, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidgetForDesigner::slotTextHAttribsChanged(bool value)
|
||||
{
|
||||
TextAlignmentEditorWidget::slotTextHAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_reportEditor->setTextAlign(true,Qt::AlignmentFlag(flag()));
|
||||
m_reportEditor->setTextAlign(true, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidgetForDesigner::slotTextVAttribsChanged(bool value)
|
||||
{
|
||||
TextAlignmentEditorWidget::slotTextVAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_reportEditor->setTextAlign(false,Qt::AlignmentFlag(flag()));
|
||||
m_reportEditor->setTextAlign(false, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,30 +30,34 @@
|
||||
#ifndef LRTEXTALIGNMENTEDITORWIDGET_H
|
||||
#define LRTEXTALIGNMENTEDITORWIDGET_H
|
||||
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lritemeditorwidget.h"
|
||||
#include <QToolBar>
|
||||
#include "lrreportdesignwidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class TextAlignmentEditorWidget:public ItemEditorWidget
|
||||
{
|
||||
class TextAlignmentEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextAlignmentEditorWidget(const QString &title, QWidget *parent = 0);
|
||||
explicit TextAlignmentEditorWidget(const QString& title, QWidget* parent = 0);
|
||||
int flag() const;
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf *item);
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
void initEditor();
|
||||
bool m_textAttibutesIsChanging;
|
||||
|
||||
private:
|
||||
void updateValues(const Qt::Alignment& align);
|
||||
Qt::Alignment createAlignment();
|
||||
protected slots:
|
||||
virtual void slotTextHAttribsChanged(bool);
|
||||
virtual void slotTextVAttribsChanged(bool);
|
||||
virtual void slotPropertyChanged(const QString& objectName, const QString& property, const QVariant &oldValue, const QVariant &newValue);
|
||||
virtual void slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
private:
|
||||
QAction* m_textAliginLeft;
|
||||
QAction* m_textAliginRight;
|
||||
@@ -65,36 +69,49 @@ private:
|
||||
int m_flag;
|
||||
};
|
||||
|
||||
class TextAlignmentEditorWidgetForPage: public TextAlignmentEditorWidget{
|
||||
class TextAlignmentEditorWidgetForPage: public TextAlignmentEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextAlignmentEditorWidgetForPage(PageDesignIntf* page, const QString &title, QWidget *parent = 0)
|
||||
:TextAlignmentEditorWidget(title, parent), m_page(page){}
|
||||
TextAlignmentEditorWidgetForPage(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
TextAlignmentEditorWidget(title, parent),
|
||||
m_page(page)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initEditor();
|
||||
protected slots:
|
||||
void slotTextHAttribsChanged(bool value);
|
||||
void slotTextVAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
PageDesignIntf* m_page;
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class TextAlignmentEditorWidgetForDesigner: public TextAlignmentEditorWidget{
|
||||
class TextAlignmentEditorWidgetForDesigner: public TextAlignmentEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextAlignmentEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0)
|
||||
:TextAlignmentEditorWidget(title, parent), m_reportEditor(reportEditor){initEditor();}
|
||||
TextAlignmentEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
TextAlignmentEditorWidget(title, parent),
|
||||
m_reportEditor(reportEditor)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
protected:
|
||||
void initEditor();
|
||||
protected slots:
|
||||
void slotTextHAttribsChanged(bool value);
|
||||
void slotTextVAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
};
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRTEXTALIGNMENTEDITORWIDGET_H
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent)
|
||||
: LayoutDesignIntf(xmlTag, owner, parent), m_isRelocating(false), m_layoutType(Layout),
|
||||
m_hideEmptyItems(false), m_layoutSpacing(0)
|
||||
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent):
|
||||
LayoutDesignIntf(xmlTag, owner, parent),
|
||||
m_isRelocating(false),
|
||||
m_layoutType(Layout),
|
||||
m_hideEmptyItems(false),
|
||||
m_layoutSpacing(0)
|
||||
{
|
||||
setPossibleResizeDirectionFlags(AllDirections);
|
||||
m_layoutMarker = new LayoutMarker(this);
|
||||
@@ -17,38 +20,25 @@ AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* pa
|
||||
AbstractLayout::~AbstractLayout()
|
||||
{
|
||||
if (m_layoutMarker) {
|
||||
delete m_layoutMarker; m_layoutMarker=0;
|
||||
delete m_layoutMarker;
|
||||
m_layoutMarker = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren()
|
||||
{
|
||||
return m_children;
|
||||
}
|
||||
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren() { return m_children; }
|
||||
|
||||
bool AbstractLayout::isRelocating() const
|
||||
{
|
||||
return m_isRelocating;
|
||||
}
|
||||
bool AbstractLayout::isRelocating() const { return m_isRelocating; }
|
||||
|
||||
void AbstractLayout::setIsRelocating(bool isRelocating)
|
||||
{
|
||||
m_isRelocating = isRelocating;
|
||||
}
|
||||
void AbstractLayout::setIsRelocating(bool isRelocating) { m_isRelocating = isRelocating; }
|
||||
|
||||
AbstractLayout::LayoutType AbstractLayout::layoutType() const
|
||||
{
|
||||
return m_layoutType;
|
||||
}
|
||||
AbstractLayout::LayoutType AbstractLayout::layoutType() const { return m_layoutType; }
|
||||
|
||||
void AbstractLayout::setLayoutType(const LayoutType& layoutType)
|
||||
{
|
||||
m_layoutType = layoutType;
|
||||
}
|
||||
void AbstractLayout::setLayoutType(const LayoutType& layoutType) { m_layoutType = layoutType; }
|
||||
|
||||
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
|
||||
{
|
||||
if (updateSize) placeItemInLayout(item);
|
||||
if (updateSize)
|
||||
placeItemInLayout(item);
|
||||
|
||||
m_children.append(item);
|
||||
item->setParentItem(this);
|
||||
@@ -58,13 +48,13 @@ void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
|
||||
|
||||
connectToLayout(item);
|
||||
|
||||
if (updateSize){
|
||||
if (updateSize) {
|
||||
relocateChildren();
|
||||
updateLayoutSize();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::removeChild(BaseDesignIntf *item)
|
||||
void AbstractLayout::removeChild(BaseDesignIntf* item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
@@ -75,8 +65,9 @@ void AbstractLayout::removeChild(BaseDesignIntf *item)
|
||||
|
||||
void AbstractLayout::restoreChild(BaseDesignIntf* item)
|
||||
{
|
||||
if (m_children.contains(item)) return;
|
||||
m_isRelocating=true;
|
||||
if (m_children.contains(item))
|
||||
return;
|
||||
m_isRelocating = true;
|
||||
|
||||
insertItemInLayout(item);
|
||||
|
||||
@@ -88,7 +79,7 @@ void AbstractLayout::restoreChild(BaseDesignIntf* item)
|
||||
item->setParentItem(this);
|
||||
|
||||
updateLayoutSize();
|
||||
m_isRelocating=false;
|
||||
m_isRelocating = false;
|
||||
}
|
||||
|
||||
bool AbstractLayout::isEmpty() const
|
||||
@@ -97,54 +88,49 @@ bool AbstractLayout::isEmpty() const
|
||||
bool allItemsIsText = true;
|
||||
foreach (QGraphicsItem* qgItem, childItems()) {
|
||||
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(qgItem);
|
||||
if (item && !item->content().isEmpty()) isEmpty = false;
|
||||
if (item && !item->content().isEmpty())
|
||||
isEmpty = false;
|
||||
if (!item && dynamic_cast<BaseDesignIntf*>(qgItem))
|
||||
allItemsIsText = false;
|
||||
}
|
||||
return (isEmpty && allItemsIsText);
|
||||
}
|
||||
|
||||
void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPainter *painter)
|
||||
void AbstractLayout::paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter)
|
||||
{
|
||||
if (!child->childBaseItems().isEmpty()){
|
||||
if (!child->childBaseItems().isEmpty()) {
|
||||
foreach (BaseDesignIntf* item, child->childBaseItems()) {
|
||||
paintChild(item, child->pos(),painter);
|
||||
paintChild(item, child->pos(), painter);
|
||||
}
|
||||
}
|
||||
painter->drawRect(
|
||||
QRectF(parentPos.x()+child->pos().x(), parentPos.y()+child->pos().y(),
|
||||
child->rect().bottomRight().rx(),
|
||||
child->rect().bottomRight().ry()
|
||||
)
|
||||
);
|
||||
painter->drawRect(QRectF(parentPos.x() + child->pos().x(), parentPos.y() + child->pos().y(),
|
||||
child->rect().bottomRight().rx(), child->rect().bottomRight().ry()));
|
||||
}
|
||||
|
||||
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget)
|
||||
{
|
||||
if (isSelected()){
|
||||
if (isSelected()) {
|
||||
painter->save();
|
||||
painter->setPen(Qt::red);
|
||||
foreach( BaseDesignIntf* item, m_children){
|
||||
paintChild(item, QPointF(0,0), painter);
|
||||
foreach (BaseDesignIntf* item, m_children) {
|
||||
paintChild(item, QPointF(0, 0), painter);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
LayoutDesignIntf::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
int AbstractLayout::childrenCount()
|
||||
{
|
||||
return m_children.size();
|
||||
}
|
||||
int AbstractLayout::childrenCount() { return m_children.size(); }
|
||||
|
||||
void AbstractLayout::beforeDelete()
|
||||
{
|
||||
#ifdef HAVE_QT5
|
||||
foreach (QObject *item, children()) {
|
||||
foreach (QObject* item, children()) {
|
||||
#else
|
||||
foreach (QObject *item, QObject::children()) {
|
||||
foreach (QObject* item, QObject::children()) {
|
||||
#endif
|
||||
BaseDesignIntf *bi = dynamic_cast<BaseDesignIntf*>(item);
|
||||
BaseDesignIntf* bi = dynamic_cast<BaseDesignIntf*>(item);
|
||||
if (bi) {
|
||||
bi->disconnect(this);
|
||||
bi->setParentItem(parentItem());
|
||||
@@ -158,16 +144,13 @@ void AbstractLayout::beforeDelete()
|
||||
m_children.clear();
|
||||
}
|
||||
|
||||
void AbstractLayout::childAddedEvent(BaseDesignIntf* child)
|
||||
{
|
||||
addChild(child,false);
|
||||
}
|
||||
void AbstractLayout::childAddedEvent(BaseDesignIntf* child) { addChild(child, false); }
|
||||
|
||||
void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
|
||||
{
|
||||
layoutMarker()->setHeight(newRect.height());
|
||||
relocateChildren();
|
||||
if (!isRelocating()){
|
||||
if (!isRelocating()) {
|
||||
divideSpace();
|
||||
}
|
||||
}
|
||||
@@ -175,7 +158,7 @@ void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
|
||||
void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode)
|
||||
{
|
||||
BaseDesignIntf::initMode(mode);
|
||||
if ((mode==PreviewMode)||(mode==PrintMode)){
|
||||
if ((mode == PreviewMode) || (mode == PrintMode)) {
|
||||
layoutMarker()->setVisible(false);
|
||||
} else {
|
||||
layoutMarker()->setVisible(true);
|
||||
@@ -185,22 +168,22 @@ void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode)
|
||||
void AbstractLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags)
|
||||
{
|
||||
BaseDesignIntf::setBorderLinesFlags(flags);
|
||||
if (flags!=0)
|
||||
if (flags != 0)
|
||||
relocateChildren();
|
||||
}
|
||||
|
||||
void AbstractLayout::collectionLoadFinished(const QString& collectionName)
|
||||
{
|
||||
ItemDesignIntf::collectionLoadFinished(collectionName);
|
||||
if (collectionName.compare("children",Qt::CaseInsensitive)==0){
|
||||
if (collectionName.compare("children", Qt::CaseInsensitive) == 0) {
|
||||
#ifdef HAVE_QT5
|
||||
foreach(QObject* obj, children()){
|
||||
foreach (QObject* obj, children()) {
|
||||
#else
|
||||
foreach(QObject* obj,QObject::children()){
|
||||
foreach (QObject* obj, QObject::children()) {
|
||||
#endif
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(obj);
|
||||
if (item) {
|
||||
addChild(item,false);
|
||||
addChild(item, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,9 +203,9 @@ bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const
|
||||
|
||||
QVariant AbstractLayout::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
|
||||
{
|
||||
if (change == QGraphicsItem::ItemSelectedHasChanged){
|
||||
if (change == QGraphicsItem::ItemSelectedHasChanged) {
|
||||
setIsRelocating(true);
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
item->setVisible(!value.toBool());
|
||||
}
|
||||
setIsRelocating(false);
|
||||
@@ -234,7 +217,7 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
{
|
||||
setIsRelocating(true);
|
||||
ItemDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
foreach(QGraphicsItem *child, childItems()){
|
||||
foreach (QGraphicsItem* child, childItems()) {
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(child);
|
||||
if (item && item->isNeedUpdateSize(pass))
|
||||
item->updateItemSize(dataManager, pass, maxHeight);
|
||||
@@ -245,8 +228,9 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
}
|
||||
|
||||
void AbstractLayout::rebuildChildrenIfNeeded(){
|
||||
if (layoutsChildren().count() < childItems().size()-1){
|
||||
void AbstractLayout::rebuildChildrenIfNeeded()
|
||||
{
|
||||
if (layoutsChildren().count() < childItems().size() - 1) {
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* childItem, childBaseItems()) {
|
||||
layoutsChildren().append(childItem);
|
||||
@@ -255,89 +239,75 @@ void AbstractLayout::rebuildChildrenIfNeeded(){
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::connectToLayout(BaseDesignIntf *item)
|
||||
void AbstractLayout::connectToLayout(BaseDesignIntf* item)
|
||||
{
|
||||
connect(
|
||||
item, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(slotOnChildDestroy(QObject*))
|
||||
);
|
||||
connect(
|
||||
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
|
||||
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
|
||||
);
|
||||
connect(
|
||||
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
|
||||
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
|
||||
);
|
||||
connect(
|
||||
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
|
||||
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
|
||||
);
|
||||
connect(
|
||||
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
|
||||
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,const ItemAlign&,const ItemAlign&))
|
||||
);
|
||||
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
|
||||
connect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
|
||||
SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
|
||||
connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
|
||||
SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
|
||||
connect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
|
||||
SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
|
||||
connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
|
||||
this,
|
||||
SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
|
||||
}
|
||||
|
||||
void AbstractLayout::disconnectFromLayout(BaseDesignIntf *item)
|
||||
void AbstractLayout::disconnectFromLayout(BaseDesignIntf* item)
|
||||
{
|
||||
disconnect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
|
||||
disconnect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
|
||||
SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
|
||||
disconnect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
|
||||
SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
|
||||
disconnect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
|
||||
SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
|
||||
disconnect(
|
||||
item, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(slotOnChildDestroy(QObject*))
|
||||
);
|
||||
disconnect(
|
||||
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
|
||||
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
|
||||
);
|
||||
disconnect(
|
||||
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
|
||||
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
|
||||
);
|
||||
disconnect(
|
||||
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
|
||||
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
|
||||
);
|
||||
disconnect(
|
||||
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
|
||||
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,const ItemAlign&,const ItemAlign&))
|
||||
);
|
||||
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)), this,
|
||||
SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
|
||||
}
|
||||
|
||||
BaseDesignIntf *AbstractLayout::findNext(BaseDesignIntf *item)
|
||||
BaseDesignIntf* AbstractLayout::findNext(BaseDesignIntf* item)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
for (int i=0; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];}
|
||||
for (int i = 0; i < layoutsChildren().count(); ++i) {
|
||||
if (layoutsChildren()[i] == item && layoutsChildren().size() > i + 1) {
|
||||
return layoutsChildren()[i + 1];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
|
||||
BaseDesignIntf* AbstractLayout::findPrior(BaseDesignIntf* item)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
for (int i=0; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
|
||||
for (int i = 0; i < layoutsChildren().count(); ++i) {
|
||||
if (layoutsChildren()[i] == item && i != 0) {
|
||||
return layoutsChildren()[i - 1];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){
|
||||
void AbstractLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||
{
|
||||
bool inserted = false;
|
||||
for (int i=0; i<layoutsChildren().length(); ++i){
|
||||
for (int i = 0; i < layoutsChildren().length(); ++i) {
|
||||
BaseDesignIntf* child = layoutsChildren()[i];
|
||||
if (child->pos() == item->pos()){
|
||||
if (child->pos() == item->pos()) {
|
||||
layoutsChildren().insert(i, item);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inserted) layoutsChildren().append(item);
|
||||
if (!inserted)
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
{
|
||||
m_children.removeAll(static_cast<BaseDesignIntf*>(child));
|
||||
if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)){
|
||||
if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)) {
|
||||
beforeDelete();
|
||||
} else {
|
||||
relocateChildren();
|
||||
@@ -345,19 +315,20 @@ void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry)
|
||||
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry,
|
||||
QRectF oldGeometry)
|
||||
{
|
||||
if (!m_isRelocating && !isLoading()){
|
||||
if (m_layoutType == Layout){
|
||||
if (!m_isRelocating && !isLoading()) {
|
||||
if (m_layoutType == Layout) {
|
||||
relocateChildren();
|
||||
updateLayoutSize();
|
||||
} else {
|
||||
m_isRelocating = true;
|
||||
qreal delta = newGeometry.width()-oldGeometry.width();
|
||||
qreal delta = newGeometry.width() - oldGeometry.width();
|
||||
BaseDesignIntf* resizingItem = findNext(dynamic_cast<BaseDesignIntf*>(item));
|
||||
if (resizingItem) {
|
||||
resizingItem->setWidth(resizingItem->width()-delta);
|
||||
resizingItem->setPos(resizingItem->pos().x()+delta,resizingItem->pos().y());
|
||||
resizingItem->setWidth(resizingItem->width() - delta);
|
||||
resizingItem->setPos(resizingItem->pos().x() + delta, resizingItem->pos().y());
|
||||
}
|
||||
updateLayoutSize();
|
||||
m_isRelocating = false;
|
||||
@@ -365,7 +336,8 @@ void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometr
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&)
|
||||
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&,
|
||||
const ItemAlign&)
|
||||
{
|
||||
item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight);
|
||||
}
|
||||
@@ -373,28 +345,25 @@ void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const Ite
|
||||
void AbstractLayout::slotOnChildVisibleHasChanged(BaseDesignIntf*)
|
||||
{
|
||||
relocateChildren();
|
||||
if (m_layoutType == Table && !m_isRelocating){
|
||||
if (m_layoutType == Table && !m_isRelocating) {
|
||||
divideSpace();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value)
|
||||
{
|
||||
item->setZValue(value ? item->zValue()+1 : item->zValue()-1);
|
||||
item->setZValue(value ? item->zValue() + 1 : item->zValue() - 1);
|
||||
}
|
||||
|
||||
int AbstractLayout::layoutSpacing() const
|
||||
{
|
||||
return m_layoutSpacing;
|
||||
}
|
||||
int AbstractLayout::layoutSpacing() const { return m_layoutSpacing; }
|
||||
|
||||
void AbstractLayout::setLayoutSpacing(int layoutSpacing)
|
||||
{
|
||||
if (m_layoutSpacing != layoutSpacing){
|
||||
if (m_layoutSpacing != layoutSpacing) {
|
||||
int oldValue = m_layoutSpacing;
|
||||
m_layoutSpacing = layoutSpacing;
|
||||
if (!isLoading()){
|
||||
int delta = (m_layoutSpacing - oldValue) * (m_children.count()-1);
|
||||
if (!isLoading()) {
|
||||
int delta = (m_layoutSpacing - oldValue) * (m_children.count() - 1);
|
||||
notify("layoutSpacing", oldValue, m_layoutSpacing);
|
||||
setWidth(width() + delta);
|
||||
}
|
||||
@@ -402,16 +371,13 @@ void AbstractLayout::setLayoutSpacing(int layoutSpacing)
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractLayout::hideEmptyItems() const
|
||||
{
|
||||
return m_hideEmptyItems;
|
||||
}
|
||||
bool AbstractLayout::hideEmptyItems() const { return m_hideEmptyItems; }
|
||||
|
||||
void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
|
||||
{
|
||||
m_hideEmptyItems = hideEmptyItems;
|
||||
|
||||
if (m_hideEmptyItems != hideEmptyItems){
|
||||
if (m_hideEmptyItems != hideEmptyItems) {
|
||||
m_hideEmptyItems = hideEmptyItems;
|
||||
notify("hideEmptyItems", !m_hideEmptyItems, m_hideEmptyItems);
|
||||
}
|
||||
@@ -420,13 +386,11 @@ void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
|
||||
QObject* AbstractLayout::at(int index)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
if (layoutsChildren().size() > index) return layoutsChildren()[index];
|
||||
if (layoutsChildren().size() > index)
|
||||
return layoutsChildren()[index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
LayoutMarker* AbstractLayout::layoutMarker() const
|
||||
{
|
||||
return m_layoutMarker;
|
||||
}
|
||||
LayoutMarker* AbstractLayout::layoutMarker() const { return m_layoutMarker; }
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -3,22 +3,25 @@
|
||||
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrlayoutmarker.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
class AbstractLayout: public LayoutDesignIntf
|
||||
{
|
||||
namespace LimeReport {
|
||||
class AbstractLayout: public LayoutDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool hideEmptyItems READ hideEmptyItems WRITE setHideEmptyItems)
|
||||
Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing)
|
||||
public:
|
||||
enum LayoutType{Layout,Table};
|
||||
enum LayoutType {
|
||||
Layout,
|
||||
Table
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(LayoutType)
|
||||
#else
|
||||
Q_ENUMS(LayoutType)
|
||||
#endif
|
||||
AbstractLayout(QString xmlTag, QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
AbstractLayout(QString xmlTag, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
~AbstractLayout();
|
||||
QList<BaseDesignIntf*>& layoutsChildren();
|
||||
LayoutMarker* layoutMarker() const;
|
||||
@@ -27,9 +30,9 @@ public:
|
||||
LayoutType layoutType() const;
|
||||
void setLayoutType(const LayoutType& layoutType);
|
||||
|
||||
void addChild(BaseDesignIntf *item,bool updateSize=true);
|
||||
void removeChild(BaseDesignIntf *item);
|
||||
void restoreChild(BaseDesignIntf *item);
|
||||
void addChild(BaseDesignIntf* item, bool updateSize = true);
|
||||
void removeChild(BaseDesignIntf* item);
|
||||
void restoreChild(BaseDesignIntf* item);
|
||||
bool isEmpty() const;
|
||||
void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter);
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
@@ -37,42 +40,45 @@ public:
|
||||
bool hideEmptyItems() const;
|
||||
void setHideEmptyItems(bool hideEmptyItems);
|
||||
Q_INVOKABLE QObject* at(int index);
|
||||
int childrenCount();
|
||||
int childrenCount();
|
||||
int layoutSpacing() const;
|
||||
void setLayoutSpacing(int layoutSpacing);
|
||||
qreal layoutSpacingMM(){ return m_layoutSpacing * Const::mmFACTOR;}
|
||||
qreal layoutSpacingMM() { return m_layoutSpacing * Const::mmFACTOR; }
|
||||
|
||||
protected:
|
||||
void beforeDelete();
|
||||
void childAddedEvent(BaseDesignIntf *child);
|
||||
void childAddedEvent(BaseDesignIntf* child);
|
||||
void geometryChangedEvent(QRectF newRect, QRectF);
|
||||
void initMode(ItemMode mode);
|
||||
void setBorderLinesFlags(BorderLines flags);
|
||||
void collectionLoadFinished(const QString &collectionName);
|
||||
void collectionLoadFinished(const QString& collectionName);
|
||||
void objectLoadFinished();
|
||||
bool isNeedUpdateSize(RenderPass pass) const;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant& value);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
void rebuildChildrenIfNeeded();
|
||||
void connectToLayout(BaseDesignIntf* item);
|
||||
void disconnectFromLayout(BaseDesignIntf* item);
|
||||
virtual void insertItemInLayout(BaseDesignIntf* item);
|
||||
|
||||
private:
|
||||
virtual void sortChildren() = 0;
|
||||
virtual void divideSpace() = 0;
|
||||
virtual void updateLayoutSize() = 0;
|
||||
virtual void relocateChildren() = 0;
|
||||
virtual BaseDesignIntf* findNext(BaseDesignIntf *item);
|
||||
virtual BaseDesignIntf* findPrior(BaseDesignIntf *item);
|
||||
virtual BaseDesignIntf* findNext(BaseDesignIntf* item);
|
||||
virtual BaseDesignIntf* findPrior(BaseDesignIntf* item);
|
||||
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
|
||||
|
||||
private slots:
|
||||
void slotOnChildDestroy(QObject *child);
|
||||
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
|
||||
void slotOnChildDestroy(QObject* child);
|
||||
void slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry);
|
||||
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
|
||||
void slotOnChildVisibleHasChanged(BaseDesignIntf*);
|
||||
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
|
||||
|
||||
private:
|
||||
QList<BaseDesignIntf *> m_children;
|
||||
QList<BaseDesignIntf*> m_children;
|
||||
bool m_isRelocating;
|
||||
LayoutMarker* m_layoutMarker;
|
||||
LayoutType m_layoutType;
|
||||
|
||||
@@ -28,54 +28,63 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lralignpropitem.h"
|
||||
#include "objectinspector/propertyItems/lrenumpropitem.h"
|
||||
#include "objectinspector/editors/lrcomboboxeditor.h"
|
||||
|
||||
#include "lrtextitem.h"
|
||||
#include "objectinspector/editors/lrcomboboxeditor.h"
|
||||
#include "objectinspector/propertyItems/lrenumpropitem.h"
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createAlignItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
|
||||
){
|
||||
return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("alignment","LimeReport::TextItem"),
|
||||
QObject::tr("alignment"),
|
||||
createAlignItem
|
||||
);
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createAlignItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("alignment", "LimeReport::TextItem"), QObject::tr("alignment"),
|
||||
createAlignItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QString AlignmentPropItem::associateValue(int value, const AlignMap* map) const
|
||||
{
|
||||
QString result;
|
||||
QMap<QString,Qt::Alignment>::const_iterator it = map->constBegin();
|
||||
for(;it!= map->constEnd();++it){
|
||||
QMap<QString, Qt::Alignment>::const_iterator it = map->constBegin();
|
||||
for (; it != map->constEnd(); ++it) {
|
||||
if ((value & it.value())) {
|
||||
if (result.isEmpty()) result+=it.key();
|
||||
else result=result+" | "+it.key();
|
||||
if (result.isEmpty())
|
||||
result += it.key();
|
||||
else
|
||||
result = result + " | " + it.key();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AlignmentPropItem::AlignmentPropItem(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)
|
||||
AlignmentPropItem::AlignmentPropItem(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)
|
||||
{
|
||||
|
||||
m_horizMap.insert(tr("Left"),Qt::AlignLeft);
|
||||
m_horizMap.insert(tr("Right"),Qt::AlignRight);
|
||||
m_horizMap.insert(tr("Center"),Qt::AlignHCenter);
|
||||
m_horizMap.insert(tr("Justify"),Qt::AlignJustify);
|
||||
m_horizMap.insert(tr("Left"), Qt::AlignLeft);
|
||||
m_horizMap.insert(tr("Right"), Qt::AlignRight);
|
||||
m_horizMap.insert(tr("Center"), Qt::AlignHCenter);
|
||||
m_horizMap.insert(tr("Justify"), Qt::AlignJustify);
|
||||
|
||||
m_vertMap.insert(tr("Top"),Qt::AlignTop);
|
||||
m_vertMap.insert(tr("Center"),Qt::AlignVCenter);
|
||||
m_vertMap.insert(tr("Botom"),Qt::AlignBottom);
|
||||
m_vertMap.insert(tr("Top"), Qt::AlignTop);
|
||||
m_vertMap.insert(tr("Center"), Qt::AlignVCenter);
|
||||
m_vertMap.insert(tr("Botom"), Qt::AlignBottom);
|
||||
|
||||
m_horizEditor = new AlignmentItemEditor(object, objects, name,tr("horizontal"),value.toInt(),this,false,m_horizMap);
|
||||
m_vertEditor = new AlignmentItemEditor(object, objects, name,tr("vertical"), value.toInt(),this,false,m_vertMap);
|
||||
m_horizEditor = new AlignmentItemEditor(object, objects, name, tr("horizontal"), value.toInt(),
|
||||
this, false, m_horizMap);
|
||||
m_vertEditor = new AlignmentItemEditor(object, objects, name, tr("vertical"), value.toInt(),
|
||||
this, false, m_vertMap);
|
||||
|
||||
this->appendItem(m_horizEditor);
|
||||
this->appendItem(m_vertEditor);
|
||||
@@ -83,8 +92,8 @@ AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, cons
|
||||
|
||||
QString AlignmentPropItem::displayValue() const
|
||||
{
|
||||
return associateValue(propertyValue().toInt(),&m_horizMap)+" | "+
|
||||
associateValue(propertyValue().toInt(),&m_vertMap);
|
||||
return associateValue(propertyValue().toInt(), &m_horizMap) + " | "
|
||||
+ associateValue(propertyValue().toInt(), &m_vertMap);
|
||||
}
|
||||
|
||||
void AlignmentPropItem::setPropertyValue(QVariant value)
|
||||
@@ -94,62 +103,67 @@ void AlignmentPropItem::setPropertyValue(QVariant value)
|
||||
ObjectPropItem::setPropertyValue(value);
|
||||
}
|
||||
|
||||
AlignmentItemEditor::AlignmentItemEditor(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent,
|
||||
bool readonly, AlignMap acceptableValues)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly),m_acceptableValues(acceptableValues)
|
||||
AlignmentItemEditor::AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly,
|
||||
AlignMap acceptableValues):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly),
|
||||
m_acceptableValues(acceptableValues)
|
||||
{
|
||||
if (! extractAcceptableValue(value.toInt()).isEmpty())
|
||||
if (!extractAcceptableValue(value.toInt()).isEmpty())
|
||||
setPropertyValue(extractAcceptableValue(value.toInt())[0]);
|
||||
else setPropertyValue(0);
|
||||
else
|
||||
setPropertyValue(0);
|
||||
}
|
||||
|
||||
void AlignmentItemEditor::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void AlignmentItemEditor::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
int flags = object()->property(propertyName().toLatin1()).toInt();
|
||||
int align = m_acceptableValues.value(qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
flags=clearAcceptableValues(flags) | align;
|
||||
object()->setProperty(propertyName().toLatin1(),flags);
|
||||
flags = clearAcceptableValues(flags) | align;
|
||||
object()->setProperty(propertyName().toLatin1(), flags);
|
||||
if (objects())
|
||||
foreach(QObject* item,*objects()){item->setProperty(propertyName().toLatin1(),flags);}
|
||||
foreach (QObject* item, *objects()) {
|
||||
item->setProperty(propertyName().toLatin1(), flags);
|
||||
}
|
||||
parent()->setPropertyValue(flags);
|
||||
model->setData(index,align);
|
||||
model->setData(index, align);
|
||||
}
|
||||
|
||||
QVector<int> AlignmentItemEditor::extractAcceptableValue(int flags)
|
||||
{
|
||||
QVector<int> result;
|
||||
AlignMap::const_iterator it = m_acceptableValues.constBegin();
|
||||
for (;it != m_acceptableValues.constEnd();++it)
|
||||
{
|
||||
if (flags & it.value()) result<<it.value();
|
||||
for (; it != m_acceptableValues.constEnd(); ++it) {
|
||||
if (flags & it.value())
|
||||
result << it.value();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int AlignmentItemEditor::clearAcceptableValues(int flags)
|
||||
{
|
||||
AlignMap::const_iterator it = m_acceptableValues.constBegin();
|
||||
for (;it != m_acceptableValues.constEnd();++it)
|
||||
{
|
||||
for (; it != m_acceptableValues.constEnd(); ++it) {
|
||||
if (flags & it.value())
|
||||
flags=flags^it.value();
|
||||
flags = flags ^ it.value();
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
QWidget *AlignmentItemEditor::createProperyEditor(QWidget *parent) const
|
||||
QWidget* AlignmentItemEditor::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent);
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent);
|
||||
QStringList enumValues;
|
||||
enumValues<<m_acceptableValues.keys();
|
||||
enumValues << m_acceptableValues.keys();
|
||||
editor->addItems(enumValues);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void AlignmentItemEditor::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void AlignmentItemEditor::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(m_acceptableValues.key(Qt::Alignment(propertyValue().toInt())));
|
||||
}
|
||||
|
||||
@@ -160,10 +174,11 @@ QString AlignmentItemEditor::displayValue() const
|
||||
|
||||
void AlignmentItemEditor::setPropertyValue(QVariant value)
|
||||
{
|
||||
QVector<int> _accpepttableValueList= extractAcceptableValue(value.toInt());
|
||||
if(_accpepttableValueList.isEmpty()) return;
|
||||
QVector<int> _accpepttableValueList = extractAcceptableValue(value.toInt());
|
||||
if (_accpepttableValueList.isEmpty())
|
||||
return;
|
||||
|
||||
ObjectPropItem::setPropertyValue(_accpepttableValueList[0]);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -33,48 +33,51 @@
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "objectinspector/propertyItems/lrenumpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
typedef QMap<QString,Qt::Alignment> AlignMap;
|
||||
typedef QMap<QString, Qt::Alignment> AlignMap;
|
||||
|
||||
class AlignmentItemEditor;
|
||||
|
||||
class AlignmentPropItem : public ObjectPropItem
|
||||
{
|
||||
class AlignmentPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AlignmentPropItem():ObjectPropItem(),m_horizEditor(NULL),m_vertEditor(NULL){}
|
||||
AlignmentPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly=true);
|
||||
AlignmentPropItem(): ObjectPropItem(), m_horizEditor(NULL), m_vertEditor(NULL) { }
|
||||
AlignmentPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true);
|
||||
QString displayValue() const;
|
||||
void setPropertyValue(QVariant value);
|
||||
|
||||
private:
|
||||
AlignMap m_vertMap;
|
||||
AlignMap m_horizMap;
|
||||
AlignmentItemEditor* m_horizEditor;
|
||||
AlignmentItemEditor* m_vertEditor;
|
||||
QString associateValue(int value, const AlignMap *map) const;
|
||||
QString associateValue(int value, const AlignMap* map) const;
|
||||
};
|
||||
|
||||
class AlignmentItemEditor : public ObjectPropItem
|
||||
{
|
||||
class AlignmentItemEditor: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AlignmentItemEditor():ObjectPropItem(){}
|
||||
AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly,
|
||||
AlignMap acceptableValues);
|
||||
void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
QString displayValue() const;
|
||||
AlignmentItemEditor(): ObjectPropItem() { }
|
||||
AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly, AlignMap acceptableValues);
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
QString displayValue() const;
|
||||
void setPropertyValue(QVariant value);
|
||||
|
||||
protected:
|
||||
QVector<int> extractAcceptableValue(int flags);
|
||||
int clearAcceptableValues(int flags);
|
||||
AlignMap acceptableValues() const {return m_acceptableValues;}
|
||||
QVector<int> extractAcceptableValue(int flags);
|
||||
int clearAcceptableValues(int flags);
|
||||
AlignMap acceptableValues() const { return m_acceptableValues; }
|
||||
|
||||
private:
|
||||
AlignMap m_acceptableValues;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRALIGNPROPITEM_H
|
||||
|
||||
@@ -28,44 +28,59 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbarcodeitem.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "qzint.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
namespace{
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "qzint.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "BarcodeItem";
|
||||
|
||||
LimeReport::BaseDesignIntf * createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::BarcodeItem(owner,parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(xmlTag, LimeReport::ItemAttribs(QObject::tr("Barcode Item"),"Item"), createBarcodeItem);
|
||||
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent)
|
||||
: ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(CODE128),
|
||||
m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0),
|
||||
m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(UNICODE_INPUT_MODE),
|
||||
m_hideText(false), m_option3(0), m_hideIfEmpty(false)
|
||||
{}
|
||||
|
||||
BarcodeItem::~BarcodeItem()
|
||||
{}
|
||||
|
||||
BaseDesignIntf *BarcodeItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
LimeReport::BaseDesignIntf* createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::BarcodeItem(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Barcode Item"), "Item"), createBarcodeItem);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
BarcodeItem::BarcodeItem(QObject* owner, QGraphicsItem* parent):
|
||||
ContentItemDesignIntf(xmlTag, owner, parent),
|
||||
m_designTestValue("1"),
|
||||
m_barcodeType(CODE128),
|
||||
m_foregroundColor(Qt::black),
|
||||
m_backgroundColor(Qt::white),
|
||||
m_whitespace(10),
|
||||
m_angle(Angle0),
|
||||
m_barcodeWidth(0),
|
||||
m_securityLevel(0),
|
||||
m_pdf417CodeWords(928),
|
||||
m_inputMode(UNICODE_INPUT_MODE),
|
||||
m_hideText(false),
|
||||
m_option3(0),
|
||||
m_hideIfEmpty(false)
|
||||
{
|
||||
return new BarcodeItem(owner,parent);
|
||||
}
|
||||
|
||||
void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
BarcodeItem::~BarcodeItem() { }
|
||||
|
||||
BaseDesignIntf* BarcodeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new BarcodeItem(owner, parent);
|
||||
}
|
||||
|
||||
void BarcodeItem::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ppainter->save();
|
||||
Zint::QZint bc;
|
||||
if (itemMode() & DesignMode) bc.setText(m_designTestValue);
|
||||
else bc.setText(m_content);
|
||||
if (itemMode() & DesignMode)
|
||||
bc.setText(m_designTestValue);
|
||||
else
|
||||
bc.setText(m_content);
|
||||
bc.setInputMode(m_inputMode);
|
||||
bc.setSymbol(m_barcodeType);
|
||||
bc.setWhitespace(m_whitespace);
|
||||
@@ -77,7 +92,8 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
|
||||
bc.setHideText(m_hideText);
|
||||
bc.setOption3(m_option3);
|
||||
|
||||
if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY);
|
||||
if (isSelected())
|
||||
ppainter->setOpacity(Const::SELECTION_OPACITY);
|
||||
|
||||
QRectF bcRect;
|
||||
|
||||
@@ -86,45 +102,42 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
|
||||
bcRect = rect();
|
||||
break;
|
||||
case Angle90:
|
||||
ppainter->translate(width(),0);
|
||||
ppainter->translate(width(), 0);
|
||||
ppainter->rotate(90);
|
||||
bcRect = QRectF(0,0,height(),width());
|
||||
bcRect = QRectF(0, 0, height(), width());
|
||||
break;
|
||||
case Angle180:
|
||||
bcRect = rect();
|
||||
ppainter->translate(width(),height());
|
||||
ppainter->translate(width(), height());
|
||||
ppainter->rotate(180);
|
||||
break;
|
||||
case Angle270:
|
||||
ppainter->translate(0,height());
|
||||
ppainter->translate(0, height());
|
||||
ppainter->rotate(270);
|
||||
bcRect = QRectF(0,0,height(),width());
|
||||
bcRect = QRectF(0, 0, height(), width());
|
||||
break;
|
||||
}
|
||||
|
||||
bc.render(*ppainter,bcRect);
|
||||
bc.render(*ppainter, bcRect);
|
||||
ppainter->restore();
|
||||
ItemDesignIntf::paint(ppainter,option,widget);
|
||||
ItemDesignIntf::paint(ppainter, option, widget);
|
||||
}
|
||||
|
||||
void BarcodeItem::setContent(const QString &content)
|
||||
void BarcodeItem::setContent(const QString& content)
|
||||
{
|
||||
if (m_content!=content){
|
||||
if (m_content != content) {
|
||||
QString oldValue = m_content;
|
||||
m_content=content;
|
||||
m_content = content;
|
||||
update();
|
||||
notify("content",oldValue,m_content);
|
||||
notify("content", oldValue, m_content);
|
||||
}
|
||||
}
|
||||
|
||||
QString BarcodeItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString BarcodeItem::datasource() const { return m_datasource; }
|
||||
|
||||
void BarcodeItem::setDatasource(const QString &datasource)
|
||||
void BarcodeItem::setDatasource(const QString& datasource)
|
||||
{
|
||||
if (m_datasource != datasource){
|
||||
if (m_datasource != datasource) {
|
||||
QString oldValue = m_datasource;
|
||||
m_datasource = datasource;
|
||||
update();
|
||||
@@ -132,14 +145,11 @@ void BarcodeItem::setDatasource(const QString &datasource)
|
||||
}
|
||||
}
|
||||
|
||||
QString BarcodeItem::field() const
|
||||
{
|
||||
return m_field;
|
||||
}
|
||||
QString BarcodeItem::field() const { return m_field; }
|
||||
|
||||
void BarcodeItem::setField(const QString &field)
|
||||
void BarcodeItem::setField(const QString& field)
|
||||
{
|
||||
if (m_field != field){
|
||||
if (m_field != field) {
|
||||
QString oldValue = m_field;
|
||||
m_field = field;
|
||||
update();
|
||||
@@ -149,189 +159,162 @@ void BarcodeItem::setField(const QString &field)
|
||||
|
||||
void BarcodeItem::setBarcodeType(BarcodeItem::BarcodeType value)
|
||||
{
|
||||
if (m_barcodeType!=value){
|
||||
if (m_barcodeType != value) {
|
||||
BarcodeType oldValue = m_barcodeType;
|
||||
m_barcodeType = value;
|
||||
update();
|
||||
notify("barcodeType",oldValue,value);
|
||||
notify("barcodeType", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setDesignTestValue(QString value)
|
||||
{
|
||||
if (m_designTestValue!=value){
|
||||
if (m_designTestValue != value) {
|
||||
QString oldValue = m_designTestValue;
|
||||
m_designTestValue=value;
|
||||
m_designTestValue = value;
|
||||
update();
|
||||
notify("testValue",oldValue,value);
|
||||
notify("testValue", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setForegroundColor(QColor value)
|
||||
{
|
||||
if (m_foregroundColor != value){
|
||||
if (m_foregroundColor != value) {
|
||||
QColor oldValue = m_foregroundColor;
|
||||
m_foregroundColor=value;
|
||||
m_foregroundColor = value;
|
||||
update();
|
||||
notify("foregroundColor",oldValue,value);
|
||||
notify("foregroundColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setBackgroundColor(QColor value)
|
||||
{
|
||||
if (m_backgroundColor != value){
|
||||
if (m_backgroundColor != value) {
|
||||
QColor oldValue = m_backgroundColor;
|
||||
m_backgroundColor=value;
|
||||
m_backgroundColor = value;
|
||||
update();
|
||||
notify("backgroundColor",oldValue,value);
|
||||
notify("backgroundColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setWhitespace(int value)
|
||||
{
|
||||
if (m_whitespace != value){
|
||||
if (m_whitespace != value) {
|
||||
int oldValue = m_whitespace;
|
||||
m_whitespace = value;
|
||||
update();
|
||||
notify("whitespace",oldValue,value);
|
||||
notify("whitespace", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::AngleType BarcodeItem::angle() const
|
||||
{
|
||||
return m_angle;
|
||||
}
|
||||
BarcodeItem::AngleType BarcodeItem::angle() const { return m_angle; }
|
||||
|
||||
void BarcodeItem::setAngle(const AngleType &angle)
|
||||
void BarcodeItem::setAngle(const AngleType& angle)
|
||||
{
|
||||
if (m_angle!=angle){
|
||||
if (m_angle != angle) {
|
||||
AngleType oldValue = m_angle;
|
||||
m_angle = angle;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("angle",oldValue,angle);
|
||||
notify("angle", oldValue, angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::barcodeWidth() const
|
||||
{
|
||||
return m_barcodeWidth;
|
||||
}
|
||||
int BarcodeItem::barcodeWidth() const { return m_barcodeWidth; }
|
||||
|
||||
void BarcodeItem::setBarcodeWidth(int barcodeWidth)
|
||||
{
|
||||
if (m_barcodeWidth != barcodeWidth){
|
||||
if (m_barcodeWidth != barcodeWidth) {
|
||||
int oldValue = m_barcodeWidth;
|
||||
m_barcodeWidth = barcodeWidth;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("barcodeWidth",oldValue,m_barcodeWidth);
|
||||
notify("barcodeWidth", oldValue, m_barcodeWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::securityLevel() const
|
||||
{
|
||||
return m_securityLevel;
|
||||
}
|
||||
int BarcodeItem::securityLevel() const { return m_securityLevel; }
|
||||
|
||||
void BarcodeItem::setSecurityLevel(int securityLevel)
|
||||
{
|
||||
if (m_securityLevel != securityLevel){
|
||||
if (m_securityLevel != securityLevel) {
|
||||
int oldValue = m_securityLevel;
|
||||
m_securityLevel = securityLevel;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("securityLevel",oldValue,m_securityLevel);
|
||||
notify("securityLevel", oldValue, m_securityLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::pdf417CodeWords() const
|
||||
{
|
||||
return m_pdf417CodeWords;
|
||||
}
|
||||
int BarcodeItem::pdf417CodeWords() const { return m_pdf417CodeWords; }
|
||||
|
||||
void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
|
||||
{
|
||||
if (m_pdf417CodeWords != pdf417CodeWords){
|
||||
if (m_pdf417CodeWords != pdf417CodeWords) {
|
||||
int oldValue = m_pdf417CodeWords;
|
||||
m_pdf417CodeWords = pdf417CodeWords;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("pdf417CodeWords",oldValue,m_pdf417CodeWords);
|
||||
notify("pdf417CodeWords", oldValue, m_pdf417CodeWords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const
|
||||
{
|
||||
return m_inputMode;
|
||||
}
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const { return m_inputMode; }
|
||||
|
||||
void BarcodeItem::setInputMode(const InputMode &inputMode)
|
||||
void BarcodeItem::setInputMode(const InputMode& inputMode)
|
||||
{
|
||||
if (m_inputMode != inputMode){
|
||||
if (m_inputMode != inputMode) {
|
||||
InputMode oldValue = m_inputMode;
|
||||
m_inputMode = inputMode;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("inputMode",oldValue,inputMode);
|
||||
notify("inputMode", oldValue, inputMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::hideText() const
|
||||
{
|
||||
return m_hideText;
|
||||
}
|
||||
bool BarcodeItem::hideText() const { return m_hideText; }
|
||||
|
||||
void BarcodeItem::setHideText(bool hideText)
|
||||
{
|
||||
if (m_hideText != hideText){
|
||||
if (m_hideText != hideText) {
|
||||
m_hideText = hideText;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("hideText", !m_hideText, m_hideText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::option3() const
|
||||
{
|
||||
return m_option3;
|
||||
}
|
||||
int BarcodeItem::option3() const { return m_option3; }
|
||||
|
||||
void BarcodeItem::setOption3(int option3)
|
||||
{
|
||||
if (m_option3 != option3){
|
||||
if (m_option3 != option3) {
|
||||
int oldValue = m_option3;
|
||||
m_option3 = option3;
|
||||
if(!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("option3", oldValue, m_option3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::hideIfEmpty() const
|
||||
{
|
||||
return m_hideIfEmpty;
|
||||
}
|
||||
bool BarcodeItem::hideIfEmpty() const { return m_hideIfEmpty; }
|
||||
|
||||
void BarcodeItem::setHideIfEmpty(bool hideIfEmpty)
|
||||
{
|
||||
if (m_hideIfEmpty != hideIfEmpty){
|
||||
if (m_hideIfEmpty != hideIfEmpty) {
|
||||
m_hideIfEmpty = hideIfEmpty;
|
||||
notify("hideIfEmpty",!m_hideIfEmpty, m_hideIfEmpty);
|
||||
notify("hideIfEmpty", !m_hideIfEmpty, m_hideIfEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::isEmpty() const
|
||||
{
|
||||
return m_content.isEmpty();
|
||||
}
|
||||
bool BarcodeItem::isEmpty() const { return m_content.isEmpty(); }
|
||||
|
||||
void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, RenderPass pass)
|
||||
{
|
||||
@@ -342,28 +325,23 @@ void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, Re
|
||||
|
||||
void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
if (content().isEmpty())
|
||||
{
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty())
|
||||
{
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds)
|
||||
{
|
||||
QVariant data = ds->data(m_field);
|
||||
if (data.isValid())
|
||||
{
|
||||
switch(pass)
|
||||
{
|
||||
case FirstPass:
|
||||
expandContent(data.toString(), dataManager, pass);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (content().isEmpty()) {
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()) {
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
if (data.isValid()) {
|
||||
switch (pass) {
|
||||
case FirstPass:
|
||||
expandContent(data.toString(), dataManager, pass);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(pass){
|
||||
switch (pass) {
|
||||
case FirstPass:
|
||||
expandContent(content(), dataManager, pass);
|
||||
break;
|
||||
@@ -371,10 +349,13 @@ void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass
|
||||
}
|
||||
}
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
if (isEmpty() && hideIfEmpty()) setVisible(false);
|
||||
if (isEmpty() && hideIfEmpty())
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
bool BarcodeItem::isNeedUpdateSize(RenderPass pass) const
|
||||
{return (pass==FirstPass)?true:false;}
|
||||
|
||||
{
|
||||
return (pass == FirstPass) ? true : false;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
#ifndef LRBARCODEITEM_H
|
||||
#define LRBARCODEITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class BarcodeItem : public LimeReport::ContentItemDesignIntf {
|
||||
class BarcodeItem: public LimeReport::ContentItemDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString content READ content WRITE setContent)
|
||||
Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType)
|
||||
@@ -54,103 +55,107 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf {
|
||||
Q_PROPERTY(bool hideIfEmpty READ hideIfEmpty WRITE setHideIfEmpty)
|
||||
public:
|
||||
enum BarcodeType {
|
||||
CODE11 =1,
|
||||
C25MATRIX =2,
|
||||
C25INTER =3,
|
||||
C25IATA =4,
|
||||
C25LOGIC =6,
|
||||
C25IND =7,
|
||||
CODE39 =8,
|
||||
EXCODE39 =9,
|
||||
EANX =13,
|
||||
EANX_CHK =14,
|
||||
EAN128 =16,
|
||||
CODABAR =18,
|
||||
CODE128 =20,
|
||||
DPLEIT =21,
|
||||
DPIDENT =22,
|
||||
CODE16K =23,
|
||||
CODE93 =25,
|
||||
FLAT =28,
|
||||
RSS14 =29,
|
||||
RSS_LTD =30,
|
||||
RSS_EXP =31,
|
||||
TELEPEN =32,
|
||||
UPCA =34,
|
||||
UPCE =37,
|
||||
POSTNET =40,
|
||||
MSI_PLESSEY =47,
|
||||
FIM =49,
|
||||
LOGMARS =50,
|
||||
PHARMA =51,
|
||||
PZN =52,
|
||||
PHARMA_TWO =53,
|
||||
PDF417 =55,
|
||||
PDF417TRUNC =56,
|
||||
MAXICODE =57,
|
||||
QRCODE =58,
|
||||
CODE128B =60,
|
||||
AUSPOST =63,
|
||||
AUSREPLY =66,
|
||||
AUSROUTE =67,
|
||||
AUSREDIRECT =68,
|
||||
ISBNX =69,
|
||||
RM4SCC =70,
|
||||
DATAMATRIX =71,
|
||||
ITF14 =72,
|
||||
CODABLOCKF =74,
|
||||
NVE18 =75,
|
||||
KOREAPOST =77,
|
||||
RSS14STACK =79,
|
||||
RSS14STACK_OMNI =80,
|
||||
RSS_EXPSTACK =81,
|
||||
PLANET =82,
|
||||
MICROPDF417 =84,
|
||||
ONECODE =85,
|
||||
PLESSEY =86,
|
||||
KIX =90,
|
||||
AZTEC =92,
|
||||
DAFT =93,
|
||||
ITALYPOST =94,
|
||||
DPD =96,
|
||||
MICROQR =97,
|
||||
HIBC_128 =98,
|
||||
HIBC_39 =99,
|
||||
HIBC_DM =102,
|
||||
HIBC_QR =104,
|
||||
HIBC_PDF =106,
|
||||
HIBC_MICPDF =108,
|
||||
HIBC_BLOCKF =110,
|
||||
HIBC_AZTEC =112,
|
||||
DOTCODE =115,
|
||||
HANXIN =116,
|
||||
TELEPEN_NUM =128,
|
||||
CODE32 =129,
|
||||
// EANX_CC =130,
|
||||
// EAN128_CC =131,
|
||||
// RSS14_CC =132,
|
||||
// RSS_LTD_CC =133,
|
||||
// RSS_EXP_CC =134,
|
||||
// UPCA_CC =135,
|
||||
// UPCE_CC =136,
|
||||
// RSS14STACK_CC =137,
|
||||
// RSS14_OMNI_CC =138,
|
||||
// RSS_EXPSTACK_CC =139,
|
||||
CHANNEL =140,
|
||||
CODEONE =141,
|
||||
GRIDMATRIX =142,
|
||||
UPNQR =143
|
||||
|
||||
CODE11 = 1,
|
||||
C25MATRIX = 2,
|
||||
C25INTER = 3,
|
||||
C25IATA = 4,
|
||||
C25LOGIC = 6,
|
||||
C25IND = 7,
|
||||
CODE39 = 8,
|
||||
EXCODE39 = 9,
|
||||
EANX = 13,
|
||||
EANX_CHK = 14,
|
||||
EAN128 = 16,
|
||||
CODABAR = 18,
|
||||
CODE128 = 20,
|
||||
DPLEIT = 21,
|
||||
DPIDENT = 22,
|
||||
CODE16K = 23,
|
||||
CODE93 = 25,
|
||||
FLAT = 28,
|
||||
RSS14 = 29,
|
||||
RSS_LTD = 30,
|
||||
RSS_EXP = 31,
|
||||
TELEPEN = 32,
|
||||
UPCA = 34,
|
||||
UPCE = 37,
|
||||
POSTNET = 40,
|
||||
MSI_PLESSEY = 47,
|
||||
FIM = 49,
|
||||
LOGMARS = 50,
|
||||
PHARMA = 51,
|
||||
PZN = 52,
|
||||
PHARMA_TWO = 53,
|
||||
PDF417 = 55,
|
||||
PDF417TRUNC = 56,
|
||||
MAXICODE = 57,
|
||||
QRCODE = 58,
|
||||
CODE128B = 60,
|
||||
AUSPOST = 63,
|
||||
AUSREPLY = 66,
|
||||
AUSROUTE = 67,
|
||||
AUSREDIRECT = 68,
|
||||
ISBNX = 69,
|
||||
RM4SCC = 70,
|
||||
DATAMATRIX = 71,
|
||||
ITF14 = 72,
|
||||
CODABLOCKF = 74,
|
||||
NVE18 = 75,
|
||||
KOREAPOST = 77,
|
||||
RSS14STACK = 79,
|
||||
RSS14STACK_OMNI = 80,
|
||||
RSS_EXPSTACK = 81,
|
||||
PLANET = 82,
|
||||
MICROPDF417 = 84,
|
||||
ONECODE = 85,
|
||||
PLESSEY = 86,
|
||||
KIX = 90,
|
||||
AZTEC = 92,
|
||||
DAFT = 93,
|
||||
ITALYPOST = 94,
|
||||
DPD = 96,
|
||||
MICROQR = 97,
|
||||
HIBC_128 = 98,
|
||||
HIBC_39 = 99,
|
||||
HIBC_DM = 102,
|
||||
HIBC_QR = 104,
|
||||
HIBC_PDF = 106,
|
||||
HIBC_MICPDF = 108,
|
||||
HIBC_BLOCKF = 110,
|
||||
HIBC_AZTEC = 112,
|
||||
DOTCODE = 115,
|
||||
HANXIN = 116,
|
||||
TELEPEN_NUM = 128,
|
||||
CODE32 = 129,
|
||||
// EANX_CC =130,
|
||||
// EAN128_CC =131,
|
||||
// RSS14_CC =132,
|
||||
// RSS_LTD_CC =133,
|
||||
// RSS_EXP_CC =134,
|
||||
// UPCA_CC =135,
|
||||
// UPCE_CC =136,
|
||||
// RSS14STACK_CC =137,
|
||||
// RSS14_OMNI_CC =138,
|
||||
// RSS_EXPSTACK_CC =139,
|
||||
CHANNEL = 140,
|
||||
CODEONE = 141,
|
||||
GRIDMATRIX = 142,
|
||||
UPNQR = 143
|
||||
};
|
||||
|
||||
enum AngleType{Angle0,Angle90,Angle180,Angle270};
|
||||
enum AngleType {
|
||||
Angle0,
|
||||
Angle90,
|
||||
Angle180,
|
||||
Angle270
|
||||
};
|
||||
|
||||
enum InputMode{
|
||||
DATA_INPUT_MODE = 0,
|
||||
UNICODE_INPUT_MODE = 1,
|
||||
GS1_INPUT_MODE = 2,
|
||||
KANJI_INPUT_MODE = 3,
|
||||
SJIS_INPUT_MODE = 4
|
||||
enum InputMode {
|
||||
DATA_INPUT_MODE = 0,
|
||||
UNICODE_INPUT_MODE = 1,
|
||||
GS1_INPUT_MODE = 2,
|
||||
KANJI_INPUT_MODE = 3,
|
||||
SJIS_INPUT_MODE = 4
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(BarcodeType)
|
||||
@@ -161,30 +166,30 @@ public:
|
||||
Q_ENUMS(AngleType)
|
||||
Q_ENUMS(InputMode)
|
||||
#endif
|
||||
BarcodeItem(QObject *owner, QGraphicsItem *parent);
|
||||
BarcodeItem(QObject* owner, QGraphicsItem* parent);
|
||||
~BarcodeItem();
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
virtual void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
virtual void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
virtual void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
virtual bool isNeedUpdateSize(RenderPass pass) const;
|
||||
void setContent(const QString& content);
|
||||
QString content() const {return m_content;}
|
||||
QString content() const { return m_content; }
|
||||
void setBarcodeType(BarcodeType value);
|
||||
BarcodeType barcodeType(){return m_barcodeType;}
|
||||
BarcodeType barcodeType() { return m_barcodeType; }
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
QString field() const;
|
||||
void setField(const QString &field);
|
||||
void setField(const QString& field);
|
||||
void setDesignTestValue(QString value);
|
||||
QString designTestValue(){return m_designTestValue;}
|
||||
QColor foregroundColor(){return m_foregroundColor;}
|
||||
QString designTestValue() { return m_designTestValue; }
|
||||
QColor foregroundColor() { return m_foregroundColor; }
|
||||
void setForegroundColor(QColor value);
|
||||
QColor backgroundColor(){return m_backgroundColor;}
|
||||
QColor backgroundColor() { return m_backgroundColor; }
|
||||
void setBackgroundColor(QColor value);
|
||||
int whitespace(){return m_whitespace;}
|
||||
int whitespace() { return m_whitespace; }
|
||||
void setWhitespace(int value);
|
||||
AngleType angle() const;
|
||||
void setAngle(const AngleType &angle);
|
||||
void setAngle(const AngleType& angle);
|
||||
int barcodeWidth() const;
|
||||
void setBarcodeWidth(int barcodeWidth);
|
||||
int securityLevel() const;
|
||||
@@ -192,7 +197,7 @@ public:
|
||||
int pdf417CodeWords() const;
|
||||
void setPdf417CodeWords(int pdf417CodeWords);
|
||||
InputMode inputMode() const;
|
||||
void setInputMode(const InputMode &inputMode);
|
||||
void setInputMode(const InputMode& inputMode);
|
||||
bool hideText() const;
|
||||
void setHideText(bool hideText);
|
||||
int option3() const;
|
||||
@@ -202,7 +207,7 @@ public:
|
||||
bool isEmpty() const;
|
||||
|
||||
private:
|
||||
void expandContent(QString data, DataSourceManager *dataManager, RenderPass pass);
|
||||
void expandContent(QString data, DataSourceManager* dataManager, RenderPass pass);
|
||||
|
||||
private:
|
||||
QString m_content;
|
||||
@@ -223,5 +228,5 @@ private:
|
||||
bool m_hideIfEmpty;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRBARCODEITEM_H
|
||||
|
||||
@@ -1,34 +1,39 @@
|
||||
#include "lrbordereditor.h"
|
||||
#include "ui_lrbordereditor.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QColorDialog>
|
||||
|
||||
BorderEditor::BorderEditor(QWidget *parent) :
|
||||
namespace LimeReport {
|
||||
|
||||
BorderEditor::BorderEditor(QWidget* parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::BorderEditor),
|
||||
m_borderStyle(1),
|
||||
m_borderWidth(1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(
|
||||
ui->borderFrame, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)),
|
||||
this, SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool))
|
||||
);
|
||||
connect(ui->borderFrame,
|
||||
SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), this,
|
||||
SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool)));
|
||||
}
|
||||
|
||||
void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item)
|
||||
void BorderEditor::loadItem(LimeReport::BaseDesignIntf* item)
|
||||
{
|
||||
m_item = item;
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::TopLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::TopLine);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::LeftLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::LeftLine);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::RightLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::RightLine);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::BottomLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::BottomLine);
|
||||
|
||||
QPen pen;
|
||||
pen.setWidthF(item->borderLineSize());
|
||||
@@ -39,7 +44,7 @@ void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item)
|
||||
ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle());
|
||||
ui->comboBox->setCurrentText(QString::number(item->borderLineSize()));
|
||||
m_borderWidth = ui->comboBox->currentText().toDouble();
|
||||
m_borderStyle =ui->listWidget->currentRow();
|
||||
m_borderStyle = ui->listWidget->currentRow();
|
||||
ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor));
|
||||
}
|
||||
|
||||
@@ -50,28 +55,19 @@ LimeReport::BaseDesignIntf::BorderLines BorderEditor::borderSides()
|
||||
borders += (ui->bottomLine->isChecked()) ? LimeReport::BaseDesignIntf::BottomLine : 0;
|
||||
borders += (ui->leftLine->isChecked()) ? LimeReport::BaseDesignIntf::LeftLine : 0;
|
||||
borders += (ui->rightLine->isChecked()) ? LimeReport::BaseDesignIntf::RightLine : 0;
|
||||
return (LimeReport::BaseDesignIntf::BorderLines) borders;
|
||||
return (LimeReport::BaseDesignIntf::BorderLines)borders;
|
||||
}
|
||||
|
||||
LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle()
|
||||
{
|
||||
return (LimeReport::BaseDesignIntf::BorderStyle) m_borderStyle;
|
||||
return (LimeReport::BaseDesignIntf::BorderStyle)m_borderStyle;
|
||||
}
|
||||
|
||||
QString BorderEditor::borderColor()
|
||||
{
|
||||
return m_borderColor;
|
||||
}
|
||||
QString BorderEditor::borderColor() { return m_borderColor; }
|
||||
|
||||
double BorderEditor::borderWidth()
|
||||
{
|
||||
return m_borderWidth;
|
||||
}
|
||||
double BorderEditor::borderWidth() { return m_borderWidth; }
|
||||
|
||||
BorderEditor::~BorderEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
BorderEditor::~BorderEditor() { delete ui; }
|
||||
|
||||
void BorderEditor::on_listWidget_currentRowChanged(int currentRow)
|
||||
{
|
||||
@@ -81,7 +77,7 @@ void BorderEditor::on_listWidget_currentRowChanged(int currentRow)
|
||||
ui->borderFrame->setPen(pen);
|
||||
}
|
||||
|
||||
void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1)
|
||||
void BorderEditor::on_comboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
QPen pen = ui->borderFrame->pen();
|
||||
pen.setWidthF(arg1.toDouble());
|
||||
@@ -91,61 +87,69 @@ void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1)
|
||||
|
||||
void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
ui->topLine->setChecked(check);
|
||||
break;
|
||||
case BaseDesignIntf::BorderSide::BottomLine:
|
||||
ui->bottomLine->setChecked(check);
|
||||
break;
|
||||
case BaseDesignIntf::BorderSide::LeftLine:
|
||||
ui->leftLine->setChecked(check);
|
||||
break;
|
||||
case BaseDesignIntf::BorderSide::RightLine:
|
||||
ui->rightLine->setChecked(check);
|
||||
break;
|
||||
switch (side) {
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
ui->topLine->setChecked(check);
|
||||
break;
|
||||
case BaseDesignIntf::BorderSide::BottomLine:
|
||||
ui->bottomLine->setChecked(check);
|
||||
break;
|
||||
case BaseDesignIntf::BorderSide::LeftLine:
|
||||
ui->leftLine->setChecked(check);
|
||||
break;
|
||||
case BaseDesignIntf::BorderSide::RightLine:
|
||||
ui->rightLine->setChecked(check);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BorderEditor::on_topLine_clicked(bool checked){
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, checked);
|
||||
void BorderEditor::on_topLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,
|
||||
checked);
|
||||
}
|
||||
|
||||
void BorderEditor::on_bottomLine_clicked(bool checked){
|
||||
void BorderEditor::on_bottomLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, checked);
|
||||
}
|
||||
|
||||
void BorderEditor::on_leftLine_clicked(bool checked){
|
||||
void BorderEditor::on_leftLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, checked);
|
||||
}
|
||||
|
||||
void BorderEditor::on_rightLine_clicked(bool checked){
|
||||
void BorderEditor::on_rightLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::RightLine, checked);
|
||||
}
|
||||
|
||||
|
||||
void BorderEditor::on_allLines_clicked()
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
|
||||
true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
|
||||
true);
|
||||
}
|
||||
|
||||
void BorderEditor::on_noLines_clicked()
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
|
||||
false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,
|
||||
false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
void BorderEditor::on_selectColor_clicked()
|
||||
{
|
||||
QColorDialog cd(this);
|
||||
if(cd.exec() == QDialog::Rejected) return;
|
||||
if (cd.exec() == QDialog::Rejected)
|
||||
return;
|
||||
QPen pen = ui->borderFrame->pen();
|
||||
pen.setColor(cd.selectedColor().name());
|
||||
m_borderColor = pen.color().name();
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
#ifndef LRBORDEREDITOR_H
|
||||
#define LRBORDEREDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QDialog>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class BorderEditor;
|
||||
}
|
||||
|
||||
|
||||
class LIMEREPORT_EXPORT BorderEditor : public QDialog
|
||||
{
|
||||
class LIMEREPORT_EXPORT BorderEditor: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BorderEditor(QWidget *parent = nullptr);
|
||||
void loadItem(LimeReport::BaseDesignIntf *item);
|
||||
explicit BorderEditor(QWidget* parent = nullptr);
|
||||
void loadItem(LimeReport::BaseDesignIntf* item);
|
||||
LimeReport::BaseDesignIntf::BorderLines borderSides();
|
||||
LimeReport::BaseDesignIntf::BorderStyle borderStyle();
|
||||
QString borderColor();
|
||||
@@ -26,7 +25,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void on_listWidget_currentRowChanged(int currentRow);
|
||||
void on_comboBox_currentTextChanged(const QString &arg1);
|
||||
void on_comboBox_currentTextChanged(const QString& arg1);
|
||||
void on_noLines_clicked();
|
||||
void on_topLine_clicked(bool checked);
|
||||
void on_bottomLine_clicked(bool checked);
|
||||
@@ -37,8 +36,8 @@ private slots:
|
||||
void on_selectColor_clicked();
|
||||
|
||||
private:
|
||||
Ui::BorderEditor *ui;
|
||||
LimeReport::BaseDesignIntf *m_item;
|
||||
Ui::BorderEditor* ui;
|
||||
LimeReport::BaseDesignIntf* m_item;
|
||||
QString m_borderColor;
|
||||
int m_borderStyle;
|
||||
double m_borderWidth;
|
||||
|
||||
@@ -1,57 +1,56 @@
|
||||
#include "lrborderframeeditor.h"
|
||||
#include "ui_lrborderframeeditor.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrbordereditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QDebug>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
BorderFrameEditor::BorderFrameEditor(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::BorderFrameEditor)
|
||||
namespace LimeReport {
|
||||
|
||||
BorderFrameEditor::BorderFrameEditor(QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::BorderFrameEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
scene = new QGraphicsScene(ui->graphicsView);
|
||||
|
||||
QRect vRect = rect();
|
||||
|
||||
//Draw corder lines
|
||||
//topLeft
|
||||
// Draw corder lines
|
||||
// topLeft
|
||||
scene->addLine(10, 5, 10, 10, QPen(Qt::gray));
|
||||
scene->addLine(5, 10, 10, 10, QPen(Qt::gray));
|
||||
//bottomLeft
|
||||
scene->addLine(10,vRect.bottom() -5, 10, vRect.bottom()-10, QPen(Qt::gray));
|
||||
scene->addLine(5,vRect.bottom()-10, 10, vRect.bottom()-10, QPen(Qt::gray));
|
||||
//bottomRight
|
||||
scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right()- 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
//topRight
|
||||
// bottomLeft
|
||||
scene->addLine(10, vRect.bottom() - 5, 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
scene->addLine(5, vRect.bottom() - 10, 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
// bottomRight
|
||||
scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right() - 10, vRect.bottom() - 10,
|
||||
QPen(Qt::gray));
|
||||
scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10,
|
||||
QPen(Qt::gray));
|
||||
// topRight
|
||||
scene->addLine(vRect.width() - 10, 5, vRect.width() - 10, 10, QPen(Qt::gray));
|
||||
scene->addLine(vRect.width() - 5, 10, vRect.width() - 10, 10, QPen(Qt::gray));
|
||||
scene->setSceneRect(vRect);
|
||||
ui->graphicsView->setScene(scene);
|
||||
QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem();
|
||||
QGraphicsSimpleTextItem* io = new QGraphicsSimpleTextItem();
|
||||
io->setAcceptedMouseButtons(Qt::LeftButton);
|
||||
io->setPos(scene->sceneRect().center());
|
||||
io->setText(tr("Text"));
|
||||
scene->addItem(io);
|
||||
|
||||
QRectF bR = io->sceneBoundingRect();
|
||||
io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 );
|
||||
connect(
|
||||
this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)),
|
||||
this, SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool))
|
||||
);
|
||||
|
||||
io->setPos(scene->sceneRect().center().x() - bR.width() / 2,
|
||||
scene->sceneRect().center().y() - bR.height() / 2);
|
||||
connect(this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), this,
|
||||
SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)));
|
||||
}
|
||||
|
||||
BorderFrameEditor::~BorderFrameEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
BorderFrameEditor::~BorderFrameEditor() { delete ui; }
|
||||
|
||||
void BorderFrameEditor::setPen(QPen pen)
|
||||
{
|
||||
@@ -59,10 +58,7 @@ void BorderFrameEditor::setPen(QPen pen)
|
||||
updateBorders();
|
||||
}
|
||||
|
||||
QPen BorderFrameEditor::pen()
|
||||
{
|
||||
return m_pen;
|
||||
}
|
||||
QPen BorderFrameEditor::pen() { return m_pen; }
|
||||
|
||||
void BorderFrameEditor::setAllLines()
|
||||
{
|
||||
@@ -78,34 +74,33 @@ void BorderFrameEditor::setAllLines()
|
||||
|
||||
void BorderFrameEditor::unSetAllLines()
|
||||
{
|
||||
if (topLine){
|
||||
if (topLine) {
|
||||
scene->removeItem(topLine);
|
||||
topLine = NULL;
|
||||
}
|
||||
if (leftLine){
|
||||
if (leftLine) {
|
||||
scene->removeItem(leftLine);
|
||||
leftLine = NULL;
|
||||
}
|
||||
if (bottomLine){
|
||||
if (bottomLine) {
|
||||
scene->removeItem(bottomLine);
|
||||
bottomLine = NULL;
|
||||
}
|
||||
if (rightLine){
|
||||
if (rightLine) {
|
||||
scene->removeItem(rightLine);
|
||||
rightLine = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BorderFrameEditor::mousePressEvent(QMouseEvent *event)
|
||||
void BorderFrameEditor::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->x() >= 10 && event->y() <30)
|
||||
if (event->x() >= 10 && event->y() < 30)
|
||||
emit borderSideClicked(BaseDesignIntf::BorderSide::TopLine, !topLine);
|
||||
|
||||
if ((event->x() >= 10 && event->x() < 30) && (event->y() > 10))
|
||||
emit borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, !leftLine);
|
||||
|
||||
if (event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom()))
|
||||
if (event->x() >= 10 && (event->y() > 80 && event->y() < rect().bottom()))
|
||||
emit borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, !bottomLine);
|
||||
|
||||
if ((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10)
|
||||
@@ -115,67 +110,80 @@ void BorderFrameEditor::mousePressEvent(QMouseEvent *event)
|
||||
void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, bool show)
|
||||
{
|
||||
|
||||
switch(side){
|
||||
switch (side) {
|
||||
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
if (show){
|
||||
if (!topLine) topLine = createSideLine(side);
|
||||
if (show) {
|
||||
if (!topLine)
|
||||
topLine = createSideLine(side);
|
||||
} else {
|
||||
if (topLine) scene->removeItem(topLine);
|
||||
if (topLine)
|
||||
scene->removeItem(topLine);
|
||||
topLine = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseDesignIntf::LeftLine:
|
||||
if (show){
|
||||
if (!leftLine) leftLine = createSideLine(side);
|
||||
if (show) {
|
||||
if (!leftLine)
|
||||
leftLine = createSideLine(side);
|
||||
} else {
|
||||
if (leftLine) scene->removeItem(leftLine);
|
||||
if (leftLine)
|
||||
scene->removeItem(leftLine);
|
||||
leftLine = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseDesignIntf::BottomLine:
|
||||
if (show){
|
||||
if (!bottomLine) bottomLine = createSideLine(side);
|
||||
if (show) {
|
||||
if (!bottomLine)
|
||||
bottomLine = createSideLine(side);
|
||||
} else {
|
||||
if (bottomLine) scene->removeItem(bottomLine);
|
||||
if (bottomLine)
|
||||
scene->removeItem(bottomLine);
|
||||
bottomLine = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseDesignIntf::RightLine:
|
||||
if (show){
|
||||
if (!rightLine) rightLine = createSideLine(side);
|
||||
if (show) {
|
||||
if (!rightLine)
|
||||
rightLine = createSideLine(side);
|
||||
} else {
|
||||
if(rightLine) scene->removeItem(rightLine);
|
||||
if (rightLine)
|
||||
scene->removeItem(rightLine);
|
||||
rightLine = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
updateBorders();
|
||||
}
|
||||
|
||||
QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side)
|
||||
QGraphicsLineItem* BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side)
|
||||
{
|
||||
switch(side){
|
||||
switch (side) {
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
return scene->addLine(QLineF(10, 10, rect().width() - 10, 10), m_pen);
|
||||
case BaseDesignIntf::BorderSide::LeftLine:
|
||||
return scene->addLine(QLineF(10, 10, 10, rect().height() - 10), m_pen);
|
||||
case BaseDesignIntf::BorderSide::RightLine:
|
||||
return scene->addLine(QLineF(rect().width() - 10, 10 ,rect().width() - 10, rect().height() - 10), m_pen);
|
||||
return scene->addLine(
|
||||
QLineF(rect().width() - 10, 10, rect().width() - 10, rect().height() - 10), m_pen);
|
||||
case BaseDesignIntf::BorderSide::BottomLine:
|
||||
return scene->addLine(QLineF(10, rect().bottom() - 10, rect().width() - 10, rect().bottom() - 10), m_pen);
|
||||
return scene->addLine(
|
||||
QLineF(10, rect().bottom() - 10, rect().width() - 10, rect().bottom() - 10), m_pen);
|
||||
}
|
||||
}
|
||||
|
||||
void BorderFrameEditor::updateBorders()
|
||||
{
|
||||
if (topLine) topLine->setPen(m_pen);
|
||||
if (leftLine) leftLine->setPen(m_pen);
|
||||
if (bottomLine) bottomLine->setPen(m_pen);
|
||||
if (rightLine) rightLine->setPen(m_pen);
|
||||
if (topLine)
|
||||
topLine->setPen(m_pen);
|
||||
if (leftLine)
|
||||
leftLine->setPen(m_pen);
|
||||
if (bottomLine)
|
||||
bottomLine->setPen(m_pen);
|
||||
if (rightLine)
|
||||
rightLine->setPen(m_pen);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,46 +1,44 @@
|
||||
#ifndef WIDGET
|
||||
#define WIDGET
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsLineItem>
|
||||
#include "lrbasedesignintf.h"
|
||||
namespace LimeReport{
|
||||
|
||||
namespace Ui { class BorderFrameEditor; }
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWidget>
|
||||
namespace LimeReport {
|
||||
|
||||
class BorderFrameEditor : public QWidget
|
||||
{
|
||||
namespace Ui {
|
||||
class BorderFrameEditor;
|
||||
}
|
||||
|
||||
class BorderFrameEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BorderFrameEditor(QWidget *parent = nullptr);
|
||||
BorderFrameEditor(QWidget* parent = nullptr);
|
||||
~BorderFrameEditor();
|
||||
void setPen(QPen pen);
|
||||
QPen pen();
|
||||
void setAllLines();
|
||||
void unSetAllLines();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
signals:
|
||||
void borderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show);
|
||||
private slots:
|
||||
void slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show);
|
||||
|
||||
private:
|
||||
QGraphicsLineItem *createSideLine(LimeReport::BaseDesignIntf::BorderSide side);
|
||||
QGraphicsLineItem* createSideLine(LimeReport::BaseDesignIntf::BorderSide side);
|
||||
void updateBorders();
|
||||
|
||||
private:
|
||||
Ui::BorderFrameEditor *ui;
|
||||
QGraphicsScene *scene;
|
||||
QGraphicsLineItem *topLine = NULL
|
||||
,*bottomLine = NULL
|
||||
,*leftLine = NULL
|
||||
,*rightLine = NULL;
|
||||
Ui::BorderFrameEditor* ui;
|
||||
QGraphicsScene* scene;
|
||||
QGraphicsLineItem *topLine = NULL, *bottomLine = NULL, *leftLine = NULL, *rightLine = NULL;
|
||||
QPen m_pen;
|
||||
|
||||
|
||||
|
||||
};
|
||||
} // namespace LimeReport
|
||||
#endif // WIDGET
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#include "lrchartaxiseditor.h"
|
||||
|
||||
#include "ui_lrchartaxiseditor.h"
|
||||
#include "lraxisdata.h"
|
||||
|
||||
#include "lraxisdata.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, bool isXAxis, QSettings *settings, QWidget *parent):
|
||||
QWidget(parent), ui(new Ui::ChartAxisEditor), m_chartItem(item), m_page(page),
|
||||
m_settings(settings), m_isXAxis(isXAxis)
|
||||
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
|
||||
bool isXAxis, QSettings* settings, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::ChartAxisEditor),
|
||||
m_chartItem(item),
|
||||
m_page(page),
|
||||
m_settings(settings),
|
||||
m_isXAxis(isXAxis)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
readSetting();
|
||||
@@ -24,16 +28,17 @@ ChartAxisEditor::~ChartAxisEditor()
|
||||
|
||||
QSettings* ChartAxisEditor::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
if (m_settings) {
|
||||
return m_settings;
|
||||
}
|
||||
m_settings = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
m_settings = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
void ChartAxisEditor::readSetting()
|
||||
{
|
||||
if (settings() == 0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
@@ -50,7 +55,7 @@ void ChartAxisEditor::writeSetting()
|
||||
return;
|
||||
}
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->setValue("Geometry", saveGeometry());
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
@@ -59,7 +64,8 @@ void ChartAxisEditor::init()
|
||||
ui->gbAxis->setTitle(m_isXAxis ? QObject::tr("X Axis") : QObject::tr("Y Axis"));
|
||||
ui->direction_checkbox->setVisible(!m_isXAxis);
|
||||
|
||||
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
LimeReport::AxisData* axisData
|
||||
= m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
|
||||
ui->minimumSpinBox->setValue(axisData->manualMinimum());
|
||||
ui->maximumSpinBox->setValue(axisData->manualMaximum());
|
||||
@@ -96,7 +102,8 @@ void ChartAxisEditor::on_stepCheckBox_stateChanged(int arg1)
|
||||
|
||||
void ChartAxisEditor::on_pushButtonOk_clicked()
|
||||
{
|
||||
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
LimeReport::AxisData* axisData
|
||||
= m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
if (!m_isXAxis) {
|
||||
axisData->setReverseDirection(ui->direction_checkbox->isChecked());
|
||||
}
|
||||
@@ -135,8 +142,4 @@ void ChartAxisEditor::on_enableScaleCalculation_checkbox_stateChanged(int arg1)
|
||||
ui->stepCheckBox->setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_cancelButton_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_cancelButton_clicked() { close(); }
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#ifndef CHARTAXISEDITOR_H
|
||||
#define CHARTAXISEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lrchartitem.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ChartAxisEditor;
|
||||
}
|
||||
|
||||
class ChartAxisEditor : public QWidget
|
||||
{
|
||||
class ChartAxisEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, bool isXAxis,
|
||||
QSettings* settings=0, QWidget *parent = 0);
|
||||
QSettings* settings = 0, QWidget* parent = 0);
|
||||
~ChartAxisEditor();
|
||||
|
||||
QSettings *settings();
|
||||
QSettings* settings();
|
||||
private slots:
|
||||
void on_minimumCheckBox_stateChanged(int arg1);
|
||||
void on_maximumCheckBox_stateChanged(int arg1);
|
||||
@@ -31,7 +31,7 @@ private:
|
||||
void writeSetting();
|
||||
void init();
|
||||
|
||||
Ui::ChartAxisEditor *ui;
|
||||
Ui::ChartAxisEditor* ui;
|
||||
LimeReport::ChartItem* m_chartItem;
|
||||
LimeReport::PageDesignIntf* m_page;
|
||||
QSettings* m_settings;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,32 +1,39 @@
|
||||
#ifndef LRCHARTITEM_H
|
||||
#define LRCHARTITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lraxisdata.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
QColor generateColor();
|
||||
extern QColor color_map[39];
|
||||
|
||||
class IDataSource;
|
||||
|
||||
class SeriesItemData : public QObject{
|
||||
class SeriesItemData: public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QList<qreal>& values(){ return m_values;}
|
||||
QList<qreal>& xAxisValues(){ return m_xAxisValues;}
|
||||
QList<QString>& labels(){ return m_labels;}
|
||||
QList<QColor>& colors() { return m_colors;}
|
||||
void clear(){ m_values.clear(); m_labels.clear(); m_colors.clear(); }
|
||||
QList<qreal>& values() { return m_values; }
|
||||
QList<qreal>& xAxisValues() { return m_xAxisValues; }
|
||||
QList<QString>& labels() { return m_labels; }
|
||||
QList<QColor>& colors() { return m_colors; }
|
||||
void clear()
|
||||
{
|
||||
m_values.clear();
|
||||
m_labels.clear();
|
||||
m_colors.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
QList<qreal> m_values, m_xAxisValues;
|
||||
QList<QString> m_labels;
|
||||
QList<QColor> m_colors;
|
||||
};
|
||||
|
||||
class SeriesItem : public QObject{
|
||||
class SeriesItem: public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString valuesColumn READ valuesColumn WRITE setValuesColumn)
|
||||
@@ -35,29 +42,33 @@ class SeriesItem : public QObject{
|
||||
Q_PROPERTY(QColor color READ color WRITE setColor)
|
||||
Q_PROPERTY(SeriesItemPreferredType preferredType READ preferredType WRITE setPreferredType)
|
||||
public:
|
||||
enum SeriesItemPreferredType {Bar, Line};
|
||||
enum SeriesItemPreferredType {
|
||||
Bar,
|
||||
Line
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(SeriesItemPreferredType)
|
||||
#else
|
||||
Q_ENUMS(SeriesItemPreferredType)
|
||||
#endif
|
||||
SeriesItem(QObject* parent = 0) : QObject(parent), m_preferredType(Bar){}
|
||||
SeriesItem(QObject* parent = 0): QObject(parent), m_preferredType(Bar) { }
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
void setName(const QString& name);
|
||||
QString valuesColumn() const;
|
||||
void setValuesColumn(const QString &valuesColumn);
|
||||
void setValuesColumn(const QString& valuesColumn);
|
||||
QString labelsColumn() const;
|
||||
void setLabelsColumn(const QString &labelsColumn);
|
||||
void setLabelsColumn(const QString& labelsColumn);
|
||||
QString xAxisColumn() const;
|
||||
void setXAxisColumn(const QString &xAxisColumn);
|
||||
void setXAxisColumn(const QString& xAxisColumn);
|
||||
SeriesItem* clone();
|
||||
void fillSeriesData(IDataSource* dataSource);
|
||||
SeriesItemData* data(){ return &m_data;}
|
||||
SeriesItemData* data() { return &m_data; }
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
void setColor(const QColor& color);
|
||||
SeriesItemPreferredType preferredType() const;
|
||||
void setPreferredType(const SeriesItemPreferredType& preferredType);
|
||||
bool isEmpty(){ return m_data.values().isEmpty();}
|
||||
bool isEmpty() { return m_data.values().isEmpty(); }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_valuesColumn;
|
||||
@@ -73,17 +84,20 @@ class ChartItem;
|
||||
class AbstractChart {
|
||||
public:
|
||||
AbstractChart(ChartItem* chartItem);
|
||||
virtual ~AbstractChart(){}
|
||||
virtual void paintChart(QPainter *painter, QRectF rect) = 0;
|
||||
virtual void paintChartLegend(QPainter *painter, QRectF legendRect) =0;
|
||||
virtual QSizeF calcChartLegendSize(const QFont &font, qreal maxWidth = 0) = 0;
|
||||
virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect, bool takeAllRect, qreal borderMargin, qreal titleOffset);
|
||||
virtual ~AbstractChart() { }
|
||||
virtual void paintChart(QPainter* painter, QRectF rect) = 0;
|
||||
virtual void paintChartLegend(QPainter* painter, QRectF legendRect) = 0;
|
||||
virtual QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0) = 0;
|
||||
virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect,
|
||||
bool takeAllRect, qreal borderMargin, qreal titleOffset);
|
||||
|
||||
QFont titleFont();
|
||||
void setTitleFont(const QFont &value);
|
||||
void setTitleFont(const QFont& value);
|
||||
|
||||
protected:
|
||||
QVector<qreal> legendColumnWidths() const;
|
||||
virtual void prepareLegendToPaint(QRectF& legendRect, QPainter *painter);
|
||||
virtual void prepareLegendToPaint(QRectF& legendRect, QPainter* painter);
|
||||
|
||||
protected:
|
||||
// Title font must be placed here instead of CharItem, becuase
|
||||
// it would cause crash when creating CharItem object on embedded
|
||||
@@ -93,57 +107,60 @@ protected:
|
||||
QVector<qreal> m_legendColumnWidths;
|
||||
};
|
||||
|
||||
class AbstractSeriesChart: public AbstractChart{
|
||||
class AbstractSeriesChart: public AbstractChart {
|
||||
public:
|
||||
AbstractSeriesChart(ChartItem* chartItem);
|
||||
|
||||
protected:
|
||||
AxisData &xAxisData() const;
|
||||
AxisData &yAxisData() const;
|
||||
AxisData& xAxisData() const;
|
||||
AxisData& yAxisData() const;
|
||||
qreal maxValue();
|
||||
qreal minValue();
|
||||
void updateMinAndMaxValues();
|
||||
int valuesCount();
|
||||
int seriesCount();
|
||||
bool verticalLabels(QPainter* painter, QRectF labelsRect);
|
||||
QSizeF calcChartLegendSize(const QFont &font, qreal maxWidth);
|
||||
qreal* designValues(){ return m_designValues;}
|
||||
QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth);
|
||||
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 paintGrid(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 void paintHorizontalLabels(QPainter* painter, QRectF labelsRect);
|
||||
virtual void paintVerticalLabels(QPainter* painter, QRectF labelsRect);
|
||||
virtual void paintHorizontalGrid(QPainter* painter, QRectF gridRect);
|
||||
virtual void paintGrid(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 adaptFont(qreal width, QFont font, const AxisData &axisData);
|
||||
virtual QString axisLabel(int i, const AxisData &axisData);
|
||||
virtual QFont adaptFont(qreal width, QFont font, const AxisData& axisData);
|
||||
virtual QString axisLabel(int i, const AxisData& axisData);
|
||||
|
||||
private:
|
||||
bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics &fm);
|
||||
bool calculateLegendSingleColumnWidth(qreal ¤tRowWidth, int ¤tColumn, int &maxColumnCount,
|
||||
const qreal itemWidth, const qreal maxRowWidth);
|
||||
qreal m_designValues [9];
|
||||
bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics& fm);
|
||||
bool calculateLegendSingleColumnWidth(qreal& currentRowWidth, int& currentColumn,
|
||||
int& maxColumnCount, const qreal itemWidth,
|
||||
const qreal maxRowWidth);
|
||||
qreal m_designValues[9];
|
||||
};
|
||||
|
||||
class AbstractBarChart: public AbstractSeriesChart{
|
||||
class AbstractBarChart: public AbstractSeriesChart {
|
||||
public:
|
||||
AbstractBarChart(ChartItem* chartItem):AbstractSeriesChart(chartItem){}
|
||||
void paintChartLegend(QPainter *painter, QRectF legendRect);
|
||||
AbstractBarChart(ChartItem* chartItem): AbstractSeriesChart(chartItem) { }
|
||||
void paintChartLegend(QPainter* painter, QRectF legendRect);
|
||||
|
||||
protected:
|
||||
QRectF verticalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect);
|
||||
virtual QRectF horizontalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect);
|
||||
|
||||
private:
|
||||
void drawVerticalLegendItem(QPainter *painter, int i, const QString &text,
|
||||
int indicatorSize, const QRectF &indicatorsRect, const QColor &indicatorColor);
|
||||
void drawHorizontalLegendItem(QPainter *painter, int i, const QString &text,
|
||||
int indicatorSize, const QRectF &indicatorsRect, const QColor &indicatorColor);
|
||||
void drawVerticalLegendItem(QPainter* painter, int i, const QString& text, int indicatorSize,
|
||||
const QRectF& indicatorsRect, const QColor& indicatorColor);
|
||||
void drawHorizontalLegendItem(QPainter* painter, int i, const QString& text, int indicatorSize,
|
||||
const QRectF& indicatorsRect, const QColor& indicatorColor);
|
||||
};
|
||||
|
||||
class ChartItem : public LimeReport::ItemDesignIntf
|
||||
{
|
||||
class ChartItem: public LimeReport::ItemDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QObject* xAxisSettings READ xAxisSettings WRITE setXAxisSettings)
|
||||
Q_PROPERTY(QObject* yAxisSettings READ yAxisSettings WRITE setYAxisSettings)
|
||||
@@ -160,23 +177,42 @@ class ChartItem : public LimeReport::ItemDesignIntf
|
||||
Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
|
||||
Q_PROPERTY(QFont font READ font WRITE setCharItemFont)
|
||||
|
||||
//linesChart
|
||||
// linesChart
|
||||
Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints)
|
||||
Q_PROPERTY(int seriesLineWidth READ seriesLineWidth WRITE setSeriesLineWidth)
|
||||
Q_PROPERTY(bool horizontalAxisOnTop READ horizontalAxisOnTop WRITE setHorizontalAxisOnTop)
|
||||
|
||||
//gridChart
|
||||
// gridChart
|
||||
Q_FLAGS(GridChartLines)
|
||||
Q_PROPERTY(QString xAxisField READ xAxisField WRITE setXAxisField)
|
||||
Q_PROPERTY(GridChartLines gridChartLines READ gridChartLines WRITE setGridChartLines)
|
||||
friend class AbstractChart;
|
||||
public:
|
||||
|
||||
enum LegendAlign{LegendAlignRightTop,LegendAlignRightCenter,LegendAlignRightBottom,
|
||||
LegendAlignBottomLeft,LegendAlignBottomCenter,LegendAlignBottomRight};
|
||||
enum LegendStyle{LegendPoints, LegendLines};
|
||||
enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight};
|
||||
enum ChartType{Pie, VerticalBar, HorizontalBar, Lines, GridLines};
|
||||
public:
|
||||
enum LegendAlign {
|
||||
LegendAlignRightTop,
|
||||
LegendAlignRightCenter,
|
||||
LegendAlignRightBottom,
|
||||
LegendAlignBottomLeft,
|
||||
LegendAlignBottomCenter,
|
||||
LegendAlignBottomRight
|
||||
};
|
||||
enum LegendStyle {
|
||||
LegendPoints,
|
||||
LegendLines
|
||||
};
|
||||
enum TitleAlign {
|
||||
TitleAlignLeft,
|
||||
TitleAlignCenter,
|
||||
TitleAlignRight
|
||||
};
|
||||
enum ChartType {
|
||||
Pie,
|
||||
VerticalBar,
|
||||
HorizontalBar,
|
||||
Lines,
|
||||
GridLines
|
||||
};
|
||||
enum LineType {
|
||||
NoLine = 0,
|
||||
HorizontalLine = 1,
|
||||
@@ -200,48 +236,48 @@ public:
|
||||
|
||||
ChartItem(QObject* owner, QGraphicsItem* parent);
|
||||
~ChartItem();
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
|
||||
QObject* xAxisSettings();
|
||||
void setYAxisSettings(QObject *axis);
|
||||
void setYAxisSettings(QObject* axis);
|
||||
QObject* yAxisSettings();
|
||||
void setXAxisSettings(QObject *axis);
|
||||
void setXAxisSettings(QObject* axis);
|
||||
|
||||
AxisData *xAxisData();
|
||||
AxisData *yAxisData();
|
||||
AxisData* xAxisData();
|
||||
AxisData* yAxisData();
|
||||
|
||||
void showAxisEditorDialog(bool isXAxis);
|
||||
|
||||
QList<SeriesItem *> &series();
|
||||
void setSeries(const QList<SeriesItem *> &series);
|
||||
QList<SeriesItem*>& series();
|
||||
void setSeries(const QList<SeriesItem*>& series);
|
||||
bool isSeriesExists(const QString& name);
|
||||
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
|
||||
QString chartTitle() const;
|
||||
void setChartTitle(const QString &chartTitle);
|
||||
void setChartTitle(const QString& chartTitle);
|
||||
|
||||
bool drawLegendBorder() const;
|
||||
void setDrawLegendBorder(bool drawLegendBorder);
|
||||
|
||||
LegendAlign legendAlign() const;
|
||||
void setLegendAlign(const LegendAlign &legendAlign);
|
||||
void setLegendAlign(const LegendAlign& legendAlign);
|
||||
|
||||
LegendStyle legendStyle() const;
|
||||
void setLegendStyle(const LegendStyle &legendStyle);
|
||||
void setLegendStyle(const LegendStyle& legendStyle);
|
||||
|
||||
TitleAlign titleAlign() const;
|
||||
void setTitleAlign(const TitleAlign &titleAlign);
|
||||
void setTitleAlign(const TitleAlign& titleAlign);
|
||||
|
||||
ChartType chartType() const;
|
||||
void setChartType(const ChartType &chartType);
|
||||
void setChartType(const ChartType& chartType);
|
||||
|
||||
QString labelsField() const;
|
||||
void setLabelsField(const QString &labelsField);
|
||||
void setLabelsField(const QString& labelsField);
|
||||
|
||||
QList<QString> labels() const;
|
||||
void setLabels(const QList<QString> &labels);
|
||||
void setLabels(const QList<QString>& labels);
|
||||
QWidget* defaultEditor();
|
||||
|
||||
bool showLegend() const;
|
||||
@@ -254,7 +290,7 @@ public:
|
||||
void setSeriesLineWidth(int newSeriesLineWidth);
|
||||
|
||||
QString xAxisField() const;
|
||||
void setXAxisField(const QString &xAxisField);
|
||||
void setXAxisField(const QString& xAxisField);
|
||||
|
||||
bool horizontalAxisOnTop() const;
|
||||
void setHorizontalAxisOnTop(bool horizontalAxisOnTop);
|
||||
@@ -266,20 +302,21 @@ public:
|
||||
void setTitleFont(QFont value);
|
||||
void setCharItemFont(QFont value);
|
||||
|
||||
QSettings *settings();
|
||||
QSettings* settings();
|
||||
|
||||
protected:
|
||||
void paintChartTitle(QPainter* painter, QRectF titleRect);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
//ICollectionContainer
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
// ICollectionContainer
|
||||
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)}
|
||||
void updateItemSize(DataSourceManager *dataManager, RenderPass, int);
|
||||
void fillLabels(IDataSource* dataSource);
|
||||
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);
|
||||
bool isNeedUpdateSize(RenderPass pass) const;
|
||||
void setSeries(ACollectionProperty series){Q_UNUSED(series)}
|
||||
void setSeries(ACollectionProperty series) { Q_UNUSED(series) }
|
||||
|
||||
private:
|
||||
QList<SeriesItem*> m_series;
|
||||
QString m_datasource;
|
||||
@@ -288,9 +325,9 @@ private:
|
||||
AbstractChart* m_chart;
|
||||
bool m_legendBorder;
|
||||
LegendAlign m_legendAlign;
|
||||
TitleAlign m_titleAlign;
|
||||
ChartType m_chartType;
|
||||
QString m_labelsField;
|
||||
TitleAlign m_titleAlign;
|
||||
ChartType m_chartType;
|
||||
QString m_labelsField;
|
||||
QList<QString> m_labels;
|
||||
bool m_isEmpty;
|
||||
bool m_showLegend;
|
||||
@@ -302,5 +339,5 @@ private:
|
||||
LegendStyle m_legendStyle;
|
||||
AxisData *m_xAxisData, *m_yAxisData;
|
||||
};
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
#endif // LRCHARTITEM_H
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
#include "lrchartitemeditor.h"
|
||||
#include "ui_lrchartitemeditor.h"
|
||||
|
||||
#include "lrchartitem.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
|
||||
ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, QSettings *settings, QWidget *parent):
|
||||
QWidget(parent), ui(new Ui::ChartItemEditor), m_charItem(item), m_page(page),
|
||||
m_settings(settings), m_ownedSettings(false), m_isReadingSetting(false)
|
||||
ChartItemEditor::ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
|
||||
QSettings* settings, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::ChartItemEditor),
|
||||
m_charItem(item),
|
||||
m_page(page),
|
||||
m_settings(settings),
|
||||
m_ownedSettings(false),
|
||||
m_isReadingSetting(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QHBoxLayout* colorLayout = new QHBoxLayout();
|
||||
colorLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_colorButton = new QToolButton();
|
||||
m_colorButton->setText("...");
|
||||
m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
m_colorButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
m_colorIndicator = new ColorIndicator();
|
||||
m_colorIndicator->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
m_colorIndicator->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
ui->colorWidget->setLayout(colorLayout);
|
||||
colorLayout->addWidget(m_colorIndicator);
|
||||
colorLayout->addWidget(m_colorButton);
|
||||
@@ -38,10 +46,10 @@ ChartItemEditor::~ChartItemEditor()
|
||||
|
||||
QSettings* ChartItemEditor::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
if (m_settings) {
|
||||
return m_settings;
|
||||
} else {
|
||||
m_settings = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
m_settings = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
m_ownedSettings = true;
|
||||
return m_settings;
|
||||
}
|
||||
@@ -49,17 +57,18 @@ QSettings* ChartItemEditor::settings()
|
||||
|
||||
void ChartItemEditor::readSetting()
|
||||
{
|
||||
if (settings()==0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
m_isReadingSetting = true;
|
||||
|
||||
settings()->beginGroup("ChartItemEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
if (v.isValid()){
|
||||
if (v.isValid()) {
|
||||
restoreGeometry(v.toByteArray());
|
||||
}
|
||||
v = settings()->value("State");
|
||||
if (v.isValid()){
|
||||
if (v.isValid()) {
|
||||
ui->splitter->restoreState(v.toByteArray());
|
||||
}
|
||||
|
||||
@@ -70,10 +79,10 @@ void ChartItemEditor::readSetting()
|
||||
|
||||
void ChartItemEditor::writeSetting()
|
||||
{
|
||||
if (settings()!=0){
|
||||
if (settings() != 0) {
|
||||
settings()->beginGroup("ChartItemEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->setValue("State",ui->splitter->saveState());
|
||||
settings()->setValue("Geometry", saveGeometry());
|
||||
settings()->setValue("State", ui->splitter->saveState());
|
||||
settings()->endGroup();
|
||||
}
|
||||
}
|
||||
@@ -82,9 +91,9 @@ void ChartItemEditor::rebuildTable()
|
||||
{
|
||||
ui->tableWidget->clearContents();
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
for( int i=0;i<m_charItem->series().count();++i){
|
||||
for (int i = 0; i < m_charItem->series().count(); ++i) {
|
||||
QTableWidgetItem* newRow = new QTableWidgetItem(m_charItem->series().at(i)->name());
|
||||
ui->tableWidget->setItem(i,0,newRow);
|
||||
ui->tableWidget->setItem(i, 0, newRow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,38 +104,41 @@ void ChartItemEditor::init()
|
||||
ui->tableWidget->setColumnCount(1);
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem(tr("Series name")));
|
||||
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Series name")));
|
||||
|
||||
rebuildTable();
|
||||
|
||||
if (!m_charItem->datasource().isEmpty()){
|
||||
if (m_page && m_page->datasourceManager()){
|
||||
LimeReport::IDataSource* ds = m_page->datasourceManager()->dataSource(m_charItem->datasource());
|
||||
if (ds){
|
||||
for (int i=0;i<ds->columnCount();++i){
|
||||
ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
ui->xAxisFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
if (!m_charItem->datasource().isEmpty()) {
|
||||
if (m_page && m_page->datasourceManager()) {
|
||||
LimeReport::IDataSource* ds
|
||||
= m_page->datasourceManager()->dataSource(m_charItem->datasource());
|
||||
if (ds) {
|
||||
for (int i = 0; i < ds->columnCount(); ++i) {
|
||||
ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
ui->xAxisFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
static int enumIndex
|
||||
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
for (int i = 0; i<enumerator.keyCount(); ++i){
|
||||
for (int i = 0; i < enumerator.keyCount(); ++i) {
|
||||
ui->seriesTypeComboBox->addItem(enumerator.key(i));
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField()));
|
||||
ui->xAxisFieldComboBox->setCurrentIndex(ui->xAxisFieldComboBox->findText( m_charItem->xAxisField()));
|
||||
ui->labelsFieldComboBox->setCurrentIndex(
|
||||
ui->labelsFieldComboBox->findText(m_charItem->labelsField()));
|
||||
ui->xAxisFieldComboBox->setCurrentIndex(
|
||||
ui->xAxisFieldComboBox->findText(m_charItem->xAxisField()));
|
||||
#else
|
||||
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField());
|
||||
ui->xAxisFieldComboBox->setCurrentText(m_charItem->xAxisField());
|
||||
#endif
|
||||
if (!m_charItem->series().isEmpty()){
|
||||
if (!m_charItem->series().isEmpty()) {
|
||||
enableSeriesEditor();
|
||||
ui->tableWidget->selectRow(0);
|
||||
} else {
|
||||
@@ -160,30 +172,30 @@ void ChartItemEditor::disableSeriesEditor()
|
||||
ui->seriesTypeComboBox->setDisabled(true);
|
||||
}
|
||||
|
||||
LimeReport::SeriesItem *ChartItemEditor::currentSeries()
|
||||
LimeReport::SeriesItem* ChartItemEditor::currentSeries()
|
||||
{
|
||||
int curRow = ui->tableWidget->currentRow();
|
||||
if ((curRow>-1) && !m_charItem->series().isEmpty() && m_charItem->series().count()>curRow){
|
||||
if ((curRow > -1) && !m_charItem->series().isEmpty() && m_charItem->series().count() > curRow) {
|
||||
return m_charItem->series().at(curRow);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ChartItemEditor::resizeEvent(QResizeEvent *)
|
||||
void ChartItemEditor::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
writeSetting();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChartItemEditor::moveEvent(QMoveEvent *)
|
||||
void ChartItemEditor::moveEvent(QMoveEvent*)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
writeSetting();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_splitter_splitterMoved(int , int )
|
||||
void ChartItemEditor::on_splitter_splitterMoved(int, int)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
writeSetting();
|
||||
@@ -200,15 +212,19 @@ void ChartItemEditor::slotAddSeries()
|
||||
{
|
||||
LimeReport::SeriesItem* series = new LimeReport::SeriesItem();
|
||||
int curSeriesNumber = m_charItem->series().count();
|
||||
while (m_charItem->isSeriesExists("Series"+QString::number(curSeriesNumber))) curSeriesNumber++;
|
||||
series->setName("Series"+QString::number(curSeriesNumber));
|
||||
while (m_charItem->isSeriesExists("Series" + QString::number(curSeriesNumber)))
|
||||
curSeriesNumber++;
|
||||
series->setName("Series" + QString::number(curSeriesNumber));
|
||||
series->setValuesColumn("");
|
||||
series->setLabelsColumn("");
|
||||
series->setColor((m_charItem->series().count()<32)?LimeReport::color_map[m_charItem->series().count()]:LimeReport::generateColor());
|
||||
series->setColor((m_charItem->series().count() < 32)
|
||||
? LimeReport::color_map[m_charItem->series().count()]
|
||||
: LimeReport::generateColor());
|
||||
m_charItem->series().append(series);
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name()));
|
||||
ui->tableWidget->selectRow(m_charItem->series().count()-1);
|
||||
ui->tableWidget->setItem(m_charItem->series().count() - 1, 0,
|
||||
new QTableWidgetItem(series->name()));
|
||||
ui->tableWidget->selectRow(m_charItem->series().count() - 1);
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setEditText("");
|
||||
#else
|
||||
@@ -219,10 +235,10 @@ void ChartItemEditor::slotAddSeries()
|
||||
void ChartItemEditor::slotDeleteSeries()
|
||||
{
|
||||
QList<LimeReport::SeriesItem*> itemsToRemove;
|
||||
foreach(QModelIndex index,ui->tableWidget->selectionModel()->selectedRows()){
|
||||
itemsToRemove.append(m_charItem->series().at(index.row()));
|
||||
foreach (QModelIndex index, ui->tableWidget->selectionModel()->selectedRows()) {
|
||||
itemsToRemove.append(m_charItem->series().at(index.row()));
|
||||
};
|
||||
foreach (LimeReport::SeriesItem* series, itemsToRemove){
|
||||
foreach (LimeReport::SeriesItem* series, itemsToRemove) {
|
||||
m_charItem->series().removeOne(series);
|
||||
delete series;
|
||||
}
|
||||
@@ -232,19 +248,23 @@ void ChartItemEditor::slotDeleteSeries()
|
||||
|
||||
void ChartItemEditor::on_tableWidget_itemSelectionChanged()
|
||||
{
|
||||
if (ui->tableWidget->selectionModel()->hasSelection()){
|
||||
LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
|
||||
if (ui->tableWidget->selectionModel()->hasSelection()) {
|
||||
LimeReport::SeriesItem* series
|
||||
= m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
|
||||
ui->seriesNameLineEdit->setText(series->name());
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setCurrentIndex(ui->valuesFieldComboBox->findText(series->valuesColumn()));
|
||||
ui->valuesFieldComboBox->setCurrentIndex(
|
||||
ui->valuesFieldComboBox->findText(series->valuesColumn()));
|
||||
#else
|
||||
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
|
||||
#endif
|
||||
m_colorIndicator->setColor(series->color());
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
static int enumIndex
|
||||
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->seriesTypeComboBox->setCurrentIndex(ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType())));
|
||||
ui->seriesTypeComboBox->setCurrentIndex(
|
||||
ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType())));
|
||||
#else
|
||||
ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType()));
|
||||
#endif
|
||||
@@ -252,22 +272,22 @@ void ChartItemEditor::on_tableWidget_itemSelectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString& arg1)
|
||||
{
|
||||
if (currentSeries()){
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setName(arg1);
|
||||
ui->tableWidget->currentItem()->setText(arg1);
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
if (currentSeries()){
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setValuesColumn(arg1);
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
if (!m_initing)
|
||||
m_charItem->setLabelsField(arg1);
|
||||
@@ -276,27 +296,30 @@ void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &a
|
||||
void ChartItemEditor::slotChangeSeriesColor()
|
||||
{
|
||||
QColorDialog colorDialog;
|
||||
if (colorDialog.exec()){
|
||||
if (colorDialog.exec()) {
|
||||
currentSeries()->setColor(colorDialog.selectedColor());
|
||||
m_colorIndicator->setColor(colorDialog.selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString& arg1)
|
||||
{
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
static int enumIndex
|
||||
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
if (currentSeries()){
|
||||
currentSeries()->setPreferredType(static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(enumerator.keysToValue(arg1.toLatin1())));
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setPreferredType(
|
||||
static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(
|
||||
enumerator.keysToValue(arg1.toLatin1())));
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
if (!m_initing)
|
||||
m_charItem->setXAxisField(arg1);
|
||||
}
|
||||
void ChartItemEditor::on_tableWidget_itemChanged(QTableWidgetItem *item)
|
||||
void ChartItemEditor::on_tableWidget_itemChanged(QTableWidgetItem* item)
|
||||
{
|
||||
if (ui->seriesNameLineEdit->hasFocus())
|
||||
return;
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
#ifndef CHARITEMEDITOR_H
|
||||
#define CHARITEMEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lrchartitem.h"
|
||||
#include "lrcolorindicator.h"
|
||||
|
||||
#include <QTableWidgetItem>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ChartItemEditor;
|
||||
}
|
||||
|
||||
class ChartItemEditor : public QWidget
|
||||
{
|
||||
class ChartItemEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
|
||||
QSettings* settings=0, QWidget *parent = 0);
|
||||
QSettings* settings = 0, QWidget* parent = 0);
|
||||
~ChartItemEditor();
|
||||
|
||||
public:
|
||||
QSettings *settings();
|
||||
QSettings* settings();
|
||||
void rebuildTable();
|
||||
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void moveEvent(QMoveEvent *);
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void moveEvent(QMoveEvent*);
|
||||
|
||||
signals:
|
||||
void editingFinished();
|
||||
@@ -35,13 +36,13 @@ private slots:
|
||||
void slotAddSeries();
|
||||
void slotDeleteSeries();
|
||||
void on_tableWidget_itemSelectionChanged();
|
||||
void on_seriesNameLineEdit_textChanged(const QString &arg1);
|
||||
void on_valuesFieldComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_labelsFieldComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_seriesNameLineEdit_textChanged(const QString& arg1);
|
||||
void on_valuesFieldComboBox_currentTextChanged(const QString& arg1);
|
||||
void on_labelsFieldComboBox_currentTextChanged(const QString& arg1);
|
||||
void slotChangeSeriesColor();
|
||||
void on_seriesTypeComboBox_currentIndexChanged(const QString &arg1);
|
||||
void on_xAxisFieldComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_tableWidget_itemChanged(QTableWidgetItem *item);
|
||||
void on_seriesTypeComboBox_currentIndexChanged(const QString& arg1);
|
||||
void on_xAxisFieldComboBox_currentTextChanged(const QString& arg1);
|
||||
void on_tableWidget_itemChanged(QTableWidgetItem* item);
|
||||
|
||||
private:
|
||||
void readSetting();
|
||||
@@ -50,8 +51,9 @@ private:
|
||||
void enableSeriesEditor();
|
||||
void disableSeriesEditor();
|
||||
LimeReport::SeriesItem* currentSeries();
|
||||
|
||||
private:
|
||||
Ui::ChartItemEditor *ui;
|
||||
Ui::ChartItemEditor* ui;
|
||||
LimeReport::ChartItem* m_charItem;
|
||||
LimeReport::PageDesignIntf* m_page;
|
||||
QSettings* m_settings;
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class IEditableImageItem{
|
||||
class IEditableImageItem {
|
||||
public:
|
||||
virtual QByteArray imageAsByteArray() const = 0;
|
||||
virtual void setImageAsByteArray(QByteArray image) = 0;
|
||||
virtual QString resourcePath() const = 0;
|
||||
virtual void setResourcePath(const QString &value) = 0;
|
||||
virtual QString resourcePath() const = 0;
|
||||
virtual void setResourcePath(const QString& value) = 0;
|
||||
virtual QString fileFilter() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LREDITABLEIMAGEITEMINTF_H
|
||||
|
||||
@@ -28,101 +28,105 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrhorizontallayout.h"
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include <QObject>
|
||||
|
||||
const QString xmlTag = "HLayout";
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesignIntf *parent)
|
||||
LimeReport::BaseDesignIntf* createHLayout(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::HorizontalLayout(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||
createHLayout
|
||||
);
|
||||
}
|
||||
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||
createHLayout);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
bool horizontalLessThen(BaseDesignIntf *c1, BaseDesignIntf* c2){
|
||||
return c1->pos().x()<c2->pos().x();
|
||||
bool horizontalLessThen(BaseDesignIntf* c1, BaseDesignIntf* c2)
|
||||
{
|
||||
return c1->pos().x() < c2->pos().x();
|
||||
}
|
||||
|
||||
HorizontalLayout::HorizontalLayout(QObject *owner, QGraphicsItem *parent)
|
||||
: AbstractLayout(xmlTag, owner, parent)
|
||||
{}
|
||||
HorizontalLayout::HorizontalLayout(QObject* owner, QGraphicsItem* parent):
|
||||
AbstractLayout(xmlTag, owner, parent)
|
||||
{
|
||||
}
|
||||
|
||||
HorizontalLayout::~HorizontalLayout()
|
||||
{}
|
||||
HorizontalLayout::~HorizontalLayout() { }
|
||||
|
||||
BaseDesignIntf *HorizontalLayout::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* HorizontalLayout::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new LimeReport::HorizontalLayout(owner, parent);
|
||||
}
|
||||
|
||||
bool HorizontalLayout::canBeSplitted(int height) const
|
||||
{
|
||||
foreach(QGraphicsItem* qgItem,childItems()){
|
||||
BaseDesignIntf* item=dynamic_cast<BaseDesignIntf*>(qgItem);
|
||||
foreach (QGraphicsItem* qgItem, childItems()) {
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
|
||||
if (item)
|
||||
if (!item->canBeSplitted(height - item->pos().y())) return false;
|
||||
if (!item->canBeSplitted(height - item->pos().y()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BaseDesignIntf *HorizontalLayout::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* HorizontalLayout::cloneUpperPart(int height, QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
HorizontalLayout* upperPart = dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner,parent));
|
||||
HorizontalLayout* upperPart
|
||||
= dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner, parent));
|
||||
upperPart->initFromItem(this);
|
||||
qreal maxHeight = 0;
|
||||
foreach(BaseDesignIntf* item,childBaseItems()){
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
|
||||
if ((item->geometry().top()<height) && (item->geometry().bottom()>height)){
|
||||
int sliceHeight = height-item->geometry().top();
|
||||
if (item->canBeSplitted(sliceHeight)){
|
||||
BaseDesignIntf* slicedPart = item->cloneUpperPart(sliceHeight,upperPart,upperPart);
|
||||
if (maxHeight<slicedPart->height()) maxHeight = slicedPart->height();
|
||||
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
|
||||
int sliceHeight = height - item->geometry().top();
|
||||
if (item->canBeSplitted(sliceHeight)) {
|
||||
BaseDesignIntf* slicedPart
|
||||
= item->cloneUpperPart(sliceHeight, upperPart, upperPart);
|
||||
if (maxHeight < slicedPart->height())
|
||||
maxHeight = slicedPart->height();
|
||||
} else {
|
||||
item->cloneEmpty(sliceHeight,upperPart,upperPart);
|
||||
item->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top()));
|
||||
item->cloneEmpty(sliceHeight, upperPart, upperPart);
|
||||
item->setPos(item->pos().x(),
|
||||
item->pos().y() + ((height + 1) - item->geometry().top()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(BaseDesignIntf* item, upperPart->childBaseItems()){
|
||||
item->setHeight((maxHeight<height)?maxHeight:height);
|
||||
foreach (BaseDesignIntf* item, upperPart->childBaseItems()) {
|
||||
item->setHeight((maxHeight < height) ? maxHeight : height);
|
||||
}
|
||||
upperPart->setHeight(height);
|
||||
|
||||
return upperPart;
|
||||
}
|
||||
|
||||
BaseDesignIntf *HorizontalLayout::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* HorizontalLayout::cloneBottomPart(int height, QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
qreal maxHeight = 0;
|
||||
HorizontalLayout* bottomPart = dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner,parent));
|
||||
HorizontalLayout* bottomPart
|
||||
= dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner, parent));
|
||||
bottomPart->initFromItem(this);
|
||||
foreach(BaseDesignIntf* item,childBaseItems()){
|
||||
if ((item->geometry().top()<height) && (item->geometry().bottom()>height)){
|
||||
BaseDesignIntf* tmpItem=item->cloneBottomPart(height,bottomPart,bottomPart);
|
||||
tmpItem->setPos(tmpItem->pos().x(),0);
|
||||
if (maxHeight<tmpItem->height())
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
|
||||
BaseDesignIntf* tmpItem = item->cloneBottomPart(height, bottomPart, bottomPart);
|
||||
tmpItem->setPos(tmpItem->pos().x(), 0);
|
||||
if (maxHeight < tmpItem->height())
|
||||
maxHeight = tmpItem->height();
|
||||
}
|
||||
}
|
||||
|
||||
if (!bottomPart->isEmpty()){
|
||||
if (!bottomPart->isEmpty()) {
|
||||
foreach (BaseDesignIntf* item, bottomPart->childBaseItems()) {
|
||||
item->setHeight(maxHeight);
|
||||
}
|
||||
@@ -131,7 +135,7 @@ BaseDesignIntf *HorizontalLayout::cloneBottomPart(int height, QObject *owner, QG
|
||||
return bottomPart;
|
||||
}
|
||||
|
||||
void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
|
||||
void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign& itemAlign)
|
||||
{
|
||||
if (itemAlign == ParentWidthItemAlign)
|
||||
setLayoutType(Table);
|
||||
@@ -140,29 +144,32 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
|
||||
|
||||
void HorizontalLayout::sortChildren()
|
||||
{
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
std::sort(layoutsChildren().begin(), layoutsChildren().end(), horizontalLessThen);
|
||||
}
|
||||
|
||||
void HorizontalLayout::updateLayoutSize()
|
||||
{
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
qreal w = spaceBorder*2;
|
||||
qreal w = spaceBorder * 2;
|
||||
qreal h = 0;
|
||||
int visibleItemCount = 0;
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
if (item->isEmpty() && hideEmptyItems()) item->setVisible(false);
|
||||
if (item->isVisible()){
|
||||
if (h<item->height()) h=item->height();
|
||||
w+=item->width();
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isEmpty() && hideEmptyItems())
|
||||
item->setVisible(false);
|
||||
if (item->isVisible()) {
|
||||
if (h < item->height())
|
||||
h = item->height();
|
||||
w += item->width();
|
||||
visibleItemCount++;
|
||||
}
|
||||
}
|
||||
if (h>0) setHeight(h+spaceBorder*2);
|
||||
if (h > 0)
|
||||
setHeight(h + spaceBorder * 2);
|
||||
if (layoutType() == Layout)
|
||||
setWidth(w + layoutSpacingMM() * (visibleItemCount-1));
|
||||
else{
|
||||
setWidth(w + layoutSpacingMM() * (visibleItemCount - 1));
|
||||
else {
|
||||
relocateChildren();
|
||||
if (!isRelocating()){
|
||||
if (!isRelocating()) {
|
||||
divideSpace();
|
||||
}
|
||||
}
|
||||
@@ -172,7 +179,7 @@ void HorizontalLayout::relocateChildren()
|
||||
{
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
QList<BaseDesignIntf*> newChildren;
|
||||
if (layoutsChildren().count() < childItems().size()-1){
|
||||
if (layoutsChildren().count() < childItems().size() - 1) {
|
||||
auto oldChildren = layoutsChildren();
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
@@ -182,14 +189,14 @@ void HorizontalLayout::relocateChildren()
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
}
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
std::sort(layoutsChildren().begin(), layoutsChildren().end(), horizontalLessThen);
|
||||
qreal curX = spaceBorder;
|
||||
setIsRelocating(true);
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isVisible() || itemMode() == DesignMode){
|
||||
item->setPos(curX,spaceBorder);
|
||||
if (item->isVisible() || itemMode() == DesignMode) {
|
||||
item->setPos(curX, spaceBorder);
|
||||
curX += item->width() + layoutSpacingMM();
|
||||
item->setHeight(height()-(spaceBorder * 2));
|
||||
item->setHeight(height() - (spaceBorder * 2));
|
||||
}
|
||||
}
|
||||
setIsRelocating(false);
|
||||
@@ -199,32 +206,36 @@ void HorizontalLayout::relocateChildren()
|
||||
}
|
||||
}
|
||||
|
||||
void HorizontalLayout::divideSpace(){
|
||||
void HorizontalLayout::divideSpace()
|
||||
{
|
||||
setIsRelocating(true);
|
||||
qreal itemsSumSize = 0;
|
||||
int visibleItemsCount = 0;
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
if (item->isVisible() || itemMode() == DesignMode ){
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isVisible() || itemMode() == DesignMode) {
|
||||
itemsSumSize += item->width();
|
||||
visibleItemsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
itemsSumSize += layoutSpacingMM() * (visibleItemsCount-1);
|
||||
itemsSumSize += layoutSpacingMM() * (visibleItemsCount - 1);
|
||||
|
||||
if (itemMode() == DesignMode && !layoutsChildren().isEmpty()){
|
||||
qreal delta = (width() - (itemsSumSize+spaceBorder*2));
|
||||
layoutsChildren().last()->setWidth(layoutsChildren().last()->width()+delta);
|
||||
if (itemMode() == DesignMode && !layoutsChildren().isEmpty()) {
|
||||
qreal delta = (width() - (itemsSumSize + spaceBorder * 2));
|
||||
layoutsChildren().last()->setWidth(layoutsChildren().last()->width() + delta);
|
||||
} else {
|
||||
qreal delta = (width() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1);
|
||||
for (int i=0; i<layoutsChildren().size(); ++i){
|
||||
qreal delta = (width() - (itemsSumSize + spaceBorder * 2))
|
||||
/ (visibleItemsCount != 0 ? visibleItemsCount : 1);
|
||||
for (int i = 0; i < layoutsChildren().size(); ++i) {
|
||||
if (layoutsChildren()[i]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i]->setWidth(layoutsChildren()[i]->width()+delta);
|
||||
if ((i+1)<layoutsChildren().size())
|
||||
if (layoutsChildren()[i+1]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i+1]->setPos(layoutsChildren()[i+1]->pos().x()+delta*(i+1),layoutsChildren()[i+1]->pos().y());
|
||||
layoutsChildren()[i]->setWidth(layoutsChildren()[i]->width() + delta);
|
||||
if ((i + 1) < layoutsChildren().size())
|
||||
if (layoutsChildren()[i + 1]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i + 1]->setPos(layoutsChildren()[i + 1]->pos().x()
|
||||
+ delta * (i + 1),
|
||||
layoutsChildren()[i + 1]->pos().y());
|
||||
}
|
||||
}
|
||||
setIsRelocating(false);
|
||||
|
||||
@@ -29,34 +29,32 @@
|
||||
****************************************************************************/
|
||||
#ifndef LRHORIZONTALLAYOUT_H
|
||||
#define LRHORIZONTALLAYOUT_H
|
||||
#include "lrabstractlayout.h"
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrlayoutmarker.h"
|
||||
#include "lrabstractlayout.h"
|
||||
|
||||
namespace LimeReport
|
||||
{
|
||||
namespace LimeReport {
|
||||
|
||||
class HorizontalLayout : public AbstractLayout
|
||||
{
|
||||
class HorizontalLayout: public AbstractLayout {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(LayoutType layoutType READ layoutType WRITE setLayoutType)
|
||||
public:
|
||||
friend class LayoutMarker;
|
||||
friend class BaseDesignIntf;
|
||||
|
||||
HorizontalLayout(QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
HorizontalLayout(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
~HorizontalLayout();
|
||||
BaseDesignIntf *createSameTypeItem(QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
bool isSplittable() const { return true;}
|
||||
bool canContainChildren() const { return true;}
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isSplittable() const { return true; }
|
||||
bool canContainChildren() const { return true; }
|
||||
|
||||
protected:
|
||||
void updateLayoutSize();
|
||||
void relocateChildren();
|
||||
bool canBeSplitted(int height) const;
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
|
||||
void setItemAlign(const ItemAlign &itemAlign);
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
void setItemAlign(const ItemAlign& itemAlign);
|
||||
|
||||
private:
|
||||
void sortChildren();
|
||||
@@ -64,5 +62,5 @@ private:
|
||||
void placeItemInLayout(BaseDesignIntf* item);
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
#endif // LRHORIZONTALLAYOUT_H
|
||||
|
||||
@@ -28,47 +28,56 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrimageitem.h"
|
||||
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrimageitemeditor.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "ImageItem";
|
||||
|
||||
LimeReport::BaseDesignIntf * createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ImageItem(owner,parent);
|
||||
LimeReport::BaseDesignIntf* createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::ImageItem(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Image Item"),"Item"), createImageItem
|
||||
);
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Image Item"), "Item"), createImageItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
ImageItem::ImageItem(QObject* owner, QGraphicsItem* parent):
|
||||
ItemDesignIntf(xmlTag, owner, parent),
|
||||
m_useExternalPainter(false),
|
||||
m_externalPainter(0),
|
||||
m_autoSize(false),
|
||||
m_scale(true),
|
||||
m_keepAspectRatio(true),
|
||||
m_center(true),
|
||||
m_format(Binary)
|
||||
{
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ImageItem::ImageItem(QObject* owner,QGraphicsItem* parent)
|
||||
:ItemDesignIntf(xmlTag,owner,parent), m_useExternalPainter(false), m_externalPainter(0),
|
||||
m_autoSize(false), m_scale(true),
|
||||
m_keepAspectRatio(true), m_center(true), m_format(Binary){}
|
||||
|
||||
BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* ImageItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
ImageItem* result = new ImageItem(owner,parent);
|
||||
ImageItem* result = new ImageItem(owner, parent);
|
||||
result->setExternalPainter(m_externalPainter);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ImageItem::loadPictureFromVariant(QVariant& data){
|
||||
//TODO: Migrate to QMetaType
|
||||
if (data.isValid()){
|
||||
void ImageItem::loadPictureFromVariant(QVariant& data)
|
||||
{
|
||||
// TODO: Migrate to QMetaType
|
||||
if (data.isValid()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QImage){
|
||||
if (data.typeId() == QMetaType::QImage) {
|
||||
#else
|
||||
if (data.type() == QVariant::Image){
|
||||
if (data.type() == QVariant::Image) {
|
||||
#endif
|
||||
m_picture = data.value<QImage>();
|
||||
m_picture = data.value<QImage>();
|
||||
} else {
|
||||
switch (m_format) {
|
||||
default:
|
||||
@@ -83,35 +92,34 @@ void ImageItem::loadPictureFromVariant(QVariant& data){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ImageItem::preparePopUpMenu(QMenu &menu)
|
||||
void ImageItem::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit"));
|
||||
menu.insertAction(menu.actions().at(0),editAction);
|
||||
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"), tr("Edit"));
|
||||
menu.insertAction(menu.actions().at(0), editAction);
|
||||
menu.insertSeparator(menu.actions().at(1));
|
||||
|
||||
menu.addSeparator();
|
||||
QAction* action = menu.addAction(tr("Watermark"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(isWatermark());
|
||||
|
||||
}
|
||||
|
||||
void ImageItem::processPopUpAction(QAction *action)
|
||||
void ImageItem::processPopUpAction(QAction* action)
|
||||
{
|
||||
if (action->text().compare(tr("Watermark")) == 0){
|
||||
page()->setPropertyToSelectedItems("watermark",action->isChecked());
|
||||
if (action->text().compare(tr("Watermark")) == 0) {
|
||||
page()->setPropertyToSelectedItems("watermark", action->isChecked());
|
||||
}
|
||||
if (action->text().compare(tr("Edit")) == 0){
|
||||
if (action->text().compare(tr("Edit")) == 0) {
|
||||
this->showEditorDialog();
|
||||
}
|
||||
ItemDesignIntf::processPopUpAction(action);
|
||||
}
|
||||
|
||||
QImage getFileByResourcePath(QString resourcePath) {
|
||||
QImage getFileByResourcePath(QString resourcePath)
|
||||
{
|
||||
QFileInfo resourceFile(resourcePath);
|
||||
if (resourceFile.exists())
|
||||
return QImage(resourcePath);
|
||||
@@ -125,21 +133,18 @@ QImage ImageItem::drawImage() const
|
||||
return image();
|
||||
}
|
||||
|
||||
bool ImageItem::useExternalPainter() const
|
||||
{
|
||||
return m_useExternalPainter;
|
||||
}
|
||||
bool ImageItem::useExternalPainter() const { return m_useExternalPainter; }
|
||||
|
||||
void ImageItem::setUseExternalPainter(bool value)
|
||||
{
|
||||
if (m_useExternalPainter != value){
|
||||
if (m_useExternalPainter != value) {
|
||||
m_useExternalPainter = value;
|
||||
notify("useExternalPainter",!value, value);
|
||||
notify("useExternalPainter", !value, value);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *ImageItem::defaultEditor()
|
||||
QWidget* ImageItem::defaultEditor()
|
||||
{
|
||||
ImageItemEditor* editor = new ImageItemEditor(this);
|
||||
editor->setAttribute(Qt::WA_DeleteOnClose);
|
||||
@@ -151,7 +156,7 @@ QByteArray ImageItem::imageAsByteArray() const
|
||||
QByteArray result;
|
||||
QBuffer buffer(&result);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
m_picture.save(&buffer,"PNG");
|
||||
m_picture.save(&buffer, "PNG");
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -165,63 +170,59 @@ void ImageItem::setImageAsByteArray(QByteArray image)
|
||||
|
||||
QString ImageItem::fileFilter() const
|
||||
{
|
||||
return tr("Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*)");
|
||||
return tr("Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg "
|
||||
"*.bmp);;All(*.*)");
|
||||
}
|
||||
|
||||
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
|
||||
if (m_picture.isNull()){
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()){
|
||||
if (m_picture.isNull()) {
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()) {
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
loadPictureFromVariant(data);
|
||||
}
|
||||
} else if (!m_resourcePath.isEmpty()){
|
||||
m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager);
|
||||
m_picture = QImage(m_resourcePath);
|
||||
} else if (!m_variable.isEmpty()){
|
||||
//TODO: Migrate to QMetaType
|
||||
QVariant data = dataManager->variable(m_variable);
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
loadPictureFromVariant(data);
|
||||
}
|
||||
} else if (!m_resourcePath.isEmpty()) {
|
||||
m_resourcePath
|
||||
= expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager);
|
||||
m_picture = QImage(m_resourcePath);
|
||||
} else if (!m_variable.isEmpty()) {
|
||||
// TODO: Migrate to QMetaType
|
||||
QVariant data = dataManager->variable(m_variable);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QString){
|
||||
if (data.typeId() == QMetaType::QString) {
|
||||
#else
|
||||
if (data.type() == QVariant::String){
|
||||
if (data.type() == QVariant::String) {
|
||||
#endif
|
||||
m_picture = QImage(data.toString());
|
||||
} else {
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QImage){
|
||||
if (data.typeId() == QMetaType::QImage) {
|
||||
#else
|
||||
if (data.type() == QVariant::Image){
|
||||
if (data.type() == QVariant::Image) {
|
||||
#endif
|
||||
loadPictureFromVariant(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_autoSize){
|
||||
setWidth(m_picture.width());
|
||||
setHeight(m_picture.height());
|
||||
}
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_autoSize) {
|
||||
setWidth(m_picture.width());
|
||||
setHeight(m_picture.height());
|
||||
}
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
}
|
||||
|
||||
bool ImageItem::isNeedUpdateSize(RenderPass) const
|
||||
bool ImageItem::isNeedUpdateSize(RenderPass) const { return m_picture.isNull() || m_autoSize; }
|
||||
|
||||
QString ImageItem::resourcePath() const { return m_resourcePath; }
|
||||
|
||||
qreal ImageItem::minHeight() const
|
||||
{
|
||||
return m_picture.isNull() || m_autoSize;
|
||||
}
|
||||
|
||||
QString ImageItem::resourcePath() const
|
||||
{
|
||||
return m_resourcePath;
|
||||
}
|
||||
|
||||
qreal ImageItem::minHeight() const{
|
||||
if (!m_picture.isNull() && autoSize())
|
||||
{
|
||||
if (!m_picture.isNull() && autoSize()) {
|
||||
return m_picture.height();
|
||||
} else {
|
||||
return 0;
|
||||
@@ -230,65 +231,53 @@ qreal ImageItem::minHeight() const{
|
||||
|
||||
void ImageItem::setVariable(const QString& content)
|
||||
{
|
||||
if (m_variable!=content){
|
||||
if (m_variable != content) {
|
||||
QString oldValue = m_variable;
|
||||
m_variable=content;
|
||||
m_variable = content;
|
||||
update();
|
||||
notify("variable", oldValue, m_variable);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::center() const
|
||||
{
|
||||
return m_center;
|
||||
}
|
||||
bool ImageItem::center() const { return m_center; }
|
||||
|
||||
void ImageItem::setCenter(bool center)
|
||||
{
|
||||
if (m_center != center){
|
||||
if (m_center != center) {
|
||||
m_center = center;
|
||||
update();
|
||||
notify("center",!center,center);
|
||||
notify("center", !center, center);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::keepAspectRatio() const
|
||||
{
|
||||
return m_keepAspectRatio;
|
||||
}
|
||||
bool ImageItem::keepAspectRatio() const { return m_keepAspectRatio; }
|
||||
|
||||
void ImageItem::setKeepAspectRatio(bool keepAspectRatio)
|
||||
{
|
||||
if (m_keepAspectRatio != keepAspectRatio){
|
||||
if (m_keepAspectRatio != keepAspectRatio) {
|
||||
m_keepAspectRatio = keepAspectRatio;
|
||||
update();
|
||||
notify("keepAspectRatio",!keepAspectRatio,keepAspectRatio);
|
||||
notify("keepAspectRatio", !keepAspectRatio, keepAspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::scale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
bool ImageItem::scale() const { return m_scale; }
|
||||
|
||||
void ImageItem::setScale(bool scale)
|
||||
{
|
||||
if (m_scale != scale){
|
||||
if (m_scale != scale) {
|
||||
m_scale = scale;
|
||||
update();
|
||||
notify("scale",!scale,scale);
|
||||
notify("scale", !scale, scale);
|
||||
}
|
||||
}
|
||||
bool ImageItem::autoSize() const
|
||||
{
|
||||
return m_autoSize;
|
||||
}
|
||||
bool ImageItem::autoSize() const { return m_autoSize; }
|
||||
|
||||
void ImageItem::setAutoSize(bool autoSize)
|
||||
{
|
||||
if (m_autoSize != autoSize){
|
||||
if (m_autoSize != autoSize) {
|
||||
m_autoSize = autoSize;
|
||||
if (m_autoSize && !m_picture.isNull()){
|
||||
if (m_autoSize && !m_picture.isNull()) {
|
||||
setWidth(drawImage().width());
|
||||
setHeight(drawImage().height());
|
||||
setPossibleResizeDirectionFlags(Fixed);
|
||||
@@ -296,52 +285,49 @@ void ImageItem::setAutoSize(bool autoSize)
|
||||
setPossibleResizeDirectionFlags(AllDirections);
|
||||
}
|
||||
update();
|
||||
notify("autoSize",!autoSize,autoSize);
|
||||
notify("autoSize", !autoSize, autoSize);
|
||||
}
|
||||
}
|
||||
|
||||
QString ImageItem::field() const
|
||||
{
|
||||
return m_field;
|
||||
}
|
||||
QString ImageItem::field() const { return m_field; }
|
||||
|
||||
void ImageItem::setField(const QString &field)
|
||||
void ImageItem::setField(const QString& field)
|
||||
{
|
||||
if (m_field != field){
|
||||
if (m_field != field) {
|
||||
QString oldValue = m_field;
|
||||
m_field = field;
|
||||
update();
|
||||
notify("field",oldValue,field);
|
||||
notify("field", oldValue, field);
|
||||
}
|
||||
}
|
||||
|
||||
QString ImageItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString ImageItem::datasource() const { return m_datasource; }
|
||||
|
||||
void ImageItem::setDatasource(const QString &datasource)
|
||||
void ImageItem::setDatasource(const QString& datasource)
|
||||
{
|
||||
if (m_datasource != datasource){
|
||||
if (m_datasource != datasource) {
|
||||
QString oldValue = m_datasource;
|
||||
m_datasource = datasource;
|
||||
update();
|
||||
notify("datasource",oldValue,datasource);
|
||||
notify("datasource", oldValue, datasource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void ImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
painter->save();
|
||||
if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY);
|
||||
else painter->setOpacity(qreal(opacity())/100);
|
||||
if (isSelected())
|
||||
painter->setOpacity(Const::SELECTION_OPACITY);
|
||||
else
|
||||
painter->setOpacity(qreal(opacity()) / 100);
|
||||
|
||||
QPointF point = rect().topLeft();
|
||||
QImage img;
|
||||
|
||||
if (m_scale && !drawImage().isNull()){
|
||||
img = drawImage().scaled(rect().width(), rect().height(), keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
if (m_scale && !drawImage().isNull()) {
|
||||
img = drawImage().scaled(rect().width(), rect().height(),
|
||||
keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
} else {
|
||||
img = drawImage();
|
||||
}
|
||||
@@ -349,73 +335,75 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
qreal shiftHeight = rect().height() - img.height();
|
||||
qreal shiftWidth = rect().width() - img.width();
|
||||
|
||||
if (m_center){
|
||||
if (shiftHeight<0 || shiftWidth<0){
|
||||
if (m_center) {
|
||||
if (shiftHeight < 0 || shiftWidth < 0) {
|
||||
qreal cutX = 0;
|
||||
qreal cutY = 0;
|
||||
qreal cutWidth = img.width();
|
||||
qreal cutHeigth = img.height();
|
||||
|
||||
if (shiftWidth > 0){
|
||||
point.setX(point.x()+shiftWidth/2);
|
||||
if (shiftWidth > 0) {
|
||||
point.setX(point.x() + shiftWidth / 2);
|
||||
} else {
|
||||
cutX = fabs(shiftWidth/2);
|
||||
cutX = fabs(shiftWidth / 2);
|
||||
cutWidth += shiftWidth;
|
||||
}
|
||||
|
||||
if (shiftHeight > 0){
|
||||
point.setY(point.y()+shiftHeight/2);
|
||||
if (shiftHeight > 0) {
|
||||
point.setY(point.y() + shiftHeight / 2);
|
||||
} else {
|
||||
cutY = fabs(shiftHeight/2);
|
||||
cutY = fabs(shiftHeight / 2);
|
||||
cutHeigth += shiftHeight;
|
||||
}
|
||||
|
||||
img = img.copy(cutX,cutY,cutWidth,cutHeigth);
|
||||
img = img.copy(cutX, cutY, cutWidth, cutHeigth);
|
||||
} else {
|
||||
point.setX(point.x()+shiftWidth/2);
|
||||
point.setY(point.y()+shiftHeight/2);
|
||||
point.setX(point.x() + shiftWidth / 2);
|
||||
point.setY(point.y() + shiftHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (img.isNull() && itemMode() == DesignMode){
|
||||
if (img.isNull() && itemMode() == DesignMode) {
|
||||
QString text;
|
||||
painter->setFont(transformToSceneFont(QFont("Arial",10)));
|
||||
painter->setFont(transformToSceneFont(QFont("Arial", 10)));
|
||||
painter->setPen(Qt::black);
|
||||
if (!datasource().isEmpty() && !field().isEmpty())
|
||||
text = datasource()+"."+field();
|
||||
else if (m_useExternalPainter) text = tr("Ext."); else text = tr("Image");
|
||||
painter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text );
|
||||
text = datasource() + "." + field();
|
||||
else if (m_useExternalPainter)
|
||||
text = tr("Ext.");
|
||||
else
|
||||
text = tr("Image");
|
||||
painter->drawText(rect().adjusted(4, 4, -4, -4), Qt::AlignCenter, text);
|
||||
} else {
|
||||
if (m_externalPainter && m_useExternalPainter)
|
||||
m_externalPainter->paintByExternalPainter(this->patternName(), painter, option);
|
||||
else
|
||||
painter->drawImage(point,img);
|
||||
painter->drawImage(point, img);
|
||||
}
|
||||
|
||||
ItemDesignIntf::paint(painter,option,widget);
|
||||
ItemDesignIntf::paint(painter, option, widget);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void ImageItem::setImage(QImage value)
|
||||
{
|
||||
if (m_picture != value){
|
||||
if (m_picture != value) {
|
||||
QImage oldValue = m_picture;
|
||||
m_picture = value;
|
||||
if (m_autoSize){
|
||||
if (m_autoSize) {
|
||||
setWidth(m_picture.width());
|
||||
setHeight(m_picture.height());
|
||||
}
|
||||
update();
|
||||
notify("image",oldValue,value);
|
||||
notify("image", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
QImage ImageItem::image() const{
|
||||
return m_picture;
|
||||
}
|
||||
QImage ImageItem::image() const { return m_picture; }
|
||||
|
||||
void ImageItem::setResourcePath(const QString &value){
|
||||
if (m_resourcePath != value){
|
||||
void ImageItem::setResourcePath(const QString& value)
|
||||
{
|
||||
if (m_resourcePath != value) {
|
||||
QString oldValue = m_resourcePath;
|
||||
m_resourcePath = value;
|
||||
update();
|
||||
@@ -423,24 +411,18 @@ void ImageItem::setResourcePath(const QString &value){
|
||||
}
|
||||
}
|
||||
|
||||
ImageItem::Format ImageItem::format() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
ImageItem::Format ImageItem::format() const { return m_format; }
|
||||
|
||||
void ImageItem::setFormat(Format format)
|
||||
{
|
||||
if (m_format!=format){
|
||||
if (m_format != format) {
|
||||
Format oldValue = m_format;
|
||||
m_format=format;
|
||||
m_format = format;
|
||||
update();
|
||||
notify("format",oldValue,format);
|
||||
notify("format", oldValue, format);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
bool LimeReport::ImageItem::isEmpty() const
|
||||
{
|
||||
return drawImage().isNull();
|
||||
}
|
||||
bool LimeReport::ImageItem::isEmpty() const { return drawImage().isNull(); }
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
****************************************************************************/
|
||||
#ifndef LRIMAGEITEM_H
|
||||
#define LRIMAGEITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lreditableimageitemintf.h"
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ImageItem : public ItemDesignIntf, public IPainterProxy, public IEditableImageItem
|
||||
{
|
||||
class ImageItem: public ItemDesignIntf, public IPainterProxy, public IEditableImageItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QImage image READ image WRITE setImage)
|
||||
Q_PROPERTY(int opacity READ opacity WRITE setOpacity)
|
||||
@@ -54,9 +54,9 @@ class ImageItem : public ItemDesignIntf, public IPainterProxy, public IEditableI
|
||||
|
||||
public:
|
||||
enum Format {
|
||||
Binary = 0,
|
||||
Hex = 1,
|
||||
Base64 = 2
|
||||
Binary = 0,
|
||||
Hex = 1,
|
||||
Base64 = 2
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(Format)
|
||||
@@ -64,16 +64,16 @@ public:
|
||||
Q_ENUMS(Format)
|
||||
#endif
|
||||
|
||||
ImageItem(QObject *owner, QGraphicsItem *parent);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
ImageItem(QObject* owner, QGraphicsItem* parent);
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
void setImage(QImage value);
|
||||
QImage image() const;
|
||||
void setResourcePath(const QString &value);
|
||||
void setResourcePath(const QString& value);
|
||||
QString resourcePath() const;
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
QString field() const;
|
||||
void setField(const QString &field);
|
||||
void setField(const QString& field);
|
||||
|
||||
bool autoSize() const;
|
||||
void setAutoSize(bool autoSize);
|
||||
@@ -87,10 +87,13 @@ public:
|
||||
void setFormat(Format format);
|
||||
qreal minHeight() const;
|
||||
|
||||
QString variable(){ return m_variable;}
|
||||
QString variable() { return m_variable; }
|
||||
void setVariable(const QString& variable);
|
||||
|
||||
void setExternalPainter(IExternalPainter* externalPainter){ m_externalPainter = externalPainter;}
|
||||
void setExternalPainter(IExternalPainter* externalPainter)
|
||||
{
|
||||
m_externalPainter = externalPainter;
|
||||
}
|
||||
|
||||
bool useExternalPainter() const;
|
||||
void setUseExternalPainter(bool value);
|
||||
@@ -100,34 +103,35 @@ public:
|
||||
QByteArray imageAsByteArray() const;
|
||||
void setImageAsByteArray(QByteArray image);
|
||||
QString fileFilter() const;
|
||||
|
||||
protected:
|
||||
BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
bool isNeedUpdateSize(RenderPass) const;
|
||||
bool drawDesignBorders() const {return m_picture.isNull();}
|
||||
bool drawDesignBorders() const { return m_picture.isNull(); }
|
||||
void loadPictureFromVariant(QVariant& data);
|
||||
void preparePopUpMenu(QMenu &menu);
|
||||
void processPopUpAction(QAction *action);
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
QImage drawImage() const;
|
||||
|
||||
private:
|
||||
QImage m_picture;
|
||||
QImage m_picture;
|
||||
bool m_useExternalPainter;
|
||||
IExternalPainter* m_externalPainter;
|
||||
QString m_resourcePath;
|
||||
QString m_datasource;
|
||||
QString m_field;
|
||||
bool m_autoSize;
|
||||
bool m_scale;
|
||||
bool m_keepAspectRatio;
|
||||
bool m_center;
|
||||
Format m_format;
|
||||
bool m_autoSize;
|
||||
bool m_scale;
|
||||
bool m_keepAspectRatio;
|
||||
bool m_center;
|
||||
Format m_format;
|
||||
QString m_variable;
|
||||
|
||||
|
||||
// BaseDesignIntf interface
|
||||
public:
|
||||
public:
|
||||
bool isEmpty() const override;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRIMAGEITEM_H
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#include "lrimageitemeditor.h"
|
||||
#include "ui_lrimageitemeditor.h"
|
||||
|
||||
#include "lrimageitem.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
||||
ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *parent) :
|
||||
ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::ImageItemEditor), m_item(item)
|
||||
ui(new Ui::ImageItemEditor),
|
||||
m_item(item)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_image = item->imageAsByteArray();
|
||||
@@ -15,15 +17,12 @@ ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *
|
||||
updateImage();
|
||||
}
|
||||
|
||||
ImageItemEditor::~ImageItemEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ImageItemEditor::~ImageItemEditor() { delete ui; }
|
||||
|
||||
void ImageItemEditor::updateImage()
|
||||
{
|
||||
QPixmap image;
|
||||
if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()){
|
||||
if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()) {
|
||||
image.load(ui->resourcePath->text());
|
||||
} else {
|
||||
image.loadFromData(m_image);
|
||||
@@ -33,9 +32,10 @@ void ImageItemEditor::updateImage()
|
||||
|
||||
void ImageItemEditor::on_tbLoadImage_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", m_item->fileFilter());
|
||||
QString fileName
|
||||
= QFileDialog::getOpenFileName(this, tr("Select image file"), "", m_item->fileFilter());
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly)){
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
m_image = file.readAll();
|
||||
}
|
||||
updateImage();
|
||||
@@ -55,10 +55,7 @@ void ImageItemEditor::on_buttonBox_accepted()
|
||||
this->close();
|
||||
}
|
||||
|
||||
void ImageItemEditor::on_buttonBox_rejected()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
void ImageItemEditor::on_buttonBox_rejected() { this->close(); }
|
||||
|
||||
void ImageItemEditor::on_toolButton_clicked()
|
||||
{
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef LRIMAGEITEMEDITOR_H
|
||||
#define LRIMAGEITEMEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lreditableimageitemintf.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ImageItemEditor;
|
||||
}
|
||||
@@ -12,17 +13,18 @@ namespace LimeReport {
|
||||
class ImageItem;
|
||||
}
|
||||
|
||||
class ImageItemEditor : public QWidget
|
||||
{
|
||||
class ImageItemEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget *parent = NULL);
|
||||
explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent = NULL);
|
||||
~ImageItemEditor();
|
||||
|
||||
private:
|
||||
void updateImage();
|
||||
|
||||
private:
|
||||
Ui::ImageItemEditor *ui;
|
||||
Ui::ImageItemEditor* ui;
|
||||
LimeReport::IEditableImageItem* m_item;
|
||||
|
||||
QByteArray m_image;
|
||||
|
||||
@@ -1,38 +1,44 @@
|
||||
#include "lrlayoutmarker.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
LayoutMarker::LayoutMarker(BaseDesignIntf* layout, QGraphicsItem *parent)
|
||||
:QGraphicsItem(parent), m_rect(0,0,30,30), m_color(Qt::red), m_layout(layout){
|
||||
LayoutMarker::LayoutMarker(BaseDesignIntf* layout, QGraphicsItem* parent):
|
||||
QGraphicsItem(parent),
|
||||
m_rect(0, 0, 30, 30),
|
||||
m_color(Qt::red),
|
||||
m_layout(layout)
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemIsMovable);
|
||||
}
|
||||
|
||||
void LayoutMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
void LayoutMarker::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
|
||||
{
|
||||
painter->save();
|
||||
painter->setOpacity(Const::LAYOUT_MARKER_OPACITY);
|
||||
painter->fillRect(boundingRect(),m_color);
|
||||
painter->fillRect(boundingRect(), m_color);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
||||
qreal size = (boundingRect().width() < boundingRect().height()) ? boundingRect().width()
|
||||
: boundingRect().height();
|
||||
|
||||
if (m_layout->isSelected()){
|
||||
if (m_layout->isSelected()) {
|
||||
painter->setOpacity(1);
|
||||
QRectF r = QRectF(0,0,size,size);
|
||||
QRectF r = QRectF(0, 0, size, size);
|
||||
painter->setBrush(Qt::white);
|
||||
painter->setPen(Qt::white);
|
||||
painter->drawEllipse(r.adjusted(5,5,-5,-5));
|
||||
painter->drawEllipse(r.adjusted(5, 5, -5, -5));
|
||||
painter->setBrush(m_color);
|
||||
painter->drawEllipse(r.adjusted(7,7,-7,-7));
|
||||
painter->drawEllipse(r.adjusted(7, 7, -7, -7));
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void LayoutMarker::setHeight(qreal height)
|
||||
{
|
||||
if (m_rect.height()!=height){
|
||||
if (m_rect.height() != height) {
|
||||
prepareGeometryChange();
|
||||
m_rect.setHeight(height);
|
||||
}
|
||||
@@ -40,7 +46,7 @@ void LayoutMarker::setHeight(qreal height)
|
||||
|
||||
void LayoutMarker::setWidth(qreal width)
|
||||
{
|
||||
if (m_rect.width()!=width){
|
||||
if (m_rect.width() != width) {
|
||||
prepareGeometryChange();
|
||||
m_rect.setWidth(width);
|
||||
}
|
||||
@@ -48,22 +54,21 @@ void LayoutMarker::setWidth(qreal width)
|
||||
|
||||
void LayoutMarker::setColor(QColor color)
|
||||
{
|
||||
if (m_color!=color){
|
||||
if (m_color != color) {
|
||||
m_color = color;
|
||||
update(boundingRect());
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
void LayoutMarker::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button()==Qt::LeftButton) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (!(event->modifiers() & Qt::ControlModifier))
|
||||
m_layout->scene()->clearSelection();
|
||||
m_layout->setSelected(true);
|
||||
//m_layout->setChildVisibility(false);
|
||||
update(0,0,boundingRect().width(),boundingRect().width());
|
||||
// m_layout->setChildVisibility(false);
|
||||
update(0, 0, boundingRect().width(), boundingRect().width());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
#ifndef LRLAYOUTMARKER_H
|
||||
#define LRLAYOUTMARKER_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "lrbanddesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QGraphicsItem>
|
||||
|
||||
class LayoutMarker : public QGraphicsItem{
|
||||
namespace LimeReport {
|
||||
|
||||
class LayoutMarker: public QGraphicsItem {
|
||||
public:
|
||||
explicit LayoutMarker(BaseDesignIntf* layout, QGraphicsItem *parent=0);
|
||||
virtual QRectF boundingRect() const{return m_rect;}
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
explicit LayoutMarker(BaseDesignIntf* layout, QGraphicsItem* parent = 0);
|
||||
virtual QRectF boundingRect() const { return m_rect; }
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
|
||||
void setHeight(qreal height);
|
||||
void setWidth(qreal width);
|
||||
void setColor(QColor color);
|
||||
qreal width(){return m_rect.width();}
|
||||
qreal height(){return m_rect.height();}
|
||||
qreal width() { return m_rect.width(); }
|
||||
qreal height() { return m_rect.height(); }
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
|
||||
private:
|
||||
QRectF m_rect;
|
||||
QColor m_color;
|
||||
|
||||
@@ -1,53 +1,58 @@
|
||||
#include "lrpageeditor.h"
|
||||
#include "ui_lrpageeditor.h"
|
||||
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QPageSize>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
|
||||
PageEditor::PageEditor(QWidget* parent, LimeReport::PageItemDesignIntf* page):
|
||||
QDialog(parent),
|
||||
ui(new Ui::PageEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_page = page;
|
||||
//Paper
|
||||
QMetaEnum pageSizes = page->metaObject()->property(page->metaObject()->indexOfProperty("pageSize")).enumerator();
|
||||
// Paper
|
||||
QMetaEnum pageSizes = page->metaObject()
|
||||
->property(page->metaObject()->indexOfProperty("pageSize"))
|
||||
.enumerator();
|
||||
|
||||
for (int i=0;i<pageSizes.keyCount();i++){
|
||||
for (int i = 0; i < pageSizes.keyCount(); i++) {
|
||||
ui->format->addItem(pageSizes.key(i));
|
||||
}
|
||||
ui->format->setCurrentIndex(m_page->pageSize());
|
||||
ui->width->setValue(m_page->width() / m_page->unitFactor());
|
||||
ui->height->setValue(m_page->height() / m_page->unitFactor());
|
||||
ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait);
|
||||
ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape);
|
||||
//Margins
|
||||
ui->landscape->setChecked(m_page->pageOrientation()
|
||||
== LimeReport::PageItemDesignIntf::Landscape);
|
||||
// Margins
|
||||
ui->marginTop->setValue(m_page->topMargin());
|
||||
ui->marginRight->setValue(m_page->rightMargin());
|
||||
ui->marginLeft->setValue(m_page->leftMargin());
|
||||
ui->marginBottom->setValue(m_page->bottomMargin());
|
||||
ui->dropPrinterMargins->setChecked(m_page->dropPrinterMargins());
|
||||
|
||||
//Other
|
||||
// Other
|
||||
ui->endlessHeight->setChecked(m_page->endlessHeight());
|
||||
ui->extendedHeight->setValue(m_page->extendedHeight());
|
||||
ui->fullPage->setChecked(m_page->fullPage());
|
||||
}
|
||||
|
||||
PageEditor::~PageEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
PageEditor::~PageEditor() { delete ui; }
|
||||
|
||||
void PageEditor::applyChanges()
|
||||
{
|
||||
m_page->setPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(ui->format->currentIndex()));
|
||||
m_page->setPageSize(
|
||||
static_cast<LimeReport::PageItemDesignIntf::PageSize>(ui->format->currentIndex()));
|
||||
m_page->setWidth(ui->width->value() * LimeReport::Const::mmFACTOR);
|
||||
m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR);
|
||||
m_page->setPageOrientation(ui->portrait->isChecked()? LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape);
|
||||
m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR);
|
||||
m_page->setPageOrientation(ui->portrait->isChecked()
|
||||
? LimeReport::PageItemDesignIntf::Portrait
|
||||
: LimeReport::PageItemDesignIntf::Landscape);
|
||||
m_page->setTopMargin(ui->marginTop->value());
|
||||
m_page->setBottomMargin(ui->marginBottom->value());
|
||||
m_page->setRightMargin(ui->marginRight->value());
|
||||
@@ -65,7 +70,8 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
|
||||
QPrinter printer;
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait : QPrinter::Landscape);
|
||||
printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait
|
||||
: QPrinter::Landscape);
|
||||
printer.setPaperSize((QPrinter::PageSize)size);
|
||||
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * m_page->unitFactor(),
|
||||
printer.paperSize(QPrinter::Millimeter).height() * m_page->unitFactor());
|
||||
@@ -73,8 +79,10 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
|
||||
#else
|
||||
printer.setPageOrientation((QPageLayout::Orientation)m_page->pageOrientation());
|
||||
printer.setPageSize(QPageSize((QPageSize::PageSizeId)size));
|
||||
return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * m_page->unitFactor(),
|
||||
printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * m_page->unitFactor());
|
||||
return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width()
|
||||
* m_page->unitFactor(),
|
||||
printer.pageLayout().pageSize().size(QPageSize::Millimeter).height()
|
||||
* m_page->unitFactor());
|
||||
#endif
|
||||
} else {
|
||||
return QSizeF(m_page->getItemWidth(), m_page->getItemHeight());
|
||||
@@ -84,27 +92,24 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
|
||||
void PageEditor::on_format_currentIndexChanged(int index)
|
||||
{
|
||||
QPageSize ps = *new QPageSize();
|
||||
if(ui->format->currentText() != "Custom")
|
||||
{
|
||||
QSizeF pageSize = getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index));
|
||||
if (ui->format->currentText() != "Custom") {
|
||||
QSizeF pageSize
|
||||
= getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index));
|
||||
ui->width->setValue(pageSize.width() / m_page->unitFactor());
|
||||
ui->height->setValue(pageSize.height() / m_page->unitFactor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PageEditor::on_buttonBox_clicked(QAbstractButton *button)
|
||||
void PageEditor::on_buttonBox_clicked(QAbstractButton* button)
|
||||
{
|
||||
switch(ui->buttonBox->buttonRole(button)){
|
||||
case QDialogButtonBox::ApplyRole:
|
||||
applyChanges();
|
||||
break;
|
||||
case QDialogButtonBox::AcceptRole:
|
||||
applyChanges();
|
||||
accept();
|
||||
switch (ui->buttonBox->buttonRole(button)) {
|
||||
case QDialogButtonBox::ApplyRole:
|
||||
applyChanges();
|
||||
break;
|
||||
case QDialogButtonBox::AcceptRole:
|
||||
applyChanges();
|
||||
accept();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
#ifndef LRPAGEEDITOR_H
|
||||
#define LRPAGEEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrpageitemdesignintf.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPushButton>
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class PageEditor;
|
||||
}
|
||||
|
||||
class LIMEREPORT_EXPORT PageEditor : public QDialog
|
||||
{
|
||||
class LIMEREPORT_EXPORT PageEditor: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PageEditor(QWidget *parent = nullptr,LimeReport::PageItemDesignIntf *page = nullptr);
|
||||
explicit PageEditor(QWidget* parent = nullptr, LimeReport::PageItemDesignIntf* page = nullptr);
|
||||
~PageEditor();
|
||||
|
||||
private slots:
|
||||
// void on_buttonBox_accepted();
|
||||
// void on_buttonBox_accepted();
|
||||
void on_format_currentIndexChanged(int index);
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
void on_buttonBox_clicked(QAbstractButton* button);
|
||||
|
||||
private:
|
||||
Ui::PageEditor *ui;
|
||||
Ui::PageEditor* ui;
|
||||
LimeReport::PageItemDesignIntf* m_page;
|
||||
|
||||
void applyChanges();
|
||||
|
||||
@@ -28,53 +28,51 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrshapeitem.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QPainter>
|
||||
|
||||
namespace{
|
||||
#include "lrdesignelementsfactory.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "ShapeItem";
|
||||
|
||||
LimeReport::BaseDesignIntf * createShapeItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ShapeItem(owner,parent);
|
||||
LimeReport::BaseDesignIntf* createShapeItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::ShapeItem(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Shape Item"),"Item"), createShapeItem
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Shape Item"), "Item"), createShapeItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ShapeItem::ShapeItem(QObject *owner, QGraphicsItem *parent)
|
||||
:ItemDesignIntf(xmlTag,owner,parent),
|
||||
m_shape(HorizontalLine),
|
||||
m_shapeColor(Qt::black),
|
||||
m_shapeBrushColor(Qt::black),
|
||||
m_shapeBrushType(Qt::NoBrush),
|
||||
m_lineWidth(1),
|
||||
m_penStyle(Qt::SolidLine),
|
||||
m_cornerRadius(0)
|
||||
ShapeItem::ShapeItem(QObject* owner, QGraphicsItem* parent):
|
||||
ItemDesignIntf(xmlTag, owner, parent),
|
||||
m_shape(HorizontalLine),
|
||||
m_shapeColor(Qt::black),
|
||||
m_shapeBrushColor(Qt::black),
|
||||
m_shapeBrushType(Qt::NoBrush),
|
||||
m_lineWidth(1),
|
||||
m_penStyle(Qt::SolidLine),
|
||||
m_cornerRadius(0)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::PenStyle ShapeItem::penStyle() const
|
||||
{
|
||||
return m_penStyle;
|
||||
}
|
||||
Qt::PenStyle ShapeItem::penStyle() const { return m_penStyle; }
|
||||
|
||||
void ShapeItem::setPenStyle(const Qt::PenStyle &value)
|
||||
void ShapeItem::setPenStyle(const Qt::PenStyle& value)
|
||||
{
|
||||
if ((value!=m_penStyle)){
|
||||
if ((value != m_penStyle)) {
|
||||
Qt::PenStyle oldValue = m_penStyle;
|
||||
m_penStyle=value;
|
||||
m_penStyle = value;
|
||||
update();
|
||||
notify("penStyle",(int)oldValue,(int)value);
|
||||
notify("penStyle", (int)oldValue, (int)value);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void ShapeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
|
||||
painter->save();
|
||||
@@ -84,32 +82,30 @@ void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
pen.setStyle(m_penStyle);
|
||||
pen.setJoinStyle(Qt::MiterJoin);
|
||||
painter->setPen(pen);
|
||||
QBrush brush(m_shapeBrushColor,m_shapeBrushType);
|
||||
QBrush brush(m_shapeBrushColor, m_shapeBrushType);
|
||||
brush.setTransform(painter->worldTransform().inverted());
|
||||
painter->setBrush(brush);
|
||||
painter->setBackground(QBrush(Qt::NoBrush));
|
||||
painter->setOpacity(qreal(opacity())/100);
|
||||
painter->setOpacity(qreal(opacity()) / 100);
|
||||
|
||||
QRectF rectangleRect = rect().adjusted((lineWidth() / 2),
|
||||
(lineWidth() / 2),
|
||||
-(lineWidth() / 2),
|
||||
QRectF rectangleRect = rect().adjusted((lineWidth() / 2), (lineWidth() / 2), -(lineWidth() / 2),
|
||||
-(lineWidth() / 2));
|
||||
|
||||
switch (m_shape){
|
||||
switch (m_shape) {
|
||||
case HorizontalLine:
|
||||
painter->drawLine(0,rect().height()/2,rect().right(),rect().height()/2);
|
||||
painter->drawLine(0, rect().height() / 2, rect().right(), rect().height() / 2);
|
||||
break;
|
||||
case VerticalLine:
|
||||
painter->drawLine(rect().width()/2,0,rect().width()/2,rect().height());
|
||||
painter->drawLine(rect().width() / 2, 0, rect().width() / 2, rect().height());
|
||||
break;
|
||||
case Ellipse:
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->drawEllipse(rect());
|
||||
break;
|
||||
case Rectangle:
|
||||
if (m_cornerRadius != 0){
|
||||
if (m_cornerRadius != 0) {
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->drawRoundedRect(rectangleRect,m_cornerRadius,m_cornerRadius);
|
||||
painter->drawRoundedRect(rectangleRect, m_cornerRadius, m_cornerRadius);
|
||||
} else {
|
||||
painter->drawRect(rectangleRect);
|
||||
}
|
||||
@@ -117,79 +113,74 @@ void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
ItemDesignIntf::paint(painter,option,widget);
|
||||
|
||||
ItemDesignIntf::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
void ShapeItem::setShapeColor(QColor value)
|
||||
{
|
||||
if ((value!=m_shapeColor)){
|
||||
if ((value != m_shapeColor)) {
|
||||
QColor oldValue = m_shapeColor;
|
||||
m_shapeColor=value;
|
||||
m_shapeColor = value;
|
||||
update();
|
||||
notify("shapeColor",oldValue,value);
|
||||
notify("shapeColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeItem::setShapeBrushColor(QColor value)
|
||||
{
|
||||
if (value!=m_shapeBrushColor){
|
||||
if (value != m_shapeBrushColor) {
|
||||
QColor oldValue = m_shapeBrushColor;
|
||||
m_shapeBrushColor=value;
|
||||
m_shapeBrushColor = value;
|
||||
update();
|
||||
notify("shapeBrushColor",oldValue,value);
|
||||
notify("shapeBrushColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeItem::setShapeBrushType(Qt::BrushStyle value)
|
||||
{
|
||||
if (m_shapeBrushType!=value){
|
||||
if (m_shapeBrushType != value) {
|
||||
Qt::BrushStyle oldValue = m_shapeBrushType;
|
||||
m_shapeBrushType=value;
|
||||
m_shapeBrushType = value;
|
||||
update(rect());
|
||||
notify("shapeBrush",QBrush(oldValue),QBrush(value));
|
||||
notify("shapeBrush", QBrush(oldValue), QBrush(value));
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeItem::setShapeType(ShapeItem::ShapeType value)
|
||||
{
|
||||
if (m_shape!=value){
|
||||
if (m_shape != value) {
|
||||
ShapeType oldValue = m_shape;
|
||||
m_shape=value;
|
||||
m_shape = value;
|
||||
update();
|
||||
notify("shape",oldValue,value);
|
||||
notify("shape", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeItem::setLineWidth(qreal value)
|
||||
{
|
||||
if (m_lineWidth!=value){
|
||||
if (m_lineWidth != value) {
|
||||
qreal oldValue = m_lineWidth;
|
||||
m_lineWidth=value;
|
||||
m_lineWidth = value;
|
||||
update();
|
||||
notify("lineWidth",oldValue,value);
|
||||
|
||||
notify("lineWidth", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
BaseDesignIntf *ShapeItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* ShapeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new ShapeItem(owner,parent);
|
||||
return new ShapeItem(owner, parent);
|
||||
}
|
||||
|
||||
int ShapeItem::cornerRadius() const
|
||||
{
|
||||
return m_cornerRadius;
|
||||
}
|
||||
int ShapeItem::cornerRadius() const { return m_cornerRadius; }
|
||||
|
||||
void ShapeItem::setCornerRadius(int borderRadius)
|
||||
{
|
||||
if (m_cornerRadius != borderRadius){
|
||||
if (m_cornerRadius != borderRadius) {
|
||||
int oldValue = m_cornerRadius;
|
||||
m_cornerRadius = borderRadius;
|
||||
update();
|
||||
notify("cornerRadius",oldValue,m_cornerRadius);
|
||||
notify("cornerRadius", oldValue, m_cornerRadius);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#ifndef LRSHAPEITEM_H
|
||||
#define LRSHAPEITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ShapeItem: public LimeReport::ItemDesignIntf
|
||||
{
|
||||
class ShapeItem: public LimeReport::ItemDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(ShapeType shape READ shapeType WRITE setShapeType)
|
||||
Q_PROPERTY(QColor shapeColor READ shapeColor WRITE setShapeColor)
|
||||
@@ -46,32 +46,38 @@ class ShapeItem: public LimeReport::ItemDesignIntf
|
||||
Q_PROPERTY(int opacity READ opacity WRITE setOpacity)
|
||||
Q_PROPERTY(int cornerRadius READ cornerRadius WRITE setCornerRadius)
|
||||
public:
|
||||
enum ShapeType{HorizontalLine,VerticalLine,Ellipse,Rectangle};
|
||||
enum ShapeType {
|
||||
HorizontalLine,
|
||||
VerticalLine,
|
||||
Ellipse,
|
||||
Rectangle
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(ShapeType)
|
||||
#else
|
||||
Q_ENUMS(ShapeType)
|
||||
#endif
|
||||
ShapeItem(QObject *owner, QGraphicsItem *parent);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void setShapeColor(QColor value);
|
||||
QColor shapeColor() const {return m_shapeColor;}
|
||||
void setShapeBrushColor(QColor value);
|
||||
QColor shapeBrushColor() const {return m_shapeBrushColor;}
|
||||
void setShapeBrushType(Qt::BrushStyle value);
|
||||
Qt::BrushStyle shapeBrushType() const {return m_shapeBrushType;}
|
||||
void setShapeType(ShapeType value);
|
||||
ShapeType shapeType() const {return m_shape;}
|
||||
void setLineWidth(qreal value);
|
||||
qreal lineWidth() const {return m_lineWidth;}
|
||||
ShapeItem(QObject* owner, QGraphicsItem* parent);
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
void setShapeColor(QColor value);
|
||||
QColor shapeColor() const { return m_shapeColor; }
|
||||
void setShapeBrushColor(QColor value);
|
||||
QColor shapeBrushColor() const { return m_shapeBrushColor; }
|
||||
void setShapeBrushType(Qt::BrushStyle value);
|
||||
Qt::BrushStyle shapeBrushType() const { return m_shapeBrushType; }
|
||||
void setShapeType(ShapeType value);
|
||||
ShapeType shapeType() const { return m_shape; }
|
||||
void setLineWidth(qreal value);
|
||||
qreal lineWidth() const { return m_lineWidth; }
|
||||
Qt::PenStyle penStyle() const;
|
||||
void setPenStyle(const Qt::PenStyle &value);
|
||||
void setPenStyle(const Qt::PenStyle& value);
|
||||
int cornerRadius() const;
|
||||
void setCornerRadius(int cornerRadius);
|
||||
|
||||
protected:
|
||||
BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
bool drawDesignBorders() const {return false;}
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
bool drawDesignBorders() const { return false; }
|
||||
|
||||
private:
|
||||
ShapeType m_shape;
|
||||
QColor m_shapeColor;
|
||||
@@ -79,9 +85,9 @@ private:
|
||||
Qt::BrushStyle m_shapeBrushType;
|
||||
qreal m_lineWidth;
|
||||
Qt::PenStyle m_penStyle;
|
||||
// int m_opacity;
|
||||
// int m_opacity;
|
||||
int m_cornerRadius;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRSHAPEITEM_H
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrsimpletagparser.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#if QT_VERSION < 0x060000
|
||||
@@ -35,28 +36,28 @@
|
||||
#else
|
||||
#include <QRegularExpression>
|
||||
#endif
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void HtmlContext::fillTagVector(QString html)
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
QRegExp rx("<[^<]*>");
|
||||
QString buff=html;
|
||||
int curPos=0;
|
||||
while(buff.contains(rx)){
|
||||
int pos=rx.indexIn(buff);
|
||||
curPos+=pos;
|
||||
buff=buff.right(buff.length()-pos);
|
||||
if (rx.cap().at(1)!='/'){
|
||||
int initPos=curPos;
|
||||
parseTag(m_tags,buff,initPos);
|
||||
QString buff = html;
|
||||
int curPos = 0;
|
||||
while (buff.contains(rx)) {
|
||||
int pos = rx.indexIn(buff);
|
||||
curPos += pos;
|
||||
buff = buff.right(buff.length() - pos);
|
||||
if (rx.cap().at(1) != '/') {
|
||||
int initPos = curPos;
|
||||
parseTag(m_tags, buff, initPos);
|
||||
}
|
||||
buff=buff.right(buff.length()-rx.matchedLength());
|
||||
buff = buff.right(buff.length() - rx.matchedLength());
|
||||
}
|
||||
#else
|
||||
QRegularExpression rx("<[^<]*>");
|
||||
QString buff=html;
|
||||
while(buff.contains(rx)){
|
||||
QString buff = html;
|
||||
while (buff.contains(rx)) {
|
||||
QRegularExpressionMatch match = rx.match(buff);
|
||||
// TODO: Qt6 port
|
||||
}
|
||||
@@ -64,32 +65,32 @@ void HtmlContext::fillTagVector(QString html)
|
||||
#endif
|
||||
}
|
||||
|
||||
QString HtmlContext::parseTag(QVector<Tag *> &storage, QString text, int &curPos, bool createTag)
|
||||
QString HtmlContext::parseTag(QVector<Tag*>& storage, QString text, int& curPos, bool createTag)
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
QRegExp rx("<[^<]*>");
|
||||
int pos=rx.indexIn(text);
|
||||
int begPos=pos+curPos;
|
||||
QString buff=text.right(text.length()-(pos+rx.matchedLength()));
|
||||
int pos = rx.indexIn(text);
|
||||
int begPos = pos + curPos;
|
||||
QString buff = text.right(text.length() - (pos + rx.matchedLength()));
|
||||
|
||||
QString tagName=rx.cap(0);
|
||||
QString tagName = rx.cap(0);
|
||||
tagName.remove('<');
|
||||
tagName.remove('>');
|
||||
|
||||
while (buff.contains(rx)){
|
||||
pos=rx.indexIn(buff);
|
||||
buff=buff.right(buff.length()-pos);
|
||||
curPos+=pos;
|
||||
if (extractWord(rx.cap(0),1).compare(extractWord(tagName,1),Qt::CaseInsensitive)==0){
|
||||
if (rx.cap(0).at(1)=='/'){
|
||||
if (createTag) storage.append(new Tag(tagName,begPos,curPos));
|
||||
return buff.right(buff.length()-rx.matchedLength());
|
||||
while (buff.contains(rx)) {
|
||||
pos = rx.indexIn(buff);
|
||||
buff = buff.right(buff.length() - pos);
|
||||
curPos += pos;
|
||||
if (extractWord(rx.cap(0), 1).compare(extractWord(tagName, 1), Qt::CaseInsensitive) == 0) {
|
||||
if (rx.cap(0).at(1) == '/') {
|
||||
if (createTag)
|
||||
storage.append(new Tag(tagName, begPos, curPos));
|
||||
return buff.right(buff.length() - rx.matchedLength());
|
||||
} else {
|
||||
buff=parseTag(storage,buff,curPos,false);
|
||||
|
||||
buff = parseTag(storage, buff, curPos, false);
|
||||
}
|
||||
} else {
|
||||
buff=buff.right(buff.length()-rx.matchedLength());
|
||||
buff = buff.right(buff.length() - rx.matchedLength());
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -103,29 +104,29 @@ void HtmlContext::parseSymbs(QString text)
|
||||
{
|
||||
#if QT_VERSION < 0x060000
|
||||
QRegExp rx("<[^<]*[^/]>");
|
||||
while (text.contains(rx)){
|
||||
int pos=rx.indexIn(text);
|
||||
if (rx.cap().compare("<br>",Qt::CaseInsensitive)==0)
|
||||
m_symbs.append(new Symb(rx.cap(),pos));
|
||||
text.remove(pos,rx.matchedLength());
|
||||
while (text.contains(rx)) {
|
||||
int pos = rx.indexIn(text);
|
||||
if (rx.cap().compare("<br>", Qt::CaseInsensitive) == 0)
|
||||
m_symbs.append(new Symb(rx.cap(), pos));
|
||||
text.remove(pos, rx.matchedLength());
|
||||
}
|
||||
|
||||
foreach(QString pattern, m_symbPatterns){
|
||||
foreach (QString pattern, m_symbPatterns) {
|
||||
rx.setPattern(pattern);
|
||||
while (text.contains(rx)){
|
||||
int pos=rx.indexIn(text);
|
||||
m_symbs.append(new Symb(rx.cap(0),pos));
|
||||
text.replace(rx.cap(0)," ");
|
||||
while (text.contains(rx)) {
|
||||
int pos = rx.indexIn(text);
|
||||
m_symbs.append(new Symb(rx.cap(0), pos));
|
||||
text.replace(rx.cap(0), " ");
|
||||
}
|
||||
}
|
||||
#else
|
||||
QRegularExpression rx("<[^<]*>");
|
||||
|
||||
while (text.contains(rx)){
|
||||
int pos=text.indexOf(rx); //rx.indexIn(text);
|
||||
if (rx.cap().compare("<br>",Qt::CaseInsensitive)==0)
|
||||
m_symbs.append(new Symb(rx.cap(),pos));
|
||||
text.remove(pos,rx.matchedLength());
|
||||
while (text.contains(rx)) {
|
||||
int pos = text.indexOf(rx); // rx.indexIn(text);
|
||||
if (rx.cap().compare("<br>", Qt::CaseInsensitive) == 0)
|
||||
m_symbs.append(new Symb(rx.cap(), pos));
|
||||
text.remove(pos, rx.matchedLength());
|
||||
}
|
||||
// TODO: Qt6 port
|
||||
#endif
|
||||
@@ -133,7 +134,8 @@ void HtmlContext::parseSymbs(QString text)
|
||||
|
||||
void HtmlContext::initSymbPatterns()
|
||||
{
|
||||
m_symbPatterns<<"&[^&]*;"<<"<[^<]*/>";
|
||||
m_symbPatterns << "&[^&]*;"
|
||||
<< "<[^<]*/>";
|
||||
}
|
||||
|
||||
HtmlContext::HtmlContext(QString html)
|
||||
@@ -154,51 +156,59 @@ QString HtmlContext::extractWord(QString text, int index)
|
||||
text.remove('<');
|
||||
text.remove('>');
|
||||
text.remove('/');
|
||||
int counter=1;
|
||||
int counter = 1;
|
||||
QString retWord("");
|
||||
for (int i=0;i<text.length();i++){
|
||||
if (text.at(i)==' '){
|
||||
if (counter==index) {return retWord;}
|
||||
else {retWord="";counter++;}
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.at(i) == ' ') {
|
||||
if (counter == index) {
|
||||
return retWord;
|
||||
} else {
|
||||
retWord = "";
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
retWord+=text.at(i);
|
||||
retWord += text.at(i);
|
||||
}
|
||||
if (counter==index) return retWord;
|
||||
else return "";
|
||||
if (counter == index)
|
||||
return retWord;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
QVector<TagDiff> HtmlContext::tagVectDiff(QVector<Tag *> source, QVector<Tag *> dest)
|
||||
QVector<TagDiff> HtmlContext::tagVectDiff(QVector<Tag*> source, QVector<Tag*> dest)
|
||||
{
|
||||
QVector<TagDiff> resVect;
|
||||
for(int i=0;i<source.count();++i){
|
||||
if (!dest.contains(source.at(i))){
|
||||
for (int i = 0; i < source.count(); ++i) {
|
||||
if (!dest.contains(source.at(i))) {
|
||||
TagDiff tagDiff;
|
||||
tagDiff.tag=source.at(i);
|
||||
tagDiff.direction=TagDiff::Outer;
|
||||
tagDiff.tag = source.at(i);
|
||||
tagDiff.direction = TagDiff::Outer;
|
||||
resVect.append(tagDiff);
|
||||
}
|
||||
}
|
||||
for(int i=0;i<dest.count();++i){
|
||||
if (!source.contains(dest.at(i))){
|
||||
for (int i = 0; i < dest.count(); ++i) {
|
||||
if (!source.contains(dest.at(i))) {
|
||||
TagDiff tagDiff;
|
||||
tagDiff.tag=dest.at(i);
|
||||
tagDiff.direction=TagDiff::Inner;
|
||||
tagDiff.tag = dest.at(i);
|
||||
tagDiff.direction = TagDiff::Inner;
|
||||
resVect.append(tagDiff);
|
||||
}
|
||||
}
|
||||
return resVect;
|
||||
}
|
||||
|
||||
bool HtmlContext::isVectorEqual(QVector<Tag *> source, QVector<Tag *> dest)
|
||||
bool HtmlContext::isVectorEqual(QVector<Tag*> source, QVector<Tag*> dest)
|
||||
{
|
||||
if (source.count()!=dest.count()) return false;
|
||||
foreach(Tag* tag,source){
|
||||
if (!dest.contains(tag)) return false;
|
||||
if (source.count() != dest.count())
|
||||
return false;
|
||||
foreach (Tag* tag, source) {
|
||||
if (!dest.contains(tag))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//QString HtmlContext::extendTextByTags(QString text, int pos)
|
||||
// QString HtmlContext::extendTextByTags(QString text, int pos)
|
||||
//{
|
||||
// QString curText="";
|
||||
// QVector<Tag*> curTags=tagsAt(pos);
|
||||
@@ -236,33 +246,37 @@ bool HtmlContext::isVectorEqual(QVector<Tag *> source, QVector<Tag *> dest)
|
||||
// return curText;
|
||||
//}
|
||||
|
||||
QVector<Tag *> HtmlContext::tagsAt(int pos)
|
||||
QVector<Tag*> HtmlContext::tagsAt(int pos)
|
||||
{
|
||||
QVector<Tag*> result;
|
||||
foreach(Tag* tag,m_tags){
|
||||
if ((pos>=tag->begin())&&(pos<=tag->end())) result.append(tag);
|
||||
foreach (Tag* tag, m_tags) {
|
||||
if ((pos >= tag->begin()) && (pos <= tag->end()))
|
||||
result.append(tag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Symb HtmlContext::symbAt(int pos)
|
||||
{
|
||||
foreach(Symb* symb,m_symbs){
|
||||
if (pos==symb->pos()) return *symb;
|
||||
foreach (Symb* symb, m_symbs) {
|
||||
if (pos == symb->pos())
|
||||
return *symb;
|
||||
}
|
||||
return Symb();
|
||||
}
|
||||
|
||||
void HtmlContext::clearTags()
|
||||
{
|
||||
foreach(Tag* tag,m_tags) delete tag;
|
||||
foreach (Tag* tag, m_tags)
|
||||
delete tag;
|
||||
m_tags.clear();
|
||||
}
|
||||
|
||||
void HtmlContext::clearSymbs()
|
||||
{
|
||||
foreach(Symb* symb,m_symbs) delete symb;
|
||||
foreach (Symb* symb, m_symbs)
|
||||
delete symb;
|
||||
m_tags.clear();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,71 +30,79 @@
|
||||
#ifndef LRSIMPLETAGPARSER_H
|
||||
#define LRSIMPLETAGPARSER_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class Tag{
|
||||
class Tag {
|
||||
public:
|
||||
Tag(QString text,int beginPos,int endPos)
|
||||
:m_tagText(text),m_beginPos(beginPos),m_endPos(endPos){}
|
||||
Tag():m_tagText(""),m_beginPos(-1),m_endPos(-1){}
|
||||
bool isValid(){return (!m_tagText.isEmpty())&&(m_beginPos>0)&&(m_endPos>0);}
|
||||
QString tagText() const {return m_tagText;}
|
||||
int begin() const {return m_beginPos;}
|
||||
int end() const {return m_endPos;}
|
||||
Tag(QString text, int beginPos, int endPos):
|
||||
m_tagText(text),
|
||||
m_beginPos(beginPos),
|
||||
m_endPos(endPos)
|
||||
{
|
||||
}
|
||||
Tag(): m_tagText(""), m_beginPos(-1), m_endPos(-1) { }
|
||||
bool isValid() { return (!m_tagText.isEmpty()) && (m_beginPos > 0) && (m_endPos > 0); }
|
||||
QString tagText() const { return m_tagText; }
|
||||
int begin() const { return m_beginPos; }
|
||||
int end() const { return m_endPos; }
|
||||
|
||||
private:
|
||||
QString m_tagText;
|
||||
int m_beginPos;
|
||||
int m_endPos;
|
||||
};
|
||||
|
||||
class Symb{
|
||||
class Symb {
|
||||
public:
|
||||
Symb(QString text, int pos):m_text(text),m_pos(pos){}
|
||||
Symb():m_text(""),m_pos(-1){}
|
||||
bool isValid(){return (!m_text.isEmpty())&&(m_pos>0);}
|
||||
bool isTag(){return isValid()&&m_text.at(0)=='<';}
|
||||
QString text(){return m_text;}
|
||||
int pos(){return m_pos;}
|
||||
Symb(QString text, int pos): m_text(text), m_pos(pos) { }
|
||||
Symb(): m_text(""), m_pos(-1) { }
|
||||
bool isValid() { return (!m_text.isEmpty()) && (m_pos > 0); }
|
||||
bool isTag() { return isValid() && m_text.at(0) == '<'; }
|
||||
QString text() { return m_text; }
|
||||
int pos() { return m_pos; }
|
||||
|
||||
private:
|
||||
QString m_text;
|
||||
int m_pos;
|
||||
};
|
||||
|
||||
struct TagDiff{
|
||||
struct TagDiff {
|
||||
enum Direction {
|
||||
Inner=0,
|
||||
Outer=1
|
||||
Inner = 0,
|
||||
Outer = 1
|
||||
};
|
||||
Tag* tag;
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
class HtmlContext
|
||||
{
|
||||
class HtmlContext {
|
||||
public:
|
||||
HtmlContext(QString html);
|
||||
~HtmlContext();
|
||||
static QString extractWord(QString text,int index);
|
||||
static QString extractWord(QString text, int index);
|
||||
static QVector<TagDiff> tagVectDiff(QVector<Tag*> source, QVector<Tag*> dest);
|
||||
static bool isVectorEqual(QVector<Tag*> source, QVector<Tag*> dest);
|
||||
void fillTagVector(QString html);
|
||||
//QString extendTextByTags(QString text, int pos);
|
||||
QVector<Tag *> tagsAt(int pos);
|
||||
// QString extendTextByTags(QString text, int pos);
|
||||
QVector<Tag*> tagsAt(int pos);
|
||||
Symb symbAt(int pos);
|
||||
void clearTags();
|
||||
void clearSymbs();
|
||||
|
||||
private:
|
||||
static QString parseTag(QVector<Tag*>& storage,QString text,int& curPos, bool createTag=true);
|
||||
static QString parseTag(QVector<Tag*>& storage, QString text, int& curPos,
|
||||
bool createTag = true);
|
||||
void parseSymbs(QString text);
|
||||
void initSymbPatterns();
|
||||
|
||||
private:
|
||||
QVector<Tag*> m_tags;
|
||||
QVector<Symb*> m_symbs;
|
||||
QStringList m_symbPatterns;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRSIMPLETAGPARSER_H
|
||||
|
||||
@@ -28,38 +28,46 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrsubitemparentpropitem.h"
|
||||
|
||||
#include "../objectinspector/editors/lrcomboboxeditor.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem*
|
||||
createLocationPropItem(QObject* object, LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName, const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ItemLocationPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("itemLocation", "LimeReport::ItemDesignIntf"),
|
||||
QObject::tr("itemLocation"), createLocationPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createLocationPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ItemLocationPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("itemLocation","LimeReport::ItemDesignIntf"),QObject::tr("itemLocation"),createLocationPropItem
|
||||
);
|
||||
LimeReport::ItemLocationPropItem::ItemLocationPropItem(QObject* object, ObjectsList* objects,
|
||||
const QString& name,
|
||||
const QString& displayName,
|
||||
const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly):
|
||||
LimeReport::ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
m_locationMap.insert(tr("Band"), LimeReport::ItemDesignIntf::Band);
|
||||
m_locationMap.insert(tr("Page"), LimeReport::ItemDesignIntf::Page);
|
||||
}
|
||||
|
||||
LimeReport::ItemLocationPropItem::ItemLocationPropItem(QObject* object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem* parent, bool readonly)
|
||||
:LimeReport::ObjectPropItem(object, objects, name, displayName, value, parent, readonly){
|
||||
m_locationMap.insert(tr("Band"),LimeReport::ItemDesignIntf::Band);
|
||||
m_locationMap.insert(tr("Page"),LimeReport::ItemDesignIntf::Page);
|
||||
}
|
||||
|
||||
|
||||
QWidget * LimeReport::ItemLocationPropItem::createProperyEditor(QWidget *parent) const{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent);
|
||||
connect(editor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotLocationChanged(QString)));
|
||||
LimeReport::BaseDesignIntf *item=dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
if (item){
|
||||
QWidget* LimeReport::ItemLocationPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent);
|
||||
connect(editor, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotLocationChanged(QString)));
|
||||
LimeReport::BaseDesignIntf* item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
if (item) {
|
||||
QStringList locationTypes;
|
||||
foreach(QString location,m_locationMap.keys()){
|
||||
foreach (QString location, m_locationMap.keys()) {
|
||||
locationTypes.append(location);
|
||||
}
|
||||
editor->addItems(locationTypes);
|
||||
@@ -67,31 +75,43 @@ QWidget * LimeReport::ItemLocationPropItem::createProperyEditor(QWidget *parent)
|
||||
return editor;
|
||||
}
|
||||
|
||||
QString LimeReport::ItemLocationPropItem::displayValue() const{
|
||||
return locationToString(static_cast<LimeReport::ItemDesignIntf::LocationType>(propertyValue().toInt()));
|
||||
QString LimeReport::ItemLocationPropItem::displayValue() const
|
||||
{
|
||||
return locationToString(
|
||||
static_cast<LimeReport::ItemDesignIntf::LocationType>(propertyValue().toInt()));
|
||||
}
|
||||
|
||||
void LimeReport::ItemLocationPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
void LimeReport::ItemLocationPropItem::setPropertyEditorData(QWidget* propertyEditor,
|
||||
const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(locationToString(propertyValue().toInt()));
|
||||
}
|
||||
|
||||
void LimeReport::ItemLocationPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index){
|
||||
void LimeReport::ItemLocationPropItem::setModelData(QWidget* propertyEditor,
|
||||
QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
Q_UNUSED(propertyEditor)
|
||||
model->setData(index,object()->property(propertyName().toLatin1()));
|
||||
model->setData(index, object()->property(propertyName().toLatin1()));
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
QString LimeReport::ItemLocationPropItem::locationToString(LimeReport::ItemDesignIntf::LocationType location) const{
|
||||
QString LimeReport::ItemLocationPropItem::locationToString(
|
||||
LimeReport::ItemDesignIntf::LocationType location) const
|
||||
{
|
||||
return m_locationMap.key(location);
|
||||
}
|
||||
|
||||
LimeReport::ItemDesignIntf::LocationType LimeReport::ItemLocationPropItem::stringToLocation(const QString &locationName){
|
||||
LimeReport::ItemDesignIntf::LocationType
|
||||
LimeReport::ItemLocationPropItem::stringToLocation(const QString& locationName)
|
||||
{
|
||||
return m_locationMap.value(locationName);
|
||||
}
|
||||
|
||||
void LimeReport::ItemLocationPropItem::slotLocationChanged(const QString &text){
|
||||
if ( locationToString(object()->property(propertyName().toLatin1()).toInt())!=text){
|
||||
object()->setProperty(propertyName().toLatin1(),stringToLocation(text));
|
||||
void LimeReport::ItemLocationPropItem::slotLocationChanged(const QString& text)
|
||||
{
|
||||
if (locationToString(object()->property(propertyName().toLatin1()).toInt()) != text) {
|
||||
object()->setProperty(propertyName().toLatin1(), stringToLocation(text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,29 +30,36 @@
|
||||
#ifndef LRSUBITEMPARENTPROPITEM_H
|
||||
#define LRSUBITEMPARENTPROPITEM_H
|
||||
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class ItemLocationPropItem : public LimeReport::ObjectPropItem{
|
||||
namespace LimeReport {
|
||||
class ItemLocationPropItem: public LimeReport::ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ItemLocationPropItem():ObjectPropItem(){}
|
||||
ItemLocationPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly);
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
ItemLocationPropItem(): ObjectPropItem() { }
|
||||
ItemLocationPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly);
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
QString displayValue() const;
|
||||
void setPropertyEditorData(QWidget *, const QModelIndex &) const;
|
||||
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &);
|
||||
void setPropertyEditorData(QWidget*, const QModelIndex&) const;
|
||||
void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&);
|
||||
private slots:
|
||||
void slotLocationChanged(const QString& text);
|
||||
|
||||
private:
|
||||
QString locationToString(LimeReport::ItemDesignIntf::LocationType location) const;
|
||||
QString locationToString(int location) const {return locationToString(static_cast<LimeReport::ItemDesignIntf::LocationType>(location));}
|
||||
QString locationToString(int location) const
|
||||
{
|
||||
return locationToString(static_cast<LimeReport::ItemDesignIntf::LocationType>(location));
|
||||
}
|
||||
LimeReport::ItemDesignIntf::LocationType stringToLocation(const QString& locationName);
|
||||
|
||||
private:
|
||||
QMap<QString,LimeReport::ItemDesignIntf::LocationType> m_locationMap;
|
||||
QMap<QString, LimeReport::ItemDesignIntf::LocationType> m_locationMap;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRSUBITEMPARENTPROPITEM_H
|
||||
|
||||
@@ -1,67 +1,59 @@
|
||||
#include "lrsvgitem.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrimageitemeditor.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
#include <QtSvg>
|
||||
|
||||
namespace{
|
||||
const QString xmlTag = "SVGItem";
|
||||
LimeReport::BaseDesignIntf * createSVGItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::SVGItem(owner,parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("SVG Item"),"Item"), createSVGItem
|
||||
);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
SVGItem::SVGItem(QObject *owner, QGraphicsItem *parent)
|
||||
:ItemDesignIntf(xmlTag,owner,parent)
|
||||
namespace {
|
||||
const QString xmlTag = "SVGItem";
|
||||
LimeReport::BaseDesignIntf* createSVGItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::SVGItem(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("SVG Item"), "Item"), createSVGItem);
|
||||
} // namespace
|
||||
|
||||
void SVGItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
namespace LimeReport {
|
||||
SVGItem::SVGItem(QObject* owner, QGraphicsItem* parent): ItemDesignIntf(xmlTag, owner, parent) { }
|
||||
|
||||
void SVGItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
painter->save();
|
||||
if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY);
|
||||
else painter->setOpacity(qreal(opacity())/100);
|
||||
if (m_image.isNull() && itemMode() == DesignMode){
|
||||
if (isSelected())
|
||||
painter->setOpacity(Const::SELECTION_OPACITY);
|
||||
else
|
||||
painter->setOpacity(qreal(opacity()) / 100);
|
||||
if (m_image.isNull() && itemMode() == DesignMode) {
|
||||
QString text;
|
||||
painter->setFont(transformToSceneFont(QFont("Arial",10)));
|
||||
painter->setFont(transformToSceneFont(QFont("Arial", 10)));
|
||||
painter->setPen(Qt::black);
|
||||
if (!datasource().isEmpty() && !field().isEmpty())
|
||||
text = datasource()+"."+field();
|
||||
else text = tr("SVG Image");
|
||||
painter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text );
|
||||
}
|
||||
else if (!m_image.isEmpty()){
|
||||
text = datasource() + "." + field();
|
||||
else
|
||||
text = tr("SVG Image");
|
||||
painter->drawText(rect().adjusted(4, 4, -4, -4), Qt::AlignCenter, text);
|
||||
} else if (!m_image.isEmpty()) {
|
||||
QSvgRenderer render;
|
||||
render.load(m_image);
|
||||
render.render(painter, option->rect);
|
||||
}
|
||||
ItemDesignIntf::paint(painter,option,widget);
|
||||
ItemDesignIntf::paint(painter, option, widget);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QByteArray SVGItem::imageAsByteArray() const
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
QByteArray SVGItem::imageAsByteArray() const { return m_image; }
|
||||
|
||||
void SVGItem::setImageAsByteArray(QByteArray image)
|
||||
{
|
||||
setImage(image);
|
||||
}
|
||||
void SVGItem::setImageAsByteArray(QByteArray image) { setImage(image); }
|
||||
|
||||
QString SVGItem::fileFilter() const
|
||||
{
|
||||
return tr("SVG (*.svg)");
|
||||
}
|
||||
QString SVGItem::fileFilter() const { return tr("SVG (*.svg)"); }
|
||||
|
||||
void SVGItem::preparePopUpMenu(QMenu &menu)
|
||||
void SVGItem::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit"));
|
||||
menu.insertAction(menu.actions().at(0),editAction);
|
||||
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"), tr("Edit"));
|
||||
menu.insertAction(menu.actions().at(0), editAction);
|
||||
menu.insertSeparator(menu.actions().at(1));
|
||||
|
||||
menu.addSeparator();
|
||||
@@ -70,49 +62,51 @@ void SVGItem::preparePopUpMenu(QMenu &menu)
|
||||
action->setChecked(isWatermark());
|
||||
}
|
||||
|
||||
void SVGItem::processPopUpAction(QAction *action)
|
||||
void SVGItem::processPopUpAction(QAction* action)
|
||||
{
|
||||
if (action->text().compare(tr("Watermark")) == 0){
|
||||
page()->setPropertyToSelectedItems("watermark",action->isChecked());
|
||||
if (action->text().compare(tr("Watermark")) == 0) {
|
||||
page()->setPropertyToSelectedItems("watermark", action->isChecked());
|
||||
}
|
||||
if (action->text().compare(tr("Edit")) == 0){
|
||||
if (action->text().compare(tr("Edit")) == 0) {
|
||||
this->showEditorDialog();
|
||||
}
|
||||
ItemDesignIntf::processPopUpAction(action);
|
||||
}
|
||||
|
||||
QWidget *SVGItem::defaultEditor()
|
||||
QWidget* SVGItem::defaultEditor()
|
||||
{
|
||||
ImageItemEditor* editor = new ImageItemEditor(this);
|
||||
editor->setAttribute(Qt::WA_DeleteOnClose);
|
||||
return editor;
|
||||
};
|
||||
|
||||
BaseDesignIntf* SVGItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent){
|
||||
BaseDesignIntf* SVGItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new SVGItem(owner, parent);
|
||||
}
|
||||
|
||||
void SVGItem::updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight)
|
||||
void SVGItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
Q_UNUSED(maxHeight)
|
||||
if (m_image.isEmpty()){
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()){
|
||||
if (m_image.isEmpty()) {
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()) {
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
m_image = data.value<QByteArray>();
|
||||
}
|
||||
} else if (!m_resourcePath.isEmpty()){
|
||||
m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
} else if (!m_resourcePath.isEmpty()) {
|
||||
m_resourcePath
|
||||
= expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager);
|
||||
m_image = imageFromResource(m_resourcePath);
|
||||
} else if (!m_variable.isEmpty()){
|
||||
//TODO: Migrate to QMetaType
|
||||
} else if (!m_variable.isEmpty()) {
|
||||
// TODO: Migrate to QMetaType
|
||||
QVariant data = dataManager->variable(m_variable);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QString){
|
||||
if (data.typeId() == QMetaType::QString) {
|
||||
#else
|
||||
if (data.type() == QVariant::String){
|
||||
if (data.type() == QVariant::String) {
|
||||
#endif
|
||||
m_image = imageFromResource(data.toString());
|
||||
} else {
|
||||
@@ -121,7 +115,7 @@ void SVGItem::updateItemSize(DataSourceManager *dataManager, RenderPass pass, in
|
||||
#else
|
||||
if (data.type() == QVariant::ByteArray) {
|
||||
#endif
|
||||
m_image = data.value<QByteArray>() ;
|
||||
m_image = data.value<QByteArray>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,20 +125,17 @@ void SVGItem::updateItemSize(DataSourceManager *dataManager, RenderPass pass, in
|
||||
QByteArray SVGItem::imageFromResource(QString resourcePath)
|
||||
{
|
||||
QFile file(resourcePath);
|
||||
if (file.open(QIODevice::ReadOnly)){
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
return file.readAll();
|
||||
}
|
||||
return QByteArray();
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QString SVGItem::variable() const
|
||||
{
|
||||
return m_variable;
|
||||
}
|
||||
QString SVGItem::variable() const { return m_variable; }
|
||||
|
||||
void SVGItem::setVariable(const QString &variable)
|
||||
void SVGItem::setVariable(const QString& variable)
|
||||
{
|
||||
if (m_variable != variable){
|
||||
if (m_variable != variable) {
|
||||
QString oldValue = m_variable;
|
||||
m_variable = variable;
|
||||
update();
|
||||
@@ -153,20 +144,17 @@ void SVGItem::setVariable(const QString &variable)
|
||||
m_variable = variable;
|
||||
}
|
||||
|
||||
bool SVGItem::isNeedUpdateSize(RenderPass) const { return m_image.isNull() ; }
|
||||
bool SVGItem::isNeedUpdateSize(RenderPass) const { return m_image.isNull(); }
|
||||
|
||||
QString SVGItem::resourcePath() const
|
||||
{
|
||||
return m_resourcePath;
|
||||
}
|
||||
QString SVGItem::resourcePath() const { return m_resourcePath; }
|
||||
|
||||
void SVGItem::setResourcePath(const QString &resourcePath)
|
||||
void SVGItem::setResourcePath(const QString& resourcePath)
|
||||
{
|
||||
if (m_resourcePath != resourcePath){
|
||||
if (m_resourcePath != resourcePath) {
|
||||
QString oldValue = m_resourcePath;
|
||||
m_resourcePath = resourcePath;
|
||||
QFile file(resourcePath);
|
||||
if (file.open(QIODevice::ReadOnly)){
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
m_image = file.readAll();
|
||||
}
|
||||
update();
|
||||
@@ -174,14 +162,11 @@ void SVGItem::setResourcePath(const QString &resourcePath)
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray SVGItem::image() const
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
QByteArray SVGItem::image() const { return m_image; }
|
||||
|
||||
void SVGItem::setImage(const QByteArray &image)
|
||||
void SVGItem::setImage(const QByteArray& image)
|
||||
{
|
||||
if (m_image != image){
|
||||
if (m_image != image) {
|
||||
QByteArray oldValue = m_image;
|
||||
m_image = image;
|
||||
update();
|
||||
@@ -189,23 +174,11 @@ void SVGItem::setImage(const QByteArray &image)
|
||||
}
|
||||
}
|
||||
|
||||
QString SVGItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString SVGItem::datasource() const { return m_datasource; }
|
||||
|
||||
void SVGItem::setDatasource(const QString &datasource)
|
||||
{
|
||||
m_datasource = datasource;
|
||||
}
|
||||
void SVGItem::setDatasource(const QString& datasource) { m_datasource = datasource; }
|
||||
|
||||
QString SVGItem::field() const
|
||||
{
|
||||
return m_field;
|
||||
}
|
||||
QString SVGItem::field() const { return m_field; }
|
||||
|
||||
void SVGItem::setField(const QString &field)
|
||||
{
|
||||
m_field = field;
|
||||
};
|
||||
void SVGItem::setField(const QString& field) { m_field = field; };
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#ifndef SVGITEM_H
|
||||
#define SVGITEM_H
|
||||
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lreditableimageitemintf.h"
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class SVGItem: public ItemDesignIntf, public IEditableImageItem
|
||||
{
|
||||
namespace LimeReport {
|
||||
class SVGItem: public ItemDesignIntf, public IEditableImageItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath)
|
||||
Q_PROPERTY(QByteArray image READ image WRITE setImage)
|
||||
@@ -16,40 +15,42 @@ class SVGItem: public ItemDesignIntf, public IEditableImageItem
|
||||
Q_PROPERTY(QString variable READ variable WRITE setVariable)
|
||||
Q_PROPERTY(bool watermark READ isWatermark WRITE setWatermark)
|
||||
public:
|
||||
SVGItem(QObject *owner, QGraphicsItem *parent);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
SVGItem(QObject* owner, QGraphicsItem* parent);
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
|
||||
QByteArray imageAsByteArray() const;
|
||||
void setImageAsByteArray(QByteArray image);
|
||||
QString fileFilter() const;
|
||||
|
||||
void preparePopUpMenu(QMenu &menu);
|
||||
void processPopUpAction(QAction *action);
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
QWidget* defaultEditor();
|
||||
|
||||
QString resourcePath() const;
|
||||
void setResourcePath(const QString &resourcePath);
|
||||
void setResourcePath(const QString& resourcePath);
|
||||
QByteArray image() const;
|
||||
void setImage(const QByteArray &image);
|
||||
void setImage(const QByteArray& image);
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
QString field() const;
|
||||
void setField(const QString &field);
|
||||
void setField(const QString& field);
|
||||
QString variable() const;
|
||||
void setVariable(const QString &variable);
|
||||
void setVariable(const QString& variable);
|
||||
bool isNeedUpdateSize(RenderPass) const;
|
||||
|
||||
protected:
|
||||
BaseDesignIntf *createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
QByteArray imageFromResource(QString resourcePath);
|
||||
|
||||
private:
|
||||
QString m_resourcePath;
|
||||
QByteArray m_image;
|
||||
QString m_datasource;
|
||||
QString m_field;
|
||||
QString m_variable;
|
||||
public:
|
||||
|
||||
public:
|
||||
};
|
||||
} // namespace LimeReport
|
||||
#endif // SVGITEM_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,20 +29,19 @@
|
||||
****************************************************************************/
|
||||
#ifndef LRTEXTITEM_H
|
||||
#define LRTEXTITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrpageinitintf.h"
|
||||
|
||||
#include <QGraphicsTextItem>
|
||||
#include <QtGui>
|
||||
#include <QLabel>
|
||||
#include <QTextDocument>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrpageinitintf.h"
|
||||
#include <QtGui>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class Tag;
|
||||
class TextItem : public ContentItemDesignIntf, IPageInit {
|
||||
class TextItem: public ContentItemDesignIntf, IPageInit {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString content READ content WRITE setContent)
|
||||
Q_PROPERTY(int margin READ marginSize WRITE setMarginSize)
|
||||
@@ -66,19 +65,35 @@ class TextItem : public ContentItemDesignIntf, IPageInit {
|
||||
Q_PROPERTY(QString format READ format WRITE setFormat)
|
||||
Q_PROPERTY(ValueType valueType READ valueType WRITE setValueType)
|
||||
Q_PROPERTY(QString followTo READ followTo WRITE setFollowTo)
|
||||
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
||||
Q_PROPERTY(
|
||||
BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
||||
Q_PROPERTY(qreal textIndent READ textIndent WRITE setTextIndent)
|
||||
Q_PROPERTY(Qt::LayoutDirection textLayoutDirection READ textLayoutDirection WRITE setTextLayoutDirection)
|
||||
Q_PROPERTY(Qt::LayoutDirection textLayoutDirection READ textLayoutDirection WRITE
|
||||
setTextLayoutDirection)
|
||||
Q_PROPERTY(bool fillInSecondPass READ fillInSecondPass WRITE setFillInSecondPass)
|
||||
Q_PROPERTY(bool watermark READ isWatermark WRITE setWatermark)
|
||||
Q_PROPERTY(bool replaceCRwithBR READ isReplaceCarriageReturns WRITE setReplaceCarriageReturns)
|
||||
Q_PROPERTY(bool hideIfEmpty READ hideIfEmpty WRITE setHideIfEmpty)
|
||||
Q_PROPERTY(int fontLetterSpacing READ fontLetterSpacing WRITE setFontLetterSpacing)
|
||||
public:
|
||||
|
||||
enum AutoWidth{NoneAutoWidth, MaxWordLength, MaxStringLength};
|
||||
enum AngleType{Angle0, Angle90, Angle180, Angle270, Angle45, Angle315};
|
||||
enum ValueType{Default, DateTime, Double};
|
||||
enum AutoWidth {
|
||||
NoneAutoWidth,
|
||||
MaxWordLength,
|
||||
MaxStringLength
|
||||
};
|
||||
enum AngleType {
|
||||
Angle0,
|
||||
Angle90,
|
||||
Angle180,
|
||||
Angle270,
|
||||
Angle45,
|
||||
Angle315
|
||||
};
|
||||
enum ValueType {
|
||||
Default,
|
||||
DateTime,
|
||||
Double
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(AutoWidth)
|
||||
Q_ENUM(AngleType)
|
||||
@@ -90,7 +105,7 @@ public:
|
||||
#endif
|
||||
|
||||
void Init();
|
||||
TextItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
TextItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
~TextItem();
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
|
||||
@@ -98,29 +113,29 @@ public:
|
||||
void setContent(const QString& value);
|
||||
|
||||
void setAlignment(Qt::Alignment value);
|
||||
Qt::Alignment alignment(){return m_alignment;}
|
||||
Qt::Alignment alignment() { return m_alignment; }
|
||||
|
||||
void geometryChangedEvent(QRectF, QRectF);
|
||||
bool isNeedUpdateSize(RenderPass) const;
|
||||
void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
|
||||
void expandContent(DataSourceManager *dataManager, RenderPass pass);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
void expandContent(DataSourceManager* dataManager, RenderPass pass);
|
||||
|
||||
void setAutoHeight(bool value);
|
||||
bool autoHeight() const {return m_autoHeight;}
|
||||
bool autoHeight() const { return m_autoHeight; }
|
||||
|
||||
void setAutoWidth(AutoWidth value);
|
||||
AutoWidth autoWidth() const {return m_autoWidth;}
|
||||
AutoWidth autoWidth() const { return m_autoWidth; }
|
||||
|
||||
void setAdaptFontToSize(bool value);
|
||||
bool adaptFontToSize() const {return m_adaptFontToSize;}
|
||||
bool adaptFontToSize() const { return m_adaptFontToSize; }
|
||||
|
||||
bool canBeSplitted(int height) const;
|
||||
bool isSplittable() const { return true;}
|
||||
bool isEmpty() const{return m_strText.trimmed().isEmpty();}
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneEmpty(int height, QObject *owner, QGraphicsItem *parent);
|
||||
bool isSplittable() const { return true; }
|
||||
bool isEmpty() const { return m_strText.trimmed().isEmpty(); }
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner, QGraphicsItem* parent);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject* owner, QGraphicsItem* parent);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
BaseDesignIntf* cloneEmpty(int height, QObject* owner, QGraphicsItem* parent);
|
||||
void objectLoadFinished();
|
||||
|
||||
void setTextItemFont(QFont value);
|
||||
@@ -131,9 +146,9 @@ public:
|
||||
void setFontColorProperty(QColor value);
|
||||
AngleType angle() const;
|
||||
void setAngle(const AngleType& value);
|
||||
int foregroundOpacity(){return m_foregroundOpacity;}
|
||||
int foregroundOpacity() { return m_foregroundOpacity; }
|
||||
void setForegroundOpacity(int value);
|
||||
bool underlines(){return m_underlines;}
|
||||
bool underlines() { return m_underlines; }
|
||||
void setUnderlines(bool value);
|
||||
|
||||
bool trimValue() const;
|
||||
@@ -152,18 +167,18 @@ public:
|
||||
void setAllowHTMLInFields(bool allowHTMLInFields);
|
||||
|
||||
QString format() const;
|
||||
void setFormat(const QString &format);
|
||||
void setFormat(const QString& format);
|
||||
|
||||
ValueType valueType() const;
|
||||
void setValueType(const ValueType valueType);
|
||||
|
||||
QSizeF textSize(){ return m_textSize;}
|
||||
QSizeF textSize() { return m_textSize; }
|
||||
QString followTo() const;
|
||||
void setFollowTo(const QString &followTo);
|
||||
void setFollowTo(const QString& followTo);
|
||||
void setFollower(TextItem* follower);
|
||||
void clearFollower();
|
||||
bool hasFollower() const;
|
||||
TextItem* follower() const { return m_follower;}
|
||||
TextItem* follower() const { return m_follower; }
|
||||
bool initFollower(QString follower);
|
||||
|
||||
// IPageInit interface
|
||||
@@ -172,12 +187,12 @@ public:
|
||||
typedef QSharedPointer<QTextDocument> TextPtr;
|
||||
|
||||
qreal textIndent() const;
|
||||
void setTextIndent(const qreal &textIndent);
|
||||
void setTextIndent(const qreal& textIndent);
|
||||
Qt::LayoutDirection textLayoutDirection() const;
|
||||
void setTextLayoutDirection(const Qt::LayoutDirection &textLayoutDirection);
|
||||
void setTextLayoutDirection(const Qt::LayoutDirection& textLayoutDirection);
|
||||
|
||||
void setWatermark(bool watermark);
|
||||
|
||||
|
||||
bool isReplaceCarriageReturns() const;
|
||||
void setReplaceCarriageReturns(bool isReplaceCarriageReturns);
|
||||
|
||||
@@ -194,24 +209,26 @@ protected:
|
||||
QString replaceReturns(QString text) const;
|
||||
QString getTextPart(int height, int skipHeight);
|
||||
void restoreLinksEvent();
|
||||
void preparePopUpMenu(QMenu &menu);
|
||||
void processPopUpAction(QAction *action);
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
void initTextSizes() const;
|
||||
void setTextFont(TextPtr text, const QFont &value) const;
|
||||
void setTextFont(TextPtr text, const QFont& value) const;
|
||||
void adaptFontSize(TextPtr text) const;
|
||||
QString formatDateTime(const QDateTime &value);
|
||||
QString formatDateTime(const QDateTime& value);
|
||||
QString formatNumber(const double value);
|
||||
QString formatFieldValue();
|
||||
QString extractText(QTextBlock& curBlock, int height);
|
||||
TextPtr textDocument() const;
|
||||
|
||||
private:
|
||||
QString m_strText;
|
||||
Qt::Alignment m_alignment;
|
||||
bool m_autoHeight;
|
||||
AutoWidth m_autoWidth;
|
||||
QSizeF mutable m_textSize;
|
||||
qreal mutable m_firstLineSize;
|
||||
qreal mutable m_firstLineSize;
|
||||
AngleType m_angle;
|
||||
int m_foregroundOpacity;
|
||||
bool m_underlines;
|
||||
@@ -225,7 +242,7 @@ private:
|
||||
|
||||
QString m_format;
|
||||
ValueType m_valueType;
|
||||
QString m_followTo;
|
||||
QString m_followTo;
|
||||
TextItem* m_follower;
|
||||
qreal m_textIndent;
|
||||
Qt::LayoutDirection m_textLayoutDirection;
|
||||
@@ -233,5 +250,5 @@ private:
|
||||
int m_fontLetterSpacing;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRTEXTITEM_H
|
||||
|
||||
@@ -30,25 +30,32 @@
|
||||
#include "lrtextitemeditor.h"
|
||||
#include "ui_lrtextitemeditor.h"
|
||||
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrscriptenginemanager.h"
|
||||
#include "lrdatadesignintf.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrscripteditor.h"
|
||||
#include "lrscriptenginemanager.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QScrollBar>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
TextItemEditor::TextItemEditor(LimeReport::TextItem *item, LimeReport::PageDesignIntf *page, QSettings* settings, QWidget *parent) :
|
||||
TextItemEditor::TextItemEditor(LimeReport::TextItem* item, LimeReport::PageDesignIntf* page,
|
||||
QSettings* settings, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::TextItemEditor), m_textItem(item), m_page(page), m_settings(settings), m_ownedSettings(false), m_isReadingSetting(false)
|
||||
ui(new Ui::TextItemEditor),
|
||||
m_textItem(item),
|
||||
m_page(page),
|
||||
m_settings(settings),
|
||||
m_ownedSettings(false),
|
||||
m_isReadingSetting(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initUI();
|
||||
setWindowIcon(QIcon(":/items/images/TextItem"));
|
||||
readSetting();
|
||||
connect(ui->codeEditor, SIGNAL(splitterMoved(int,int)), this, SLOT(slotSplitterMoved(int,int)) );
|
||||
connect(ui->codeEditor, SIGNAL(splitterMoved(int, int)), this,
|
||||
SLOT(slotSplitterMoved(int, int)));
|
||||
}
|
||||
|
||||
TextItemEditor::~TextItemEditor()
|
||||
@@ -66,17 +73,17 @@ void TextItemEditor::setSettings(QSettings* value)
|
||||
{
|
||||
if (m_ownedSettings)
|
||||
delete m_settings;
|
||||
m_settings=value;
|
||||
m_ownedSettings=false;
|
||||
m_settings = value;
|
||||
m_ownedSettings = false;
|
||||
readSetting();
|
||||
}
|
||||
|
||||
QSettings*TextItemEditor::settings()
|
||||
QSettings* TextItemEditor::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
if (m_settings) {
|
||||
return m_settings;
|
||||
} else {
|
||||
m_settings = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
m_settings = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
m_ownedSettings = true;
|
||||
return m_settings;
|
||||
}
|
||||
@@ -98,9 +105,9 @@ void TextItemEditor::moveEvent(QMoveEvent*)
|
||||
|
||||
void TextItemEditor::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (settings()!=0){
|
||||
if (settings() != 0) {
|
||||
settings()->beginGroup("TextItemEditor");
|
||||
settings()->setValue("CodeEditorState",ui->codeEditor->saveState());
|
||||
settings()->setValue("CodeEditorState", ui->codeEditor->saveState());
|
||||
settings()->endGroup();
|
||||
}
|
||||
QWidget::closeEvent(event);
|
||||
@@ -108,7 +115,7 @@ void TextItemEditor::closeEvent(QCloseEvent* event)
|
||||
|
||||
void TextItemEditor::on_pbOk_clicked()
|
||||
{
|
||||
if (m_textItem->content()!= ui->codeEditor->toPlainText()){
|
||||
if (m_textItem->content() != ui->codeEditor->toPlainText()) {
|
||||
m_textItem->setContent(ui->codeEditor->toPlainText());
|
||||
}
|
||||
close();
|
||||
@@ -118,48 +125,46 @@ void TextItemEditor::initUI()
|
||||
{
|
||||
QStringList dataWords;
|
||||
|
||||
LimeReport::DataSourceManager* dm = m_page->datasourceManager();
|
||||
LimeReport::DataSourceManager* dm = m_page->datasourceManager();
|
||||
LimeReport::ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
|
||||
se.setDataManager(dm);
|
||||
|
||||
ScriptEditor* scriptEditor = dynamic_cast<ScriptEditor*>(ui->codeEditor);
|
||||
if (scriptEditor){
|
||||
if (scriptEditor) {
|
||||
scriptEditor->setReportPage(m_page);
|
||||
scriptEditor->setPageBand(findParentBand());
|
||||
scriptEditor->setPlainText(m_textItem->content());
|
||||
}
|
||||
}
|
||||
|
||||
void TextItemEditor::on_pbCancel_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
void TextItemEditor::on_pbCancel_clicked() { close(); }
|
||||
|
||||
void TextItemEditor::readSetting()
|
||||
{
|
||||
if (settings()==0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
m_isReadingSetting = true;
|
||||
|
||||
settings()->beginGroup("TextItemEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
if (v.isValid()){
|
||||
if (v.isValid()) {
|
||||
restoreGeometry(v.toByteArray());
|
||||
}
|
||||
v = settings()->value("CodeEditorState");
|
||||
if (v.isValid()){
|
||||
if (v.isValid()) {
|
||||
ui->codeEditor->restoreState(v.toByteArray());
|
||||
}
|
||||
settings()->endGroup();
|
||||
settings()->beginGroup("ScriptEditor");
|
||||
QVariant fontName = settings()->value("DefaultFontName");
|
||||
if (fontName.isValid()){
|
||||
if (fontName.isValid()) {
|
||||
QVariant fontSize = settings()->value("DefaultFontSize");
|
||||
ui->codeEditor->setEditorFont(QFont(fontName.toString(),fontSize.toInt()));
|
||||
ui->codeEditor->setEditorFont(QFont(fontName.toString(), fontSize.toInt()));
|
||||
}
|
||||
|
||||
QVariant tabIndention = settings()->value("TabIndention");
|
||||
if (tabIndention.isValid()){
|
||||
if (tabIndention.isValid()) {
|
||||
ui->codeEditor->setTabIndention(tabIndention.toInt());
|
||||
} else {
|
||||
ui->codeEditor->setTabIndention(LimeReport::Const::DEFAULT_TAB_INDENTION);
|
||||
@@ -171,29 +176,28 @@ void TextItemEditor::readSetting()
|
||||
|
||||
void TextItemEditor::writeSetting()
|
||||
{
|
||||
if (settings()!=0){
|
||||
if (settings() != 0) {
|
||||
settings()->beginGroup("TextItemEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->setValue("CodeEditorState",ui->codeEditor->saveState());
|
||||
settings()->setValue("Geometry", saveGeometry());
|
||||
settings()->setValue("CodeEditorState", ui->codeEditor->saveState());
|
||||
settings()->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void TextItemEditor::slotSplitterMoved(int, int)
|
||||
{
|
||||
writeSetting();
|
||||
}
|
||||
void TextItemEditor::slotSplitterMoved(int, int) { writeSetting(); }
|
||||
|
||||
BandDesignIntf *TextItemEditor::findParentBand()
|
||||
BandDesignIntf* TextItemEditor::findParentBand()
|
||||
{
|
||||
BandDesignIntf* result = 0;
|
||||
BaseDesignIntf* item = m_textItem;
|
||||
while (true){
|
||||
while (true) {
|
||||
item = dynamic_cast<BaseDesignIntf*>(item->parentItem());
|
||||
if (item){
|
||||
if (item) {
|
||||
result = dynamic_cast<BandDesignIntf*>(item);
|
||||
if (result) break;
|
||||
} else break;
|
||||
if (result)
|
||||
break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -30,61 +30,63 @@
|
||||
#ifndef LRTEXTITEMEDITOR_H
|
||||
#define LRTEXTITEMEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QCompleter>
|
||||
|
||||
#include "lrtextitem.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrtextitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QCompleter>
|
||||
#include <QTextEdit>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class TextItemEditor;
|
||||
class TextItemEditor;
|
||||
}
|
||||
|
||||
//class CompleaterTextEditor :public QTextEdit
|
||||
// class CompleaterTextEditor :public QTextEdit
|
||||
//{
|
||||
// Q_OBJECT
|
||||
//public:
|
||||
// public:
|
||||
// CompleaterTextEditor(QWidget* parent=0);
|
||||
// void setCompleter(QCompleter* value);
|
||||
// QCompleter* compleater() const{ return m_compleater;}
|
||||
//protected:
|
||||
// protected:
|
||||
// virtual void keyPressEvent(QKeyEvent *e);
|
||||
// virtual void focusInEvent(QFocusEvent *e);
|
||||
//private:
|
||||
// private:
|
||||
// QString textUnderCursor() const;
|
||||
//private slots:
|
||||
// private slots:
|
||||
// void insertCompletion(const QString& completion);
|
||||
//private:
|
||||
// private:
|
||||
// QCompleter* m_compleater;
|
||||
//};
|
||||
|
||||
class TextItemEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
class TextItemEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextItemEditor(LimeReport::TextItem* item, LimeReport::PageDesignIntf* page,
|
||||
QSettings* settings=0, QWidget *parent = 0);
|
||||
QSettings* settings = 0, QWidget* parent = 0);
|
||||
~TextItemEditor();
|
||||
void setSettings(QSettings* value);
|
||||
QSettings* settings();
|
||||
QSettings* settings();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void moveEvent(QMoveEvent *);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void moveEvent(QMoveEvent*);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
BandDesignIntf* findParentBand();
|
||||
private slots:
|
||||
void on_pbOk_clicked();
|
||||
void on_pbCancel_clicked();
|
||||
void slotSplitterMoved(int, int);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void readSetting();
|
||||
void writeSetting();
|
||||
|
||||
private:
|
||||
Ui::TextItemEditor *ui;
|
||||
Ui::TextItemEditor* ui;
|
||||
LimeReport::TextItem* m_textItem;
|
||||
LimeReport::PageDesignIntf* m_page;
|
||||
QSettings* m_settings;
|
||||
|
||||
@@ -7,29 +7,28 @@ const QString xmlTag = "VLayout";
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf *createVLayout(QObject *owner, LimeReport::BaseDesignIntf *parent)
|
||||
LimeReport::BaseDesignIntf* createVLayout(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::VerticalLayout(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("VLayout"), LimeReport::Const::bandTAG),
|
||||
createVLayout
|
||||
);
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("VLayout"), LimeReport::Const::bandTAG),
|
||||
createVLayout);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
bool verticalLessThen(BaseDesignIntf* c1, BaseDesignIntf* c2)
|
||||
{
|
||||
return c1->pos().y() < c2->pos().y();
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
bool verticalLessThen(BaseDesignIntf *c1, BaseDesignIntf* c2){
|
||||
return c1->pos().y()<c2->pos().y();
|
||||
VerticalLayout::VerticalLayout(QObject* owner, QGraphicsItem* parent):
|
||||
AbstractLayout(xmlTag, owner, parent)
|
||||
{
|
||||
}
|
||||
|
||||
VerticalLayout::VerticalLayout(QObject* owner, QGraphicsItem* parent)
|
||||
: AbstractLayout(xmlTag, owner, parent)
|
||||
{}
|
||||
|
||||
VerticalLayout::~VerticalLayout()
|
||||
{}
|
||||
VerticalLayout::~VerticalLayout() { }
|
||||
|
||||
BaseDesignIntf* VerticalLayout::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
@@ -39,26 +38,29 @@ BaseDesignIntf* VerticalLayout::createSameTypeItem(QObject* owner, QGraphicsItem
|
||||
void VerticalLayout::updateLayoutSize()
|
||||
{
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
int h = spaceBorder*2;
|
||||
int h = spaceBorder * 2;
|
||||
qreal w = 0;
|
||||
int visibleItemCount = 0;
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
if (item->isEmpty() && hideEmptyItems()) item->setVisible(false);
|
||||
if (item->isVisible()){
|
||||
if (w < item->width()) w = item->width();
|
||||
h+=item->height();
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isEmpty() && hideEmptyItems())
|
||||
item->setVisible(false);
|
||||
if (item->isVisible()) {
|
||||
if (w < item->width())
|
||||
w = item->width();
|
||||
h += item->height();
|
||||
visibleItemCount++;
|
||||
}
|
||||
}
|
||||
if (w>0) setWidth(w+spaceBorder*2);
|
||||
setHeight(h + layoutSpacingMM() *(visibleItemCount-1));
|
||||
if (w > 0)
|
||||
setWidth(w + spaceBorder * 2);
|
||||
setHeight(h + layoutSpacingMM() * (visibleItemCount - 1));
|
||||
}
|
||||
|
||||
void VerticalLayout::relocateChildren()
|
||||
{
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
QList<BaseDesignIntf*> newChildren;
|
||||
if (layoutsChildren().count() < childItems().size() - 1){
|
||||
if (layoutsChildren().count() < childItems().size() - 1) {
|
||||
auto oldChildren = layoutsChildren();
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
@@ -68,13 +70,13 @@ void VerticalLayout::relocateChildren()
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
}
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(), verticalLessThen);
|
||||
std::sort(layoutsChildren().begin(), layoutsChildren().end(), verticalLessThen);
|
||||
qreal curY = spaceBorder;
|
||||
setIsRelocating(true);
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isVisible() || itemMode() == DesignMode){
|
||||
if (item->isVisible() || itemMode() == DesignMode) {
|
||||
item->setPos(spaceBorder, curY);
|
||||
curY+=item->height() + layoutSpacingMM();
|
||||
curY += item->height() + layoutSpacingMM();
|
||||
item->setWidth(width() - (spaceBorder * 2));
|
||||
}
|
||||
}
|
||||
@@ -87,28 +89,30 @@ void VerticalLayout::relocateChildren()
|
||||
|
||||
bool VerticalLayout::canBeSplitted(int height) const
|
||||
{
|
||||
if (childItems().isEmpty()) return false;
|
||||
if (childItems().isEmpty())
|
||||
return false;
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(childItems().at(0));
|
||||
if (item){
|
||||
if (item->height() > height )
|
||||
if (item) {
|
||||
if (item->height() > height)
|
||||
return item->canBeSplitted(height);
|
||||
else return true;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BaseDesignIntf* VerticalLayout::cloneUpperPart(int height, QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
VerticalLayout* upperPart = dynamic_cast<VerticalLayout*>(createSameTypeItem(owner,parent));
|
||||
VerticalLayout* upperPart = dynamic_cast<VerticalLayout*>(createSameTypeItem(owner, parent));
|
||||
upperPart->initFromItem(this);
|
||||
foreach(BaseDesignIntf* item, childBaseItems()){
|
||||
if ((item->geometry().bottom() <= height) ){
|
||||
item->cloneItem(item->itemMode(),upperPart,upperPart);
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if ((item->geometry().bottom() <= height)) {
|
||||
item->cloneItem(item->itemMode(), upperPart, upperPart);
|
||||
} else {
|
||||
if ((item->geometry().top() < height) && ( item->geometry().bottom() > height)){
|
||||
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
|
||||
int sliceHeight = height - item->geometry().top();
|
||||
if (item->isSplittable() && item->canBeSplitted(sliceHeight)){
|
||||
item->cloneUpperPart(sliceHeight,upperPart,upperPart);
|
||||
if (item->isSplittable() && item->canBeSplitted(sliceHeight)) {
|
||||
item->cloneUpperPart(sliceHeight, upperPart, upperPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,14 +125,15 @@ BaseDesignIntf* VerticalLayout::cloneUpperPart(int height, QObject* owner, QGrap
|
||||
|
||||
BaseDesignIntf* VerticalLayout::cloneBottomPart(int height, QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
VerticalLayout* bottomPart = dynamic_cast<VerticalLayout*>(createSameTypeItem(owner,parent));
|
||||
VerticalLayout* bottomPart = dynamic_cast<VerticalLayout*>(createSameTypeItem(owner, parent));
|
||||
bottomPart->initFromItem(this);
|
||||
|
||||
foreach(BaseDesignIntf* item,childBaseItems()){
|
||||
if (item->geometry().bottom() > height){
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if (item->geometry().bottom() > height) {
|
||||
int sliceHeight = height - item->geometry().top();
|
||||
if ((item->geometry().top() < height) && (item->canBeSplitted(sliceHeight))){
|
||||
BaseDesignIntf* tmpItem = item->cloneBottomPart(sliceHeight, bottomPart, bottomPart);
|
||||
if ((item->geometry().top() < height) && (item->canBeSplitted(sliceHeight))) {
|
||||
BaseDesignIntf* tmpItem
|
||||
= item->cloneBottomPart(sliceHeight, bottomPart, bottomPart);
|
||||
tmpItem->setHeight(sliceHeight);
|
||||
bottomPart->addChild(tmpItem);
|
||||
} else {
|
||||
@@ -137,10 +142,10 @@ BaseDesignIntf* VerticalLayout::cloneBottomPart(int height, QObject* owner, QGra
|
||||
}
|
||||
}
|
||||
|
||||
if (!bottomPart->isEmpty()){
|
||||
if (!bottomPart->isEmpty()) {
|
||||
int currentHeight = 0;
|
||||
foreach (BaseDesignIntf* item, bottomPart->childBaseItems()) {
|
||||
currentHeight+=item->height();
|
||||
currentHeight += item->height();
|
||||
}
|
||||
bottomPart->setHeight(currentHeight);
|
||||
}
|
||||
@@ -149,7 +154,7 @@ BaseDesignIntf* VerticalLayout::cloneBottomPart(int height, QObject* owner, QGra
|
||||
|
||||
void VerticalLayout::sortChildren()
|
||||
{
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),verticalLessThen);
|
||||
std::sort(layoutsChildren().begin(), layoutsChildren().end(), verticalLessThen);
|
||||
}
|
||||
|
||||
void VerticalLayout::divideSpace()
|
||||
@@ -159,22 +164,25 @@ void VerticalLayout::divideSpace()
|
||||
int visibleItemsCount = 0;
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
if (item->isVisible() || itemMode() == DesignMode ){
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isVisible() || itemMode() == DesignMode) {
|
||||
itemsSumSize += item->height();
|
||||
visibleItemsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
itemsSumSize += layoutSpacingMM() * (visibleItemsCount - 1);
|
||||
qreal delta = (height() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1);
|
||||
qreal delta = (height() - (itemsSumSize + spaceBorder * 2))
|
||||
/ (visibleItemsCount != 0 ? visibleItemsCount : 1);
|
||||
|
||||
for (int i=0; i<layoutsChildren().size(); ++i){
|
||||
for (int i = 0; i < layoutsChildren().size(); ++i) {
|
||||
if (layoutsChildren()[i]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i]->setHeight(layoutsChildren()[i]->height()+delta);
|
||||
if ((i+1)<layoutsChildren().size())
|
||||
if (layoutsChildren()[i+1]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i+1]->setPos(layoutsChildren()[i+1]->pos().x(), layoutsChildren()[i+1]->pos().y()+delta*(i+1));
|
||||
layoutsChildren()[i]->setHeight(layoutsChildren()[i]->height() + delta);
|
||||
if ((i + 1) < layoutsChildren().size())
|
||||
if (layoutsChildren()[i + 1]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i + 1]->setPos(layoutsChildren()[i + 1]->pos().x(),
|
||||
layoutsChildren()[i + 1]->pos().y()
|
||||
+ delta * (i + 1));
|
||||
}
|
||||
setIsRelocating(false);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
#ifndef LRVERTICALLAYOUT_H
|
||||
#define LRVERTICALLAYOUT_H
|
||||
|
||||
#include "lrabstractlayout.h"
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrlayoutmarker.h"
|
||||
#include "lrabstractlayout.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class VerticalLayout : public AbstractLayout
|
||||
{
|
||||
class VerticalLayout: public AbstractLayout {
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class BaseDesignIntf;
|
||||
VerticalLayout(QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
VerticalLayout(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
~VerticalLayout();
|
||||
// BaseDesignIntf interface
|
||||
BaseDesignIntf*createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
bool isSplittable() const { return true;}
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
bool isSplittable() const { return true; }
|
||||
|
||||
protected:
|
||||
void updateLayoutSize();
|
||||
void relocateChildren();
|
||||
bool canBeSplitted(int height) const;
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
|
||||
private:
|
||||
void sortChildren();
|
||||
void divideSpace();
|
||||
|
||||
Reference in New Issue
Block a user