--- queensgui/src/queensmain.cpp 2007/07/19 23:44:01 4
+++ queensgui/src/queensmain.cpp 2007/07/20 17:03:41 10
@@ -31,7 +31,10 @@
#include "queensmain.h"
#include "board.h"
#include "queens.h"
+
#include "solution.h"
+#include "solutionmatrix.h"
+#include "solutionint.h"
#include "containervector.h"
#include "containerlist.h"
@@ -40,7 +43,7 @@
#include "config.h"
-#define MatrixSolution Solution
+
QueensMain::QueensMain(QWidget *parent, const char *name)
: QDialog(parent, name)
@@ -79,7 +82,7 @@
m_sizeSelector->setValue( 8 );
m_board->setSize( 8 );
- m_storage = StorageMatrix;
+ m_storage = StorageInt;
m_sortalgo = SortList;
m_solutions = NULL;
m_queens = NULL;
@@ -126,6 +129,11 @@
QueensMain::~QueensMain()
{
delete m_board;
+
+ if (m_solutions != NULL)
+ delete m_solutions;
+ if (m_sol != NULL)
+ delete m_sol;
}
void QueensMain::start()
@@ -136,9 +144,12 @@
m_list->clear();
m_status->setText( QString("Searching ...") );
+ m_board->setMatrix(0);
+
if (m_queens != NULL) {
m_queens->wait();
delete m_queens;
+ m_queens = 0;
}
if (m_solutions != NULL)
@@ -163,11 +174,10 @@
switch(this->m_storage) {
case StorageInt:
- #warning MatrixSolution<=>IntSolution
- m_sol = new MatrixSolution(m_sizeSelector->value());
+ m_sol = new SolutionInt(m_sizeSelector->value());
break;
case StorageMatrix:
- m_sol = new MatrixSolution(m_sizeSelector->value());
+ m_sol = new SolutionMatrix(m_sizeSelector->value());
break;
}
@@ -275,7 +285,7 @@
{
QPopupMenu *contextMenu = new QPopupMenu( this );
contextMenu->setCheckable( true );
- QLabel *sortCaption = new QLabel("Sort algorithm", this);
+ QLabel *sortCaption = new QLabel("Container class", this);
sortCaption->setAlignment( Qt::AlignCenter );
contextMenu->insertItem( sortCaption );
@@ -284,7 +294,8 @@
contextMenu->insertItem("Hash", this, SLOT( sortHash() ), 0, 3);
contextMenu->insertItem("M*N Vector", this, SLOT(sortMNVector()), 0, 4);
- QLabel *storageCaption = new QLabel("Storage class", this);
+ QLabel *storageCaption = new QLabel("Solution class", this);
+ storageCaption->setAlignment( Qt::AlignCenter );
contextMenu->insertItem( storageCaption );
contextMenu->insertItem("Matrix Solution", this, SLOT( storageMatrix() ), 0, 5);
contextMenu->insertItem("Int Solution", this, SLOT( storageInt() ), 0, 6);