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,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
|
||||
|
||||
Reference in New Issue
Block a user