Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sudoku solver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Dohm
sudoku solver
Merge requests
!3
responsive design
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
responsive design
visualize
into
main
Overview
0
Commits
3
Pipelines
0
Changes
4
Merged
Silas Dohm
requested to merge
visualize
into
main
2 years ago
Overview
0
Commits
3
Pipelines
0
Changes
4
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
e0473e3c
3 commits,
2 years ago
4 files
+
77
−
52
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
cell.cpp
+
36
−
22
View file @ e0473e3c
Edit in single-file editor
Open in Web IDE
#include
"cell.h"
#include
"cell.h"
#include
<QPushButton>
#include
<QPushButton>
#include
<QToolButton>
#include
<QDebug>
#include
<QDebug>
#include
<QSignalMapper>
#include
<QSignalMapper>
#include
<QGridLayout>
#include
<QStackedWidget>
#include
<QGroupBox>
Cell
::
Cell
(
QWidget
*
parent
)
:
QWidget
(
parent
)
Cell
::
Cell
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
{
// Set size of the window
// Create and position the button
setAutoFillBackground
(
true
);
setStyleSheet
(
"background-color:gray;"
);
setFixedSize
(
100
,
100
);
float
w
=
width
()
/
3.0
;
float
h
=
height
()
/
3.0
;
QSignalMapper
*
mapper
=
new
QSignalMapper
(
this
);
QSignalMapper
*
mapper
=
new
QSignalMapper
(
this
);
connect
(
mapper
,
SIGNAL
(
mapped
(
int
)),
this
,
SLOT
(
collapse
(
int
)));
connect
(
mapper
,
SIGNAL
(
mapped
(
int
)),
this
,
SLOT
(
collapse
(
int
)));
QGroupBox
*
groupBox
=
new
QGroupBox
();
QGridLayout
*
layout
=
new
QGridLayout
();
setStyleSheet
(
"border: 1px solid #1e282c; border-radius: 0px;background-color:#52585d;"
);
for
(
char
i
=
0
;
i
<
9
;
i
++
)
for
(
char
i
=
0
;
i
<
9
;
i
++
)
{
{
m_states
[
i
]
=
new
QPushButton
(
QString
::
number
(
i
+
1
),
this
);
m_states
[
i
]
=
new
QPushButton
(
QString
::
number
(
i
+
1
),
this
);
m_states
[
i
]
->
setGeometry
(
i
%
3
*
w
,
i
/
3
*
h
,
w
,
h
);
layout
->
addWidget
(
m_states
[
i
],
i
%
3
,
i
/
3
);
m_states
[
i
]
->
setStyleSheet
(
"border:none"
);
m_states
[
i
]
->
setStyleSheet
(
"border:none"
);
connect
(
m_states
[
i
],
SIGNAL
(
clicked
()),
mapper
,
SLOT
(
map
()));
connect
(
m_states
[
i
],
SIGNAL
(
clicked
()),
mapper
,
SLOT
(
map
()));
mapper
->
setMapping
(
m_states
[
i
],
i
);
mapper
->
setMapping
(
m_states
[
i
],
i
);
m_blocked
[
i
]
=
0
;
m_blocked
[
i
]
=
0
;
}
}
groupBox
->
setLayout
(
layout
);
m_number
=
new
QPushButton
(
this
);
m_number
=
new
QPushButton
(
this
);
m_number
->
setFixedSize
(
100
,
100
);
m_number
->
setStyleSheet
(
"font-size:44px"
);
m_number
->
hide
();
connect
(
m_number
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
un
()));
connect
(
m_number
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
un
()));
m_stackedWidget
=
new
QStackedWidget
(
this
);
m_stackedWidget
->
addWidget
(
groupBox
);
m_stackedWidget
->
addWidget
(
m_number
);
setMinimumSize
(
70
,
70
);
}
void
Cell
::
resizeEvent
(
QResizeEvent
*
event
)
{
QWidget
::
resizeEvent
(
event
);
m_stackedWidget
->
setFixedSize
(
this
->
size
());
int
smallest
=
this
->
width
()
<
this
->
height
()
?
this
->
width
()
:
this
->
height
();
m_number
->
setStyleSheet
(
"font-size:"
+
QString
::
number
(
smallest
/
2
)
+
"px;"
);
return
;
}
}
void
Cell
::
collapse
(
int
x
)
void
Cell
::
collapse
(
int
x
)
{
{
collapsed
=
true
;
collapsed
=
true
;
m_
number
->
show
(
);
m_
stackedWidget
->
setCurrentIndex
(
1
);
m_number
->
setText
(
QString
::
number
(
x
+
1
));
m_number
->
setText
(
QString
::
number
(
x
+
1
));
emit
(
update
(
x
));
emit
(
update
(
x
));
}
}
void
Cell
::
removeOption
(
int
x
)
void
Cell
::
removeOption
(
int
x
)
{
{
// states[x]->hide();
if
(
m_blocked
[
x
]
==
0
)
if
(
m_states
[
x
]
->
isEnabled
())
{
{
m_states
[
x
]
->
setText
(
" "
);
m_states
[
x
]
->
setDisabled
(
true
);
m_states
[
x
]
->
setDisabled
(
true
);
possibleStates
--
;
possibleStates
--
;
index
.
erase
(
std
::
find
(
index
.
begin
(),
index
.
end
(),
x
));
index
.
erase
(
std
::
find
(
index
.
begin
(),
index
.
end
(),
x
));
}
}
m_blocked
[
x
]
++
;
m_blocked
[
x
]
++
;
}
}
void
Cell
::
addOption
(
int
x
)
void
Cell
::
addOption
(
int
x
)
{
{
m_blocked
[
x
]
--
;
m_blocked
[
x
]
--
;
//if (!m_states[x]->isEnabled())
//
if (!m_states[x]->isEnabled())
if
(
m_blocked
[
x
]
<
1
)
if
(
m_blocked
[
x
]
<
1
)
{
{
m_states
[
x
]
->
setText
(
QString
::
number
(
x
+
1
));
m_states
[
x
]
->
setDisabled
(
false
);
m_states
[
x
]
->
setDisabled
(
false
);
possibleStates
++
;
possibleStates
++
;
index
.
push_back
(
x
);
index
.
push_back
(
x
);
}
}
}
}
void
Cell
::
un
(
void
){
void
Cell
::
un
(
void
)
{
collapsed
=
false
;
collapsed
=
false
;
m_
number
->
hide
(
);
m_
stackedWidget
->
setCurrentIndex
(
0
);
emit
(
undo
(
m_number
->
text
().
toInt
()
-
1
));
emit
(
undo
(
m_number
->
text
().
toInt
()
-
1
));
}
}
\ No newline at end of file
Loading