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