@@ -87,7 +87,6 int main(int argc, char *argv[]) | |||||
87 | *weeklyCrop << (qrand() % 20); |
|
87 | *weeklyCrop << (qrand() % 20); | |
88 | // Get the drilldown series from season series and add crop to it. |
|
88 | // Get the drilldown series from season series and add crop to it. | |
89 | seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop); |
|
89 | seasonSeries->drilldownSeries(month)->appendBarSet(weeklyCrop); | |
90 | seasonSeries->drilldownSeries(month)->setToolTipEnabled(true); |
|
|||
91 | *monthlyCrop << weeklyCrop->sum(); |
|
90 | *monthlyCrop << weeklyCrop->sum(); | |
92 | } |
|
91 | } | |
93 | seasonSeries->appendBarSet(monthlyCrop); |
|
92 | seasonSeries->appendBarSet(monthlyCrop); |
@@ -41,13 +41,15 void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||||
41 |
|
41 | |||
42 | void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
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 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
48 | void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | |
48 | { |
|
49 | { | |
49 | Q_UNUSED(event) |
|
50 | Q_UNUSED(event) | |
50 |
emit hover |
|
51 | emit hovered(false); | |
|
52 | emit hovered(m_barset, false); | |||
51 | } |
|
53 | } | |
52 |
|
54 | |||
53 | #include "moc_bar_p.cpp" |
|
55 | #include "moc_bar_p.cpp" |
@@ -43,8 +43,8 public: | |||||
43 | Q_SIGNALS: |
|
43 | Q_SIGNALS: | |
44 | void clicked(QString category, Qt::MouseButtons button); |
|
44 | void clicked(QString category, Qt::MouseButtons button); | |
45 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
45 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); | |
46 |
void hover |
|
46 | void hovered(bool status); | |
47 | void hoverLeaved(); |
|
47 | void hovered(QBarSet *barset, bool status); | |
48 |
|
48 | |||
49 | private: |
|
49 | private: | |
50 | QString m_category; |
|
50 | QString m_category; |
@@ -31,7 +31,6 | |||||
31 | #include "chartpresenter_p.h" |
|
31 | #include "chartpresenter_p.h" | |
32 | #include "chartanimator_p.h" |
|
32 | #include "chartanimator_p.h" | |
33 | #include "chartdataset_p.h" |
|
33 | #include "chartdataset_p.h" | |
34 | #include <QToolTip> |
|
|||
35 | #include <QPainter> |
|
34 | #include <QPainter> | |
36 |
|
35 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
@@ -42,7 +41,6 BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |||||
42 | m_series(series) |
|
41 | m_series(series) | |
43 | { |
|
42 | { | |
44 | setFlag(ItemClipsChildrenToShape); |
|
43 | setFlag(ItemClipsChildrenToShape); | |
45 | connect(series->d_func(), SIGNAL(showToolTip(QPoint,QString)), this, SLOT(showToolTip(QPoint,QString))); |
|
|||
46 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
44 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); | |
47 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); |
|
45 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); | |
48 | setZValue(ChartPresenter::BarSeriesZValue); |
|
46 | setZValue(ChartPresenter::BarSeriesZValue); | |
@@ -51,7 +49,6 BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |||||
51 |
|
49 | |||
52 | BarChartItem::~BarChartItem() |
|
50 | BarChartItem::~BarChartItem() | |
53 | { |
|
51 | { | |
54 | disconnect(this,SLOT(showToolTip(QPoint,QString))); |
|
|||
55 | } |
|
52 | } | |
56 |
|
53 | |||
57 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
54 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
@@ -68,7 +65,6 QRectF BarChartItem::boundingRect() const | |||||
68 |
|
65 | |||
69 | void BarChartItem::dataChanged() |
|
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 | foreach(QGraphicsItem *item, childItems()) { |
|
68 | foreach(QGraphicsItem *item, childItems()) { | |
73 | delete item; |
|
69 | delete item; | |
74 | } |
|
70 | } | |
@@ -86,8 +82,8 void BarChartItem::dataChanged() | |||||
86 | m_bars.append(bar); |
|
82 | m_bars.append(bar); | |
87 | connect(bar, SIGNAL(clicked(QString,Qt::MouseButtons)), set, SIGNAL(clicked(QString,Qt::MouseButtons))); |
|
83 | connect(bar, SIGNAL(clicked(QString,Qt::MouseButtons)), set, SIGNAL(clicked(QString,Qt::MouseButtons))); | |
88 | connect(bar, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), m_series, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons))); |
|
84 | connect(bar, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons)), m_series, SIGNAL(clicked(QBarSet*,QString,Qt::MouseButtons))); | |
89 |
connect(bar, SIGNAL(hover |
|
85 | connect(bar, SIGNAL(hovered(bool)), set, SIGNAL(hovered(bool))); | |
90 |
connect(bar, SIGNAL(hover |
|
86 | connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); | |
91 | m_layout.append(QRectF(0, 0, 0, 0)); |
|
87 | m_layout.append(QRectF(0, 0, 0, 0)); | |
92 | } |
|
88 | } | |
93 | } |
|
89 | } | |
@@ -207,12 +203,6 void BarChartItem::handleLayoutChanged() | |||||
207 | update(); |
|
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 | #include "moc_barchartitem_p.cpp" |
|
206 | #include "moc_barchartitem_p.cpp" | |
217 |
|
207 | |||
218 | QTCOMMERCIALCHART_END_NAMESPACE |
|
208 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -63,9 +63,6 public Q_SLOTS: | |||||
63 | void handleGeometryChanged(const QRectF &size); |
|
63 | void handleGeometryChanged(const QRectF &size); | |
64 | void handleLayoutChanged(); |
|
64 | void handleLayoutChanged(); | |
65 |
|
65 | |||
66 | // Internal slots |
|
|||
67 | void showToolTip(QPoint pos, QString tip); // shows tooltip (if enabled) |
|
|||
68 |
|
||||
69 | protected: |
|
66 | protected: | |
70 |
|
67 | |||
71 | // TODO: consider these. |
|
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 | \fn bool QBarSeries::setModel(QAbstractItemModel *model) |
|
208 | \fn bool QBarSeries::setModel(QAbstractItemModel *model) | |
220 | Sets the \a model to be used as a data source |
|
209 | Sets the \a model to be used as a data source | |
221 | */ |
|
210 | */ | |
@@ -289,22 +278,6 QString QBarSeriesPrivate::categoryName(int category) | |||||
289 | return m_internalModel->categoryName(category); |
|
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 | qreal QBarSeriesPrivate::min() |
|
281 | qreal QBarSeriesPrivate::min() | |
309 | { |
|
282 | { | |
310 | return m_internalModel->min(); |
|
283 | return m_internalModel->min(); |
@@ -67,9 +67,7 protected: | |||||
67 | Q_SIGNALS: |
|
67 | Q_SIGNALS: | |
68 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
68 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); | |
69 | void selected(); |
|
69 | void selected(); | |
70 |
|
70 | void hovered(QBarSet* barset, bool status); | ||
71 | public Q_SLOTS: |
|
|||
72 | void setToolTipEnabled(bool enabled = true); // enables tooltips |
|
|||
73 |
|
71 | |||
74 | protected: |
|
72 | protected: | |
75 | Q_DECLARE_PRIVATE(QBarSeries) |
|
73 | Q_DECLARE_PRIVATE(QBarSeries) |
@@ -40,10 +40,6 Q_SIGNALS: | |||||
40 | void selected(); |
|
40 | void selected(); | |
41 | void updatedBars(); |
|
41 | void updatedBars(); | |
42 | void restructuredBars(); |
|
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 | private Q_SLOTS: |
|
44 | private Q_SLOTS: | |
49 | // slots for updating bars when data in model changes |
|
45 | // slots for updating bars when data in model changes |
@@ -20,7 +20,6 | |||||
20 |
|
20 | |||
21 | #include "qbarset.h" |
|
21 | #include "qbarset.h" | |
22 | #include "qbarset_p.h" |
|
22 | #include "qbarset_p.h" | |
23 | #include <QToolTip> |
|
|||
24 |
|
23 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
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 | Constructs QBarSet with a name of \a name and with parent of \a parent |
|
53 | Constructs QBarSet with a name of \a name and with parent of \a parent | |
50 | */ |
|
54 | */ | |
51 | QBarSet::QBarSet(QString name, QObject *parent) |
|
55 | QBarSet::QBarSet(QString name, QObject *parent) | |
@@ -257,21 +261,6 bool QBarSet::labelsVisible() const | |||||
257 | return d_ptr->m_labelsVisible; |
|
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 | QBarSetPrivate::QBarSetPrivate(QString name, QBarSet *parent) : QObject(parent), |
|
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 | #include "moc_qbarset.cpp" |
|
278 | #include "moc_qbarset.cpp" | |
306 | #include "moc_qbarset_p.cpp" |
|
279 | #include "moc_qbarset_p.cpp" | |
307 |
|
280 |
@@ -66,7 +66,9 public: | |||||
66 | bool labelsVisible() const; |
|
66 | bool labelsVisible() const; | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
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 | private: |
|
73 | private: | |
72 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
74 | QScopedPointer<QBarSetPrivate> d_ptr; |
@@ -17,15 +17,8 Q_SIGNALS: | |||||
17 | void clicked(QString category, Qt::MouseButtons button); |
|
17 | void clicked(QString category, Qt::MouseButtons button); | |
18 | void structureChanged(); |
|
18 | void structureChanged(); | |
19 | void valueChanged(); |
|
19 | void valueChanged(); | |
20 | void hoverEnter(QPoint pos); |
|
|||
21 | void hoverLeave(); |
|
|||
22 | void showToolTip(QPoint pos, QString tip); |
|
|||
23 | void labelsVisibleChanged(bool visible); |
|
20 | void labelsVisibleChanged(bool visible); | |
24 |
|
21 | |||
25 | public Q_SLOTS: |
|
|||
26 | void barHoverEnterEvent(QPoint pos); |
|
|||
27 | void barHoverLeaveEvent(); |
|
|||
28 |
|
||||
29 | public: |
|
22 | public: | |
30 | QBarSet * const q_ptr; |
|
23 | QBarSet * const q_ptr; | |
31 | QString m_name; |
|
24 | QString m_name; |
@@ -287,9 +287,6 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS | |||||
287 | series->appendBarSet(set); |
|
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 | m_chart->addSeries(series); |
|
290 | m_chart->addSeries(series); | |
294 | } else if (seriesName == "Spline") { |
|
291 | } else if (seriesName == "Spline") { | |
295 | for (int j(0); j < data.count(); j ++) { |
|
292 | for (int j(0); j < data.count(); j ++) { |
@@ -312,7 +312,6 void TableWidget::updateChartType(bool toggle) | |||||
312 | QBarSeries* barSeries = new QBarSeries(QStringList()); |
|
312 | QBarSeries* barSeries = new QBarSeries(QStringList()); | |
313 | barSeries->setModel(m_model); |
|
313 | barSeries->setModel(m_model); | |
314 | barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
314 | barSeries->setModelMapping(5, 2, 4, Qt::Vertical); | |
315 | barSeries->setToolTipEnabled(true); |
|
|||
316 | m_chart->addSeries(barSeries); |
|
315 | m_chart->addSeries(barSeries); | |
317 | QList<QBarSet*> barsets = barSeries->barSets(); |
|
316 | QList<QBarSet*> barsets = barSeries->barSets(); | |
318 | for (int i = 0; i < barsets.count(); i++) { |
|
317 | for (int i = 0; i < barsets.count(); i++) { |
General Comments 0
You need to be logged in to leave comments.
Login now