Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Kiten
Commits
be120daf
Commit
be120daf
authored
Jan 21, 2021
by
Frédéric Brière
Browse files
radselect: Display radicals in the same order as listed in radkfile
parent
27512846
Changes
4
Hide whitespace changes
Inline
Side-by-side
radselect/buttongrid.cpp
View file @
be120daf
...
...
@@ -58,14 +58,14 @@ void ButtonGrid::buildRadicalButtons()
//Get a list of radicals (organized by strokes)
QMultiMap
<
int
,
Radical
>
*
radicalMap
=
m_radicalInfo
->
mapRadicalsByStrokes
();
Q
MultiMap
<
int
,
R
adical
>::
const_iterator
it
=
radicalMap
->
constBegin
();
Q
List
<
int
>
r
adical
StrokeCounts
=
radicalMap
->
uniqueKeys
();
//Now create all the buttons
unsigned
int
last_column
=
0
;
int
row_index
=
1
;
while
(
it
!=
radicalMap
->
constEnd
()
)
foreach
(
i
n
t
strokeCount
,
radicalStrokeCounts
)
{
//
For each radical, figure out which slot it goes in
(0-based column index)
unsigned
int
column_index
=
it
.
key
()
-
1
;
//(0-based column index)
unsigned
int
column_index
=
strokeCount
-
1
;
if
(
column_index
>=
number_of_radical_columns
)
{
column_index
=
number_of_radical_columns
-
1
;
...
...
@@ -77,20 +77,24 @@ void ButtonGrid::buildRadicalButtons()
row_index
=
1
;
}
//Make the button
RadicalButton
*
button
=
new
RadicalButton
(
*
it
,
this
);
grid
->
addWidget
(
button
,
row_index
++
,
column_index
);
//Bind slots/signals for this button
connect
(
button
,
&
RadicalButton
::
userClicked
,
this
,
&
ButtonGrid
::
radicalClicked
);
connect
(
this
,
&
ButtonGrid
::
clearButtonSelections
,
button
,
&
RadicalButton
::
resetButton
);
//Add this button to our list
m_buttons
.
insert
(
*
it
,
button
);
QList
<
Radical
>
radicals
=
radicalMap
->
values
(
strokeCount
);
std
::
sort
(
radicals
.
begin
(),
radicals
.
end
()
);
foreach
(
const
Radical
&
radical
,
radicals
)
{
//Make the button
RadicalButton
*
button
=
new
RadicalButton
(
radical
,
this
);
grid
->
addWidget
(
button
,
row_index
++
,
column_index
);
//Bind slots/signals for this button
connect
(
button
,
&
RadicalButton
::
userClicked
,
this
,
&
ButtonGrid
::
radicalClicked
);
connect
(
this
,
&
ButtonGrid
::
clearButtonSelections
,
button
,
&
RadicalButton
::
resetButton
);
//Add this button to our list
m_buttons
.
insert
(
radical
,
button
);
}
last_column
=
column_index
;
++
it
;
}
delete
radicalMap
;
setLayout
(
grid
);
...
...
radselect/radical.cpp
View file @
be120daf
...
...
@@ -12,9 +12,10 @@ Radical::Radical()
{
}
Radical
::
Radical
(
const
QString
&
irad
,
unsigned
int
strokes
)
Radical
::
Radical
(
const
QString
&
irad
,
unsigned
int
strokes
,
unsigned
int
index
)
:
QString
(
irad
.
at
(
0
)
)
,
strokeCount
(
strokes
)
,
idx
(
index
)
{
}
...
...
@@ -35,5 +36,5 @@ unsigned int Radical::strokes() const
bool
Radical
::
operator
<
(
const
Radical
&
other
)
const
{
return
this
->
strokeCount
<
other
.
strokeCount
;
return
this
->
idx
<
other
.
idx
;
}
radselect/radical.h
View file @
be120daf
...
...
@@ -16,7 +16,8 @@ class Radical : public QString
public:
Radical
();
explicit
Radical
(
const
QString
&
irad
,
unsigned
int
strokes
=
0
);
,
unsigned
int
strokes
=
0
,
unsigned
int
index
=
0
);
const
QSet
<
QString
>&
getKanji
()
const
;
void
addKanji
(
const
QSet
<
QString
>
&
newKanji
);
...
...
@@ -26,6 +27,7 @@ class Radical : public QString
protected:
unsigned
int
strokeCount
;
unsigned
int
idx
;
QSet
<
QString
>
kanji
;
QSet
<
QString
>
components
;
};
...
...
radselect/radicalfile.cpp
View file @
be120daf
...
...
@@ -82,7 +82,8 @@ bool RadicalFile::loadRadicalFile( QString &radkfile )
delete
newestRadical
;
QStringList
lineElements
=
line
.
split
(
QRegExp
(
QStringLiteral
(
"
\\
s+"
)
)
);
newestRadical
=
new
Radical
(
lineElements
.
at
(
1
)
,
lineElements
.
at
(
2
).
toUInt
()
);
,
lineElements
.
at
(
2
).
toUInt
()
,
m_radicals
.
size
()
);
}
else
if
(
newestRadical
!=
nullptr
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment