@@ -4,9 +4,7 | |||||
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 |
|
|||
9 | HEADERS += \ |
|
8 | HEADERS += \ | |
10 |
chartwidget.h |
|
9 | chartwidget.h | |
11 | custombarset.h |
|
|||
12 |
|
10 |
@@ -5,8 +5,6 | |||||
5 | #include <qbarset.h> |
|
5 | #include <qbarset.h> | |
6 | #include <qbarcategory.h> |
|
6 | #include <qbarcategory.h> | |
7 |
|
7 | |||
8 | #include "custombarset.h" |
|
|||
9 |
|
||||
10 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | QTCOMMERCIALCHART_USE_NAMESPACE | |
11 |
|
9 | |||
12 | int main(int argc, char *argv[]) |
|
10 | int main(int argc, char *argv[]) | |
@@ -20,11 +18,11 int main(int argc, char *argv[]) | |||||
20 | QBarChartSeries* series= new QBarChartSeries(category); |
|
18 | QBarChartSeries* series= new QBarChartSeries(category); | |
21 |
|
19 | |||
22 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals |
|
20 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals | |
23 |
|
|
21 | QBarSet *set0 = new QBarSet("Bub"); | |
24 |
|
|
22 | QBarSet *set1 = new QBarSet("Bob"); | |
25 |
|
|
23 | QBarSet *set2 = new QBarSet("Guybrush"); | |
26 |
|
|
24 | QBarSet *set3 = new QBarSet("Larry"); | |
27 |
|
|
25 | QBarSet *set4 = new QBarSet("Zak"); | |
28 |
|
26 | |||
29 | // Create some test data to chart |
|
27 | // Create some test data to chart | |
30 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
28 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; | |
@@ -39,6 +37,9 int main(int argc, char *argv[]) | |||||
39 | series->addBarSet(set3); |
|
37 | series->addBarSet(set3); | |
40 | series->addBarSet(set4); |
|
38 | series->addBarSet(set4); | |
41 |
|
39 | |||
|
40 | series->enableToolTip(true); | |||
|
41 | series->enableFloatingValues(true); | |||
|
42 | ||||
42 | QChartView* chartView = new QChartView(&window); |
|
43 | QChartView* chartView = new QChartView(&window); | |
43 | chartView->addSeries(series); |
|
44 | chartView->addSeries(series); | |
44 | chartView->setChartTitle("simple stacked barchart"); |
|
45 | chartView->setChartTitle("simple stacked barchart"); |
@@ -4,8 +4,7 | |||||
4 | #include <qpercentbarchartseries.h> |
|
4 | #include <qpercentbarchartseries.h> | |
5 | #include <qbarcategory.h> |
|
5 | #include <qbarcategory.h> | |
6 | #include <qchartview.h> |
|
6 | #include <qchartview.h> | |
7 |
|
7 | #include <qbarset.h> | ||
8 | #include "custombarset.h" |
|
|||
9 |
|
8 | |||
10 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
9 | QTCOMMERCIALCHART_USE_NAMESPACE | |
11 |
|
10 | |||
@@ -19,12 +18,11 int main(int argc, char *argv[]) | |||||
19 |
|
18 | |||
20 | QPercentBarChartSeries* series = new QPercentBarChartSeries(category); |
|
19 | QPercentBarChartSeries* series = new QPercentBarChartSeries(category); | |
21 |
|
20 | |||
22 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals |
|
21 | QBarSet *set0 = new QBarSet("Bub"); | |
23 |
|
|
22 | QBarSet *set1 = new QBarSet("Bob"); | |
24 |
|
|
23 | QBarSet *set2 = new QBarSet("Guybrush"); | |
25 |
|
|
24 | QBarSet *set3 = new QBarSet("Larry"); | |
26 |
|
|
25 | QBarSet *set4 = new QBarSet("Zak"); | |
27 | CustomBarSet *set4 = new CustomBarSet("Zak"); |
|
|||
28 |
|
26 | |||
29 | // Create some test data to chart |
|
27 | // Create some test data to chart | |
30 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
28 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; | |
@@ -39,6 +37,9 int main(int argc, char *argv[]) | |||||
39 | series->addBarSet(set3); |
|
37 | series->addBarSet(set3); | |
40 | series->addBarSet(set4); |
|
38 | series->addBarSet(set4); | |
41 |
|
39 | |||
|
40 | series->enableToolTip(true); | |||
|
41 | series->enableFloatingValues(true); | |||
|
42 | ||||
42 | QChartView* chartView = new QChartView(&window); |
|
43 | QChartView* chartView = new QChartView(&window); | |
43 | chartView->addSeries(series); |
|
44 | chartView->addSeries(series); | |
44 | chartView->setChartTitle("simple percent barchart"); |
|
45 | chartView->setChartTitle("simple percent barchart"); |
@@ -4,9 +4,7 | |||||
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 |
|
|||
9 | HEADERS += \ |
|
8 | HEADERS += \ | |
10 |
chartwidget.h |
|
9 | chartwidget.h | |
11 | custombarset.h |
|
|||
12 |
|
10 |
@@ -5,8 +5,6 | |||||
5 | #include <qbarset.h> |
|
5 | #include <qbarset.h> | |
6 | #include <qbarcategory.h> |
|
6 | #include <qbarcategory.h> | |
7 |
|
7 | |||
8 | #include "custombarset.h" |
|
|||
9 |
|
||||
10 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | QTCOMMERCIALCHART_USE_NAMESPACE | |
11 |
|
9 | |||
12 | int main(int argc, char *argv[]) |
|
10 | int main(int argc, char *argv[]) | |
@@ -19,12 +17,11 int main(int argc, char *argv[]) | |||||
19 |
|
17 | |||
20 | QStackedBarChartSeries* series = new QStackedBarChartSeries(category); |
|
18 | QStackedBarChartSeries* series = new QStackedBarChartSeries(category); | |
21 |
|
19 | |||
22 | // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals |
|
20 | QBarSet *set0 = new QBarSet("Bub"); | |
23 |
|
|
21 | QBarSet *set1 = new QBarSet("Bob"); | |
24 |
|
|
22 | QBarSet *set2 = new QBarSet("Guybrush"); | |
25 |
|
|
23 | QBarSet *set3 = new QBarSet("Larry"); | |
26 |
|
|
24 | QBarSet *set4 = new QBarSet("Zak"); | |
27 | CustomBarSet *set4 = new CustomBarSet("Zak"); |
|
|||
28 |
|
25 | |||
29 | // Create some test data to chart |
|
26 | // Create some test data to chart | |
30 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
27 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; | |
@@ -39,6 +36,9 int main(int argc, char *argv[]) | |||||
39 | series->addBarSet(set3); |
|
36 | series->addBarSet(set3); | |
40 | series->addBarSet(set4); |
|
37 | series->addBarSet(set4); | |
41 |
|
38 | |||
|
39 | series->enableToolTip(true); | |||
|
40 | series->enableFloatingValues(true); | |||
|
41 | ||||
42 | QChartView* chartView = new QChartView(&window); |
|
42 | QChartView* chartView = new QChartView(&window); | |
43 | chartView->addSeries(series); |
|
43 | chartView->addSeries(series); | |
44 | chartView->setChartTitle("simple stacked barchart"); |
|
44 | chartView->setChartTitle("simple stacked barchart"); |
@@ -3,9 +3,7 | |||||
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 |
|
|||
8 | HEADERS += \ |
|
7 | HEADERS += \ | |
9 |
chartwidget.h |
|
8 | chartwidget.h | |
10 | custombarset.h |
|
|||
11 |
|
9 |
@@ -15,20 +15,16 BarPresenterBase::BarPresenterBase(QBarChartSeries *series, QGraphicsItem *paren | |||||
15 | ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready |
|
15 | ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready | |
16 | ,mLayoutSet(false) |
|
16 | ,mLayoutSet(false) | |
17 | ,mLayoutDirty(true) |
|
17 | ,mLayoutDirty(true) | |
|
18 | ,mSeparatorsEnabled(false) | |||
18 | ,mSeries(series) |
|
19 | ,mSeries(series) | |
19 | { |
|
20 | { | |
20 | connect(series,SIGNAL(floatingValuesEnabled(bool)),this,SLOT(enableFloatingValues(bool))); |
|
|||
21 | connect(series,SIGNAL(toolTipEnabled(bool)),this,SLOT(enableToolTip(bool))); |
|
|||
22 | connect(series,SIGNAL(separatorsEnabled(bool)),this,SLOT(enableSeparators(bool))); |
|
|||
23 | connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString))); |
|
21 | connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString))); | |
|
22 | connect(series,SIGNAL(separatorsEnabled(bool)),this,SLOT(enableSeparators(bool))); | |||
24 | dataChanged(); |
|
23 | dataChanged(); | |
25 | } |
|
24 | } | |
26 |
|
25 | |||
27 | BarPresenterBase::~BarPresenterBase() |
|
26 | BarPresenterBase::~BarPresenterBase() | |
28 | { |
|
27 | { | |
29 | disconnect(this,SLOT(enableFloatingValues(bool))); |
|
|||
30 | disconnect(this,SLOT(enableToolTip(bool))); |
|
|||
31 | disconnect(this,SLOT(enableSeparators(bool))); |
|
|||
32 | disconnect(this,SLOT(showToolTip(QPoint,QString))); |
|
28 | disconnect(this,SLOT(showToolTip(QPoint,QString))); | |
33 | delete mSeries; |
|
29 | delete mSeries; | |
34 | } |
|
30 | } | |
@@ -79,7 +75,6 void BarPresenterBase::dataChanged() | |||||
79 | childItems().append(bar); |
|
75 | childItems().append(bar); | |
80 | mBars.append(bar); |
|
76 | mBars.append(bar); | |
81 | connect(bar,SIGNAL(clicked()),set,SLOT(barClicked())); |
|
77 | connect(bar,SIGNAL(clicked()),set,SLOT(barClicked())); | |
82 | // TODO: should the event be passed to set or not? |
|
|||
83 | connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEntered(QPoint))); |
|
78 | connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEntered(QPoint))); | |
84 | connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaved())); |
|
79 | connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaved())); | |
85 | } |
|
80 | } | |
@@ -99,6 +94,7 void BarPresenterBase::dataChanged() | |||||
99 | for (int i=0; i<count; i++) { |
|
94 | for (int i=0; i<count; i++) { | |
100 | Separator* sep = new Separator(this); |
|
95 | Separator* sep = new Separator(this); | |
101 | sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme |
|
96 | sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme | |
|
97 | sep->setVisible(mSeparatorsEnabled); | |||
102 | childItems().append(sep); |
|
98 | childItems().append(sep); | |
103 | mSeparators.append(sep); |
|
99 | mSeparators.append(sep); | |
104 | } |
|
100 | } | |
@@ -143,27 +139,18 void BarPresenterBase::handleGeometryChanged(const QRectF& rect) | |||||
143 | setPos(rect.topLeft()); |
|
139 | setPos(rect.topLeft()); | |
144 | } |
|
140 | } | |
145 |
|
141 | |||
146 | void BarPresenterBase::enableFloatingValues(bool enabled) |
|
142 | void BarPresenterBase::showToolTip(QPoint pos, QString tip) | |
147 | { |
|
|||
148 | mFloatingValuesEnabled = enabled; |
|
|||
149 | } |
|
|||
150 |
|
||||
151 | void BarPresenterBase::enableToolTip(bool enabled) |
|
|||
152 | { |
|
143 | { | |
153 | mToolTipEnabled = enabled; |
|
144 | // TODO: cool tooltip instead of default | |
|
145 | QToolTip::showText(pos,tip); | |||
154 | } |
|
146 | } | |
155 |
|
147 | |||
156 | void BarPresenterBase::enableSeparators(bool enabled) |
|
148 | void BarPresenterBase::enableSeparators(bool enabled) | |
157 | { |
|
149 | { | |
158 | mSeparatorsEnabled = enabled; |
|
150 | for (int i=0; i<mSeparators.count(); i++) { | |
159 | } |
|
151 | mSeparators.at(i)->setVisible(enabled); | |
160 |
|
||||
161 | void BarPresenterBase::showToolTip(QPoint pos, QString tip) |
|
|||
162 | { |
|
|||
163 | if (mToolTipEnabled) { |
|
|||
164 | // TODO: cool tooltip instead of default |
|
|||
165 | QToolTip::showText(pos,tip); |
|
|||
166 | } |
|
152 | } | |
|
153 | mSeparatorsEnabled = enabled; | |||
167 | } |
|
154 | } | |
168 |
|
155 | |||
169 | #include "moc_barpresenterbase.cpp" |
|
156 | #include "moc_barpresenterbase.cpp" |
@@ -41,10 +41,8 protected slots: | |||||
41 | void handleGeometryChanged(const QRectF& size); |
|
41 | void handleGeometryChanged(const QRectF& size); | |
42 |
|
42 | |||
43 | // Internal slots |
|
43 | // Internal slots | |
44 | void enableFloatingValues(bool enabled=true); // enables floating values on top of bars |
|
|||
45 | void enableToolTip(bool enabled=true); // enables tooltips |
|
|||
46 | void enableSeparators(bool enabled=true); // enables separators between categories |
|
|||
47 | void showToolTip(QPoint pos, QString tip); // shows tooltip (if enabled) |
|
44 | void showToolTip(QPoint pos, QString tip); // shows tooltip (if enabled) | |
|
45 | void enableSeparators(bool enabled); | |||
48 |
|
46 | |||
49 | protected: |
|
47 | protected: | |
50 |
|
48 | |||
@@ -56,8 +54,6 protected: | |||||
56 | bool mLayoutSet; // True, if component has been laid out. |
|
54 | bool mLayoutSet; // True, if component has been laid out. | |
57 | bool mLayoutDirty; |
|
55 | bool mLayoutDirty; | |
58 |
|
56 | |||
59 | bool mFloatingValuesEnabled; |
|
|||
60 | bool mToolTipEnabled; |
|
|||
61 | bool mSeparatorsEnabled; |
|
57 | bool mSeparatorsEnabled; | |
62 |
|
58 | |||
63 | // Owned |
|
59 | // Owned |
@@ -15,18 +15,11 QBarChartSeries::QBarChartSeries(QBarCategory *category, QObject *parent) | |||||
15 |
|
15 | |||
16 | void QBarChartSeries::addBarSet(QBarSet *set) |
|
16 | void QBarChartSeries::addBarSet(QBarSet *set) | |
17 | { |
|
17 | { | |
18 | connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); |
|
|||
19 | connect(this,SIGNAL(separatorsEnabled(bool)),set,SLOT(enableSeparators(bool))); |
|
|||
20 | connect(this,SIGNAL(toolTipEnabled(bool)),set,SLOT(enableToolTip(bool))); |
|
|||
21 | connect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); |
|
|||
22 | mModel->addBarSet(set); |
|
18 | mModel->addBarSet(set); | |
23 | } |
|
19 | } | |
24 |
|
20 | |||
25 | void QBarChartSeries::removeBarSet(QBarSet *set) |
|
21 | void QBarChartSeries::removeBarSet(QBarSet *set) | |
26 | { |
|
22 | { | |
27 | disconnect(set,SLOT(enableFloatingValues(bool))); |
|
|||
28 | disconnect(set,SLOT(enableSeparators(bool))); |
|
|||
29 | disconnect(set,SLOT(enableToolTip(bool))); |
|
|||
30 | mModel->removeBarSet(set); |
|
23 | mModel->removeBarSet(set); | |
31 | } |
|
24 | } | |
32 |
|
25 | |||
@@ -57,12 +50,32 QString QBarChartSeries::label(int category) | |||||
57 |
|
50 | |||
58 | void QBarChartSeries::enableFloatingValues(bool enabled) |
|
51 | void QBarChartSeries::enableFloatingValues(bool enabled) | |
59 | { |
|
52 | { | |
60 | emit floatingValuesEnabled(enabled); |
|
53 | if (enabled) { | |
|
54 | for (int i=0; i<mModel->countSets(); i++) { | |||
|
55 | QBarSet *set = mModel->setAt(i); | |||
|
56 | connect(set,SIGNAL(clicked()),set,SIGNAL(toggleFloatingValues())); | |||
|
57 | } | |||
|
58 | } else { | |||
|
59 | for (int i=0; i<mModel->countSets(); i++) { | |||
|
60 | QBarSet *set = mModel->setAt(i); | |||
|
61 | disconnect(set,SIGNAL(clicked()),set,SIGNAL(toggleFloatingValues())); | |||
|
62 | } | |||
|
63 | } | |||
61 | } |
|
64 | } | |
62 |
|
65 | |||
63 | void QBarChartSeries::enableToolTip(bool enabled) |
|
66 | void QBarChartSeries::enableToolTip(bool enabled) | |
64 | { |
|
67 | { | |
65 | emit toolTipEnabled(enabled); |
|
68 | if (enabled) { | |
|
69 | for (int i=0; i<mModel->countSets(); i++) { | |||
|
70 | QBarSet *set = mModel->setAt(i); | |||
|
71 | connect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); | |||
|
72 | } | |||
|
73 | } else { | |||
|
74 | for (int i=0; i<mModel->countSets(); i++) { | |||
|
75 | QBarSet *set = mModel->setAt(i); | |||
|
76 | disconnect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); | |||
|
77 | } | |||
|
78 | } | |||
66 | } |
|
79 | } | |
67 |
|
80 | |||
68 | void QBarChartSeries::enableSeparators(bool enabled) |
|
81 | void QBarChartSeries::enableSeparators(bool enabled) | |
@@ -110,7 +123,6 BarChartModel& QBarChartSeries::model() | |||||
110 | return *mModel; |
|
123 | return *mModel; | |
111 | } |
|
124 | } | |
112 |
|
125 | |||
113 |
|
||||
114 | #include "moc_qbarchartseries.cpp" |
|
126 | #include "moc_qbarchartseries.cpp" | |
115 |
|
127 | |||
116 | QTCOMMERCIALCHART_END_NAMESPACE |
|
128 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -27,38 +27,38 public: | |||||
27 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) |
|
27 | QList<QString> legend(); // Returns legend of series (ie. names of all sets in series) | |
28 | QString label(int category); |
|
28 | QString label(int category); | |
29 |
|
29 | |||
30 | public Q_SLOTS: |
|
|||
31 | // Disabled by default. Call these to change behavior. |
|
|||
32 | void enableFloatingValues(bool enabled=true); // enables floating values on top of bars |
|
|||
33 | void enableToolTip(bool enabled=true); // enables tooltips |
|
|||
34 | void enableSeparators(bool enabled=true); // enables separators between categories |
|
|||
35 |
|
||||
36 | public: |
|
30 | public: | |
37 | // 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 | |
38 |
// to private implementation, when we start using it |
|
32 | // to private implementation, when we start using it | |
|
33 | // TODO: TO PIMPL ---> | |||
39 | int countCategories(); |
|
34 | int countCategories(); | |
40 | qreal min(); |
|
35 | qreal min(); | |
41 | qreal max(); |
|
36 | qreal max(); | |
42 | qreal valueAt(int set, int category); |
|
37 | qreal valueAt(int set, int category); | |
43 | qreal percentageAt(int set, int category); |
|
38 | qreal percentageAt(int set, int category); | |
44 |
|
||||
45 | qreal categorySum(int category); |
|
39 | qreal categorySum(int category); | |
46 | qreal maxCategorySum(); |
|
40 | qreal maxCategorySum(); | |
47 |
|
||||
48 | BarChartModel& model(); |
|
41 | BarChartModel& model(); | |
|
42 | // <--- TO PIMPL | |||
49 |
|
43 | |||
50 | signals: |
|
44 | signals: | |
51 | void changed(int index); |
|
45 | void changed(int index); | |
52 |
|
46 | |||
53 | // TODO: internal signals, these to private implementation. |
|
47 | // TODO: internal signals, these to private implementation. | |
|
48 | // TODO: TO PIMPL ---> | |||
54 | void floatingValuesEnabled(bool enabled); |
|
49 | void floatingValuesEnabled(bool enabled); | |
55 | void toolTipEnabled(bool enabled); |
|
50 | void toolTipEnabled(bool enabled); | |
56 | void separatorsEnabled(bool enabled); |
|
51 | void separatorsEnabled(bool enabled); | |
57 | void showToolTip(QPoint pos, QString tip); |
|
52 | void showToolTip(QPoint pos, QString tip); | |
|
53 | // <--- TO PIMPL | |||
|
54 | ||||
|
55 | public Q_SLOTS: | |||
|
56 | void enableFloatingValues(bool enabled=true); // enables floating values on top of bars | |||
|
57 | void enableToolTip(bool enabled=true); // enables tooltips | |||
|
58 | void enableSeparators(bool enabled=true); // enables separators between categories | |||
58 |
|
59 | |||
59 | protected: |
|
60 | protected: | |
60 | BarChartModel* mModel; |
|
61 | BarChartModel* mModel; | |
61 |
|
||||
62 | }; |
|
62 | }; | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
64 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -7,8 +7,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
7 | QBarSet::QBarSet(QString name, QObject *parent) |
|
7 | QBarSet::QBarSet(QString name, QObject *parent) | |
8 | : QObject(parent) |
|
8 | : QObject(parent) | |
9 | ,mName(name) |
|
9 | ,mName(name) | |
10 | ,mToolTipEnabled(true) // TODO: these 2 as false by default, when implementation is ready |
|
|||
11 | ,mFloatingValuesEnabled(true) |
|
|||
12 | { |
|
10 | { | |
13 | } |
|
11 | } | |
14 |
|
12 | |||
@@ -62,24 +60,6 const QBrush& QBarSet::brush() const | |||||
62 | return mBrush; |
|
60 | return mBrush; | |
63 | } |
|
61 | } | |
64 |
|
62 | |||
65 | void QBarSet::enableFloatingValues(bool enabled) |
|
|||
66 | { |
|
|||
67 | qDebug() << "QBarSet::enableFloatingValues"; |
|
|||
68 | mFloatingValuesEnabled = enabled; |
|
|||
69 | } |
|
|||
70 |
|
||||
71 | void QBarSet::enableToolTip(bool enabled) |
|
|||
72 | { |
|
|||
73 | qDebug() << "QBarSet::enableToolTip"; |
|
|||
74 | mToolTipEnabled = enabled; |
|
|||
75 | } |
|
|||
76 |
|
||||
77 | void QBarSet::enableSeparators(bool enabled) |
|
|||
78 | { |
|
|||
79 | qDebug() << "QBarSet::enableSeparators"; |
|
|||
80 | mSeparatorsEnabled = enabled; |
|
|||
81 | } |
|
|||
82 |
|
||||
83 | void QBarSet::barClicked() |
|
63 | void QBarSet::barClicked() | |
84 | { |
|
64 | { | |
85 | // qDebug() << "QBarset::barClicked" << this; |
|
65 | // qDebug() << "QBarset::barClicked" << this; | |
@@ -90,10 +70,7 void QBarSet::barClicked() | |||||
90 |
|
70 | |||
91 | void QBarSet::barHoverEntered(QPoint pos) |
|
71 | void QBarSet::barHoverEntered(QPoint pos) | |
92 | { |
|
72 | { | |
93 | if (mToolTipEnabled) { |
|
|||
94 |
|
|
73 | emit showToolTip(pos, mName); | |
95 | } |
|
|||
96 | // Emit signal to user of charts |
|
|||
97 | emit hoverEnter(pos); |
|
74 | emit hoverEnter(pos); | |
98 | } |
|
75 | } | |
99 |
|
76 |
@@ -31,19 +31,20 Q_SIGNALS: | |||||
31 | void clicked(); // Clicked and hover signals exposed to user |
|
31 | void clicked(); // Clicked and hover signals exposed to user | |
32 | void hoverEnter(QPoint pos); |
|
32 | void hoverEnter(QPoint pos); | |
33 | void hoverLeave(); |
|
33 | void hoverLeave(); | |
34 | void toggleFloatingValues(); // Private signal, TODO: move to private impl |
|
|||
35 | void showToolTip(QPoint pos, QString tip); // Private signal, TODO: move to private impl |
|
|||
36 |
|
34 | |||
37 | public Q_SLOTS: |
|
35 | // TODO: Expose this to user or not? | |
38 | void enableFloatingValues(bool enabled); // enables floating values on top of bars |
|
36 | // TODO: TO PIMPL ---> | |
39 | void enableToolTip(bool enabled); // enables tooltips |
|
37 | void toggleFloatingValues(); | |
40 | void enableSeparators(bool enabled); // enables separators between categories |
|
38 | void showToolTip(QPoint pos, QString tip); // Private signal | |
|
39 | // <--- TO PIMPL | |||
41 |
|
40 | |||
42 | // TODO: these slots belong to private implementation. |
|
41 | public Q_SLOTS: | |
43 | // These are for single bars to notify set about internal events |
|
42 | // These are for internal communication | |
|
43 | // TODO: TO PIMPL ---> | |||
44 | void barClicked(); |
|
44 | void barClicked(); | |
45 | void barHoverEntered(QPoint pos); |
|
45 | void barHoverEntered(QPoint pos); | |
46 | void barHoverLeaved(); |
|
46 | void barHoverLeaved(); | |
|
47 | // <--- TO PIMPL | |||
47 |
|
48 | |||
48 | private: |
|
49 | private: | |
49 |
|
50 | |||
@@ -52,10 +53,6 private: | |||||
52 | QPen mPen; |
|
53 | QPen mPen; | |
53 | QBrush mBrush; |
|
54 | QBrush mBrush; | |
54 |
|
55 | |||
55 | // TODO: to pimpl |
|
|||
56 | bool mFloatingValuesEnabled; |
|
|||
57 | bool mToolTipEnabled; |
|
|||
58 | bool mSeparatorsEnabled; |
|
|||
59 | }; |
|
56 | }; | |
60 |
|
57 | |||
61 | QTCOMMERCIALCHART_END_NAMESPACE |
|
58 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -28,11 +28,12 void Separator::setSize(const QSizeF &size) | |||||
28 |
|
28 | |||
29 | void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
29 | void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
30 | { |
|
30 | { | |
31 | // TODO: real pen |
|
31 | if (isVisible()) { | |
32 | QPen pen(mColor); |
|
32 | QPen pen(mColor); | |
33 | painter->setPen(pen); |
|
33 | painter->setPen(pen); | |
34 | painter->drawLine(mXpos,mYpos,mXpos,mHeight); |
|
34 | painter->drawLine(mXpos,mYpos,mXpos,mHeight); | |
35 | } |
|
35 | } | |
|
36 | } | |||
36 |
|
37 | |||
37 | QRectF Separator::boundingRect() const |
|
38 | QRectF Separator::boundingRect() const | |
38 | { |
|
39 | { |
@@ -271,6 +271,9 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS | |||||
271 | } |
|
271 | } | |
272 | series->addBarSet(set); |
|
272 | series->addBarSet(set); | |
273 | } |
|
273 | } | |
|
274 | series->enableFloatingValues(); | |||
|
275 | series->enableToolTip(); | |||
|
276 | series->enableSeparators(false); | |||
274 | m_chartWidget->addSeries(series); |
|
277 | m_chartWidget->addSeries(series); | |
275 | setCurrentSeries(series); |
|
278 | setCurrentSeries(series); | |
276 | } |
|
279 | } |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now