##// END OF EJS Templates
combined clicked and rightclicked events of legend to one event with parameter
sauimone -
r567:17f0257049a1
parent child
Show More
@@ -82,31 +82,15 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
82 switch (mType)
82 switch (mType)
83 {
83 {
84 case LegendMarkerTypeSeries: {
84 case LegendMarkerTypeSeries: {
85
85 emit clicked(mSeries,event->button());
86 if (event->button() == Qt::LeftButton) {
87 emit clicked(mSeries);
88 } else if (event->button() == Qt::RightButton) {
89 emit rightClicked(mSeries);
90 }
91 break;
86 break;
92 }
87 }
93 case LegendMarkerTypeBarset: {
88 case LegendMarkerTypeBarset: {
94
89 emit clicked(mBarset,event->button());
95 if (event->button() == Qt::LeftButton) {
96 emit clicked(mBarset);
97 } else if (event->button() == Qt::RightButton) {
98 emit rightClicked(mBarset);
99 }
100 break;
90 break;
101 }
91 }
102
103 case LegendMarkerTypePieslice: {
92 case LegendMarkerTypePieslice: {
104
93 emit clicked(mPieslice,event->button());
105 if (event->button() == Qt::LeftButton) {
106 emit clicked(mPieslice);
107 } else if (event->button() == Qt::RightButton) {
108 emit rightClicked(mPieslice);
109 }
110 break;
94 break;
111 }
95 }
112 default: {
96 default: {
@@ -43,12 +43,9 public:
43 void mousePressEvent(QGraphicsSceneMouseEvent *event);
43 void mousePressEvent(QGraphicsSceneMouseEvent *event);
44
44
45 Q_SIGNALS:
45 Q_SIGNALS:
46 void clicked(QSeries* series);
46 void clicked(QSeries* series, Qt::MouseButton button);
47 void rightClicked(QSeries* series);
47 void clicked(QBarSet* barset, Qt::MouseButton button);
48 void clicked(QBarSet* barset);
48 void clicked(QPieSlice* pieslice, Qt::MouseButton button);
49 void rightClicked(QBarSet* barset);
50 void clicked(QPieSlice* pieslice);
51 void rightClicked(QPieSlice* pieslice);
52
49
53 private:
50 private:
54 QRectF mBoundingRect;
51 QRectF mBoundingRect;
@@ -141,8 +141,7 void QLegend::createMarker(QXYSeries* series)
141 LegendMarker* marker = new LegendMarker(series,this);
141 LegendMarker* marker = new LegendMarker(series,this);
142 marker->setName(series->name());
142 marker->setName(series->name());
143 marker->setBrush(series->brush());
143 marker->setBrush(series->brush());
144 connect(marker,SIGNAL(clicked(QSeries*)),this,SIGNAL(markerClicked(QSeries*)));
144 connect(marker,SIGNAL(clicked(QSeries*,Qt::MouseButton)),this,SIGNAL(clicked(QSeries*,Qt::MouseButton)));
145 connect(marker,SIGNAL(rightClicked(QSeries*)),this,SIGNAL(markerRightClicked(QSeries*)));
146 mMarkers.append(marker);
145 mMarkers.append(marker);
147 childItems().append(marker);
146 childItems().append(marker);
148 }
147 }
@@ -153,8 +152,7 void QLegend::createMarkers(QBarSeries *series)
153 LegendMarker* marker = new LegendMarker(series,this);
152 LegendMarker* marker = new LegendMarker(series,this);
154 marker->setName(s->name());
153 marker->setName(s->name());
155 marker->setBrush(s->brush());
154 marker->setBrush(s->brush());
156 connect(marker,SIGNAL(clicked(QBarSet*)),this,SIGNAL(markerClicked(QBarSet*)));
155 connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton)));
157 connect(marker,SIGNAL(rightClicked(QBarSet*)),this,SIGNAL(markerRightClicked(QBarSet*)));
158 mMarkers.append(marker);
156 mMarkers.append(marker);
159 childItems().append(marker);
157 childItems().append(marker);
160 }
158 }
@@ -166,8 +164,7 void QLegend::createMarkers(QPieSeries *series)
166 LegendMarker* marker = new LegendMarker(series,this);
164 LegendMarker* marker = new LegendMarker(series,this);
167 marker->setName(s->label());
165 marker->setName(s->label());
168 marker->setBrush(s->sliceBrush());
166 marker->setBrush(s->sliceBrush());
169 connect(marker,SIGNAL(clicked(QPieSlice*)),this,SIGNAL(markerClicked(QPieSlice*)));
167 connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)));
170 connect(marker,SIGNAL(rightClicked(QPieSlice*)),this,SIGNAL(markerRightClicked(QPieSlice*)));
171 mMarkers.append(marker);
168 mMarkers.append(marker);
172 childItems().append(marker);
169 childItems().append(marker);
173 }
170 }
@@ -30,12 +30,9 public:
30
30
31 signals:
31 signals:
32 // for interactions.
32 // for interactions.
33 void clicked(QSeries* series);
33 void clicked(QSeries* series, Qt::MouseButton button);
34 void rightClicked(QSeries* series);
34 void clicked(QBarSet* barset, Qt::MouseButton button);
35 void clicked(QBarSet* barset);
35 void clicked(QPieSlice* slice, Qt::MouseButton button);
36 void rightClicked(QBarSet* series);
37 void clicked(QPieSlice* slice);
38 void rightClicked(QPieSlice* series);
39
36
40 public slots:
37 public slots:
41 void handleSeriesAdded(QSeries* series,Domain* domain);
38 void handleSeriesAdded(QSeries* series,Domain* domain);
General Comments 0
You need to be logged in to leave comments. Login now