@@ -35,11 +35,7 Bar::Bar(QString category, QGraphicsItem *parent) | |||||
35 |
|
35 | |||
36 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
36 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
37 | { |
|
37 | { | |
38 | if (event->button() == Qt::LeftButton) { |
|
38 | emit clicked(m_category, event->button()); | |
39 | emit clicked(m_category); |
|
|||
40 | } else if (event->button() == Qt::RightButton) { |
|
|||
41 | emit rightClicked(m_category); |
|
|||
42 | } |
|
|||
43 | } |
|
39 | } | |
44 |
|
40 | |||
45 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
41 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
@@ -39,8 +39,7 public: | |||||
39 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
|
39 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | |
40 |
|
40 | |||
41 | Q_SIGNALS: |
|
41 | Q_SIGNALS: | |
42 | void clicked(QString category); |
|
42 | void clicked(QString category, Qt::MouseButtons button); | |
43 | void rightClicked(QString category); |
|
|||
44 | void hoverEntered(QPoint pos); |
|
43 | void hoverEntered(QPoint pos); | |
45 | void hoverLeaved(); |
|
44 | void hoverLeaved(); | |
46 |
|
45 |
@@ -87,8 +87,7 void BarChartItem::dataChanged() | |||||
87 | Bar *bar = new Bar(category,this); |
|
87 | Bar *bar = new Bar(category,this); | |
88 | childItems().append(bar); |
|
88 | childItems().append(bar); | |
89 | m_bars.append(bar); |
|
89 | m_bars.append(bar); | |
90 | connect(bar, SIGNAL(clicked(QString)), set, SIGNAL(clicked(QString))); |
|
90 | connect(bar, SIGNAL(clicked(QString,Qt::MouseButtons)), set, SIGNAL(clicked(QString,Qt::MouseButtons))); | |
91 | connect(bar, SIGNAL(rightClicked(QString)), set, SIGNAL(rightClicked(QString))); |
|
|||
92 | connect(bar, SIGNAL(hoverEntered(QPoint)), set, SLOT(barHoverEnterEvent(QPoint))); |
|
91 | connect(bar, SIGNAL(hoverEntered(QPoint)), set, SLOT(barHoverEnterEvent(QPoint))); | |
93 | connect(bar, SIGNAL(hoverLeaved()), set, SLOT(barHoverLeaveEvent())); |
|
92 | connect(bar, SIGNAL(hoverLeaved()), set, SLOT(barHoverLeaveEvent())); | |
94 | m_layout.append(QRectF(0, 0, 0, 0)); |
|
93 | m_layout.append(QRectF(0, 0, 0, 0)); |
@@ -67,27 +67,25 QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) : QSeries(par | |||||
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | Adds a set of bars to series. Takes ownership of \a set. |
|
69 | Adds a set of bars to series. Takes ownership of \a set. | |
70 |
Connects the clicked(QString |
|
70 | Connects the clicked(QString, Qt::MouseButtons) signal | |
71 | of \a set to this series |
|
71 | of \a set to this series | |
72 | */ |
|
72 | */ | |
73 | void QBarSeries::appendBarSet(QBarSet *set) |
|
73 | void QBarSeries::appendBarSet(QBarSet *set) | |
74 | { |
|
74 | { | |
75 | m_internalModel->appendBarSet(set); |
|
75 | m_internalModel->appendBarSet(set); | |
76 | connect(set, SIGNAL(clicked(QString)), this, SLOT(barsetClicked(QString))); |
|
76 | connect(set, SIGNAL(clicked(QString,Qt::MouseButtons)), this, SLOT(barsetClicked(QString,Qt::MouseButtons))); | |
77 | connect(set, SIGNAL(rightClicked(QString)), this, SLOT(barsetRightClicked(QString))); |
|
|||
78 | connect(set, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); |
|
77 | connect(set, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); | |
79 | emit updatedBars(); |
|
78 | emit updatedBars(); | |
80 | } |
|
79 | } | |
81 |
|
80 | |||
82 | /*! |
|
81 | /*! | |
83 | Removes a set of bars from series. Releases ownership of \a set. Doesnt delete \a set. |
|
82 | Removes a set of bars from series. Releases ownership of \a set. Doesnt delete \a set. | |
84 |
Disconnects the clicked(QString |
|
83 | Disconnects the clicked(QString, Qt::MouseButtons) signal | |
85 | of \a set from this series |
|
84 | of \a set from this series | |
86 | */ |
|
85 | */ | |
87 | void QBarSeries::removeBarSet(QBarSet *set) |
|
86 | void QBarSeries::removeBarSet(QBarSet *set) | |
88 | { |
|
87 | { | |
89 | disconnect(set, SIGNAL(clicked(QString)), this, SLOT(barsetClicked(QString))); |
|
88 | disconnect(set, SIGNAL(clicked(QString,Qt::MouseButtons)), this, SLOT(barsetClicked(QString,Qt::MouseButtons))); | |
90 | disconnect(set, SIGNAL(rightClicked(QString)), this, SLOT(barsetRightClicked(QString))); |
|
|||
91 | m_internalModel->removeBarSet(set); |
|
89 | m_internalModel->removeBarSet(set); | |
92 | emit updatedBars(); |
|
90 | emit updatedBars(); | |
93 | } |
|
91 | } | |
@@ -176,21 +174,12 void QBarSeries::setToolTipEnabled(bool enabled) | |||||
176 | /*! |
|
174 | /*! | |
177 | \internal \a category |
|
175 | \internal \a category | |
178 | */ |
|
176 | */ | |
179 | void QBarSeries::barsetClicked(QString category) |
|
177 | void QBarSeries::barsetClicked(QString category, Qt::MouseButtons button) | |
180 | { |
|
178 | { | |
181 | emit clicked(qobject_cast<QBarSet*>(sender()), category); |
|
179 | emit clicked(qobject_cast<QBarSet*>(sender()), category, button); | |
182 | } |
|
180 | } | |
183 |
|
181 | |||
184 | /*! |
|
182 | /*! | |
185 | \internal \a category |
|
|||
186 | */ |
|
|||
187 | void QBarSeries::barsetRightClicked(QString category) |
|
|||
188 | { |
|
|||
189 | emit rightClicked(qobject_cast<QBarSet*>(sender()), category); |
|
|||
190 | } |
|
|||
191 |
|
||||
192 |
|
||||
193 | /*! |
|
|||
194 | \internal |
|
183 | \internal | |
195 | */ |
|
184 | */ | |
196 | qreal QBarSeries::min() |
|
185 | qreal QBarSeries::min() |
@@ -72,9 +72,7 public: | |||||
72 | // <--- TO PIMPL |
|
72 | // <--- TO PIMPL | |
73 |
|
73 | |||
74 | Q_SIGNALS: |
|
74 | Q_SIGNALS: | |
75 | //void changed(int index); |
|
75 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); // Up to user of api, what to do with these signals | |
76 | void clicked(QBarSet *barset, QString category); // Up to user of api, what to do with these signals |
|
|||
77 | void rightClicked(QBarSet *barset, QString category); |
|
|||
78 |
|
76 | |||
79 | // |
|
77 | // | |
80 | void updatedBars(); |
|
78 | void updatedBars(); | |
@@ -89,8 +87,7 public Q_SLOTS: | |||||
89 | void setToolTipEnabled(bool enabled = true); // enables tooltips |
|
87 | void setToolTipEnabled(bool enabled = true); // enables tooltips | |
90 |
|
88 | |||
91 | // TODO: TO PIMPL ---> |
|
89 | // TODO: TO PIMPL ---> | |
92 | void barsetClicked(QString category); |
|
90 | void barsetClicked(QString category, Qt::MouseButtons button); | |
93 | void barsetRightClicked(QString category); |
|
|||
94 | // <--- TO PIMPL |
|
91 | // <--- TO PIMPL | |
95 |
|
92 | |||
96 | private Q_SLOTS: |
|
93 | private Q_SLOTS: |
@@ -39,15 +39,10 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \fn void QBarSet::clicked(QString category) |
|
42 | \fn void QBarSet::clicked(QString category, Qt::MouseButtons button) | |
43 | \brief signals that set has been clicked |
|
43 | \brief signals that set has been clicked | |
44 | Parameter \a category describes on which category was clicked |
|
44 | Parameter \a category describes on which category was clicked | |
45 | */ |
|
45 | Parameter \a button mouse button | |
46 |
|
||||
47 | /*! |
|
|||
48 | \fn void QBarSet::rightClicked(QString category) |
|
|||
49 | \brief signals that set has been clicked with right mouse button |
|
|||
50 | Parameter \a category describes on which category was clicked |
|
|||
51 | */ |
|
46 | */ | |
52 |
|
47 | |||
53 | /*! |
|
48 | /*! |
@@ -59,8 +59,7 public: | |||||
59 | QPen floatingValuePen() const; |
|
59 | QPen floatingValuePen() const; | |
60 |
|
60 | |||
61 | Q_SIGNALS: |
|
61 | Q_SIGNALS: | |
62 | void clicked(QString category); // Clicked and hover signals exposed to user |
|
62 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user | |
63 | void rightClicked(QString category); |
|
|||
64 | void toggleFloatingValues(); |
|
63 | void toggleFloatingValues(); | |
65 |
|
64 | |||
66 | // TODO: Expose this to user or not? |
|
65 | // TODO: Expose this to user or not? |
General Comments 0
You need to be logged in to leave comments.
Login now