@@ -41,7 +41,6 BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |||||
41 | { |
|
41 | { | |
42 | connect(series, SIGNAL(showToolTip(QPoint,QString)), this, SLOT(showToolTip(QPoint,QString))); |
|
42 | connect(series, SIGNAL(showToolTip(QPoint,QString)), this, SLOT(showToolTip(QPoint,QString))); | |
43 | connect(series, SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
43 | connect(series, SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); | |
44 | //TODO: connect(series,SIGNAL("position or size has changed"), this, SLOT(handleLayoutChanged())); |
|
|||
45 | connect(series, SIGNAL(restructuredBar(int)), this, SLOT(handleModelChanged(int))); |
|
44 | connect(series, SIGNAL(restructuredBar(int)), this, SLOT(handleModelChanged(int))); | |
46 | setZValue(ChartPresenter::BarSeriesZValue); |
|
45 | setZValue(ChartPresenter::BarSeriesZValue); | |
47 | dataChanged(); |
|
46 | dataChanged(); | |
@@ -76,7 +75,7 void BarChartItem::dataChanged() | |||||
76 | delete item; |
|
75 | delete item; | |
77 |
|
76 | |||
78 | m_bars.clear(); |
|
77 | m_bars.clear(); | |
79 |
m_ |
|
78 | m_values.clear(); | |
80 | m_layout.clear(); |
|
79 | m_layout.clear(); | |
81 |
|
80 | |||
82 | // Create new graphic items for bars |
|
81 | // Create new graphic items for bars | |
@@ -100,8 +99,8 void BarChartItem::dataChanged() | |||||
100 | QBarSet *set = m_series->barsetAt(s); |
|
99 | QBarSet *set = m_series->barsetAt(s); | |
101 | BarValue *value = new BarValue(*set, this); |
|
100 | BarValue *value = new BarValue(*set, this); | |
102 | childItems().append(value); |
|
101 | childItems().append(value); | |
103 |
m_ |
|
102 | m_values.append(value); | |
104 | connect(set, SIGNAL(toggleFloatingValues()), value, SLOT(toggleVisible())); |
|
103 | connect(set,SIGNAL(valuesVisibleChanged(bool)),value,SLOT(valuesVisibleChanged(bool))); | |
105 | } |
|
104 | } | |
106 | } |
|
105 | } | |
107 | } |
|
106 | } | |
@@ -152,7 +151,7 QVector<QRectF> BarChartItem::calculateLayout() | |||||
152 | qreal yPos = height; |
|
151 | qreal yPos = height; | |
153 | for (int set=0; set < m_series->barsetCount(); set++) { |
|
152 | for (int set=0; set < m_series->barsetCount(); set++) { | |
154 | qreal barHeight = m_series->valueAt(set, category) * scale; |
|
153 | qreal barHeight = m_series->valueAt(set, category) * scale; | |
155 |
BarValue* value = m_ |
|
154 | BarValue* value = m_values.at(itemIndex); | |
156 |
|
155 | |||
157 | QBarSet* barSet = m_series->barsetAt(set); |
|
156 | QBarSet* barSet = m_series->barsetAt(set); | |
158 |
|
157 |
@@ -84,7 +84,7 protected: | |||||
84 | // Not owned. |
|
84 | // Not owned. | |
85 | QBarSeries *m_series; |
|
85 | QBarSeries *m_series; | |
86 | QList<Bar *> m_bars; |
|
86 | QList<Bar *> m_bars; | |
87 |
QList<BarValue *> m_ |
|
87 | QList<BarValue *> m_values; | |
88 | }; |
|
88 | }; | |
89 |
|
89 | |||
90 | QTCOMMERCIALCHART_END_NAMESPACE |
|
90 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -29,6 +29,7 BarValue::BarValue(QBarSet &set, QGraphicsItem *parent) : QGraphicsObject(parent | |||||
29 | m_barSet(set), |
|
29 | m_barSet(set), | |
30 | m_textItem(new QGraphicsSimpleTextItem(this)) |
|
30 | m_textItem(new QGraphicsSimpleTextItem(this)) | |
31 | { |
|
31 | { | |
|
32 | // connect(&set,SIGNAL(valuesVisibleChanged(bool)),value,SLOT(valuesVisibleChanged(bool))); | |||
32 | setVisible(false); |
|
33 | setVisible(false); | |
33 | } |
|
34 | } | |
34 |
|
35 | |||
@@ -78,10 +79,9 QRectF BarValue::boundingRect() const | |||||
78 | return m_textItem->boundingRect(); |
|
79 | return m_textItem->boundingRect(); | |
79 | } |
|
80 | } | |
80 |
|
81 | |||
81 |
void BarValue:: |
|
82 | void BarValue::valuesVisibleChanged(bool visible) | |
82 | { |
|
83 | { | |
83 | qDebug() << "toggle visible"; |
|
84 | setVisible(visible); | |
84 | setVisible(!isVisible()); |
|
|||
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | #include "moc_barvalue_p.cpp" |
|
87 | #include "moc_barvalue_p.cpp" |
@@ -54,7 +54,7 public: | |||||
54 | QRectF boundingRect() const; |
|
54 | QRectF boundingRect() const; | |
55 |
|
55 | |||
56 | public Q_SLOTS: |
|
56 | public Q_SLOTS: | |
57 |
void |
|
57 | void valuesVisibleChanged(bool visible); | |
58 |
|
58 | |||
59 | private: |
|
59 | private: | |
60 |
|
60 |
@@ -71,7 +71,7 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||||
71 | qreal scale = (height / colSum); |
|
71 | qreal scale = (height / colSum); | |
72 | for (int set=0; set < m_series->barsetCount(); set++) { |
|
72 | for (int set=0; set < m_series->barsetCount(); set++) { | |
73 | qreal barHeight = m_series->valueAt(set,category) * scale; |
|
73 | qreal barHeight = m_series->valueAt(set,category) * scale; | |
74 |
BarValue* value = m_ |
|
74 | BarValue* value = m_values.at(itemIndex); | |
75 |
|
75 | |||
76 | QBarSet* barSet = m_series->barsetAt(set); |
|
76 | QBarSet* barSet = m_series->barsetAt(set); | |
77 |
|
77 |
@@ -391,6 +391,14 QBarCategories QBarSeries::categories() const | |||||
391 | return categories; |
|
391 | return categories; | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
|
394 | void QBarSeries::setValuesVisible(bool visible) | |||
|
395 | { | |||
|
396 | foreach (QBarSet* s, barSets()) { | |||
|
397 | s->setValuesVisible(visible); | |||
|
398 | } | |||
|
399 | } | |||
|
400 | ||||
|
401 | ||||
394 | #include "moc_qbarseries.cpp" |
|
402 | #include "moc_qbarseries.cpp" | |
395 |
|
403 | |||
396 | QTCOMMERCIALCHART_END_NAMESPACE |
|
404 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -51,6 +51,8 public: | |||||
51 | QList<QBarSet*> barSets() const; |
|
51 | QList<QBarSet*> barSets() const; | |
52 | QBarCategories categories() const; |
|
52 | QBarCategories categories() const; | |
53 |
|
53 | |||
|
54 | void setValuesVisible(bool visible = true); | |||
|
55 | ||||
54 | bool setModel(QAbstractItemModel *model); |
|
56 | bool setModel(QAbstractItemModel *model); | |
55 | QAbstractItemModel *modelExt() { return m_model; } |
|
57 | QAbstractItemModel *modelExt() { return m_model; } | |
56 | void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); |
|
58 | void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); |
@@ -199,6 +199,14 QPen QBarSet::floatingValuePen() const | |||||
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
|
202 | Sets the visibility of barset values to \a visible | |||
|
203 | */ | |||
|
204 | void QBarSet::setValuesVisible(bool visible) | |||
|
205 | { | |||
|
206 | emit valuesVisibleChanged(visible); | |||
|
207 | } | |||
|
208 | ||||
|
209 | /*! | |||
202 | \internal \a pos |
|
210 | \internal \a pos | |
203 | */ |
|
211 | */ | |
204 | void QBarSet::barHoverEnterEvent(QPoint pos) |
|
212 | void QBarSet::barHoverEnterEvent(QPoint pos) |
@@ -58,17 +58,18 public: | |||||
58 | void setFloatingValuePen(const QPen &pen); |
|
58 | void setFloatingValuePen(const QPen &pen); | |
59 | QPen floatingValuePen() const; |
|
59 | QPen floatingValuePen() const; | |
60 |
|
60 | |||
|
61 | void setValuesVisible(bool visible = true); | |||
|
62 | ||||
61 | Q_SIGNALS: |
|
63 | Q_SIGNALS: | |
62 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user |
|
64 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user | |
63 | void toggleFloatingValues(); |
|
|||
64 |
|
65 | |||
65 | // TODO: Expose this to user or not? |
|
|||
66 | // TODO: TO PIMPL ---> |
|
66 | // TODO: TO PIMPL ---> | |
67 | void structureChanged(); |
|
67 | void structureChanged(); | |
68 | void valueChanged(); |
|
68 | void valueChanged(); | |
69 | void hoverEnter(QPoint pos); |
|
69 | void hoverEnter(QPoint pos); | |
70 | void hoverLeave(); |
|
70 | void hoverLeave(); | |
71 | void showToolTip(QPoint pos, QString tip); // Private signal |
|
71 | void showToolTip(QPoint pos, QString tip); // Private signal | |
|
72 | void valuesVisibleChanged(bool visible); | |||
72 | // <--- TO PIMPL |
|
73 | // <--- TO PIMPL | |
73 |
|
74 | |||
74 | public Q_SLOTS: |
|
75 | public Q_SLOTS: |
@@ -77,7 +77,7 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||||
77 | qreal yPos = height; |
|
77 | qreal yPos = height; | |
78 | for (int set=0; set < m_series->barsetCount(); set++) { |
|
78 | for (int set=0; set < m_series->barsetCount(); set++) { | |
79 | qreal barHeight = m_series->valueAt(set, category) * scale; |
|
79 | qreal barHeight = m_series->valueAt(set, category) * scale; | |
80 |
BarValue* value = m_ |
|
80 | BarValue* value = m_values.at(itemIndex); | |
81 |
|
81 | |||
82 | QBarSet* barSet = m_series->barsetAt(set); |
|
82 | QBarSet* barSet = m_series->barsetAt(set); | |
83 |
|
83 |
General Comments 0
You need to be logged in to leave comments.
Login now