--- queensgui/src/queensmain.cpp 2007/07/20 09:54:09 6 +++ queensgui/src/queensmain.cpp 2007/07/28 08:49:40 17 @@ -40,6 +40,7 @@ #include "containerlist.h" #include "containerhash.h" #include "containermnvector.h" +#include "containerminimalvector.h" #include "config.h" @@ -82,8 +83,8 @@ m_sizeSelector->setValue( 8 ); m_board->setSize( 8 ); - m_storage = StorageMatrix; - m_sortalgo = SortList; + m_storage = StorageInt; + m_sortalgo = SortMinimalVector; m_solutions = NULL; m_queens = NULL; m_sol = NULL; @@ -129,6 +130,11 @@ QueensMain::~QueensMain() { delete m_board; + + if (m_solutions != NULL) + delete m_solutions; + if (m_sol != NULL) + delete m_sol; } void QueensMain::start() @@ -144,6 +150,7 @@ if (m_queens != NULL) { m_queens->wait(); delete m_queens; + m_queens = 0; } if (m_solutions != NULL) @@ -161,6 +168,9 @@ case SortMNVector: m_solutions = new ContainerMNVector(this); break; + case SortMinimalVector: + m_solutions = new ContainerMinimalVector(this); + break; } if (m_sol != NULL) @@ -256,7 +266,7 @@ void QueensMain::uniqueSolutions() { - m_totalcount = m_solutions->numSolutions(); + m_totalcount = m_solutions->totalSolutions(); m_status->setText( QString("sorting ") + QString::number(m_totalcount,10).append(" solutions...") ); m_elapsed.restart(); @@ -279,7 +289,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 ); @@ -287,11 +297,13 @@ contextMenu->insertItem("Vector", this, SLOT( sortVector() ), 0, 2); contextMenu->insertItem("Hash", this, SLOT( sortHash() ), 0, 3); contextMenu->insertItem("M*N Vector", this, SLOT(sortMNVector()), 0, 4); + contextMenu->insertItem("Minimal Vector", this, SLOT(sortMinimalVector()), 0, 5); - 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); + contextMenu->insertItem("Matrix Solution", this, SLOT( storageMatrix() ), 0, 6); + contextMenu->insertItem("Int Solution", this, SLOT( storageInt() ), 0, 7); switch (m_sortalgo) { @@ -307,14 +319,17 @@ case SortMNVector: contextMenu->setItemChecked( 4, true); break; + case SortMinimalVector: + contextMenu->setItemChecked( 5, true); + break; } switch (m_storage) { case StorageMatrix: - contextMenu->setItemChecked(5, true); + contextMenu->setItemChecked(6, true); break; case StorageInt: - contextMenu->setItemChecked(6, true); + contextMenu->setItemChecked(7, true); break; } @@ -355,6 +370,12 @@ m_sortalgo = SortMNVector; } +void QueensMain::sortMinimalVector() +{ + m_sortalgo = SortMinimalVector; +} + + void QueensMain::storageInt() { m_storage = StorageInt; @@ -366,3 +387,4 @@ } +