##// END OF EJS Templates
Proof-of-concept for QML api...
Proof-of-concept for QML api Line, scatter and pie series now shown on a QML app. Uses hard-coded test data.

File last commit:

r110:d11ac5a26e2a
r120:c64ea33f6f52
Show More
charttheme_p.h
84 lines | 2.0 KiB | text/x-c | CLexer
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 #ifndef CHARTTHEME_H
#define CHARTTHEME_H
#include "qchartglobal.h"
#include <QObject>
#include <QSharedData>
#include <QColor>
#include <QLinearGradient>
#include <QPen>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Tero Ahola
One more alternative for changing themes
r108 class ChartTheme;
class ChartThemeObserver
{
public:
virtual void themeChanged(ChartTheme *theme) = 0;
};
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 /*!
* The theme specific settings for the appearance of a series. TODO: These can be overridden by setting
* custom settings to a QChartSeries object.
*/
struct SeriesTheme {
public:
SeriesTheme() :
Tero Ahola
One more alternative for changing themes
r108 linePen(QPen()),
markerPen(QPen()) {}
SeriesTheme(QColor lineColor, qreal lineWidth/*, QPen marker*/) :
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 linePen(QPen(QBrush(lineColor), lineWidth)),
markerPen(linePen) {}
//const QBrush & brush, qreal width, Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap, Qt::PenJoinStyle join = Qt::BevelJo
// TODO:
//QColor lineColor;
QPen linePen;
//QBrush lineBrush;
QPen markerPen;
//QBrush markerBrush;
};
/*!
* Explicitly shared data class for the themes.
*/
class ChartThemeData : public QSharedData
{
public:
ChartThemeData() : m_currentTheme(0) {}
~ChartThemeData() {}
public:
void setTheme(int theme);
public:
int m_currentTheme;
Tero Ahola
One more alternative for changing themes
r108 QList<ChartThemeObserver *> m_observers;
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 QColor m_gradientStartColor;
QColor m_gradientEndColor;
QList<SeriesTheme> m_seriesThemes;
int m_seriesIndex;
};
class ChartTheme : public QObject
{
Q_OBJECT
public:
explicit ChartTheme(QObject *parent = 0);
Tero Ahola
Refactored the test app
r110 explicit ChartTheme(const ChartTheme &other, QObject *parent = 0) : QObject(parent), d(other.d) {}
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 void operator =(const ChartTheme &other) { d = other.d; }
Tero Ahola
One more alternative for changing themes
r108 void setTheme(int theme);
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103 SeriesTheme themeForSeries();
Tero Ahola
One more alternative for changing themes
r108 void addObserver(ChartThemeObserver *o) { d->m_observers << o; }
Tero Ahola
Refactored themes; now enabled for line, scatter and pies...
r103
public:
// All the graphical elements of a QChart share the same theme settings
// so let's use explicitly shared data
QExplicitlySharedDataPointer<ChartThemeData> d;
};
QTCOMMERCIALCHART_END_NAMESPACE
#endif // CHARTTHEME_H