##// END OF EJS Templates
Refactor barchart...
Michal Klocek -
r1707:a9fe09868de9
parent child
Show More
@@ -0,0 +1,13
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/qhorizontalbarseries.cpp \
6 $$PWD/horizontalbarchartitem.cpp
7
8 PRIVATE_HEADERS += \
9 $$PWD/qhorizontalbarseries_p.h \
10 $$PWD/horizontalbarchartitem_p.h
11
12 PUBLIC_HEADERS += \
13 $$PWD/qhorizontalbarseries.h
@@ -0,0 +1,3
1 include(bar/bar.pri)
2 include(percent/percent.pri)
3 include(stacked/stacked.pri) No newline at end of file
@@ -0,0 +1,13
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/qhorizontalpercentbarseries.cpp \
6 $$PWD/horizontalpercentbarchartitem.cpp
7
8 PRIVATE_HEADERS += \
9 $$PWD/qhorizontalpercentbarseries_p.h \
10 $$PWD/horizontalpercentbarchartitem_p.h
11
12 PUBLIC_HEADERS += \
13 $$PWD/qhorizontalpercentbarseries.h
@@ -0,0 +1,15
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/qhorizontalstackedbarseries.cpp \
6 $$PWD/horizontalstackedbarchartitem.cpp
7
8
9 PRIVATE_HEADERS += \
10 $$PWD/qhorizontalstackedbarseries_p.h \
11 $$PWD/horizontalstackedbarchartitem_p.h
12
13 PUBLIC_HEADERS += \
14 $$PWD/qhorizontalstackedbarseries.h
15
@@ -0,0 +1,13
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/barchartitem.cpp \
6 $$PWD/qbarseries.cpp
7
8 PRIVATE_HEADERS += \
9 $$PWD/barchartitem_p.h \
10 $$PWD/qbarseries_p.h
11
12 PUBLIC_HEADERS += \
13 $$PWD/qbarseries.h
@@ -0,0 +1,14
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/percentbarchartitem.cpp \
6 $$PWD/qpercentbarseries.cpp
7
8
9 PRIVATE_HEADERS += \
10 $$PWD/percentbarchartitem_p.h \
11 $$PWD/qpercentbarseries_p.h
12
13 PUBLIC_HEADERS += \
14 $$PWD/qpercentbarseries.h
@@ -0,0 +1,13
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/qstackedbarseries.cpp \
6 $$PWD/stackedbarchartitem.cpp
7
8 PRIVATE_HEADERS += \
9 $$PWD/stackedbarchartitem_p.h \
10 $$PWD/qstackedbarseries_p.h
11
12 PUBLIC_HEADERS += \
13 $$PWD/qstackedbarseries.h
@@ -0,0 +1,3
1 include(bar/bar.pri)
2 include(percent/percent.pri)
3 include(stacked/stacked.pri) No newline at end of file
@@ -1,55 +1,28
1 include(vertical/vertical.pri)
2 include(horizontal/horizontal.pri)
3
1 4 INCLUDEPATH += $$PWD
2 5 DEPENDPATH += $$PWD
3 6
4 7 SOURCES += \
5 8 $$PWD/bar.cpp \
6 9 $$PWD/abstractbarchartitem.cpp \
7 $$PWD/percentbarchartitem.cpp \
8 $$PWD/barchartitem.cpp \
9 10 $$PWD/qabstractbarseries.cpp \
10 11 $$PWD/qbarset.cpp \
11 $$PWD/qpercentbarseries.cpp \
12 $$PWD/qstackedbarseries.cpp \
13 $$PWD/qbarseries.cpp \
14 $$PWD/stackedbarchartitem.cpp \
15 12 $$PWD/qbarmodelmapper.cpp \
16 13 $$PWD/qvbarmodelmapper.cpp \
17 14 $$PWD/qhbarmodelmapper.cpp \
18 $$PWD/qhorizontalbarseries.cpp \
19 $$PWD/horizontalbarchartitem.cpp \
20 $$PWD/qhorizontalstackedbarseries.cpp \
21 $$PWD/horizontalstackedbarchartitem.cpp \
22 $$PWD/qhorizontalpercentbarseries.cpp \
23 $$PWD/horizontalpercentbarchartitem.cpp
24 15
25 16 PRIVATE_HEADERS += \
26 17 $$PWD/bar_p.h \
27 $$PWD/abstractbarchartitem_p.h \
28 $$PWD/percentbarchartitem_p.h \
29 $$PWD/stackedbarchartitem_p.h \
30 $$PWD/barchartitem_p.h \
31 18 $$PWD/qbarset_p.h \
19 $$PWD/abstractbarchartitem_p.h \
32 20 $$PWD/qabstractbarseries_p.h \
33 $$PWD/qstackedbarseries_p.h\
34 $$PWD/qpercentbarseries_p.h \
35 $$PWD/qbarseries_p.h \
36 $$PWD/qbarmodelmapper_p.h \
37 $$PWD/qhorizontalbarseries_p.h \
38 $$PWD/horizontalbarchartitem_p.h \
39 $$PWD/qhorizontalstackedbarseries_p.h \
40 $$PWD/horizontalstackedbarchartitem_p.h \
41 $$PWD/qhorizontalpercentbarseries_p.h \
42 $$PWD/horizontalpercentbarchartitem_p.h
21 $$PWD/qbarmodelmapper_p.h
43 22
44 23 PUBLIC_HEADERS += \
45 24 $$PWD/qabstractbarseries.h \
46 25 $$PWD/qbarset.h \
47 $$PWD/qpercentbarseries.h \
48 $$PWD/qstackedbarseries.h \
49 $$PWD/qbarseries.h \
50 26 $$PWD/qbarmodelmapper.h \
51 27 $$PWD/qvbarmodelmapper.h \
52 $$PWD/qhbarmodelmapper.h \
53 $$PWD/qhorizontalbarseries.h \
54 $$PWD/qhorizontalstackedbarseries.h \
55 $$PWD/qhorizontalpercentbarseries.h
28 $$PWD/qhbarmodelmapper.h
1 NO CONTENT: file renamed from src/barchart/horizontalbarchartitem.cpp to src/barchart/horizontal/bar/horizontalbarchartitem.cpp
1 NO CONTENT: file renamed from src/barchart/horizontalbarchartitem_p.h to src/barchart/horizontal/bar/horizontalbarchartitem_p.h
@@ -1,3 +1,23
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 21 #include "qhorizontalbarseries.h"
2 22 #include "qhorizontalbarseries_p.h"
3 23 #include "horizontalbarchartitem_p.h"
@@ -20,8 +40,6 QAbstractSeries::SeriesType QHorizontalBarSeries::type() const
20 40 return QAbstractSeries::SeriesTypeHorizontalBar;
21 41 }
22 42
23
24
25 43 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26 44
27 45 QHorizontalBarSeriesPrivate::QHorizontalBarSeriesPrivate(QHorizontalBarSeries *q) : QAbstractBarSeriesPrivate(q)
@@ -46,7 +64,6 void QHorizontalBarSeriesPrivate::scaleDomain(Domain& domain)
46 64 domain.setRange(minX,maxX,minY,maxY);
47 65 }
48 66
49
50 67 Chart* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
51 68 {
52 69 Q_Q(QHorizontalBarSeries);
@@ -60,30 +77,6 Chart* QHorizontalBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
60 77 return bar;
61 78 }
62 79
63 void QHorizontalBarSeriesPrivate::initializeAxis(QAbstractAxis* axis)
64 {
65
66 if(axis->type()==QAbstractAxis::AxisTypeCategories && axis->orientation()==Qt::Vertical)
67 {
68 QBarCategoriesAxis* cataxis = qobject_cast<QBarCategoriesAxis*>(axis);
69 Q_ASSERT(cataxis);
70 QStringList categories;
71 if(cataxis->categories().isEmpty()){
72 for (int i(1); i < categoryCount()+1; i++)
73 categories << QString::number(i);
74 cataxis->append(categories);
75 }
76 }
77 }
78
79 QAbstractAxis::AxisType QHorizontalBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
80 {
81 if(orientation==Qt::Vertical)
82 return QAbstractAxis::AxisTypeCategories;
83 else
84 return QAbstractAxis::AxisTypeValues;
85 }
86
87 80 #include "moc_qhorizontalbarseries.cpp"
88 81
89 82 QTCOMMERCIALCHART_END_NAMESPACE
1 NO CONTENT: file renamed from src/barchart/qhorizontalbarseries.h to src/barchart/horizontal/bar/qhorizontalbarseries.h
@@ -41,9 +41,6 public:
41 41 QHorizontalBarSeriesPrivate(QHorizontalBarSeries* q);
42 42 Chart* createGraphics(ChartPresenter* presenter);
43 43 void scaleDomain(Domain& domain);
44 void initializeAxis(QAbstractAxis* axis);
45 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
46
47 44 private:
48 45 Q_DECLARE_PUBLIC(QHorizontalBarSeries)
49 46 };
1 NO CONTENT: file renamed from src/barchart/horizontalpercentbarchartitem.cpp to src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp
1 NO CONTENT: file renamed from src/barchart/horizontalpercentbarchartitem_p.h to src/barchart/horizontal/percent/horizontalpercentbarchartitem_p.h
1 NO CONTENT: file renamed from src/barchart/qhorizontalpercentbarseries.cpp to src/barchart/horizontal/percent/qhorizontalpercentbarseries.cpp
1 NO CONTENT: file renamed from src/barchart/qhorizontalpercentbarseries.h to src/barchart/horizontal/percent/qhorizontalpercentbarseries.h
@@ -41,7 +41,6 public:
41 41 QHorizontalPercentBarSeriesPrivate(QHorizontalPercentBarSeries* q);
42 42 Chart* createGraphics(ChartPresenter* presenter);
43 43 void scaleDomain(Domain& domain);
44
45 44 private:
46 45 Q_DECLARE_PUBLIC(QHorizontalPercentBarSeries)
47 46 };
1 NO CONTENT: file renamed from src/barchart/horizontalstackedbarchartitem.cpp to src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp
1 NO CONTENT: file renamed from src/barchart/horizontalstackedbarchartitem_p.h to src/barchart/horizontal/stacked/horizontalstackedbarchartitem_p.h
@@ -57,17 +57,6 Chart* QHorizontalStackedBarSeriesPrivate::createGraphics(ChartPresenter* presen
57 57 return bar;
58 58 }
59 59
60 QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisXType() const
61 {
62 return QAbstractAxis::AxisTypeValues;
63 }
64
65 QAbstractAxis::AxisType QHorizontalStackedBarSeriesPrivate::defaultAxisYType() const
66 {
67 return QAbstractAxis::AxisTypeCategories;
68 }
69
70
71 60 #include "moc_qhorizontalstackedbarseries.cpp"
72 61
73 62 QTCOMMERCIALCHART_END_NAMESPACE
1 NO CONTENT: file renamed from src/barchart/qhorizontalstackedbarseries.h to src/barchart/horizontal/stacked/qhorizontalstackedbarseries.h
@@ -41,9 +41,6 public:
41 41 QHorizontalStackedBarSeriesPrivate(QHorizontalStackedBarSeries* q);
42 42 Chart* createGraphics(ChartPresenter* presenter);
43 43 void scaleDomain(Domain& domain);
44 QAbstractAxis::AxisType defaultAxisXType() const;
45 QAbstractAxis::AxisType defaultAxisYType() const;
46
47 44 private:
48 45 Q_DECLARE_PUBLIC(QHorizontalStackedBarSeries)
49 46 };
@@ -189,11 +189,10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
189 189 */
190 190
191 191 /*!
192 Constructs empty QAbstractBarSeries.
193 QAbstractBarSeries is QObject which is a child of a \a parent.
192 This is depreciated constructor.
194 193 */
195 194 QAbstractBarSeries::QAbstractBarSeries(QObject *parent) :
196 QAbstractSeries(*new QAbstractBarSeriesPrivate(this),parent)
195 QAbstractSeries(*(QAbstractBarSeriesPrivate*)(0),parent)
197 196 {
198 197 }
199 198
@@ -701,25 +700,84 bool QAbstractBarSeriesPrivate::insert(int index, QBarSet *set)
701 700
702 701 void QAbstractBarSeriesPrivate::initializeAxis(QAbstractAxis* axis)
703 702 {
704 if(axis->type()==QAbstractAxis::AxisTypeCategories && axis->orientation()==Qt::Horizontal)
705 {
706 QBarCategoriesAxis* cataxis = qobject_cast<QBarCategoriesAxis*>(axis);
707 Q_ASSERT(cataxis);
708 QStringList categories;
709 if(cataxis->categories().isEmpty()){
710 for (int i(1); i < categoryCount()+1; i++)
711 categories << QString::number(i);
712 cataxis->append(categories);
703 Q_Q(QAbstractBarSeries);
704
705 if(axis->type()==QAbstractAxis::AxisTypeCategories) {
706
707 switch(q->type()) {
708
709 case QAbstractSeries::SeriesTypeHorizontalBar:
710 case QAbstractSeries::SeriesTypeHorizontalPercentBar:
711 case QAbstractSeries::SeriesTypeHorizontalStackedBar: {
712
713 if(axis->orientation()==Qt::Vertical)
714 {
715 populateCategories(qobject_cast<QBarCategoriesAxis*>(axis));
716 }
717 break;
718 }
719 case QAbstractSeries::SeriesTypeBar:
720 case QAbstractSeries::SeriesTypePercentBar:
721 case QAbstractSeries::SeriesTypeStackedBar: {
722
723 if(axis->orientation()==Qt::Horizontal)
724 {
725 populateCategories(qobject_cast<QBarCategoriesAxis*>(axis));
726 }
727 break;
728 }
729 default:
730 qWarning()<<"Unexpected series type";
731 break;
732
713 733 }
714 734 }
715 735 }
716 736
717 737 QAbstractAxis::AxisType QAbstractBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
718 738 {
719 Q_UNUSED(orientation);
720 return QAbstractAxis::AxisTypeNoAxis;
739 Q_Q(const QAbstractBarSeries);
740
741 switch(q->type()) {
742
743 case QAbstractSeries::SeriesTypeHorizontalBar:
744 case QAbstractSeries::SeriesTypeHorizontalPercentBar:
745 case QAbstractSeries::SeriesTypeHorizontalStackedBar: {
746
747 if(orientation==Qt::Vertical)
748 {
749 return QAbstractAxis::AxisTypeCategories;
750 }
751 break;
752 }
753 case QAbstractSeries::SeriesTypeBar:
754 case QAbstractSeries::SeriesTypePercentBar:
755 case QAbstractSeries::SeriesTypeStackedBar: {
756
757 if(orientation==Qt::Horizontal)
758 {
759 return QAbstractAxis::AxisTypeCategories;
760 }
761 break;
762 }
763 default:
764 qWarning()<<"Unexpected series type";
765 break;
766
767 }
768 return QAbstractAxis::AxisTypeValues;
769
721 770 }
722 771
772 void QAbstractBarSeriesPrivate::populateCategories(QBarCategoriesAxis* axis)
773 {
774 QStringList categories;
775 if(axis->categories().isEmpty()) {
776 for (int i(1); i < categoryCount()+1; i++)
777 categories << QString::number(i);
778 axis->append(categories);
779 }
780 }
723 781
724 782 #include "moc_qabstractbarseries.cpp"
725 783 #include "moc_qabstractbarseries_p.cpp"
@@ -38,6 +38,7 class QTCOMMERCIALCHART_EXPORT QAbstractBarSeries : public QAbstractSeries
38 38 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 39
40 40 protected:
41 //TODO DEPRECIATED
41 42 explicit QAbstractBarSeries(QObject *parent = 0);
42 43
43 44 public:
@@ -38,6 +38,7
38 38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 39
40 40 class QBarModelMapper;
41 class QBarCategoriesAxis;
41 42
42 43 class QAbstractBarSeriesPrivate : public QAbstractSeriesPrivate
43 44 {
@@ -82,6 +83,9 Q_SIGNALS:
82 83 void restructuredBars();
83 84 void labelsVisibleChanged(bool visible);
84 85
86 private:
87 void populateCategories(QBarCategoriesAxis* axis);
88
85 89 protected:
86 90 QList<QBarSet *> m_barSets;
87 91 qreal m_barWidth;
1 NO CONTENT: file renamed from src/barchart/barchartitem.cpp to src/barchart/vertical/bar/barchartitem.cpp
1 NO CONTENT: file renamed from src/barchart/barchartitem_p.h to src/barchart/vertical/bar/barchartitem_p.h
@@ -26,6 +26,7
26 26 #include "chartanimator_p.h"
27 27 #include "baranimation_p.h"
28 28 #include "qvaluesaxis.h"
29 #include "qbarcategoriesaxis.h"
29 30
30 31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 32
@@ -110,14 +111,6 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
110 111 return bar;
111 112 }
112 113
113 QAbstractAxis::AxisType QBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
114 {
115 if(orientation==Qt::Horizontal)
116 return QAbstractAxis::AxisTypeCategories;
117 else
118 return QAbstractAxis::AxisTypeValues;
119 }
120
121 114 #include "moc_qbarseries.cpp"
122 115
123 116 QTCOMMERCIALCHART_END_NAMESPACE
1 NO CONTENT: file renamed from src/barchart/qbarseries.h to src/barchart/vertical/bar/qbarseries.h
@@ -42,10 +42,6 public:
42 42 QBarSeriesPrivate(QBarSeries* q);
43 43 Chart* createGraphics(ChartPresenter* presenter);
44 44 void scaleDomain(Domain& domain);
45
46 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
47
48
49 45 private:
50 46 Q_DECLARE_PUBLIC(QBarSeries)
51 47 };
1 NO CONTENT: file renamed from src/barchart/percentbarchartitem.cpp to src/barchart/vertical/percent/percentbarchartitem.cpp
1 NO CONTENT: file renamed from src/barchart/percentbarchartitem_p.h to src/barchart/vertical/percent/percentbarchartitem_p.h
@@ -109,15 +109,6 Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
109 109 return bar;
110 110 }
111 111
112 QAbstractAxis::AxisType QPercentBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
113 {
114 if(orientation==Qt::Horizontal)
115 return QAbstractAxis::AxisTypeCategories;
116 else
117 return QAbstractAxis::AxisTypeValues;
118 }
119
120
121 112 #include "moc_qpercentbarseries.cpp"
122 113
123 114 QTCOMMERCIALCHART_END_NAMESPACE
1 NO CONTENT: file renamed from src/barchart/qpercentbarseries.h to src/barchart/vertical/percent/qpercentbarseries.h
@@ -42,8 +42,6 public:
42 42 QPercentBarSeriesPrivate(QPercentBarSeries* q);
43 43 void scaleDomain(Domain& domain);
44 44 Chart* createGraphics(ChartPresenter* presenter);
45 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
46
47 45 private:
48 46 Q_DECLARE_PUBLIC(QPercentBarSeries)
49 47 };
@@ -111,15 +111,6 Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
111 111 return bar;
112 112 }
113 113
114 QAbstractAxis::AxisType QStackedBarSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
115 {
116 if(orientation==Qt::Horizontal)
117 return QAbstractAxis::AxisTypeCategories;
118 else
119 return QAbstractAxis::AxisTypeValues;
120 }
121
122
123 114 #include "moc_qstackedbarseries.cpp"
124 115
125 116 QTCOMMERCIALCHART_END_NAMESPACE
1 NO CONTENT: file renamed from src/barchart/qstackedbarseries.h to src/barchart/vertical/stacked/qstackedbarseries.h
@@ -42,8 +42,6 public:
42 42 QStackedBarSeriesPrivate(QStackedBarSeries* q);
43 43 Chart* createGraphics(ChartPresenter* presenter);
44 44 void scaleDomain(Domain& domain);
45 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
46
47 45 private:
48 46 Q_DECLARE_PUBLIC(QStackedBarSeries)
49 47 };
1 NO CONTENT: file renamed from src/barchart/stackedbarchartitem.cpp to src/barchart/vertical/stacked/stackedbarchartitem.cpp
1 NO CONTENT: file renamed from src/barchart/stackedbarchartitem_p.h to src/barchart/vertical/stacked/stackedbarchartitem_p.h
General Comments 0
You need to be logged in to leave comments. Login now