Skip to content
Snippets Groups Projects
Commit 48e8331e authored by Silas Dohm's avatar Silas Dohm
Browse files

cell blocked array added

parent 315e79d9
Branches
No related tags found
1 merge request!1Master
......@@ -10,7 +10,6 @@ Cell::Cell(QWidget *parent) : QWidget(parent)
setAutoFillBackground(true);
setStyleSheet("background-color:gray;");
setFixedSize(100, 100);
// qInfo("width=%d,height=%d",parent->width(),height());
float w = width() / 3.0;
float h = height() / 3.0;
QSignalMapper *mapper = new QSignalMapper(this);
......@@ -22,6 +21,7 @@ Cell::Cell(QWidget *parent) : QWidget(parent)
m_states[i]->setStyleSheet("border:none");
connect(m_states[i], SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(m_states[i], i);
m_blocked[i] = 0;
}
m_number = new QPushButton(this);
m_number->setFixedSize(100, 100);
......@@ -32,6 +32,12 @@ Cell::Cell(QWidget *parent) : QWidget(parent)
}
Cell::Cell(const Cell &old_obj){
possibleStates = old_obj.possibleStates;
collapsed = old_obj.collapsed;
index = old_obj.index;
m_number = new QPushButton(old_obj.m_number);
//m_states = old_obj.m_states;
qInfo("aaa");
}
void Cell::collapse(int x)
......@@ -50,11 +56,14 @@ void Cell::removeOption(int x)
possibleStates--;
index.erase(std::find(index.begin(), index.end(), x));
}
m_blocked[x] ++;
}
void Cell::addOption(int x)
{
if (!m_states[x]->isEnabled())
m_blocked[x] --;
//if (!m_states[x]->isEnabled())
if (m_blocked[x]<1)
{
m_states[x]->setDisabled(false);
possibleStates++;
......
......@@ -17,6 +17,7 @@ public:
private:
QPushButton *m_states[9];
QPushButton *m_number;
std::array<int,9> m_blocked;
signals:
void update(int x);
......
......@@ -71,7 +71,7 @@ Window::Window(QWidget *parent)
void Window::solveButtonClicked()
{
std::array<Cell,81> start = m_cell;
// std::array<Cell,81> start = m_cell;
srand(time(NULL));
while (1)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment