summaryrefslogtreecommitdiffstats
path: root/src/axis
diff options
context:
space:
mode:
Diffstat (limited to 'src/axis')
-rw-r--r--src/axis/axis.pri3
-rw-r--r--src/axis/chartaxis.cpp10
-rw-r--r--src/axis/chartaxis_p.h6
-rw-r--r--src/axis/chartaxisx.cpp5
-rw-r--r--src/axis/chartaxisx_p.h4
-rw-r--r--src/axis/chartaxisy.cpp5
-rw-r--r--src/axis/chartaxisy_p.h4
-rw-r--r--src/axis/qabstractaxis.h15
-rw-r--r--src/axis/qaxis.cpp680
-rw-r--r--src/axis/qaxis.h136
-rw-r--r--src/axis/qaxis_p.h85
-rw-r--r--src/axis/qcategoriesaxis.cpp24
-rw-r--r--src/axis/qcategoriesaxis.h11
-rw-r--r--src/axis/qvaluesaxis.cpp24
-rw-r--r--src/axis/qvaluesaxis.h6
15 files changed, 86 insertions, 932 deletions
diff --git a/src/axis/axis.pri b/src/axis/axis.pri
index a9bd4963..9b576437 100644
--- a/src/axis/axis.pri
+++ b/src/axis/axis.pri
@@ -5,7 +5,6 @@ SOURCES += \
$$PWD/chartaxis.cpp \
$$PWD/chartaxisx.cpp \
$$PWD/chartaxisy.cpp \
- $$PWD/qaxis.cpp \
$$PWD/qaxiscategories.cpp \
$$PWD/qcategoriesaxis.cpp \
$$PWD/qvaluesaxis.cpp \
@@ -15,14 +14,12 @@ PRIVATE_HEADERS += \
$$PWD/chartaxis_p.h \
$$PWD/chartaxisx_p.h \
$$PWD/chartaxisy_p.h \
- $$PWD/qaxis_p.h \
$$PWD/qaxiscategories_p.h \
$$PWD/qcategoriesaxis_p.h \
$$PWD/qvaluesaxis_p.h \
$$PWD/qabstractaxis_p.h
PUBLIC_HEADERS += \
- $$PWD/qaxis.h \
$$PWD/qaxiscategories.h \
$$PWD/qcategoriesaxis.h \
$$PWD/qvaluesaxis.h \
diff --git a/src/axis/chartaxis.cpp b/src/axis/chartaxis.cpp
index c5c63cee..8502f50d 100644
--- a/src/axis/chartaxis.cpp
+++ b/src/axis/chartaxis.cpp
@@ -19,8 +19,8 @@
****************************************************************************/
#include "chartaxis_p.h"
-#include "qaxis.h"
-#include "qaxis_p.h"
+#include "qabstractaxis.h"
+#include "qabstractaxis_p.h"
#include "qaxiscategories_p.h"
#include "chartpresenter_p.h"
#include "chartanimator_p.h"
@@ -30,7 +30,7 @@
QTCOMMERCIALCHART_BEGIN_NAMESPACE
-ChartAxis::ChartAxis(QAxis *axis,ChartPresenter *presenter) : Chart(presenter),
+ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : Chart(presenter),
m_chartAxis(axis),
m_labelsAngle(0),
m_grid(new QGraphicsItemGroup(presenter->rootItem())),
@@ -52,7 +52,6 @@ ChartAxis::ChartAxis(QAxis *axis,ChartPresenter *presenter) : Chart(presenter),
m_grid->setZValue(ChartPresenter::GridZValue);
QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
- QObject::connect(m_chartAxis->categories()->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated()));
QGraphicsSimpleTextItem item;
m_font = item.font();
@@ -150,7 +149,8 @@ bool ChartAxis::createLabels(QStringList &labels,qreal min, qreal max,int ticks)
Q_ASSERT(max>min);
Q_ASSERT(ticks>1);
- QAxisCategories* categories = m_chartAxis->categories();
+ //TODO:: QAxisCategories* categories = m_chartAxis->categories();
+ QAxisCategories* categories = new QAxisCategories();
bool category = categories->count()>0;
diff --git a/src/axis/chartaxis_p.h b/src/axis/chartaxis_p.h
index a971bc40..0fa31a5a 100644
--- a/src/axis/chartaxis_p.h
+++ b/src/axis/chartaxis_p.h
@@ -38,7 +38,7 @@
QTCOMMERCIALCHART_BEGIN_NAMESPACE
-class QAxis;
+class QAbstractAxis;
class ChartPresenter;
class ChartAxis : public Chart
@@ -47,7 +47,7 @@ class ChartAxis : public Chart
public:
enum AxisType{ X_AXIS,Y_AXIS };
- ChartAxis(QAxis *axis, ChartPresenter *presenter);
+ ChartAxis(QAbstractAxis *axis, ChartPresenter *presenter);
~ChartAxis();
virtual AxisType axisType() const = 0;
@@ -107,7 +107,7 @@ private:
void axisSelected();
protected:
- QAxis* m_chartAxis;
+ QAbstractAxis* m_chartAxis;
QRectF m_rect;
int m_labelsAngle;
QScopedPointer<QGraphicsItemGroup> m_grid;
diff --git a/src/axis/chartaxisx.cpp b/src/axis/chartaxisx.cpp
index 24b81f37..a33ac14e 100644
--- a/src/axis/chartaxisx.cpp
+++ b/src/axis/chartaxisx.cpp
@@ -19,8 +19,7 @@
****************************************************************************/
#include "chartaxisx_p.h"
-#include "qaxis.h"
-#include "qaxis_p.h"
+#include "qabstractaxis.h"
#include "qaxiscategories_p.h"
#include "chartpresenter_p.h"
#include "chartanimator_p.h"
@@ -32,7 +31,7 @@ static int label_padding = 5;
QTCOMMERCIALCHART_BEGIN_NAMESPACE
-ChartAxisX::ChartAxisX(QAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter)
+ChartAxisX::ChartAxisX(QAbstractAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter)
{
}
diff --git a/src/axis/chartaxisx_p.h b/src/axis/chartaxisx_p.h
index 63b666d3..5e23ce46 100644
--- a/src/axis/chartaxisx_p.h
+++ b/src/axis/chartaxisx_p.h
@@ -34,13 +34,13 @@
QTCOMMERCIALCHART_BEGIN_NAMESPACE
-class QAxis;
+class QAbstractAxis;
class ChartPresenter;
class ChartAxisX : public ChartAxis
{
public:
- ChartAxisX(QAxis *axis, ChartPresenter *presenter);
+ ChartAxisX(QAbstractAxis *axis, ChartPresenter *presenter);
~ChartAxisX();
AxisType axisType() const { return X_AXIS;}
diff --git a/src/axis/chartaxisy.cpp b/src/axis/chartaxisy.cpp
index ae909a31..9020f46a 100644
--- a/src/axis/chartaxisy.cpp
+++ b/src/axis/chartaxisy.cpp
@@ -19,8 +19,7 @@
****************************************************************************/
#include "chartaxisy_p.h"
-#include "qaxis.h"
-#include "qaxis_p.h"
+#include "qabstractaxis.h"
#include "qaxiscategories_p.h"
#include "chartpresenter_p.h"
#include "chartanimator_p.h"
@@ -32,7 +31,7 @@ static int label_padding = 5;
QTCOMMERCIALCHART_BEGIN_NAMESPACE
-ChartAxisY::ChartAxisY(QAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter)
+ChartAxisY::ChartAxisY(QAbstractAxis *axis,ChartPresenter *presenter) : ChartAxis(axis,presenter)
{
}
diff --git a/src/axis/chartaxisy_p.h b/src/axis/chartaxisy_p.h
index d192fa8e..342ede1e 100644
--- a/src/axis/chartaxisy_p.h
+++ b/src/axis/chartaxisy_p.h
@@ -34,13 +34,13 @@
QTCOMMERCIALCHART_BEGIN_NAMESPACE
-class QAxis;
+class QAbstractAxis;
class ChartPresenter;
class ChartAxisY : public ChartAxis
{
public:
- ChartAxisY(QAxis *axis, ChartPresenter *presenter);
+ ChartAxisY(QAbstractAxis *axis, ChartPresenter *presenter);
~ChartAxisY();
AxisType axisType() const { return Y_AXIS;}
diff --git a/src/axis/qabstractaxis.h b/src/axis/qabstractaxis.h
index 0d7dcbc8..a49c39d8 100644
--- a/src/axis/qabstractaxis.h
+++ b/src/axis/qabstractaxis.h
@@ -24,6 +24,7 @@
#include <qchartglobal.h>
#include <QPen>
#include <QFont>
+#include <QVariant>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -101,7 +102,12 @@ public:
void setShadesBorderColor(QColor color);
QColor shadesBorderColor() const;
- int ticksCount() const;
+ //range handling
+ virtual void setMin(QVariant min) = 0;
+ virtual void setMax(QVariant max) = 0 ;
+ virtual void setRange(QVariant min, QVariant max) = 0;
+
+ virtual int ticksCount() const = 0;
void show();
void hide();
@@ -110,18 +116,17 @@ Q_SIGNALS:
void visibleChanged(bool visible);
void labelsVisibleChanged(bool visible);
void gridVisibleChanged(bool visible);
- void rangeChanged();
void colorChanged(QColor color);
void labelsColorChanged(QColor color);
void shadesVisibleChanged(bool visible);
void shadesColorChanged(QColor color);
void shadesBorderColorChanged(QColor color);
- void minChanged();
- void maxChanged();
protected:
QScopedPointer<QAbstractAxisPrivate> d_ptr;
- Q_DISABLE_COPY(QAbstractAxis)
+ Q_DISABLE_COPY(QAbstractAxis);
+ friend class ChartDataSet;
+ friend class ChartAxis;
};
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/axis/qaxis.cpp b/src/axis/qaxis.cpp
deleted file mode 100644
index 517f1c0e..00000000
--- a/src/axis/qaxis.cpp
+++ /dev/null
@@ -1,680 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qaxis.h"
-#include "qaxis_p.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-/*!
- \class QAxis
- \brief The QAxis class is used for manipulating chart's axis
- and for adding optional axes to the chart.
- \mainclass
-
- There is only one x Axis, however there can be multiple y axes.
- Each chart series can be bound to exactly one Y axis and the shared common X axis.
- Axis can be setup to show axis line with tick marks, grid lines and shades.
-*/
-
-/*!
- \qmlclass Axis QAxis
- \brief The Axis element is used for manipulating chart's axes
-
- There is only one x Axis, however there can be multiple y axes on a ChartView.
- Each chart series can be bound to exactly one Y axis and the shared common X axis.
- Axis can be setup to show axis line with tick marks, grid lines and shades.
-
- To access Axes you can use ChartView API. For example:
- \code
- ChartView {
- axisX.min: 0
- axisX.max: 3
- axisX.ticksCount: 4
- axisY.min: 0
- axisY.max: 4
- // Add a few series...
- }
- \endcode
-*/
-
-/*!
- \property QAxis::labelsVisible
- Defines if axis labels are visible.
-*/
-/*!
- \qmlproperty bool Axis::labelsVisible
- Defines if axis labels are visible.
-*/
-
-/*!
- \property QAxis::min
- Defines the minimum value on the axis.
-*/
-/*!
- \qmlproperty real Axis::min
- Defines the minimum value on the axis.
-*/
-
-/*!
- \property QAxis::max
- Defines the maximum value on the axis.
-*/
-/*!
- \qmlproperty real Axis::max
- Defines the maximum value on the axis.
-*/
-
-/*!
- \property QAxis::visible
- The visibility of the axis.
-*/
-/*!
- \qmlproperty bool Axis::visible
- The visibility of the axis.
-*/
-
-/*!
- \property QAxis::gridVisible
- The visibility of the grid lines.
-*/
-/*!
- \qmlproperty bool Axis::gridVisible
- The visibility of the grid lines.
-*/
-
-/*!
- \property QAxis::color
- The color of the axis and ticks.
-*/
-/*!
- \qmlproperty color Axis::color
- The color of the axis and ticks.
-*/
-
-/*!
- \property QAxis::labelsFont
- The font of the axis labels.
-*/
-/*!
- \qmlproperty Font Axis::labelsFont
- The font of the axis labels.
-
- See the \l {Font} {QML Font Element} for detailed documentation.
-*/
-
-/*!
- \property QAxis::labelsColor
- The color of the axis labels.
-*/
-/*!
- \qmlproperty color Axis::labelsColor
- The color of the axis labels.
-*/
-
-/*!
- \property QAxis::labelsAngle
- The angle of the axis labels in degrees.
-*/
-/*!
- \qmlproperty int Axis::labelsAngle
- The angle of the axis labels in degrees.
-*/
-
-/*!
- \property QAxis::shadesVisible
- The visibility of the axis shades.
-*/
-/*!
- \qmlproperty bool Axis::shadesVisible
- The visibility of the axis shades.
-*/
-
-/*!
- \property QAxis::shadesColor
- The fill (brush) color of the axis shades.
-*/
-/*!
- \qmlproperty color Axis::shadesColor
- The fill (brush) color of the axis shades.
-*/
-
-/*!
- \property QAxis::shadesBorderColor
- The border (pen) color of the axis shades.
-*/
-/*!
- \qmlproperty color Axis::shadesBorderColor
- The border (pen) color of the axis shades.
-*/
-
-/*!
- \property QAxis::ticksCount
- The number of tick marks for the axis.
-*/
-/*!
- \qmlproperty int Axis::ticksCount
- The number of tick marks for the axis.
-*/
-
-/*!
- \property QAxis::niceNumbersEnabled
- Whether the nice numbers algorithm is enabled or not for the axis.
-*/
-/*!
- \qmlproperty bool Axis::niceNumbersEnabled
- Whether the nice numbers algorithm is enabled or not for the axis.
-*/
-
-/*!
- \fn void QAxis::visibleChanged(bool)
- Visiblity of the axis has changed to \a visible.
-*/
-
-/*!
- \fn void QAxis::labelsVisibleChanged(bool)
- Visiblity of the labels of the axis has changed to \a visible.
-*/
-
-/*!
- \fn void QAxis::gridVisibleChanged(bool)
- Visiblity of the grid lines of the axis has changed to \a visible.
-*/
-
-/*!
- \fn void QAxis::minChanged(qreal min)
- Axis emits signal when \a min of axis has changed.
-*/
-/*!
- \qmlsignal Axis::onMinChanged(real min)
- Axis emits signal when \a min of axis has changed. This may happen for example if you zoom, scroll or
- enable nice numbers algorithm.
-*/
-
-/*!
- \fn void QAxis::maxChanged(qreal max)
- Axis emits signal when \a max of axis has changed.
-*/
-/*!
- \qmlsignal Axis::onMaxChanged(real max)
- Axis emits signal when \a max of axis has changed. This may happen for example if you zoom, scroll or
- enable nice numbers algorithm.
-*/
-
-/*!
- \fn void QAxis::rangeChanged(qreal min, qreal max)
- Axis emits signal when \a min or \a max of axis has changed.
-*/
-/*!
- \qmlsignal Axis::onRangeChanged(real min, real max)
- Axis emits signal when \a min or \a max of axis has changed. This may happen for example if you zoom, scroll or
- enable nice numbers algorithm.
-*/
-
-/*!
- \fn QChartAxisCategories* QAxis::categories()
- Returns pointer to the list of categories which correspond to the values on the axis.
-*/
-
-/*!
- \fn void QAxis::colorChanged(QColor)
- Emitted if the \a color of the axis is changed.
-*/
-
-/*!
- \fn void QAxis::labelsColorChanged(QColor)
- Emitted if the \a color of the axis labels is changed.
-*/
-
-/*!
- \fn void QAxis::shadesVisibleChanged(bool)
- Emitted if the visibility of the axis shades is changed to \a visible.
-*/
-
-/*!
- \fn void QAxis::shadesColorChanged(QColor)
- Emitted if the \a color of the axis shades is changed.
-*/
-
-/*!
- \fn void QAxis::shadesBorderColorChanged(QColor)
- Emitted if the border \a color of the axis shades is changed.
-*/
-
-/*!
- Constructs new axis object which is a child of \a parent. Ownership is taken by
- QChart when axis added.
-*/
-QAxis::QAxis(QObject *parent) : QObject(parent),
-d_ptr(new QAxisPrivate(this))
-{
-
-}
-
-/*!
- Destructor of the axis object. When axis is added to chart, chart object takes ownership.
-*/
-
-QAxis::~QAxis()
-{
-}
-
-/*!
- Sets \a pen used to draw axis line and ticks.
- */
-void QAxis::setAxisPen(const QPen &pen)
-{
- if (d_ptr->m_axisPen!=pen) {
- d_ptr->m_axisPen = pen;
- emit d_ptr->updated();
- }
-}
-
-/*!
- Returns pen used to draw axis and ticks.
-*/
-QPen QAxis::axisPen() const
-{
- return d_ptr->m_axisPen;
-}
-
-void QAxis::setAxisPenColor(QColor color)
-{
- QPen p = d_ptr->m_axisPen;
- if (p.color() != color) {
- p.setColor(color);
- setAxisPen(p);
- emit colorChanged(color);
- }
-}
-
-QColor QAxis::axisPenColor() const
-{
- return d_ptr->m_axisPen.color();
-}
-
-/*!
- Sets if axis and ticks are \a visible.
- */
-void QAxis::setAxisVisible(bool visible)
-{
- if (d_ptr->m_axisVisible != visible) {
- d_ptr->m_axisVisible = visible;
- emit d_ptr->updated();
- emit visibleChanged(visible);
- }
-}
-
-bool QAxis::isAxisVisible() const
-{
- return d_ptr->m_axisVisible;
-}
-
-void QAxis::setGridLineVisible(bool visible)
-{
- if (d_ptr->m_gridLineVisible != visible) {
- d_ptr->m_gridLineVisible = visible;
- emit d_ptr->updated();
- emit gridVisibleChanged(visible);
- }
-}
-
-bool QAxis::isGridLineVisible() const
-{
- return d_ptr->m_gridLineVisible;
-}
-
-/*!
- Sets \a pen used to draw grid line.
-*/
-void QAxis::setGridLinePen(const QPen &pen)
-{
- if (d_ptr->m_gridLinePen != pen) {
- d_ptr->m_gridLinePen = pen;
- emit d_ptr->updated();
- }
-}
-
-/*!
- Returns pen used to draw grid.
-*/
-QPen QAxis::gridLinePen() const
-{
- return d_ptr->m_gridLinePen;
-}
-
-void QAxis::setLabelsVisible(bool visible)
-{
- if (d_ptr->m_labelsVisible != visible) {
- d_ptr->m_labelsVisible = visible;
- emit d_ptr->updated();
- emit labelsVisibleChanged(visible);
- }
-}
-
-bool QAxis::labelsVisible() const
-{
- return d_ptr->m_labelsVisible;
-}
-
-/*!
- Sets \a pen used to draw labels.
-*/
-void QAxis::setLabelsPen(const QPen &pen)
-{
- if (d_ptr->m_labelsPen != pen) {
- d_ptr->m_labelsPen = pen;
- emit d_ptr->updated();
- }
-}
-
-/*!
- Returns the pen used to labels.
-*/
-QPen QAxis::labelsPen() const
-{
- return d_ptr->m_labelsPen;
-}
-
-/*!
- Sets \a brush used to draw labels.
- */
-void QAxis::setLabelsBrush(const QBrush &brush)
-{
- if (d_ptr->m_labelsBrush != brush) {
- d_ptr->m_labelsBrush = brush;
- emit d_ptr->updated();
- }
-}
-
-/*!
- Returns brush used to draw labels.
-*/
-QBrush QAxis::labelsBrush() const
-{
- return d_ptr->m_labelsBrush;
-}
-
-/*!
- Sets \a font used to draw labels.
-*/
-void QAxis::setLabelsFont(const QFont &font)
-{
- if (d_ptr->m_labelsFont != font) {
- d_ptr->m_labelsFont = font;
- emit d_ptr->updated();
- }
-}
-
-/*!
- Returns font used to draw labels.
-*/
-QFont QAxis::labelsFont() const
-{
- return d_ptr->m_labelsFont;
-}
-
-void QAxis::setLabelsAngle(int angle)
-{
- if (d_ptr->m_labelsAngle != angle) {
- d_ptr->m_labelsAngle = angle;
- emit d_ptr->updated();
- }
-}
-
-int QAxis::labelsAngle() const
-{
- return d_ptr->m_labelsAngle;
-}
-
-void QAxis::setLabelsColor(QColor color)
-{
- QBrush b = d_ptr->m_labelsBrush;
- if (b.color() != color) {
- b.setColor(color);
- setLabelsBrush(b);
- emit labelsColorChanged(color);
- }
-}
-
-QColor QAxis::labelsColor() const
-{
- return d_ptr->m_labelsBrush.color();
-}
-
-void QAxis::setShadesVisible(bool visible)
-{
- if (d_ptr->m_shadesVisible != visible) {
- d_ptr->m_shadesVisible = visible;
- emit d_ptr->updated();
- emit shadesVisibleChanged(visible);
- }
-}
-
-bool QAxis::shadesVisible() const
-{
- return d_ptr->m_shadesVisible;
-}
-
-/*!
- Sets \a pen used to draw shades.
-*/
-void QAxis::setShadesPen(const QPen &pen)
-{
- if (d_ptr->m_shadesPen != pen) {
- d_ptr->m_shadesPen = pen;
- emit d_ptr->updated();
- }
-}
-
-/*!
- Returns pen used to draw shades.
-*/
-QPen QAxis::shadesPen() const
-{
- return d_ptr->m_shadesPen;
-}
-
-/*!
- Sets \a brush used to draw shades.
-*/
-void QAxis::setShadesBrush(const QBrush &brush)
-{
- if (d_ptr->m_shadesBrush != brush) {
- d_ptr->m_shadesBrush = brush;
- emit d_ptr->updated();
- emit shadesColorChanged(brush.color());
- }
-}
-
-/*!
- \brief Returns brush used to draw shades.
-*/
-QBrush QAxis::shadesBrush() const
-{
- return d_ptr->m_shadesBrush;
-}
-
-void QAxis::setShadesColor(QColor color)
-{
- QBrush b = d_ptr->m_shadesBrush;
- b.setColor(color);
- setShadesBrush(b);
-}
-
-QColor QAxis::shadesColor() const
-{
- return d_ptr->m_shadesBrush.color();
-}
-
-void QAxis::setShadesBorderColor(QColor color)
-{
- QPen p = d_ptr->m_shadesPen;
- p.setColor(color);
- setShadesPen(p);
-}
-
-QColor QAxis::shadesBorderColor() const
-{
- return d_ptr->m_shadesPen.color();
-}
-
-void QAxis::setMin(qreal min)
-{
- setRange(min,d_ptr->m_max);
-}
-
-qreal QAxis::min() const
-{
- return d_ptr->m_min;
-}
-
-void QAxis::setMax(qreal max)
-{
- setRange(d_ptr->m_min,max);
-}
-
-qreal QAxis::max() const
-{
- return d_ptr->m_max;
-}
-
-/*!
- Sets range from \a min to \a max on the axis.
-*/
-void QAxis::setRange(qreal min, qreal max)
-{
- bool changed = false;
- if (!qFuzzyIsNull(d_ptr->m_min - min)) {
- d_ptr->m_min = min;
- changed = true;
- emit minChanged(min);
- }
-
- if (!qFuzzyIsNull(d_ptr->m_max - max)) {
- d_ptr->m_max = max;
- changed = true;
- emit maxChanged(max);
- }
-
- if (changed) {
- emit rangeChanged(d_ptr->m_min,d_ptr->m_max);
- emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
- }
-}
-
-/*!
- Sets \a count for ticks on the axis.
-*/
-void QAxis::setTicksCount(int count)
-{
- if (d_ptr->m_ticksCount != count) {
- d_ptr->m_ticksCount = count;
- emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
- }
-}
-
-/*!
- \fn int QAxis::ticksCount() const
- Return number of ticks on the axis
-*/
-int QAxis::ticksCount() const
-{
- return d_ptr->m_ticksCount;
-}
-
-/*!
- Sets axis, shades, labels and grid lines to be visible.
-*/
-void QAxis::show()
-{
- d_ptr->m_axisVisible=true;
- d_ptr->m_gridLineVisible=true;
- d_ptr->m_labelsVisible=true;
- d_ptr->m_shadesVisible=true;
- emit d_ptr->updated();
-}
-
-/*!
- Sets axis, shades, labels and grid lines to not be visible.
-*/
-void QAxis::hide()
-{
- d_ptr->m_axisVisible = false;
- d_ptr->m_gridLineVisible = false;
- d_ptr->m_labelsVisible = false;
- d_ptr->m_shadesVisible = false;
- emit d_ptr->updated();
-}
-
-void QAxis::setNiceNumbersEnabled(bool enable)
-{
- if (d_ptr->m_niceNumbers != enable){
- d_ptr->m_niceNumbers = enable;
- emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
- }
-}
-
-bool QAxis::niceNumbersEnabled() const
-{
- return d_ptr->m_niceNumbers;
-}
-
-QAxisCategories* QAxis::categories()
-{
- return &d_ptr->m_category;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-QAxisPrivate::QAxisPrivate(QAxis* q):
- q_ptr(q),
- m_axisVisible(true),
- m_gridLineVisible(true),
- m_labelsVisible(true),
- m_labelsAngle(0),
- m_shadesVisible(false),
- m_shadesBrush(Qt::SolidPattern),
- m_shadesOpacity(1.0),
- m_min(0),
- m_max(0),
- m_ticksCount(5),
- m_niceNumbers(false)
-{
-
-}
-
-QAxisPrivate::~QAxisPrivate()
-{
-
-}
-
-void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
-{
- q_ptr->setRange(min,max);
- q_ptr->setTicksCount(count);
-}
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-QTCOMMERCIALCHART_USE_NAMESPACE
-
-#include "moc_qaxis.cpp"
-#include "moc_qaxis_p.cpp"
diff --git a/src/axis/qaxis.h b/src/axis/qaxis.h
deleted file mode 100644
index 0bbedbbc..00000000
--- a/src/axis/qaxis.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QAXIS_H
-#define QAXIS_H
-
-#include <qchartglobal.h>
-#include <qaxiscategories.h>
-#include <QPen>
-#include <QFont>
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class QAxisPrivate;
-
-class QTCOMMERCIALCHART_EXPORT QAxis : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged)
- Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
- Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
- Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
- Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
- Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
- Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
- Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
- Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
- Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
- Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
- Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
- Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount)
- Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled)
-
-public:
-
- QAxis(QObject *parent =0);
- ~QAxis();
-
- //axis handling
- bool isAxisVisible() const;
- void setAxisVisible(bool visible = true);
- void setAxisPen(const QPen &pen);
- QPen axisPen() const;
- void setAxisPenColor(QColor color);
- QColor axisPenColor() const;
-
- //grid handling
- bool isGridLineVisible() const;
- void setGridLineVisible(bool visible = true);
- void setGridLinePen(const QPen &pen);
- QPen gridLinePen() const;
-
- //labels handling
- bool labelsVisible() const;
- void setLabelsVisible(bool visible = true);
- void setLabelsPen(const QPen &pen);
- QPen labelsPen() const;
- void setLabelsBrush(const QBrush &brush);
- QBrush labelsBrush() const;
- void setLabelsFont(const QFont &font);
- QFont labelsFont() const;
- void setLabelsAngle(int angle);
- int labelsAngle() const;
- void setLabelsColor(QColor color);
- QColor labelsColor() const;
-
- //shades handling
- bool shadesVisible() const;
- void setShadesVisible(bool visible = true);
- void setShadesPen(const QPen &pen);
- QPen shadesPen() const;
- void setShadesBrush(const QBrush &brush);
- QBrush shadesBrush() const;
- void setShadesColor(QColor color);
- QColor shadesColor() const;
- void setShadesBorderColor(QColor color);
- QColor shadesBorderColor() const;
-
- //range handling
- void setMin(qreal min);
- qreal min() const;
- void setMax(qreal max);
- qreal max() const;
- void setRange(qreal min, qreal max);
-
- //ticks handling
- void setTicksCount(int count);
- int ticksCount() const;
-
- void setNiceNumbersEnabled(bool enable = true);
- bool niceNumbersEnabled() const;
-
- QAxisCategories* categories();
-
- void show();
- void hide();
-
-Q_SIGNALS:
- void visibleChanged(bool visible);
- void labelsVisibleChanged(bool visible);
- void gridVisibleChanged(bool visible);
- void rangeChanged(qreal min, qreal max);
- void colorChanged(QColor color);
- void labelsColorChanged(QColor color);
- void shadesVisibleChanged(bool visible);
- void shadesColorChanged(QColor color);
- void shadesBorderColorChanged(QColor color);
- void minChanged(qreal min);
- void maxChanged(qreal max);
-
-private:
- QScopedPointer<QAxisPrivate> d_ptr;
- Q_DISABLE_COPY(QAxis)
- friend class ChartDataSet;
- friend class ChartAxis;
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-#endif /* QCHARTAXIS_H_ */
diff --git a/src/axis/qaxis_p.h b/src/axis/qaxis_p.h
deleted file mode 100644
index df7869d7..00000000
--- a/src/axis/qaxis_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc
-** All rights reserved.
-** For any questions to Digia, please use contact form at http://qt.digia.com
-**
-** This file is part of the Qt Commercial Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia.
-**
-** If you have questions regarding the use of this file, please use
-** contact form at http://qt.digia.com
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// W A R N I N G
-// -------------
-//
-// This file is not part of the QtCommercial Chart API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef QAXIS_P_H
-#define QAXIS_P_H
-
-#include "qaxis.h"
-
-QTCOMMERCIALCHART_BEGIN_NAMESPACE
-
-class QAxisPrivate : public QObject
-{
- Q_OBJECT
-public:
- QAxisPrivate(QAxis *q);
- ~QAxisPrivate();
-
-Q_SIGNALS:
- void updated();
- void changed(qreal min, qreal max, int tickCount,bool niceNumbers);
-
-public Q_SLOTS:
- void handleAxisRangeChanged(qreal min, qreal max,int count);
-
-private:
- QAxis *q_ptr;
-
- bool m_axisVisible;
- QPen m_axisPen;
- QBrush m_axisBrush;
-
- bool m_gridLineVisible;
- QPen m_gridLinePen;
-
- bool m_labelsVisible;
- QPen m_labelsPen;
- QBrush m_labelsBrush;
- QFont m_labelsFont;
- int m_labelsAngle;
-
- bool m_shadesVisible;
- QPen m_shadesPen;
- QBrush m_shadesBrush;
- qreal m_shadesOpacity;
-
- qreal m_min;
- qreal m_max;
-
- int m_ticksCount;
- QAxisCategories m_category;
-
- bool m_niceNumbers;
-
- friend class QAxis;
-};
-
-QTCOMMERCIALCHART_END_NAMESPACE
-
-#endif
diff --git a/src/axis/qcategoriesaxis.cpp b/src/axis/qcategoriesaxis.cpp
index 12f3c304..e331638d 100644
--- a/src/axis/qcategoriesaxis.cpp
+++ b/src/axis/qcategoriesaxis.cpp
@@ -42,7 +42,7 @@ QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbs
/*!
Appends \a categories to axis
*/
-void QCategoriesAxis::append(QStringList &categories)
+void QCategoriesAxis::append(const QStringList &categories)
{
Q_D(QCategoriesAxis);
d->m_categories.append(categories);
@@ -94,9 +94,9 @@ void QCategoriesAxis::clear()
/*!
Returns number of categories.
*/
-int QCategoriesAxis::count()
+int QCategoriesAxis::count() const
{
- Q_D(QCategoriesAxis);
+ Q_D(const QCategoriesAxis);
return d->m_categories.count();
}
@@ -153,7 +153,25 @@ QAbstractAxis::AxisType QCategoriesAxis::type() const
return AxisTypeCategories;
}
+void QCategoriesAxis::setMin(QVariant min)
+{
+ setMin(min.toString());
+}
+
+void QCategoriesAxis::setMax(QVariant max)
+{
+ setMax(max.toString());
+}
+
+void QCategoriesAxis::setRange(QVariant min, QVariant max)
+{
+ setRange(min.toString(),max.toString());
+}
+int QCategoriesAxis::ticksCount() const
+{
+ return count();
+}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q):
diff --git a/src/axis/qcategoriesaxis.h b/src/axis/qcategoriesaxis.h
index 94575970..9774e263 100644
--- a/src/axis/qcategoriesaxis.h
+++ b/src/axis/qcategoriesaxis.h
@@ -40,12 +40,12 @@ protected:
public:
AxisType type() const;
- void append(QStringList &categories);
+ void append(const QStringList &categories);
void append(const QString &category);
void remove(const QString &category);
void insert(int index, const QString &category);
void clear();
- int count();
+ int count() const;
QString at(int index) const;
@@ -54,6 +54,13 @@ public:
void setMax(QString maxCategory);
void setRange(QString minCategory, QString maxCategory);
+private:
+ //range handling
+ void setMin(QVariant min);
+ void setMax(QVariant max);
+ void setRange(QVariant min, QVariant max);
+ int ticksCount() const;
+
Q_SIGNALS:
void categoriesChanged();
diff --git a/src/axis/qvaluesaxis.cpp b/src/axis/qvaluesaxis.cpp
index 17d233a8..f39e63b2 100644
--- a/src/axis/qvaluesaxis.cpp
+++ b/src/axis/qvaluesaxis.cpp
@@ -130,6 +130,30 @@ QAbstractAxis::AxisType QValuesAxis::type() const
return AxisTypeValues;
}
+void QValuesAxis::setMin(QVariant min)
+{
+ bool ok;
+ qreal value = min.toReal(&ok);
+ if(ok) setMin(value);
+}
+
+void QValuesAxis::setMax(QVariant max)
+{
+ bool ok;
+ qreal value = max.toReal(&ok);
+ if(ok) setMax(value);
+}
+
+void QValuesAxis::setRange(QVariant min, QVariant max)
+{
+ bool ok1;
+ bool ok2;
+ qreal value1 = min.toReal(&ok1);
+ qreal value2 = max.toReal(&ok2);
+ if(ok1&&ok2) setRange(value1,value2);
+}
+
+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q):
diff --git a/src/axis/qvaluesaxis.h b/src/axis/qvaluesaxis.h
index a1d1b641..da0dd4ee 100644
--- a/src/axis/qvaluesaxis.h
+++ b/src/axis/qvaluesaxis.h
@@ -59,6 +59,12 @@ public:
void setNiceNumbersEnabled(bool enable = true);
bool niceNumbersEnabled() const;
+private:
+ //range handling
+ void setMin(QVariant min);
+ void setMax(QVariant max);
+ void setRange(QVariant min, QVariant max);
+
Q_SIGNALS:
void minChanged(qreal min);
void maxChanged(qreal max);