##// END OF EJS Templates
Adds BarCategories typedef
Michal Klocek -
r703:44befe5b9760
parent child
Show More
@@ -13,10 +13,10 QChartAxisCategories::~QChartAxisCategories()
13 // TODO Auto-generated destructor stub
13 // TODO Auto-generated destructor stub
14 }
14 }
15
15
16 void QChartAxisCategories::insert(QBarCategory& category)
16 void QChartAxisCategories::insert(const QBarCategories& categories)
17 {
17 {
18 int i=1;
18 int i=1;
19 foreach(QString string , category){
19 foreach(QString string , categories){
20 m_map.insert(i,string);
20 m_map.insert(i,string);
21 i++;
21 i++;
22 }
22 }
@@ -14,7 +14,7 private:
14 public:
14 public:
15 ~QChartAxisCategories();
15 ~QChartAxisCategories();
16
16
17 void insert(QBarCategory& category);
17 void insert(const QBarCategories& category);
18 void insert(qreal value,QString label);
18 void insert(qreal value,QString label);
19 void remove(qreal value);
19 void remove(qreal value);
20 QString label(qreal value) const;
20 QString label(qreal value) const;
@@ -33,7 +33,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 Constructs empty QBarSeries. Parameter \a categories defines the categories for chart.
33 Constructs empty QBarSeries. Parameter \a categories defines the categories for chart.
34 QBarSeries is QObject which is a child of a \a parent.
34 QBarSeries is QObject which is a child of a \a parent.
35 */
35 */
36 QBarSeries::QBarSeries(QStringList categories, QObject *parent)
36 QBarSeries::QBarSeries(QBarCategories categories, QObject *parent)
37 : QSeries(parent)
37 : QSeries(parent)
38 ,mModel(new BarChartModel(categories, this))
38 ,mModel(new BarChartModel(categories, this))
39 {
39 {
@@ -365,6 +365,16 void QBarSeries::barsetChanged()
365 emit updatedBars();
365 emit updatedBars();
366 }
366 }
367
367
368 QBarCategories QBarSeries::categories() const
369 {
370 QBarCategories categories;
371 int count = mModel->categoryCount();
372 for (int i=1; i<=count; i++) {
373 categories.insert(i, mModel->categoryName(i-1));
374 }
375 return categories;
376 }
377
368 #include "moc_qbarseries.cpp"
378 #include "moc_qbarseries.cpp"
369
379
370 QTCOMMERCIALCHART_END_NAMESPACE
380 QTCOMMERCIALCHART_END_NAMESPACE
@@ -6,7 +6,7
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 typedef QStringList QBarCategory;
9 typedef QStringList QBarCategories;
10
10
11 class QBarSet;
11 class QBarSet;
12 class BarChartModel;
12 class BarChartModel;
@@ -29,6 +29,8 public:
29 int barsetCount();
29 int barsetCount();
30 int categoryCount();
30 int categoryCount();
31 QList<QBarSet*> barSets();
31 QList<QBarSet*> barSets();
32 QBarCategories categories() const;
33
32
34
33 bool setModel(QAbstractItemModel* model);
35 bool setModel(QAbstractItemModel* model);
34 QAbstractItemModel* modelExt() {return m_model;}
36 QAbstractItemModel* modelExt() {return m_model;}
@@ -240,12 +240,9 void ChartDataSet::calculateDomain(QSeries* series,Domain* domain)
240
240
241 void ChartDataSet::setupCategories(QBarSeries* series)
241 void ChartDataSet::setupCategories(QBarSeries* series)
242 {
242 {
243 int count = series->categoryCount();
244 QChartAxisCategories* categories = axisX()->categories();
243 QChartAxisCategories* categories = axisX()->categories();
245 categories->clear();
244 categories->clear();
246 for (int i=1; i<=count; i++) {
245 categories->insert(series->categories());
247 categories->insert(i,series->categoryName(i-1));
248 }
249 }
246 }
250
247
251 void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size)
248 void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size)
General Comments 0
You need to be logged in to leave comments. Login now