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

removed delay/slider

parent adbac78b
Branches
No related tags found
No related merge requests found
...@@ -17,12 +17,6 @@ Window::Window(QWidget *parent) ...@@ -17,12 +17,6 @@ Window::Window(QWidget *parent)
clearButton = new QPushButton("Clear", this); clearButton = new QPushButton("Clear", this);
connect(clearButton, SIGNAL(clicked()), this, SLOT(clearButtonClicked())); connect(clearButton, SIGNAL(clicked()), this, SLOT(clearButtonClicked()));
slider = new QSlider(this);
slider->setRange(0, 1000);
slider->setOrientation(Qt::Horizontal);
slider->setValue(delayTime);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
horizontalLayout = new QHBoxLayout(this); horizontalLayout = new QHBoxLayout(this);
verticalLayout = new QVBoxLayout(); verticalLayout = new QVBoxLayout();
layout = new QGridLayout(); layout = new QGridLayout();
...@@ -33,7 +27,6 @@ Window::Window(QWidget *parent) ...@@ -33,7 +27,6 @@ Window::Window(QWidget *parent)
verticalLayout->addItem(spacer[2]); verticalLayout->addItem(spacer[2]);
verticalLayout->addWidget(solveButton); verticalLayout->addWidget(solveButton);
verticalLayout->addWidget(slider);
verticalLayout->addWidget(clearButton); verticalLayout->addWidget(clearButton);
horizontalLayout->addLayout(layout, 5); horizontalLayout->addLayout(layout, 5);
horizontalLayout->addLayout(verticalLayout, 1); horizontalLayout->addLayout(verticalLayout, 1);
...@@ -83,8 +76,6 @@ void Window::solveButtonClicked() ...@@ -83,8 +76,6 @@ void Window::solveButtonClicked()
srand(time(NULL)); // random seed srand(time(NULL)); // random seed
while (1) while (1)
{ {
repaint(); // draw cells again
delay(delayTime);
if (backtracking) if (backtracking)
{ {
hist.back().cell->collapsedCellClicked(); hist.back().cell->collapsedCellClicked();
...@@ -99,8 +90,6 @@ void Window::solveButtonClicked() ...@@ -99,8 +90,6 @@ void Window::solveButtonClicked()
} }
backtracking = false; backtracking = false;
int rndNr = rand() % validNrs.size(); // choose a random number; int rndNr = rand() % validNrs.size(); // choose a random number;
repaint(); // draw cells again
delay(delayTime);
hist.back().cell->collapse(validNrs[rndNr]); // collapse cell with chosen number; hist.back().cell->collapse(validNrs[rndNr]); // collapse cell with chosen number;
hist.back().blocked[validNrs[rndNr]]++; hist.back().blocked[validNrs[rndNr]]++;
} }
...@@ -128,7 +117,6 @@ void Window::solveButtonClicked() ...@@ -128,7 +117,6 @@ void Window::solveButtonClicked()
else if (minEtropy == 0) else if (minEtropy == 0)
{ {
qInfo("backtracking");
backtracking = true; backtracking = true;
continue; continue;
} }
...@@ -146,14 +134,6 @@ void Window::solveButtonClicked() ...@@ -146,14 +134,6 @@ void Window::solveButtonClicked()
} }
} }
} }
inline void Window::delay(int millisecondsWait)
{
QEventLoop loop;
QTimer t;
t.connect(&t, &QTimer::timeout, &loop, &QEventLoop::quit);
t.start(millisecondsWait);
loop.exec();
}
void Window::clearButtonClicked() void Window::clearButtonClicked()
{ {
for (auto &x : grid) for (auto &x : grid)
...@@ -163,8 +143,3 @@ void Window::clearButtonClicked() ...@@ -163,8 +143,3 @@ void Window::clearButtonClicked()
} }
return; return;
} }
\ No newline at end of file
void Window::setValue(int s)
{
delayTime = s;
return;
}
\ No newline at end of file
...@@ -8,7 +8,6 @@ class QHBoxLayout; ...@@ -8,7 +8,6 @@ class QHBoxLayout;
class QVBoxLayout; class QVBoxLayout;
class QGridLayout; class QGridLayout;
class QPushButton; class QPushButton;
class QSlider;
class Window : public QWidget class Window : public QWidget
{ {
Q_OBJECT Q_OBJECT
...@@ -18,9 +17,7 @@ public: ...@@ -18,9 +17,7 @@ public:
private: private:
QPushButton *clearButton; QPushButton *clearButton;
QPushButton *solveButton; QPushButton *solveButton;
QSlider *slider;
std::array<Cell, 81> grid; std::array<Cell, 81> grid;
int delayTime = 300;
QSpacerItem *spacer[3]; QSpacerItem *spacer[3];
QHBoxLayout *horizontalLayout; QHBoxLayout *horizontalLayout;
QVBoxLayout *verticalLayout; QVBoxLayout *verticalLayout;
...@@ -36,10 +33,8 @@ private: ...@@ -36,10 +33,8 @@ private:
blocked[choice] ++; blocked[choice] ++;
} }
}; };
inline void delay(int millisecondsWait);
private slots: private slots:
void setValue(int s);
void solveButtonClicked(); void solveButtonClicked();
void clearButtonClicked(); void clearButtonClicked();
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment