##// END OF EJS Templates
replaced qbarcategory with qstringlist
sauimone -
r377:a61a7697be62
parent child
Show More
@@ -3,7 +3,7
3 3 #include <qchartview.h>
4 4 #include <qbarseries.h>
5 5 #include <qbarset.h>
6 #include <qbarcategory.h>
6 #include <QStringList>
7 7
8 8 QTCOMMERCIALCHART_USE_NAMESPACE
9 9
@@ -13,9 +13,9 int main(int argc, char *argv[])
13 13 QMainWindow window;
14 14
15 15 //! [1]
16 // Create category
17 QBarCategory *category = new QBarCategory;
18 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
16 // Define categories
17 QStringList catecories;
18 catecories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
19 19 //! [1]
20 20
21 21 //! [2]
@@ -36,7 +36,7 int main(int argc, char *argv[])
36 36
37 37 //! [3]
38 38 // Create series and add sets to it
39 QBarSeries* series= new QBarSeries(category);
39 QBarSeries* series= new QBarSeries(catecories);
40 40
41 41 series->addBarSet(set0);
42 42 series->addBarSet(set1);
@@ -6,8 +6,8
6 6 #include <qscatterseries.h>
7 7 #include <qbarseries.h>
8 8 #include <qbarset.h>
9 #include <qbarcategory.h>
10 9 #include <qpieseries.h>
10 #include <QStringList>
11 11
12 12 QTCOMMERCIALCHART_USE_NAMESPACE
13 13
@@ -60,8 +60,8 int main(int argc, char *argv[])
60 60 //! [5]
61 61 // ...
62 62 // Add bar series
63 QBarCategory *barCategory = new QBarCategory();
64 *barCategory << "Jan"
63 QStringList barCategory;
64 barCategory << "Jan"
65 65 << "Feb"
66 66 << "Mar";
67 67 QBarSeries *bar = new QBarSeries(barCategory);
@@ -13,12 +13,12
13 13 #include <qscatterseries.h>
14 14 #include <qchartview.h>
15 15 #include <qchartaxis.h>
16 #include <qbarcategory.h>
17 16 #include <qbarset.h>
18 17 #include <QListWidget>
19 18 #include <QPrinter>
20 19 #include <QPrintDialog>
21 20 #include <QRadioButton>
21 #include <QStringList>
22 22
23 23 QTCOMMERCIALCHART_USE_NAMESPACE
24 24
@@ -121,9 +121,9 void Widget::refreshChart()
121 121 if (barChartRadioButton->isChecked())
122 122 {
123 123 // use the sorted selected coutries list to initialize BarCategory
124 QBarCategory* category = new QBarCategory;
124 QStringList category;
125 125 for (int i = 0; i < selectedCountriesStrings.size(); i++)
126 *category << selectedCountriesStrings[i];
126 category << selectedCountriesStrings[i];
127 127 series0 = new QBarSeries(category);
128 128
129 129 // prepare the selected counries SQL query
@@ -2,9 +2,9
2 2 #include <QMainWindow>
3 3 #include <QStandardItemModel>
4 4 #include <qpercentbarseries.h>
5 #include <qbarcategory.h>
6 5 #include <qchartview.h>
7 6 #include <qbarset.h>
7 #include <QStringList>
8 8
9 9 QTCOMMERCIALCHART_USE_NAMESPACE
10 10
@@ -14,9 +14,9 int main(int argc, char *argv[])
14 14 QMainWindow window;
15 15
16 16 //! [1]
17 // Create category
18 QBarCategory *category = new QBarCategory;
19 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
17 // Define categories
18 QStringList categories;
19 categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
20 20 //! [1]
21 21
22 22 //! [2]
@@ -36,7 +36,7 int main(int argc, char *argv[])
36 36
37 37 //! [3]
38 38 // Create series and add sets to it
39 QPercentBarSeries* series = new QPercentBarSeries(category);
39 QPercentBarSeries* series = new QPercentBarSeries(categories);
40 40
41 41 series->addBarSet(set0);
42 42 series->addBarSet(set1);
@@ -3,7 +3,7
3 3 #include <qchartview.h>
4 4 #include <qstackedbarseries.h>
5 5 #include <qbarset.h>
6 #include <qbarcategory.h>
6 #include <QStringList>
7 7
8 8 QTCOMMERCIALCHART_USE_NAMESPACE
9 9
@@ -13,9 +13,9 int main(int argc, char *argv[])
13 13 QMainWindow window;
14 14
15 15 //! [1]
16 // Create category
17 QBarCategory *category = new QBarCategory;
18 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
16 // Define categories
17 QStringList catecories;
18 catecories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
19 19 //! [1]
20 20
21 21 //! [2]
@@ -35,7 +35,7 int main(int argc, char *argv[])
35 35
36 36 //! [3]
37 37 // Create series and add sets to it
38 QStackedBarSeries* series = new QStackedBarSeries(category);
38 QStackedBarSeries* series = new QStackedBarSeries(catecories);
39 39
40 40 series->addBarSet(set0);
41 41 series->addBarSet(set1);
@@ -8,7 +8,6 SOURCES += \
8 8 $$PWD/barpresenter.cpp \
9 9 $$PWD/barpresenterbase.cpp \
10 10 $$PWD/percentbarpresenter.cpp \
11 $$PWD/qbarcategory.cpp \
12 11 $$PWD/qbarseries.cpp \
13 12 $$PWD/qbarset.cpp \
14 13 $$PWD/qpercentbarseries.cpp \
@@ -29,7 +28,6 PRIVATE_HEADERS += \
29 28 $$PWD/barvalue_p.h
30 29
31 30 PUBLIC_HEADERS += \
32 $$PWD/qbarcategory.h \
33 31 $$PWD/qbarseries.h \
34 32 $$PWD/qbarset.h \
35 33 $$PWD/qpercentbarseries.h \
@@ -2,26 +2,19
2 2 #include <QVector>
3 3 #include <QDebug>
4 4 #include "barchartmodel_p.h"
5 #include "qbarcategory.h"
6 5 #include "qbarset.h"
7 6
8 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 8
10 BarChartModel::BarChartModel(QBarCategory *category, QObject *parent) :
9 BarChartModel::BarChartModel(QStringList categories, QObject *parent) :
11 10 QObject(parent)
12 ,mCategory(category)
11 ,mCategory(categories)
13 12 {
14 13 }
15 14
16 BarChartModel::~BarChartModel()
15 QStringList BarChartModel::category()
17 16 {
18 delete mCategory;
19 }
20
21
22 QBarCategory& BarChartModel::category()
23 {
24 return *mCategory;
17 return mCategory;
25 18 }
26 19
27 20 void BarChartModel::addBarSet(QBarSet *set)
@@ -182,7 +175,7 qreal BarChartModel::maxCategorySum()
182 175
183 176 QString BarChartModel::label(int category)
184 177 {
185 return mCategory->label(category);
178 return mCategory.at(category);
186 179 }
187 180
188 181 #include "moc_barchartmodel_p.cpp"
@@ -2,6 +2,7
2 2 #define BARCHARTMODEL_H
3 3
4 4 #include <QObject>
5 #include <QStringList>
5 6 #include "qchartglobal.h"
6 7
7 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -10,16 +11,14 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 11 // TODO: Implement as QAbstractItemModel?
11 12
12 13 class QBarSet;
13 class QBarCategory;
14 14
15 15 class BarChartModel : public QObject //, public QAbstractItemModel
16 16 {
17 17 Q_OBJECT
18 18 public:
19 explicit BarChartModel(QBarCategory *category, QObject *parent = 0);
20 ~BarChartModel();
19 explicit BarChartModel(QStringList categories, QObject *parent = 0);
21 20
22 QBarCategory& category();
21 QStringList category();
23 22 void addBarSet(QBarSet *set);
24 23 void removeBarSet(QBarSet *set);
25 24 QBarSet *setAt(int index);
@@ -49,7 +48,7 public slots:
49 48 private:
50 49
51 50 QList<QBarSet*> mDataModel;
52 QBarCategory* mCategory; // Owned
51 QStringList mCategory;
53 52
54 53 int mCurrentSet;
55 54
@@ -1,6 +1,5
1 1 #include <QDebug>
2 2 #include "qbarseries.h"
3 #include "qbarcategory.h"
4 3 #include "qbarset.h"
5 4 #include "barchartmodel_p.h"
6 5
@@ -13,11 +12,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13 12
14 13 QBarSeries represents a series of data shown as bars. One QBarSeries can contain multible
15 14 QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined
16 by QBarCategory class.
15 by QStringList.
17 16
18 17 \mainclass
19 18
20 \sa QBarCategory, QBarSet, QStackedBarSeries, QPercentBarSeries
19 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
21 20 */
22 21
23 22 /*!
@@ -48,12 +47,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
48 47
49 48 /*!
50 49 Constructs empty QBarSeries. Parameter \a category defines the categories for chart.
51 Takes ownership of \a category.
52 50 QBarSeries is QObject which is a child of a \a parent.
53 51 */
54 QBarSeries::QBarSeries(QBarCategory *category, QObject *parent)
52 QBarSeries::QBarSeries(QStringList categories, QObject *parent)
55 53 : QSeries(parent)
56 ,mModel(new BarChartModel(category, this))
54 ,mModel(new BarChartModel(categories, this))
57 55 {
58 56 }
59 57
@@ -2,10 +2,10
2 2 #define BARSERIES_H
3 3
4 4 #include "qseries.h"
5 #include <QStringList>
5 6
6 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 8
8 class QBarCategory;
9 9 class QBarSet;
10 10 class BarChartModel;
11 11
@@ -14,7 +14,7 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries
14 14 {
15 15 Q_OBJECT
16 16 public:
17 QBarSeries(QBarCategory *category, QObject* parent=0);
17 QBarSeries(QStringList categories, QObject* parent=0);
18 18
19 19 virtual QSeriesType type() const { return QSeries::SeriesTypeBar; }
20 20
@@ -15,7 +15,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
15 15
16 16 \mainclass
17 17
18 \sa QBarCategory, QBarSeries, QStackedBarSeries, QPercentBarSeries
18 \sa QBarSeries, QStackedBarSeries, QPercentBarSeries
19 19 */
20 20
21 21 /*!
@@ -8,11 +8,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 9 QPercentBarSeries represents a series of data shown as bars. Each bar of QBarSet is shown as percentage
10 10 of all bars in category. One QPercentBarSeries can contain multible QBarSet data sets.
11 QBarSeries groups the data from sets to categories, which are defined by QBarCategory class.
11 QBarSeries groups the data from sets to categories, which are defined by QStringList.
12 12
13 13 \mainclass
14 14
15 \sa QBarCategory, QBarSet, QStackedBarSeries, QBarSeries
15 \sa QBarSet, QStackedBarSeries, QBarSeries
16 16 */
17 17
18 18 /*!
@@ -25,8 +25,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25 Constructs empty QPercentBarSeries. Parameter \a category defines the categories for chart.
26 26 QPercentBarSeries is QObject which is a child of a \a parent.
27 27 */
28 QPercentBarSeries::QPercentBarSeries(QBarCategory *category, QObject *parent)
29 : QBarSeries(category, parent)
28 QPercentBarSeries::QPercentBarSeries(QStringList categories, QObject *parent)
29 : QBarSeries(categories, parent)
30 30 {
31 31 }
32 32
@@ -1,6 +1,7
1 1 #ifndef PERCENTBARSERIES_H
2 2 #define PERCENTBARSERIES_H
3 3
4 #include <QStringList>
4 5 #include "qbarseries.h"
5 6
6 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -9,7 +10,7 class QTCOMMERCIALCHART_EXPORT QPercentBarSeries : public QBarSeries
9 10 {
10 11 Q_OBJECT
11 12 public:
12 QPercentBarSeries(QBarCategory *category, QObject* parent=0);
13 QPercentBarSeries(QStringList categories, QObject* parent=0);
13 14
14 15 virtual QSeriesType type() const { return QSeries::SeriesTypePercentBar; }
15 16 };
@@ -8,11 +8,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8
9 9 QStackedBarSeries represents a series of data shown as bars. All bars in same category are
10 10 stacked on top of each other. One QStackedBarSeries can contain multible QBarSet data sets.
11 QStackedBarSeries groups the data from sets to categories, which are defined by QBarCategory class.
11 QStackedBarSeries groups the data from sets to categories, which are defined by QStringList.
12 12
13 13 \mainclass
14 14
15 \sa QBarCategory, QBarSet, QPercentBarSeries, QBarSeries
15 \sa QBarSet, QPercentBarSeries, QBarSeries
16 16 */
17 17
18 18 /*!
@@ -25,8 +25,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25 Constructs empty QStackedBarSeries. Parameter \a category defines the categories for chart.
26 26 QStackedBarSeries is QObject which is a child of a \a parent.
27 27 */
28 QStackedBarSeries::QStackedBarSeries(QBarCategory *category, QObject *parent)
29 : QBarSeries(category, parent)
28 QStackedBarSeries::QStackedBarSeries(QStringList categories, QObject *parent)
29 : QBarSeries(categories, parent)
30 30 {
31 31 }
32 32
@@ -1,17 +1,16
1 1 #ifndef STACKEDBARSERIES_H
2 2 #define STACKEDBARSERIES_H
3 3
4 #include <QStringList>
4 5 #include "qbarseries.h"
5 6
6 7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 8
8 class QBarCategory;
9
10 9 class QTCOMMERCIALCHART_EXPORT QStackedBarSeries : public QBarSeries
11 10 {
12 11 Q_OBJECT
13 12 public:
14 QStackedBarSeries(QBarCategory *category, QObject* parent=0);
13 QStackedBarSeries(QStringList categories, QObject* parent=0);
15 14
16 15 virtual QSeriesType type() const { return QSeries::SeriesTypeStackedBar; }
17 16 };
@@ -4,7 +4,6
4 4 #include "qscatterseries.h"
5 5 #include <qlineseries.h>
6 6 #include <qbarset.h>
7 #include <qbarcategory.h>
8 7 #include <qbarseries.h>
9 8 #include <qstackedbarseries.h>
10 9 #include <qpercentbarseries.h>
@@ -253,11 +252,10 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
253 252 } else if (seriesName == "Bar"
254 253 || seriesName == "Stacked bar"
255 254 || seriesName == "Percent bar") {
256 // TODO: replace QBarCategory with QStringList?
257 QBarCategory *category = new QBarCategory;
255 QStringList category;
258 256 QStringList labels = generateLabels(rowCount);
259 257 foreach(QString label, labels)
260 *category << label;
258 category << label;
261 259 QBarSeries* series = 0;
262 260 if (seriesName == "Bar")
263 261 series = new QBarSeries(category, this);
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now