##// END OF EJS Templates
Adds ekg example draft
Adds ekg example draft

File last commit:

r594:e5ccf0c99fad
r599:86354d1a97be
Show More
barpresenterbase.cpp
184 lines | 5.0 KiB | text/x-c | CppLexer
/ src / barchart / barpresenterbase.cpp
sauimone
added _p to private class headers
r381 #include "barpresenterbase_p.h"
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 #include "bar_p.h"
sauimone
Floating values to bar charts
r263 #include "barvalue_p.h"
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 #include "separator_p.h"
sauimone
minor fix
r240 #include "qbarset.h"
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include "qbarseries.h"
sauimone
Labels for barchart to axis
r487 #include "qchart.h"
#include "qchartaxis.h"
#include "qchartaxiscategories.h"
sauimone
barhcart zvalue added
r594 #include "chartpresenter_p.h"
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 #include <QDebug>
sauimone
moved tooltip to presenter
r288 #include <QToolTip>
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Tero Ahola
Fixed initial bounding rect issue with bar series
r518 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent) :
ChartItem(parent),
mLayoutSet(false),
mSeries(series),
mChart(parent),
mWidth(0),
mHeight(0)
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
sauimone
moved tooltip to presenter
r288 connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString)));
sauimone
commented out separatos. feature, we dont need?
r592 // connect(series,SIGNAL(enableSeparators(bool)),this,SLOT(enableSeparators(bool)));
// enableSeparators(series->separatorsVisible());
sauimone
barhcart zvalue added
r594 setZValue(ChartPresenter::BarSeriesZValue);
sauimone
Labels for barchart to axis
r487 initAxisLabels();
sauimone
added labels to series, intergrated with test app. minor hack to test app
r167 dataChanged();
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
moved tooltip to presenter
r288 BarPresenterBase::~BarPresenterBase()
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
sauimone
moved tooltip to presenter
r288 disconnect(this,SLOT(showToolTip(QPoint,QString)));
sauimone
barchart separators fixed, layout fixed
r505 disconnect(this,SLOT(enableSeparators(bool)));
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
Common naming convention for barcharts
r216 void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
if (!mLayoutSet) {
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 qDebug() << "BarPresenterBase::paint called without layout set. Aborting.";
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 return;
}
sauimone
Fixed layout for barcharts
r473 foreach(QGraphicsItem* i, childItems()) {
i->paint(painter,option,widget);
}
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
Common naming convention for barcharts
r216 QRectF BarPresenterBase::boundingRect() const
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
Tero Ahola
Fixed initial bounding rect issue with bar series
r518 return QRectF(0, 0, mWidth, mHeight);
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
bug fix in bar charts. Crashed, if layout was set before data. Also integrated to test app.
r165
sauimone
Common naming convention for barcharts
r216 void BarPresenterBase::dataChanged()
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
sauimone
removed barchartseriesbase. functionality is now in model
r172 // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them?
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 // Delete old bars
foreach (QGraphicsItem* item, childItems()) {
delete item;
}
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 mBars.clear();
sauimone
commented out separatos. feature, we dont need?
r592 // mSeparators.clear();
sauimone
Floating values to bar charts
r263 mFloatingValues.clear();
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 // Create new graphic items for bars
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int c=0; c<mSeries->categoryCount(); c++) {
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 QString category = mSeries->categoryName(c);
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int s=0; s<mSeries->barsetCount(); s++) {
sauimone
review fix: Removed iterator from barseries. Remove const from brush and pen. Renamed setters for tooltip, floating values and separators
r357 QBarSet *set = mSeries->barsetAt(s);
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 Bar *bar = new Bar(category,this);
sauimone
signals and slots for bars and sets
r239 childItems().append(bar);
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 mBars.append(bar);
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 connect(bar,SIGNAL(clicked(QString)),set,SIGNAL(clicked(QString)));
connect(bar,SIGNAL(rightClicked(QString)),set,SIGNAL(rightClicked(QString)));
sauimone
right click feature for bar series. Enables drilldown
r412 connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEnterEvent(QPoint)));
connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaveEvent()));
sauimone
signals and slots for bars and sets
r239 }
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
commented out separatos. feature, we dont need?
r592 /*
sauimone
Floating values to bar charts
r263 // Create separators
sauimone
Labels for barchart to axis
r487 int count = mSeries->categoryCount() - 1; // There is one less separator than columns
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 for (int i=0; i<count; i++) {
Separator* sep = new Separator(this);
sauimone
barchart separators fixed, layout fixed
r505 sep->setVisible(mSeries->separatorsVisible());
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 childItems().append(sep);
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 mSeparators.append(sep);
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
commented out separatos. feature, we dont need?
r592 */
sauimone
Floating values to bar charts
r263 // Create floating values
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int category=0; category<mSeries->categoryCount(); category++) {
for (int s=0; s<mSeries->barsetCount(); s++) {
sauimone
review fix: Removed iterator from barseries. Remove const from brush and pen. Renamed setters for tooltip, floating values and separators
r357 QBarSet *set = mSeries->barsetAt(s);
sauimone
toggling of floating values. still bit buggy
r267 BarValue *value = new BarValue(*set, this);
sauimone
Floating values to bar charts
r263 childItems().append(value);
mFloatingValues.append(value);
sauimone
updated barchart examples. minor fixes
r276 connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible()));
sauimone
Floating values to bar charts
r263 }
}
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
Labels for barchart to axis
r487 void BarPresenterBase::initAxisLabels()
{
int count = mSeries->categoryCount();
if (0 == count) {
return;
}
Michal Klocek
Axis refactoring to support better barcharts
r502 mChart->axisX()->setTicksCount(count+2);
sauimone
Labels for barchart to axis
r487
qreal min = 0;
Michal Klocek
Axis refactoring to support better barcharts
r502 qreal max = count+1;
sauimone
Labels for barchart to axis
r487
mChart->axisX()->setMin(min);
mChart->axisX()->setMax(max);
Michal Klocek
Axis refactoring to support better barcharts
r502
Michal Klocek
Adds draft of axis bar label support
r497 QChartAxisCategories* categories = mChart->axisX()->categories();
categories->clear();
Michal Klocek
Axis refactoring to support better barcharts
r502 for (int i=0; i<count; i++) {
categories->insert(i+1,mSeries->categoryName(i));
sauimone
Labels for barchart to axis
r487 }
Michal Klocek
Axis refactoring to support better barcharts
r502
sauimone
Labels for barchart to axis
r487 mChart->axisX()->setLabelsVisible(true);
}
Michal Klocek
Refactored for MVP...
r139 //handlers
sauimone
Common naming convention for barcharts
r216 void BarPresenterBase::handleModelChanged(int index)
Michal Klocek
Refactored for MVP...
r139 {
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 // qDebug() << "BarPresenterBase::handleModelChanged" << index;
sauimone
model delegate for bar series. updated examples
r161 dataChanged();
Michal Klocek
Refactored for MVP...
r139 }
sauimone
Common naming convention for barcharts
r216 void BarPresenterBase::handleDomainChanged(const Domain& domain)
Michal Klocek
Refactored for MVP...
r139 {
sauimone
Labels for barchart to axis
r487 qDebug() << "BarPresenterBase::handleDomainChanged";
/*
int count = mSeries->categoryCount();
if (0 == count) {
return;
}
// Position labels to domain
qreal min = domain.minX();
qreal max = domain.maxX();
qreal step = (max-min)/count;
QChartAxisCategories& categories = mChart->axisX()->categories();
categories.clear();
for (int i=0; i<count; i++) {
categories.insert(min,mSeries->categoryName(i));
min += step;
}
*/
Michal Klocek
Refactored for MVP...
r139 }
sauimone
Common naming convention for barcharts
r216 void BarPresenterBase::handleGeometryChanged(const QRectF& rect)
Michal Klocek
Refactored for MVP...
r139 {
mWidth = rect.width();
mHeight = rect.height();
layoutChanged();
mLayoutSet = true;
setPos(rect.topLeft());
}
sauimone
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
r296 void BarPresenterBase::showToolTip(QPoint pos, QString tip)
sauimone
moved tooltip to presenter
r288 {
sauimone
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
r296 // TODO: cool tooltip instead of default
QToolTip::showText(pos,tip);
sauimone
moved tooltip to presenter
r288 }
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280
sauimone
commented out separatos. feature, we dont need?
r592 /*
sauimone
moved tooltip to presenter
r288 void BarPresenterBase::enableSeparators(bool enabled)
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280 {
sauimone
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
r296 for (int i=0; i<mSeparators.count(); i++) {
mSeparators.at(i)->setVisible(enabled);
sauimone
moved tooltip to presenter
r288 }
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280 }
sauimone
commented out separatos. feature, we dont need?
r592 */
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280
sauimone
added _p to private class headers
r381 #include "moc_barpresenterbase_p.cpp"
Michal Klocek
Refactored for MVP...
r139
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 QTCOMMERCIALCHART_END_NAMESPACE