summaryrefslogtreecommitdiff
path: root/noncore/games/minesweep/minefield.h
Unidiff
Diffstat (limited to 'noncore/games/minesweep/minefield.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/minesweep/minefield.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/noncore/games/minesweep/minefield.h b/noncore/games/minesweep/minefield.h
index 4ede435..1349c35 100644
--- a/noncore/games/minesweep/minefield.h
+++ b/noncore/games/minesweep/minefield.h
@@ -20,12 +20,12 @@
20#ifndef MINEFIELD_H 20#ifndef MINEFIELD_H
21#define MINEFIELD_H 21#define MINEFIELD_H
22 22
23#include <qtable.h> 23#include <qscrollview.h>
24 24
25class Mine; 25class Mine;
26class Config; 26class Config;
27 27
28class MineField : public QTable 28class MineField : public QScrollView
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
@@ -41,6 +41,7 @@ public:
41 41
42 int level() const { return lev; } 42 int level() const { return lev; }
43 43
44 void setAvailableRect( const QRect & );
44public slots: 45public slots:
45 void setup( int level ); 46 void setup( int level );
46 47
@@ -52,16 +53,21 @@ signals:
52 void mineCount( int ); 53 void mineCount( int );
53 54
54protected: 55protected:
55 void paintFocus( QPainter*, const QRect& ); 56
56 void viewportMousePressEvent( QMouseEvent* ); 57 void contentsMousePressEvent( QMouseEvent* );
57 void viewportMouseReleaseEvent( QMouseEvent* ); 58 void contentsMouseReleaseEvent( QMouseEvent* );
58 void keyPressEvent( QKeyEvent* ); 59 void keyPressEvent( QKeyEvent* );
59 void keyReleaseEvent( QKeyEvent* ); 60 void keyReleaseEvent( QKeyEvent* );
61 void drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph );
60 62
61 int getHint( int row, int col ); 63 int getHint( int row, int col );
62 void setHint( Mine* ); 64 void setHint( int r, int c );
63 void updateMine( int row, int col ); 65 void updateMine( int row, int col );
64 void paletteChange( const QPalette & ); 66 void paletteChange( const QPalette & );
67 void updateCell( int r, int c );
68 bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
69 Mine *mine( int row, int col ) { return onBoard(row, col ) ? mines[row+numCols*col] : 0; }
70 const Mine *mine( int row, int col ) const { return onBoard(row, col ) ? mines[row+numCols*col] : 0; }
65 71
66protected slots: 72protected slots:
67 void cellPressed( int row, int col ); 73 void cellPressed( int row, int col );
@@ -69,6 +75,9 @@ protected slots:
69 void held(); 75 void held();
70 76
71private: 77private:
78 int findCellSize();
79 void setCellSize( int );
80
72 State stat; 81 State stat;
73 void MineField::setState( State st ); 82 void MineField::setState( State st );
74 void MineField::placeMines(); 83 void MineField::placeMines();
@@ -77,11 +86,16 @@ private:
77 bool ignoreClick; 86 bool ignoreClick;
78 int currRow; 87 int currRow;
79 int currCol; 88 int currCol;
89 int numRows, numCols;
90
80 int minecount; 91 int minecount;
81 int mineguess; 92 int mineguess;
82 int nonminecount; 93 int nonminecount;
83 int lev; 94 int lev;
95 QRect availableRect;
96 int cellSize;
84 QTimer *holdTimer; 97 QTimer *holdTimer;
98 Mine **mines;
85}; 99};
86 100
87#endif // MINEFIELD_H 101#endif // MINEFIELD_H