##// END OF EJS Templates
updated barchart examples. minor fixes
updated barchart examples. minor fixes

File last commit:

r276:d062a7f38647
r276:d062a7f38647
Show More
barpresenterbase.cpp
138 lines | 3.9 KiB | text/x-c | CppLexer
/ src / barchart / barpresenterbase.cpp
sauimone
Common naming convention for barcharts
r216 #include "barpresenterbase.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 "barlabel_p.h"
#include "separator_p.h"
sauimone
minor fix
r240 #include "qbarset.h"
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
Common naming convention for barcharts
r216 BarPresenterBase::BarPresenterBase(BarChartModel& model, QGraphicsItem *parent)
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 : ChartItem(parent)
,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready
,mLayoutSet(false)
,mLayoutDirty(true)
sauimone
Floating values to bar charts
r263 ,mSeparatorsVisible(false)
sauimone
removed barchartseriesbase. functionality is now in model
r172 ,mModel(model)
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
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
Common naming convention for barcharts
r216 void BarPresenterBase::setSeparatorsVisible(bool visible)
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
mSeparatorsVisible = visible;
}
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
model delegate for bar series. updated examples
r161 // if (mLayoutDirty) {
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 // Layout or data has changed. Need to redraw.
foreach(QGraphicsItem* i, childItems()) {
i->paint(painter,option,widget);
}
sauimone
model delegate for bar series. updated examples
r161 // }
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 {
return QRectF(0,0,mWidth,mHeight);
}
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::setBarWidth( int w )
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 {
mBarDefaultWidth = w;
}
sauimone
brush support for bargroups
r183
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
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 qDebug() << "datachanged";
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();
mLabels.clear();
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
floating values working now. bounding rect bug fixed
r273 for (int c=0; c<mModel.countCategories(); c++) {
for (int s=0; s<mModel.countSets(); s++) {
QBarSet *set = mModel.setAt(s);
sauimone
signals and slots for bars and sets
r239 Bar *bar = new Bar(this);
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
floating values working now. bounding rect bug fixed
r273 connect(bar,SIGNAL(clicked()),set,SLOT(barClicked()));
sauimone
updated barchart examples. minor fixes
r276 connect(bar,SIGNAL(hoverEntered()),set,SLOT(barHoverEntered()));
connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaved()));
sauimone
signals and slots for bars and sets
r239 }
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
Floating values to bar charts
r263 // Create labels
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 int count = mModel.countCategories();
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 for (int i=0; i<count; i++) {
BarLabel* label = new BarLabel(this);
sauimone
removed barchartseriesbase. functionality is now in model
r172 label->set(mModel.label(i));
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 childItems().append(label);
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 mLabels.append(label);
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
Floating values to bar charts
r263 // Create separators
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 count = mModel.countCategories() - 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);
sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme
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
Floating values to bar charts
r263 // Create floating values
sauimone
floating values working now. bounding rect bug fixed
r273 for (int category=0; category<mModel.countCategories(); category++) {
for (int s=0; s<mModel.countSets(); s++) {
QBarSet *set = mModel.setAt(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 // TODO: if (autolayout) { layoutChanged() } or something
mLayoutDirty = 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
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 // qDebug() << "BarPresenterBase::handleDomainChanged";
sauimone
added labels to series, intergrated with test app. minor hack to test app
r167 // TODO: Figure out the use case for this.
// Affects the size of visible item, so layout is changed.
// layoutChanged();
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
Common naming convention for barcharts
r216 #include "moc_barpresenterbase.cpp"
Michal Klocek
Refactored for MVP...
r139
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 QTCOMMERCIALCHART_END_NAMESPACE