multicookview.h 1.29 KB
#ifndef MULTICOOKVIEW_H
#define MULTICOOKVIEW_H

#include <QWidget>
#include <QPixmap>
#include <QTimer>

#include "multicookcontainer.h"
#include "multicooktimebar.h"

class MultiCookView : public QWidget
{
    Q_OBJECT
public:
    explicit MultiCookView(QWidget *parent = 0);

    void setContainer(MultiCookContainer *container);
    void setTimeBar(MultiCookTimeBar *bar);

signals:
    void clicked(int);

public slots:
    void showNow();
    void showNext();
    void showPrev();
    void updateView();

protected:
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
    virtual void paintEvent(QPaintEvent *event);
    virtual void resizeEvent(QResizeEvent *event);

private:
    // helper methods
    QList<QRect> calcRects();
    int calcSlot(int x, int y);
    void paintGrids(QPainter &painter);
    void paintBars(QPainter &painter);
    void paintCurrentTime(QPainter &painter);
    void paintBar(QPainter &painter, QRect r);
    int currentTimePosition();
    bool nothingOnRight();

    MultiCookContainer *container;
    MultiCookTimeBar *bar;
    QList<QRect> rects;
    int timePosition;

    // for click signal
    int pressedSlot;

    QPixmap barPixmap;

    QTimer checkTimer;

private slots:
    void check();

};


#endif // MULTICOOKVIEW_H