#include <QBrush>
class QPaintEvent;
+class QMouseEvent;
class Field : public QWidget
{
typedef QVector<Field::FieldRect> RectVector;
- Field (QWidget *parent);
+ 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:
- 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;
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