@@ -87,7 +87,6 int main(int argc, char *argv[]) | |||
|
87 | 87 | *weeklyCrop << (qrand() % 20); |
|
88 | 88 | // Get the drilldown series from season series and add crop to it. |
|
89 | 89 | seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop); |
|
90 | seasonSeries->drilldownSeries(month)->setToolTipEnabled(true); | |
|
91 | 90 | *monthlyCrop << weeklyCrop->sum(); |
|
92 | 91 | } |
|
93 | 92 | seasonSeries->appendBarSet(monthlyCrop); |
@@ -41,13 +41,15 void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||
|
41 | 41 | |
|
42 | 42 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
43 | 43 | { |
|
44 | emit hoverEntered(event->lastScreenPos()); | |
|
44 | emit hovered(true); | |
|
45 | emit hovered(m_barset, true); | |
|
45 | 46 | } |
|
46 | 47 | |
|
47 | 48 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
48 | 49 | { |
|
49 | 50 | Q_UNUSED(event) |
|
50 |
emit hover |
|
|
51 | emit hovered(false); | |
|
52 | emit hovered(m_barset, false); | |
|
51 | 53 | } |
|
52 | 54 | |
|
53 | 55 | #include "moc_bar_p.cpp" |
@@ -43,8 +43,8 public: | |||
|
43 | 43 | Q_SIGNALS: |
|
44 | 44 | void clicked(QString category, Qt::MouseButtons button); |
|
45 | 45 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
46 |
void hover |
|
|
47 | void hoverLeaved(); | |
|
46 | void hovered(bool status); | |
|
47 | void hovered(QBarSet *barset, bool status); | |
|
48 | 48 | |
|
49 | 49 | private: |
|
50 | 50 | QString m_category; |
@@ -31,7 +31,6 | |||
|
31 | 31 | #include "chartpresenter_p.h" |
|
32 | 32 | #include "chartanimator_p.h" |
|
33 | 33 | #include "chartdataset_p.h" |
|
34 | #include <QToolTip> | |
|
35 | 34 | #include <QPainter> |
|
36 | 35 | |
|
37 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -42,7 +41,6 BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |||
|
42 | 41 | m_series(series) |
|
43 | 42 | { |
|
44 | 43 | setFlag(ItemClipsChildrenToShape); |
|
45 | connect(series->d_func(), SIGNAL(showToolTip(QPoint,QString)), this, SLOT(showToolTip(QPoint,QString))); | |
|
46 | 44 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
47 | 45 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); |
|
48 | 46 | setZValue(ChartPresenter::BarSeriesZValue); |
@@ -51,7 +49,6 BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |||
|
51 | 49 | |
|
52 | 50 | BarChartItem::~BarChartItem() |
|
53 | 51 | { |
|
54 | disconnect(this,SLOT(showToolTip(QPoint,QString))); | |
|
55 | 52 | } |
|
56 | 53 | |
|
57 | 54 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
@@ -68,7 +65,6 QRectF BarChartItem::boundingRect() const | |||
|
68 | 65 | |
|
69 | 66 | void BarChartItem::dataChanged() |
|
70 | 67 | { |
|
71 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? | |
|
72 | 68 | foreach(QGraphicsItem *item, childItems()) { |
|
73 | 69 | delete item; |
|
74 | 70 | } |
@@ -86,8 +82,8 void BarChartItem::dataChanged() | |||
|
86 | 82 | m_bars.append(bar); |
|
87 | 83 | connect(bar, SIGNAL(clicked(QString,Qt::MouseButtons)), set, SIGNAL(clicked(QString,Qt::MouseButtons))); |
|
88 | 84 | connect(bar, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), m_series, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons))); |
|
89 |
connect(bar, SIGNAL(hover |
|
|
90 |
connect(bar, SIGNAL(hover |
|
|
85 | connect(bar, SIGNAL(hovered(bool)), set, SIGNAL(hovered(bool))); | |
|
86 | connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); | |
|
91 | 87 | m_layout.append(QRectF(0, 0, 0, 0)); |
|
92 | 88 | } |
|
93 | 89 | } |
@@ -207,12 +203,6 void BarChartItem::handleLayoutChanged() | |||
|
207 | 203 | update(); |
|
208 | 204 | } |
|
209 | 205 | |
|
210 | void BarChartItem::showToolTip(QPoint pos, QString tip) | |
|
211 | { | |
|
212 | // TODO: cool tooltip instead of default | |
|
213 | QToolTip::showText(pos, tip); | |
|
214 | } | |
|
215 | ||
|
216 | 206 | #include "moc_barchartitem_p.cpp" |
|
217 | 207 | |
|
218 | 208 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -63,9 +63,6 public Q_SLOTS: | |||
|
63 | 63 | void handleGeometryChanged(const QRectF &size); |
|
64 | 64 | void handleLayoutChanged(); |
|
65 | 65 | |
|
66 | // Internal slots | |
|
67 | void showToolTip(QPoint pos, QString tip); // shows tooltip (if enabled) | |
|
68 | ||
|
69 | 66 | protected: |
|
70 | 67 | |
|
71 | 68 | // TODO: consider these. |
@@ -205,17 +205,6 QList<QBarSet*> QBarSeries::barSets() const | |||
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | /*! |
|
208 | Enables or disables tooltip depending on parameter \a enabled. | |
|
209 | Tooltip shows the name of set, when mouse is hovering on top of bar. | |
|
210 | Calling without parameter \a enabled, enables the tooltip | |
|
211 | */ | |
|
212 | void QBarSeries::setToolTipEnabled(bool enabled) | |
|
213 | { | |
|
214 | Q_D(QBarSeries); | |
|
215 | d->setToolTipEnabled(enabled); | |
|
216 | } | |
|
217 | ||
|
218 | /*! | |
|
219 | 208 | \fn bool QBarSeries::setModel(QAbstractItemModel *model) |
|
220 | 209 | Sets the \a model to be used as a data source |
|
221 | 210 | */ |
@@ -289,22 +278,6 QString QBarSeriesPrivate::categoryName(int category) | |||
|
289 | 278 | return m_internalModel->categoryName(category); |
|
290 | 279 | } |
|
291 | 280 | |
|
292 | void QBarSeriesPrivate::setToolTipEnabled(bool enabled) | |
|
293 | { | |
|
294 | // TODO: what if we add sets after call to this function? Those sets won't have tooltip enabled. | |
|
295 | if (enabled) { | |
|
296 | for (int i=0; i<m_internalModel->barsetCount(); i++) { | |
|
297 | QBarSet *set = m_internalModel->barsetAt(i); | |
|
298 | connect(set->d_ptr.data(), SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); | |
|
299 | } | |
|
300 | } else { | |
|
301 | for (int i=0; i<m_internalModel->barsetCount(); i++) { | |
|
302 | QBarSet *set = m_internalModel->barsetAt(i); | |
|
303 | disconnect(set->d_ptr.data(), SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); | |
|
304 | } | |
|
305 | } | |
|
306 | } | |
|
307 | ||
|
308 | 281 | qreal QBarSeriesPrivate::min() |
|
309 | 282 | { |
|
310 | 283 | return m_internalModel->min(); |
@@ -67,9 +67,7 protected: | |||
|
67 | 67 | Q_SIGNALS: |
|
68 | 68 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
69 | 69 | void selected(); |
|
70 | ||
|
71 | public Q_SLOTS: | |
|
72 | void setToolTipEnabled(bool enabled = true); // enables tooltips | |
|
70 | void hovered(QBarSet* barset, bool status); | |
|
73 | 71 | |
|
74 | 72 | protected: |
|
75 | 73 | Q_DECLARE_PRIVATE(QBarSeries) |
@@ -40,10 +40,6 Q_SIGNALS: | |||
|
40 | 40 | void selected(); |
|
41 | 41 | void updatedBars(); |
|
42 | 42 | void restructuredBars(); |
|
43 | void showToolTip(QPoint pos, QString tip); | |
|
44 | ||
|
45 | public Q_SLOTS: | |
|
46 | void setToolTipEnabled(bool enabled = true); // enables tooltips | |
|
47 | 43 | |
|
48 | 44 | private Q_SLOTS: |
|
49 | 45 | // slots for updating bars when data in model changes |
@@ -20,7 +20,6 | |||
|
20 | 20 | |
|
21 | 21 | #include "qbarset.h" |
|
22 | 22 | #include "qbarset_p.h" |
|
23 | #include <QToolTip> | |
|
24 | 23 | |
|
25 | 24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 25 | |
@@ -46,6 +45,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
46 | 45 | */ |
|
47 | 46 | |
|
48 | 47 | /*! |
|
48 | \fn void QBarSet::hovered(bool status) | |
|
49 | \brief signals that mouse has hovered over the set. If \a status is true, then mouse was entered. If \a status is false, then mouse was left. | |
|
50 | */ | |
|
51 | ||
|
52 | /*! | |
|
49 | 53 | Constructs QBarSet with a name of \a name and with parent of \a parent |
|
50 | 54 | */ |
|
51 | 55 | QBarSet::QBarSet(QString name, QObject *parent) |
@@ -257,21 +261,6 bool QBarSet::labelsVisible() const | |||
|
257 | 261 | return d_ptr->m_labelsVisible; |
|
258 | 262 | } |
|
259 | 263 | |
|
260 | /* | |
|
261 | void QBarSet::barHoverEnterEvent(QPoint pos) | |
|
262 | { | |
|
263 | emit showToolTip(pos, m_name); | |
|
264 | emit hoverEnter(pos); | |
|
265 | } | |
|
266 | */ | |
|
267 | /* | |
|
268 | void QBarSet::barHoverLeaveEvent() | |
|
269 | { | |
|
270 | // Emit signal to user of charts | |
|
271 | emit hoverLeave(); | |
|
272 | } | |
|
273 | */ | |
|
274 | ||
|
275 | 264 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
276 | 265 | |
|
277 | 266 | QBarSetPrivate::QBarSetPrivate(QString name, QBarSet *parent) : QObject(parent), |
@@ -286,22 +275,6 QBarSetPrivate::~QBarSetPrivate() | |||
|
286 | 275 | { |
|
287 | 276 | |
|
288 | 277 | } |
|
289 | ||
|
290 | ||
|
291 | //TODO: fixme , refactor it and get rid of it | |
|
292 | void QBarSetPrivate::barHoverEnterEvent(QPoint pos) | |
|
293 | { | |
|
294 | emit showToolTip(pos, m_name); | |
|
295 | emit hoverEnter(pos); | |
|
296 | } | |
|
297 | ||
|
298 | //TODO: fixme , refactor it and get rid of it | |
|
299 | void QBarSetPrivate::barHoverLeaveEvent() | |
|
300 | { | |
|
301 | // Emit signal to user of charts | |
|
302 | emit hoverLeave(); | |
|
303 | } | |
|
304 | ||
|
305 | 278 | #include "moc_qbarset.cpp" |
|
306 | 279 | #include "moc_qbarset_p.cpp" |
|
307 | 280 |
@@ -66,7 +66,9 public: | |||
|
66 | 66 | bool labelsVisible() const; |
|
67 | 67 | |
|
68 | 68 | Q_SIGNALS: |
|
69 |
void clicked(QString category, Qt::MouseButtons button); |
|
|
69 | void clicked(QString category, Qt::MouseButtons button); | |
|
70 | void selected(); | |
|
71 | void hovered(bool status); | |
|
70 | 72 | |
|
71 | 73 | private: |
|
72 | 74 | QScopedPointer<QBarSetPrivate> d_ptr; |
@@ -17,15 +17,8 Q_SIGNALS: | |||
|
17 | 17 | void clicked(QString category, Qt::MouseButtons button); |
|
18 | 18 | void structureChanged(); |
|
19 | 19 | void valueChanged(); |
|
20 | void hoverEnter(QPoint pos); | |
|
21 | void hoverLeave(); | |
|
22 | void showToolTip(QPoint pos, QString tip); | |
|
23 | 20 | void labelsVisibleChanged(bool visible); |
|
24 | 21 | |
|
25 | public Q_SLOTS: | |
|
26 | void barHoverEnterEvent(QPoint pos); | |
|
27 | void barHoverLeaveEvent(); | |
|
28 | ||
|
29 | 22 | public: |
|
30 | 23 | QBarSet * const q_ptr; |
|
31 | 24 | QString m_name; |
@@ -287,9 +287,6 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS | |||
|
287 | 287 | series->appendBarSet(set); |
|
288 | 288 | } |
|
289 | 289 | |
|
290 | // TODO: new implementation of setFloatingValuesEnabled with signals | |
|
291 | //series->setFloatingValuesEnabled(true); | |
|
292 | series->setToolTipEnabled(true); | |
|
293 | 290 | m_chart->addSeries(series); |
|
294 | 291 | } else if (seriesName == "Spline") { |
|
295 | 292 | for (int j(0); j < data.count(); j ++) { |
@@ -312,7 +312,6 void TableWidget::updateChartType(bool toggle) | |||
|
312 | 312 | QBarSeries* barSeries = new QBarSeries(QStringList()); |
|
313 | 313 | barSeries->setModel(m_model); |
|
314 | 314 | barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
315 | barSeries->setToolTipEnabled(true); | |
|
316 | 315 | m_chart->addSeries(barSeries); |
|
317 | 316 | QList<QBarSet*> barsets = barSeries->barSets(); |
|
318 | 317 | for (int i = 0; i < barsets.count(); i++) { |
General Comments 0
You need to be logged in to leave comments.
Login now