X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=colorflood%2Fsrc%2Ffield.hpp;h=9009857e2151e050a9cd14ea375e99fcf31bc520;hb=4cacdbdfa626074f692dc67a49b960fbd4244150;hp=0d78d3475d7a81839aebf28be3603ba67cccc94a;hpb=58db3b3c242f622eb29d126dce5e162b08d08407;p=colorflood diff --git a/colorflood/src/field.hpp b/colorflood/src/field.hpp index 0d78d34..9009857 100644 --- a/colorflood/src/field.hpp +++ b/colorflood/src/field.hpp @@ -19,6 +19,7 @@ #include class QPaintEvent; +class QMouseEvent; class Field : public QWidget { @@ -41,27 +42,37 @@ public: typedef QVector RectVector; - Field (QWidget *parent); + Field (QWidget *parent, int *turns); ~Field (); FieldSize getSize () const; - void randomize (); static int getNumRectsOfSize (FieldSize size); static int getNumTurnsOfSize (FieldSize size); private: - static const int rects[NUM_SIZES]; - static const int turns[NUM_SIZES]; + static const int numRects[NUM_SIZES]; + static const int numTurns[NUM_SIZES]; - void init (const QVector &brushes, FieldSize size); + void randomize (); static int getRectSize (FieldSize size); + void tryFloodRecurse (quint8 brush, int x, int y); + void floodNeighbours (quint8 brush, int x, int y); FieldSize size; RectVector data; + int turns; + bool finished; protected: + void mousePressEvent (QMouseEvent *event); void paintEvent (QPaintEvent *event); + +signals: + void turnsChanged (int turns); + +public slots: + void flood (int colorIndex); }; #endif // !_FIELD_HPP