From 48e8331eafa8a92acaf2335c0e6e1a81b392405b Mon Sep 17 00:00:00 2001
From: Silas Dohm <silas.dohm@stud.hs-bochum.de>
Date: Sat, 30 Jul 2022 12:47:51 +0200
Subject: [PATCH] cell blocked array added

---
 cell.cpp   | 13 +++++++++++--
 cell.h     |  1 +
 window.cpp |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/cell.cpp b/cell.cpp
index 4fe652f..d448ede 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 1588540..808e5a1 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 90141c9..b055b88 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)
     {
-- 
GitLab