31 |
#include "queensmain.h" |
#include "queensmain.h" |
32 |
#include "board.h" |
#include "board.h" |
33 |
#include "queens.h" |
#include "queens.h" |
34 |
|
|
35 |
#include "solution.h" |
#include "solution.h" |
36 |
#include "solutionvector.h" |
#include "solutionmatrix.h" |
37 |
#include "solutionlist.h" |
#include "solutionint.h" |
38 |
#include "solutionhash.h" |
|
39 |
#include "solutionmnvector.h" |
#include "containervector.h" |
40 |
|
#include "containerlist.h" |
41 |
|
#include "containerhash.h" |
42 |
|
#include "containermnvector.h" |
43 |
|
|
44 |
#include "config.h" |
#include "config.h" |
45 |
|
|
46 |
#define MatrixSolution Solution |
|
47 |
|
|
48 |
QueensMain::QueensMain(QWidget *parent, const char *name) |
QueensMain::QueensMain(QWidget *parent, const char *name) |
49 |
: QDialog(parent, name) |
: QDialog(parent, name) |
86 |
m_sortalgo = SortList; |
m_sortalgo = SortList; |
87 |
m_solutions = NULL; |
m_solutions = NULL; |
88 |
m_queens = NULL; |
m_queens = NULL; |
89 |
|
m_sol = NULL; |
90 |
|
|
91 |
connect(m_quit, |
connect(m_quit, |
92 |
SIGNAL( clicked() ), |
SIGNAL( clicked() ), |
139 |
m_list->clear(); |
m_list->clear(); |
140 |
m_status->setText( QString("Searching ...") ); |
m_status->setText( QString("Searching ...") ); |
141 |
|
|
142 |
|
m_board->setMatrix(0); |
143 |
|
|
144 |
if (m_queens != NULL) { |
if (m_queens != NULL) { |
145 |
m_queens->wait(); |
m_queens->wait(); |
146 |
delete m_queens; |
delete m_queens; |
150 |
delete m_solutions; |
delete m_solutions; |
151 |
switch (m_sortalgo) { |
switch (m_sortalgo) { |
152 |
case SortList: |
case SortList: |
153 |
m_solutions = new SolutionList(this); |
m_solutions = new ContainerList(this); |
154 |
break; |
break; |
155 |
case SortVector: |
case SortVector: |
156 |
m_solutions = new SolutionVector(this); |
m_solutions = new ContainerVector(this); |
157 |
break; |
break; |
158 |
case SortHash: |
case SortHash: |
159 |
m_solutions = new SolutionHash(this); |
m_solutions = new ContainerHash(this); |
160 |
break; |
break; |
161 |
case SortMNVector: |
case SortMNVector: |
162 |
m_solutions = new SolutionMNVector(this); |
m_solutions = new ContainerMNVector(this); |
163 |
break; |
break; |
164 |
} |
} |
165 |
|
|
168 |
|
|
169 |
switch(this->m_storage) { |
switch(this->m_storage) { |
170 |
case StorageInt: |
case StorageInt: |
171 |
#warning MatrixSolution<=>IntSolution |
m_sol = new SolutionInt(m_sizeSelector->value()); |
|
m_sol = new MatrixSolution(m_sizeSelector->value()); |
|
172 |
break; |
break; |
173 |
case StorageMatrix: |
case StorageMatrix: |
174 |
m_sol = new MatrixSolution(m_sizeSelector->value()); |
m_sol = new SolutionMatrix(m_sizeSelector->value()); |
175 |
break; |
break; |
176 |
} |
} |
177 |
|
|
178 |
|
|
179 |
m_elapsed.start(); |
m_elapsed.start(); |
180 |
m_time.start(); |
m_time.start(); |
181 |
m_queens = new Queens(this, m_solutions, m_sizeSelector->value() ,false); |
m_queens = new Queens(this, m_sol, m_solutions, m_sizeSelector->value() ,false); |
182 |
m_queens->start(); |
m_queens->start(); |
183 |
} |
} |
184 |
|
|
226 |
{ |
{ |
227 |
int index = m_list->currentItem(); |
int index = m_list->currentItem(); |
228 |
Solution* sol = m_solutions->solution( index ); |
Solution* sol = m_solutions->solution( index ); |
229 |
m_board->setMatrix( *sol ); |
m_board->setMatrix( sol ); |
230 |
} |
} |
231 |
|
|
232 |
void QueensMain::resize(int size) |
void QueensMain::resize(int size) |