fix start/stop/pause
[Sak.git] / piechart.h
blob4bfd39cd7032fd7558148adaca4f0e9a46ee937d
1 #ifndef PIECHART_H_
2 #define PIECHART_H_
4 #include "task.h"
6 class TaskSummaryPieChart : public QGraphicsItem
8 public:
9 QRectF boundingRect() const { return QRectF(-0.61,-0.6,1.2,1.2);}
10 void setHits(const QMap<double, Task*>& hits) { m_hits = hits; }
11 virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */ ) {
12 painter->save();
13 QMap<double,Task*>::const_iterator itr = m_hits.begin(), end=m_hits.end();
15 while(itr != end) {
16 double startAngle = (start - m_min) / (m_max - m_min) * 16 * 360;
17 double spanAngle = itr.duration / (m_max - m_min) * 16 * 360;
18 QPainterPath p;
19 p.moveTo(0,0);
20 p.arcTo(QRectF(0,0,1,1), spanAngle + startAngle, spanAngle);
21 painter->setBrush(itr.value().second);
22 painter->setPen(Qt::NoPen);
23 painter->drawPath(p);
24 itr++;
27 painter->restore();
29 protected:
30 QMap<double, Task*> m_hits;
33 #endif