1 |
torben |
1 |
/*************************************************************************** |
2 |
|
|
* Copyright (C) 2005 by Torben Nielsen * |
3 |
|
|
* torben@t-hoerup.dk * |
4 |
|
|
* * |
5 |
|
|
* This program is free software; you can redistribute it and/or modify * |
6 |
|
|
* it under the terms of the GNU General Public License as published by * |
7 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
8 |
|
|
* (at your option) any later version. * |
9 |
|
|
* * |
10 |
|
|
* This program is distributed in the hope that it will be useful, * |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
|
|
* GNU General Public License for more details. * |
14 |
|
|
* * |
15 |
|
|
* You should have received a copy of the GNU General Public License * |
16 |
|
|
* along with this program; if not, write to the * |
17 |
|
|
* Free Software Foundation, Inc., * |
18 |
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 |
|
|
***************************************************************************/ |
20 |
|
|
#ifndef QUEENSMAIN_H |
21 |
|
|
#define QUEENSMAIN_H |
22 |
|
|
|
23 |
|
|
#include <qdialog.h> |
24 |
|
|
#include <qdatetime.h> |
25 |
|
|
#include <qtimer.h> |
26 |
|
|
|
27 |
|
|
#include "guiupdate.h" |
28 |
|
|
|
29 |
|
|
class QPushButton; |
30 |
|
|
class QSpinBox; |
31 |
|
|
class QListBox; |
32 |
|
|
class QLabel; |
33 |
|
|
class QString; |
34 |
torben |
2 |
class Solution; |
35 |
torben |
1 |
|
36 |
|
|
class SolutionContainer; |
37 |
|
|
class Queens; |
38 |
|
|
class Board; |
39 |
|
|
|
40 |
|
|
enum SortingAlgorithm{SortVector, SortList, SortHash, SortMNVector}; |
41 |
torben |
2 |
enum StorageClass{ StorageInt, StorageMatrix }; |
42 |
torben |
1 |
|
43 |
torben |
2 |
|
44 |
torben |
1 |
/** |
45 |
|
|
@author Torben Nielsen |
46 |
|
|
*/ |
47 |
|
|
class QueensMain : public QDialog, public GUIUpdate |
48 |
|
|
{ |
49 |
|
|
Q_OBJECT |
50 |
|
|
private: |
51 |
|
|
Board *m_board; |
52 |
|
|
QPushButton *m_quit; |
53 |
|
|
QPushButton *m_start; |
54 |
|
|
QPushButton *m_stop; |
55 |
|
|
QListBox *m_list; |
56 |
|
|
QSpinBox *m_sizeSelector; |
57 |
|
|
QLabel *m_status; |
58 |
|
|
QTime m_time; |
59 |
|
|
|
60 |
torben |
2 |
Solution* m_sol; |
61 |
torben |
1 |
SolutionContainer *m_solutions; |
62 |
|
|
Queens *m_queens; |
63 |
|
|
SortingAlgorithm m_sortalgo; |
64 |
torben |
2 |
StorageClass m_storage; |
65 |
torben |
1 |
|
66 |
|
|
QTime m_elapsed; |
67 |
|
|
int m_totalcount; |
68 |
|
|
|
69 |
|
|
|
70 |
|
|
void contextMenuEvent(QContextMenuEvent *); |
71 |
|
|
|
72 |
|
|
public: |
73 |
|
|
QueensMain(QWidget *parent = 0, const char *name = 0); |
74 |
|
|
|
75 |
|
|
~QueensMain(); |
76 |
|
|
QString elapsed(); |
77 |
|
|
void uniqueSolutions(); |
78 |
|
|
|
79 |
|
|
public slots: |
80 |
|
|
void start(); |
81 |
|
|
void stop(); |
82 |
|
|
void foundSolution(); |
83 |
|
|
void finishedSearch(); |
84 |
|
|
void showSolution(); |
85 |
|
|
void resize(int size); |
86 |
|
|
void duplicateRemoved(); |
87 |
|
|
|
88 |
|
|
void sortList(); |
89 |
|
|
void sortVector(); |
90 |
|
|
void sortHash(); |
91 |
|
|
void sortMNVector(); |
92 |
torben |
2 |
|
93 |
|
|
void storageInt(); |
94 |
|
|
void storageMatrix(); |
95 |
|
|
|
96 |
torben |
1 |
}; |
97 |
|
|
|
98 |
|
|
#endif |