ksudoku.h 4.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/***************************************************************************
 *   Copyright 2005-2007 Francesco Rossi <redsh@email.it>                  *
 *   Copyright 2006-2007 Mick Kappenburg <ksudoku@kappendburg.net>         *
 *   Copyright 2006-2007 Johannes Bergmeier <johannes.bergmeier@gmx.net>   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
Johannes Bergmeier's avatar
Johannes Bergmeier committed
19
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
20
 ***************************************************************************/
21
22
23
24
25
26
27
28
29

#ifndef _KSUDOKU_H_
#define _KSUDOKU_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kapplication.h>
30
#include <kxmlguiwindow.h>
31
32
33
34
35
#include <qdatetime.h>
//Added by qt3to4:
#include <QDropEvent>
#include <QDragEnterEvent>
#include <kurl.h>
36
#if 0
37
#include <knewstuff/knewstuff.h>
38
#endif
39

40
#include "sudokuview.h"
41
42
#include "roxdokuview.h"

Johannes Bergmeier's avatar
Johannes Bergmeier committed
43
44
45
46
#include "symbols.h"

#include <QSignalMapper>

47
48
#include <QListWidget>

49
50
51
52
53
54
55
//#include "skgraph.h"
//#include "sksolver.h"

class ksudoku::KsView;
class KUrl;

namespace ksudoku {
56
class GameVariantCollection;
57
class ValueListWidget;
58
class WelcomeScreen;
59
60
61
62
63
64
65
66
67
68
69
70
71
}

/**
 * This class serves as the main window for ksudoku.  It handles the
 * menus, toolbars, and status bars.
 *
 * @short Main window class
 * @author Francesco Rossi <redsh@email.it>
 * @version 0.3
 */

class KSudoku;

72
#if 0
73
74
75
76
77
78
79
80
81
class KSudokuNewStuff : public KNewStuff
{
public:
	KSudoku* parent;
public:
	KSudokuNewStuff(KSudoku* p);
	bool install( const QString &fileName );
	bool createUploadFile( const QString &fileName );
};
82
#endif
83

84
class KSudoku : public KXmlGuiWindow
85
86
87
88
89
90
91
{
    Q_OBJECT

public:
    /**
     * Default Constructor
     */
92
	KSudoku();
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

    /**
     * Default Destructor
     */
	virtual ~KSudoku();
	
	void loadGame(const KUrl& url);
	
	Game             currentGame() const;
	ksudoku::KsView* currentView() const;

protected:
    /**
     * Overridden virtuals for Qt drag 'n drop (XDND)
     */
	virtual void dragEnterEvent(QDragEnterEvent *event);
	virtual void dropEvent(QDropEvent *event);

public slots:
	void onCompleted(bool isCorrect, const QTime& required, bool withHelp = false);
	
	void showWelcomeScreen();

116
	void startGame(const Game& game);
117
	void endCurrentGame();
118
	
119
private slots:
120
121
122
123
124
125
	void gameNew();
	void gameOpen();
	void gameSave();
	void gameSaveAs();
	void gamePrint();
	void gameExport();
126
127
128
129
130
131
132
133
134
135
136

	void undo();
	void redo();
	void push();
	void pop();

	void giveHint();
	void autoSolve();
	void dubPuzzle();
	void genMultiple();

Johannes Bergmeier's avatar
Johannes Bergmeier committed
137
138
139
	void selectValue(int value);
	void enterValue(int value);
	void markValue(int value);
140
141
142
143
144
	void moveUp();
	void moveDown();
	void moveLeft();
	void moveRight();
	void clearCell();
145
146

	void optionsPreferences();
Johannes Bergmeier's avatar
Johannes Bergmeier committed
147
	void settingsChanged();
148
149
150
151
152
153
154
155
156
157
158
159
160
	void changeStatusbar(const QString& text);
	void changeCaption(const QString& text);

	//web
	void homepage();
	void support();
	void sendComment();

	void updateStatusBar();

	void onModified(bool isModified);
	
public:
161
	void updateShapesList();
162
163
164
165
	void loadCustomShapeFromPath();
	void createCustomShape();

private:
166
	void createAction(const QString& text, const char* slot, const QString& name, const QString& icon);
167
168
169
170
171
172
173
	void setupAccel();
	void setupActions();

	void adaptActions2View();

	
private:
174
	QWidget* wrapper;
175
	
Johannes Bergmeier's avatar
Johannes Bergmeier committed
176
177
178
179
	QSignalMapper* m_selectValueMapper;
	QSignalMapper* m_enterValueMapper;
	QSignalMapper* m_markValueMapper;
	
180
181
	QAction* m_gameSave;
	QAction* m_gameSaveAs;
182
183
184
185
	QAction* m_moveUpAct;
	QAction* m_moveDownAct;
	QAction* m_moveLeftAct;
	QAction* m_moveRightAct;
Johannes Bergmeier's avatar
Johannes Bergmeier committed
186
	
187
188
	GameVariantCollection* m_gameVariants;
	WelcomeScreen* m_welcomeScreen;
189
	
190
191
	QWidget* m_gameWidget;
	ValueListWidget* m_valueListWidget;
Johannes Bergmeier's avatar
Johannes Bergmeier committed
192
193
	
	KsView* m_gameUI;
194

Johannes Bergmeier's avatar
Johannes Bergmeier committed
195
	Symbols m_symbols;
196
197
198
199
};

#endif // _KSUDOKU_H_