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 "solutionmatrix.h" |
37 |
|
#include "solutionint.h" |
38 |
|
|
39 |
#include "containervector.h" |
#include "containervector.h" |
40 |
#include "containerlist.h" |
#include "containerlist.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) |
129 |
QueensMain::~QueensMain() |
QueensMain::~QueensMain() |
130 |
{ |
{ |
131 |
delete m_board; |
delete m_board; |
132 |
|
|
133 |
|
if (m_solutions != NULL) |
134 |
|
delete m_solutions; |
135 |
|
if (m_sol != NULL) |
136 |
|
delete m_sol; |
137 |
} |
} |
138 |
|
|
139 |
void QueensMain::start() |
void QueensMain::start() |
144 |
m_list->clear(); |
m_list->clear(); |
145 |
m_status->setText( QString("Searching ...") ); |
m_status->setText( QString("Searching ...") ); |
146 |
|
|
147 |
|
m_board->setMatrix(0); |
148 |
|
|
149 |
if (m_queens != NULL) { |
if (m_queens != NULL) { |
150 |
m_queens->wait(); |
m_queens->wait(); |
151 |
delete m_queens; |
delete m_queens; |
152 |
|
m_queens = 0; |
153 |
} |
} |
154 |
|
|
155 |
if (m_solutions != NULL) |
if (m_solutions != NULL) |
174 |
|
|
175 |
switch(this->m_storage) { |
switch(this->m_storage) { |
176 |
case StorageInt: |
case StorageInt: |
177 |
#warning MatrixSolution<=>IntSolution |
m_sol = new SolutionInt(m_sizeSelector->value()); |
|
m_sol = new MatrixSolution(m_sizeSelector->value()); |
|
178 |
break; |
break; |
179 |
case StorageMatrix: |
case StorageMatrix: |
180 |
m_sol = new MatrixSolution(m_sizeSelector->value()); |
m_sol = new SolutionMatrix(m_sizeSelector->value()); |
181 |
break; |
break; |
182 |
} |
} |
183 |
|
|
285 |
{ |
{ |
286 |
QPopupMenu *contextMenu = new QPopupMenu( this ); |
QPopupMenu *contextMenu = new QPopupMenu( this ); |
287 |
contextMenu->setCheckable( true ); |
contextMenu->setCheckable( true ); |
288 |
QLabel *sortCaption = new QLabel("<b><i>Sort algorithm</i></b>", this); |
QLabel *sortCaption = new QLabel("<b><i>Container class</i></b>", this); |
289 |
sortCaption->setAlignment( Qt::AlignCenter ); |
sortCaption->setAlignment( Qt::AlignCenter ); |
290 |
contextMenu->insertItem( sortCaption ); |
contextMenu->insertItem( sortCaption ); |
291 |
|
|
294 |
contextMenu->insertItem("Hash", this, SLOT( sortHash() ), 0, 3); |
contextMenu->insertItem("Hash", this, SLOT( sortHash() ), 0, 3); |
295 |
contextMenu->insertItem("M*N Vector", this, SLOT(sortMNVector()), 0, 4); |
contextMenu->insertItem("M*N Vector", this, SLOT(sortMNVector()), 0, 4); |
296 |
|
|
297 |
QLabel *storageCaption = new QLabel("<b><i>Storage class</i></b>", this); |
QLabel *storageCaption = new QLabel("<b><i>Solution class</i></b>", this); |
298 |
|
storageCaption->setAlignment( Qt::AlignCenter ); |
299 |
contextMenu->insertItem( storageCaption ); |
contextMenu->insertItem( storageCaption ); |
300 |
contextMenu->insertItem("Matrix Solution", this, SLOT( storageMatrix() ), 0, 5); |
contextMenu->insertItem("Matrix Solution", this, SLOT( storageMatrix() ), 0, 5); |
301 |
contextMenu->insertItem("Int Solution", this, SLOT( storageInt() ), 0, 6); |
contextMenu->insertItem("Int Solution", this, SLOT( storageInt() ), 0, 6); |