@@ -0,0 +1,8 | |||||
|
1 | #include "custombarset.h" | |||
|
2 | ||||
|
3 | CustomBarSet::CustomBarSet(QObject *parent) : | |||
|
4 | QBarSet(parent) | |||
|
5 | { | |||
|
6 | // Using signal to signal connection here. | |||
|
7 | connect(this,SIGNAL(clicked()),this,SIGNAL(toggleFloatingValues())); | |||
|
8 | } |
@@ -0,0 +1,20 | |||||
|
1 | #ifndef CUSTOMBARSET_H | |||
|
2 | #define CUSTOMBARSET_H | |||
|
3 | ||||
|
4 | #include <qbarset.h> | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
7 | ||||
|
8 | class CustomBarSet : public QBarSet | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | public: | |||
|
12 | explicit CustomBarSet(QObject *parent = 0); | |||
|
13 | ||||
|
14 | signals: | |||
|
15 | ||||
|
16 | public slots: | |||
|
17 | ||||
|
18 | }; | |||
|
19 | ||||
|
20 | #endif // CUSTOMBARSET_H |
@@ -0,0 +1,8 | |||||
|
1 | #include "custombarset.h" | |||
|
2 | ||||
|
3 | CustomBarSet::CustomBarSet(QObject *parent) : | |||
|
4 | QBarSet(parent) | |||
|
5 | { | |||
|
6 | // Using signal to signal connection here. | |||
|
7 | connect(this,SIGNAL(clicked()),this,SIGNAL(toggleFloatingValues())); | |||
|
8 | } |
@@ -0,0 +1,20 | |||||
|
1 | #ifndef CUSTOMBARSET_H | |||
|
2 | #define CUSTOMBARSET_H | |||
|
3 | ||||
|
4 | #include <qbarset.h> | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
7 | ||||
|
8 | class CustomBarSet : public QBarSet | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | public: | |||
|
12 | explicit CustomBarSet(QObject *parent = 0); | |||
|
13 | ||||
|
14 | signals: | |||
|
15 | ||||
|
16 | public slots: | |||
|
17 | ||||
|
18 | }; | |||
|
19 | ||||
|
20 | #endif // CUSTOMBARSET_H |
@@ -0,0 +1,8 | |||||
|
1 | #include "custombarset.h" | |||
|
2 | ||||
|
3 | CustomBarSet::CustomBarSet(QObject *parent) : | |||
|
4 | QBarSet(parent) | |||
|
5 | { | |||
|
6 | // Using signal to signal connection here. | |||
|
7 | connect(this,SIGNAL(clicked()),this,SIGNAL(toggleFloatingValues())); | |||
|
8 | } |
@@ -0,0 +1,20 | |||||
|
1 | #ifndef CUSTOMBARSET_H | |||
|
2 | #define CUSTOMBARSET_H | |||
|
3 | ||||
|
4 | #include <qbarset.h> | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
7 | ||||
|
8 | class CustomBarSet : public QBarSet | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | public: | |||
|
12 | explicit CustomBarSet(QObject *parent = 0); | |||
|
13 | ||||
|
14 | signals: | |||
|
15 | ||||
|
16 | public slots: | |||
|
17 | ||||
|
18 | }; | |||
|
19 | ||||
|
20 | #endif // CUSTOMBARSET_H |
@@ -4,7 +4,9 | |||||
4 |
|
4 | |||
5 | TARGET = barchart |
|
5 | TARGET = barchart | |
6 | SOURCES += main.cpp \ |
|
6 | SOURCES += main.cpp \ | |
7 | chartwidget.cpp |
|
7 | chartwidget.cpp \ | |
|
8 | custombarset.cpp | |||
8 | HEADERS += \ |
|
9 | HEADERS += \ | |
9 | chartwidget.h |
|
10 | chartwidget.h \ | |
|
11 | custombarset.h | |||
10 |
|
12 |
@@ -1,10 +1,11 | |||||
1 | #include <QApplication> |
|
1 | #include <QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <QStandardItemModel> |
|
3 | #include <qchartview.h> | |
4 | #include <qbarchartseries.h> |
|
4 | #include <qbarchartseries.h> | |
5 | #include <qbarcategory.h> |
|
|||
6 | #include <qbarset.h> |
|
5 | #include <qbarset.h> | |
7 |
#include |
|
6 | #include <qbarcategory.h> | |
|
7 | ||||
|
8 | #include "custombarset.h" | |||
8 |
|
9 | |||
9 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
10 | QTCOMMERCIALCHART_USE_NAMESPACE | |
10 |
|
11 | |||
@@ -16,13 +17,14 int main(int argc, char *argv[]) | |||||
16 | QBarCategory *category = new QBarCategory; |
|
17 | QBarCategory *category = new QBarCategory; | |
17 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
18 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; | |
18 |
|
19 | |||
19 |
QBarChartSeries* series |
|
20 | QBarChartSeries* series= new QBarChartSeries(category); | |
20 |
|
21 | |||
21 | QBarSet *set0 = new QBarSet; |
|
22 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals | |
22 |
|
|
23 | CustomBarSet *set0 = new CustomBarSet; | |
23 |
|
|
24 | CustomBarSet *set1 = new CustomBarSet; | |
24 |
|
|
25 | CustomBarSet *set2 = new CustomBarSet; | |
25 |
|
|
26 | CustomBarSet *set3 = new CustomBarSet; | |
|
27 | CustomBarSet *set4 = new CustomBarSet; | |||
26 |
|
28 | |||
27 | // Create some test data to chart |
|
29 | // Create some test data to chart | |
28 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
30 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; | |
@@ -31,16 +33,18 int main(int argc, char *argv[]) | |||||
31 | *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; |
|
33 | *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; | |
32 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; |
|
34 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; | |
33 |
|
35 | |||
34 |
series |
|
36 | series->addBarSet(set0); | |
35 |
series |
|
37 | series->addBarSet(set1); | |
36 |
series |
|
38 | series->addBarSet(set2); | |
37 |
series |
|
39 | series->addBarSet(set3); | |
38 |
series |
|
40 | series->addBarSet(set4); | |
39 |
|
41 | |||
40 |
|
|
42 | QChartView* chartView = new QChartView(&window); | |
41 |
chart |
|
43 | chartView->addSeries(series); | |
|
44 | chartView->setChartTitle("simple stacked barchart"); | |||
|
45 | chartView->setChartTheme(QChart::ChartThemeIcy); | |||
42 |
|
46 | |||
43 |
window.setCentralWidget(chart |
|
47 | window.setCentralWidget(chartView); | |
44 | window.resize(400, 300); |
|
48 | window.resize(400, 300); | |
45 | window.show(); |
|
49 | window.show(); | |
46 |
|
50 |
@@ -2,9 +2,11 | |||||
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <QStandardItemModel> |
|
3 | #include <QStandardItemModel> | |
4 | #include <qpercentbarchartseries.h> |
|
4 | #include <qpercentbarchartseries.h> | |
5 | #include "chartwidget.h" |
|
|||
6 | #include <qbarcategory.h> |
|
5 | #include <qbarcategory.h> | |
7 |
#include <q |
|
6 | #include <qchartview.h> | |
|
7 | ||||
|
8 | //#include <qbarset.h> | |||
|
9 | #include "custombarset.h" | |||
8 |
|
10 | |||
9 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
11 | QTCOMMERCIALCHART_USE_NAMESPACE | |
10 |
|
12 | |||
@@ -16,13 +18,14 int main(int argc, char *argv[]) | |||||
16 | QBarCategory *category = new QBarCategory; |
|
18 | QBarCategory *category = new QBarCategory; | |
17 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
19 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; | |
18 |
|
20 | |||
19 |
QPercentBarChartSeries* series |
|
21 | QPercentBarChartSeries* series = new QPercentBarChartSeries(category); | |
20 |
|
22 | |||
21 | QBarSet *set0 = new QBarSet; |
|
23 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals | |
22 |
|
|
24 | CustomBarSet *set0 = new CustomBarSet; | |
23 |
|
|
25 | CustomBarSet *set1 = new CustomBarSet; | |
24 |
|
|
26 | CustomBarSet *set2 = new CustomBarSet; | |
25 |
|
|
27 | CustomBarSet *set3 = new CustomBarSet; | |
|
28 | CustomBarSet *set4 = new CustomBarSet; | |||
26 |
|
29 | |||
27 | // Create some test data to chart |
|
30 | // Create some test data to chart | |
28 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
31 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; | |
@@ -31,16 +34,18 int main(int argc, char *argv[]) | |||||
31 | *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; |
|
34 | *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; | |
32 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; |
|
35 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; | |
33 |
|
36 | |||
34 |
series |
|
37 | series->addBarSet(set0); | |
35 |
series |
|
38 | series->addBarSet(set1); | |
36 |
series |
|
39 | series->addBarSet(set2); | |
37 |
series |
|
40 | series->addBarSet(set3); | |
38 |
series |
|
41 | series->addBarSet(set4); | |
39 |
|
42 | |||
40 |
|
|
43 | QChartView* chartView = new QChartView(&window); | |
41 |
chart |
|
44 | chartView->addSeries(series); | |
|
45 | chartView->setChartTitle("simple percent barchart"); | |||
|
46 | chartView->setChartTheme(QChart::ChartThemeIcy); | |||
42 |
|
47 | |||
43 |
window.setCentralWidget(chart |
|
48 | window.setCentralWidget(chartView); | |
44 | window.resize(400, 300); |
|
49 | window.resize(400, 300); | |
45 | window.show(); |
|
50 | window.show(); | |
46 |
|
51 |
@@ -4,7 +4,9 | |||||
4 |
|
4 | |||
5 | TARGET = percentbarchart |
|
5 | TARGET = percentbarchart | |
6 | SOURCES += main.cpp \ |
|
6 | SOURCES += main.cpp \ | |
7 | chartwidget.cpp |
|
7 | chartwidget.cpp \ | |
|
8 | custombarset.cpp | |||
8 | HEADERS += \ |
|
9 | HEADERS += \ | |
9 | chartwidget.h |
|
10 | chartwidget.h \ | |
|
11 | custombarset.h | |||
10 |
|
12 |
@@ -1,11 +1,12 | |||||
1 | #include <QApplication> |
|
1 | #include <QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <QStandardItemModel> |
|
3 | #include <qchartview.h> | |
4 | #include <qstackedbarchartseries.h> |
|
4 | #include <qstackedbarchartseries.h> | |
5 | #include "chartwidget.h" |
|
|||
6 | #include <qbarset.h> |
|
5 | #include <qbarset.h> | |
7 | #include <qbarcategory.h> |
|
6 | #include <qbarcategory.h> | |
8 |
|
7 | |||
|
8 | #include "custombarset.h" | |||
|
9 | ||||
9 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
10 | QTCOMMERCIALCHART_USE_NAMESPACE | |
10 |
|
11 | |||
11 | int main(int argc, char *argv[]) |
|
12 | int main(int argc, char *argv[]) | |
@@ -16,31 +17,34 int main(int argc, char *argv[]) | |||||
16 | QBarCategory *category = new QBarCategory; |
|
17 | QBarCategory *category = new QBarCategory; | |
17 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
18 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; | |
18 |
|
19 | |||
19 |
QStackedBarChartSeries* series |
|
20 | QStackedBarChartSeries* series = new QStackedBarChartSeries(category); | |
20 |
|
21 | |||
21 | QBarSet *set0 = new QBarSet; |
|
22 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals | |
22 |
|
|
23 | CustomBarSet *set0 = new CustomBarSet; | |
23 |
|
|
24 | CustomBarSet *set1 = new CustomBarSet; | |
24 |
|
|
25 | CustomBarSet *set2 = new CustomBarSet; | |
25 |
|
|
26 | CustomBarSet *set3 = new CustomBarSet; | |
|
27 | CustomBarSet *set4 = new CustomBarSet; | |||
26 |
|
28 | |||
27 | // Create some test data to chart |
|
29 | // Create some test data to chart | |
28 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
30 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; | |
29 |
|
|
31 | *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2; | |
30 |
|
|
32 | *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5; | |
31 |
|
|
33 | *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; | |
32 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; |
|
34 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; | |
33 |
|
35 | |||
34 |
series |
|
36 | series->addBarSet(set0); | |
35 |
|
|
37 | series->addBarSet(set1); | |
36 |
|
|
38 | series->addBarSet(set2); | |
37 |
|
|
39 | series->addBarSet(set3); | |
38 |
series |
|
40 | series->addBarSet(set4); | |
39 |
|
41 | |||
40 |
|
|
42 | QChartView* chartView = new QChartView(&window); | |
41 |
chart |
|
43 | chartView->addSeries(series); | |
|
44 | chartView->setChartTitle("simple stacked barchart"); | |||
|
45 | chartView->setChartTheme(QChart::ChartThemeIcy); | |||
42 |
|
46 | |||
43 |
window.setCentralWidget(chart |
|
47 | window.setCentralWidget(chartView); | |
44 | window.resize(400, 300); |
|
48 | window.resize(400, 300); | |
45 | window.show(); |
|
49 | window.show(); | |
46 |
|
50 |
@@ -3,7 +3,9 | |||||
3 | } |
|
3 | } | |
4 | TARGET = stackedbarchart |
|
4 | TARGET = stackedbarchart | |
5 | SOURCES += main.cpp \ |
|
5 | SOURCES += main.cpp \ | |
6 | chartwidget.cpp |
|
6 | chartwidget.cpp \ | |
|
7 | custombarset.cpp | |||
7 | HEADERS += \ |
|
8 | HEADERS += \ | |
8 | chartwidget.h |
|
9 | chartwidget.h \ | |
|
10 | custombarset.h | |||
9 |
|
11 |
@@ -72,6 +72,16 void Bar::mousePressEvent(QGraphicsSceneMouseEvent* /*event*/) | |||||
72 | emit clicked(); |
|
72 | emit clicked(); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
|
75 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/) | |||
|
76 | { | |||
|
77 | emit hoverEntered(); | |||
|
78 | } | |||
|
79 | ||||
|
80 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) | |||
|
81 | { | |||
|
82 | emit hoverLeaved(); | |||
|
83 | } | |||
|
84 | ||||
75 | #include "moc_bar_p.cpp" |
|
85 | #include "moc_bar_p.cpp" | |
76 |
|
86 | |||
77 | QTCOMMERCIALCHART_END_NAMESPACE |
|
87 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -27,13 +27,16 public: // from ChartItem | |||||
27 |
|
27 | |||
28 | public: |
|
28 | public: | |
29 | // From QGraphicsItem |
|
29 | // From QGraphicsItem | |
30 |
|
||||
31 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
30 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
32 | QRectF boundingRect() const; |
|
31 | QRectF boundingRect() const; | |
33 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
32 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
|
33 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | |||
|
34 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | |||
34 |
|
35 | |||
35 | Q_SIGNALS: |
|
36 | Q_SIGNALS: | |
36 | void clicked(); |
|
37 | void clicked(); | |
|
38 | void hoverEntered(); | |||
|
39 | void hoverLeaved(); | |||
37 |
|
40 | |||
38 | private: |
|
41 | private: | |
39 |
|
42 |
@@ -76,11 +76,14 void BarPresenter::layoutChanged() | |||||
76 |
|
76 | |||
77 | // TODO: remove hard coding, apply layout |
|
77 | // TODO: remove hard coding, apply layout | |
78 | value->resize(100,50); |
|
78 | value->resize(100,50); | |
79 |
value->setPos(xPos |
|
79 | value->setPos(xPos, yPos-barHeight/2); | |
80 | value->setPen(QPen(QColor(255,255,255,255))); |
|
80 | value->setPen(QPen(QColor(255,255,255,255))); | |
81 |
|
81 | |||
82 |
|
|
82 | if (mModel.valueAt(set,category) != 0) { | |
83 |
value->setValueString( |
|
83 | value->setValueString(QString::number(mModel.valueAt(set,category))); | |
|
84 | } else { | |||
|
85 | value->setValueString(QString("")); | |||
|
86 | } | |||
84 |
|
87 | |||
85 | itemIndex++; |
|
88 | itemIndex++; | |
86 | xPos += mBarDefaultWidth; |
|
89 | xPos += mBarDefaultWidth; |
@@ -70,6 +70,8 void BarPresenterBase::dataChanged() | |||||
70 | childItems().append(bar); |
|
70 | childItems().append(bar); | |
71 | mBars.append(bar); |
|
71 | mBars.append(bar); | |
72 | connect(bar,SIGNAL(clicked()),set,SLOT(barClicked())); |
|
72 | connect(bar,SIGNAL(clicked()),set,SLOT(barClicked())); | |
|
73 | connect(bar,SIGNAL(hoverEntered()),set,SLOT(barHoverEntered())); | |||
|
74 | connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaved())); | |||
73 | } |
|
75 | } | |
74 | } |
|
76 | } | |
75 |
|
77 | |||
@@ -98,7 +100,7 void BarPresenterBase::dataChanged() | |||||
98 | BarValue *value = new BarValue(*set, this); |
|
100 | BarValue *value = new BarValue(*set, this); | |
99 | childItems().append(value); |
|
101 | childItems().append(value); | |
100 | mFloatingValues.append(value); |
|
102 | mFloatingValues.append(value); | |
101 |
connect(set,SIGNAL( |
|
103 | connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible())); | |
102 | } |
|
104 | } | |
103 | } |
|
105 | } | |
104 |
|
106 |
@@ -84,12 +84,16 void PercentBarPresenter::layoutChanged() | |||||
84 | BarValue* value = mFloatingValues.at(itemIndex); |
|
84 | BarValue* value = mFloatingValues.at(itemIndex); | |
85 |
|
85 | |||
86 | // TODO: remove hard coding, apply layout |
|
86 | // TODO: remove hard coding, apply layout | |
87 |
value->setPos(xPos |
|
87 | value->setPos(xPos, yPos-barHeight/2); | |
88 | value->setPen(QPen(QColor(255,255,255,255))); |
|
88 | value->setPen(QPen(QColor(255,255,255,255))); | |
89 |
|
89 | |||
|
90 | if (mModel.valueAt(set,category) != 0) { | |||
90 | QString vString(QString::number(mModel.percentageAt(set,category) * 100)); |
|
91 | QString vString(QString::number(mModel.percentageAt(set,category) * 100)); | |
91 | vString.append("%"); |
|
92 | vString.append("%"); | |
92 | value->setValueString(vString); |
|
93 | value->setValueString(vString); | |
|
94 | } else { | |||
|
95 | value->setValueString(QString("")); | |||
|
96 | } | |||
93 |
|
97 | |||
94 | itemIndex++; |
|
98 | itemIndex++; | |
95 | yPos -= barHeight; |
|
99 | yPos -= barHeight; |
@@ -3,7 +3,8 | |||||
3 |
|
3 | |||
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
5 |
|
5 | |||
6 | QBarSet::QBarSet() |
|
6 | QBarSet::QBarSet(QObject *parent) | |
|
7 | : QObject(parent) | |||
7 | { |
|
8 | { | |
8 | mFloatingValuesVisible = false; |
|
9 | mFloatingValuesVisible = false; | |
9 | } |
|
10 | } | |
@@ -71,5 +72,17 void QBarSet::barClicked() | |||||
71 | emit clicked(); // Notify that set has been clicked |
|
72 | emit clicked(); // Notify that set has been clicked | |
72 | } |
|
73 | } | |
73 |
|
74 | |||
|
75 | void QBarSet::barHoverEntered() | |||
|
76 | { | |||
|
77 | qDebug() << "QBarset::barHoverEntered" << this; | |||
|
78 | emit hoverEnter(); | |||
|
79 | } | |||
|
80 | ||||
|
81 | void QBarSet::barHoverLeaved() | |||
|
82 | { | |||
|
83 | qDebug() << "QBarset::barHoverLeaved" << this; | |||
|
84 | emit hoverLeave(); | |||
|
85 | } | |||
|
86 | ||||
74 | #include "moc_qbarset.cpp" |
|
87 | #include "moc_qbarset.cpp" | |
75 | QTCOMMERCIALCHART_END_NAMESPACE |
|
88 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,7 +1,7 | |||||
1 | #ifndef QBARSET_H |
|
1 | #ifndef QBARSET_H | |
2 | #define QBARSET_H |
|
2 | #define QBARSET_H | |
3 |
|
3 | |||
4 |
#include |
|
4 | #include <qchartglobal.h> | |
5 | #include <QPen> |
|
5 | #include <QPen> | |
6 | #include <QBrush> |
|
6 | #include <QBrush> | |
7 |
|
7 | |||
@@ -11,7 +11,7 class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject | |||||
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 | public: |
|
13 | public: | |
14 | QBarSet(); |
|
14 | QBarSet(QObject *parent = 0); | |
15 |
|
15 | |||
16 | void setName(QString name); |
|
16 | void setName(QString name); | |
17 | QString name(); |
|
17 | QString name(); | |
@@ -31,13 +31,14 public: | |||||
31 |
|
31 | |||
32 | Q_SIGNALS: |
|
32 | Q_SIGNALS: | |
33 | void clicked(); |
|
33 | void clicked(); | |
34 | /* |
|
|||
35 | void hoverEnter(); |
|
34 | void hoverEnter(); | |
36 | void hoverLeave(); |
|
35 | void hoverLeave(); | |
37 | */ |
|
36 | void toggleFloatingValues(); | |
38 |
|
37 | |||
39 | public Q_SLOTS: |
|
38 | public Q_SLOTS: | |
40 | void barClicked(); |
|
39 | void barClicked(); | |
|
40 | void barHoverEntered(); | |||
|
41 | void barHoverLeaved(); | |||
41 |
|
42 | |||
42 | private: |
|
43 | private: | |
43 |
|
44 |
@@ -20,12 +20,12 public: | |||||
20 | // from QChartSeries |
|
20 | // from QChartSeries | |
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } |
|
21 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } | |
22 |
|
22 | |||
|
23 | // Set handling | |||
23 | void addBarSet(QBarSet *set); // Takes ownership |
|
24 | void addBarSet(QBarSet *set); // Takes ownership | |
24 | void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned. |
|
25 | void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned. | |
25 | int countSets(); |
|
26 | int countSets(); | |
26 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true |
|
27 | QBarSet* nextSet(bool first=false); // Returns first set, if called with true | |
27 |
|
28 | |||
28 | //TODO: |
|
|||
29 | //QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) |
|
29 | //QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) | |
30 |
|
30 | |||
31 | // TODO: Functions below this are not part of api and will be moved |
|
31 | // TODO: Functions below this are not part of api and will be moved |
@@ -88,11 +88,14 void StackedBarPresenter::layoutChanged() | |||||
88 |
|
88 | |||
89 | // TODO: remove hard coding, apply layout |
|
89 | // TODO: remove hard coding, apply layout | |
90 | value->resize(100,50); |
|
90 | value->resize(100,50); | |
91 |
value->setPos(xPos |
|
91 | value->setPos(xPos, yPos-barHeight/2); | |
92 | value->setPen(QPen(QColor(255,255,255,255))); |
|
92 | value->setPen(QPen(QColor(255,255,255,255))); | |
93 |
|
93 | |||
94 |
|
|
94 | if (mModel.valueAt(set,category) != 0) { | |
95 |
value->setValueString( |
|
95 | value->setValueString(QString::number(mModel.valueAt(set,category))); | |
|
96 | } else { | |||
|
97 | value->setValueString(QString("")); | |||
|
98 | } | |||
96 |
|
99 | |||
97 | itemIndex++; |
|
100 | itemIndex++; | |
98 | yPos -= barHeight; |
|
101 | yPos -= barHeight; |
General Comments 0
You need to be logged in to leave comments.
Login now