diff --git a/cell.cpp b/cell.cpp index 4fe652f52c611b5adb683144377f03447cc275d9..d448ede2b5c9460d3c3ac82e4300706552108acb 100644 --- a/cell.cpp +++ b/cell.cpp @@ -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++; diff --git a/cell.h b/cell.h index 15885400ab4c161e9cce484b96602721820f5ea4..808e5a163e2d37ab48c21f868cd569eca5a80b8a 100644 --- a/cell.h +++ b/cell.h @@ -17,6 +17,7 @@ public: private: QPushButton *m_states[9]; QPushButton *m_number; + std::array<int,9> m_blocked; signals: void update(int x); diff --git a/window.cpp b/window.cpp index 90141c95001d8895fe7c11b25d1dced91d46199d..b055b889300a12cabc7261ba8a7993cefc2fc51b 100644 --- a/window.cpp +++ b/window.cpp @@ -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) {