Update debian/control to point to garage.
[weightgraph] / weightgraph / weightgraphview.h
1 #ifndef WEIGHTGRAPHVIEW_H
2 #define WEIGHTGRAPHVIEW_H
3
4 #include <QWidget>
5 #include <QKeyEvent>
6 #include "weightdata.h"
7 #include "settings.h"
8
9 class WeightGraphView : public QWidget
10 {
11     Q_OBJECT
12 public:
13   explicit WeightGraphView(WeightDataModel *wdm, const QString &id, QWidget *parent = 0);
14   QSize sizeHint() const;
15 signals:
16   void clicked();
17 public slots:
18   void paintEvent(QPaintEvent *);
19   void show();
20   void update() {
21     grabZoomKeys(Settings::grabZoomKeys());
22     QWidget::update();
23   }
24
25   void grabZoomKeys(bool grab);
26   void incPeriod() {
27     if (period == 0)
28       period = wdm->getWeights().first().date.daysTo(wdm->getWeights().last().date) + 1;
29     else
30       period++;
31     update();
32   }
33   void decPeriod() {
34     if (period == 0)
35       period = wdm->getWeights().first().date.daysTo(wdm->getWeights().last().date) - 1;
36     else
37       period = qMax(1, period-1);
38     update();
39   }
40   void setPeriod(int period) { this->period = period; update(); }
41 protected:
42   void mousePressEvent(QMouseEvent *);
43   void keyPressEvent(QKeyEvent* event);
44 private:
45   QString id;
46   WeightDataModel *wdm;
47   int period;
48 };
49
50 #endif // WEIGHTGRAPHVIEW_H