#include <QBrush>
class QPaintEvent;
+class QMouseEvent;
class Field : public QWidget
{
NUM_SIZES
}FieldSize;
- Field (QWidget *parent, const QVector<QBrush> &brushes, FieldSize size);
- Field (QWidget *parent);
+ typedef struct
+ {
+ quint8 brush;
+ bool flood;
+ }FieldRect;
+
+ typedef QVector<Field::FieldRect> RectVector;
+
+ Field (QWidget *parent, int *turns);
~Field ();
FieldSize getSize () const;
- void randomize ();
+ void setSize (int size);
static int getNumRectsOfSize (FieldSize size);
static int getNumTurnsOfSize (FieldSize size);
private:
- typedef struct
- {
- char brush;
- bool flood;
- }FieldRect;
-
- 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<QBrush> &brushes, FieldSize size);
static int getRectSize (FieldSize size);
+ void tryFloodRecurse (quint8 brush, int x, int y);
+ void floodNeighbours (quint8 brush, int x, int y);
- FieldSize size;
- QVector<QBrush> brushes;
- QVector<FieldRect> data;
+ FieldSize size;
+ RectVector data;
+ int turns;
+ bool finished;
protected:
void paintEvent (QPaintEvent *event);
+
+signals:
+ void turnsChanged (int turns);
+
+public slots:
+ void randomize ();
+ void flood (int colorIndex);
};
#endif // !_FIELD_HPP