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
25f14794
Commit
25f14794
authored
Jan 21, 2021
by
Frédéric Brière
Browse files
radselect: Merge last button column directly in mapRadicalsByStrokes()
parent
be120daf
Changes
3
Hide whitespace changes
Inline
Side-by-side
radselect/buttongrid.cpp
View file @
25f14794
...
...
@@ -57,25 +57,14 @@ void ButtonGrid::buildRadicalButtons()
}
//Get a list of radicals (organized by strokes)
QMultiMap
<
int
,
Radical
>
*
radicalMap
=
m_radicalInfo
->
mapRadicalsByStrokes
();
QMultiMap
<
int
,
Radical
>
*
radicalMap
=
m_radicalInfo
->
mapRadicalsByStrokes
(
number_of_radical_columns
);
QList
<
int
>
radicalStrokeCounts
=
radicalMap
->
uniqueKeys
();
//Now create all the buttons
unsigned
int
last_column
=
0
;
int
row_index
=
1
;
foreach
(
int
strokeCount
,
radicalStrokeCounts
)
{
//(0-based column index)
unsigned
int
column_index
=
strokeCount
-
1
;
if
(
column_index
>=
number_of_radical_columns
)
{
column_index
=
number_of_radical_columns
-
1
;
}
//If we're starting a new column, reset the row
if
(
last_column
!=
column_index
)
{
row_index
=
1
;
}
int
row_index
=
1
;
QList
<
Radical
>
radicals
=
radicalMap
->
values
(
strokeCount
);
std
::
sort
(
radicals
.
begin
(),
radicals
.
end
()
);
...
...
@@ -93,8 +82,6 @@ void ButtonGrid::buildRadicalButtons()
//Add this button to our list
m_buttons
.
insert
(
radical
,
button
);
}
last_column
=
column_index
;
}
delete
radicalMap
;
setLayout
(
grid
);
...
...
radselect/radicalfile.cpp
View file @
25f14794
...
...
@@ -152,12 +152,17 @@ bool RadicalFile::loadKanjidic( const QString &kanjidic )
return
true
;
}
QMultiMap
<
int
,
Radical
>*
RadicalFile
::
mapRadicalsByStrokes
()
const
QMultiMap
<
int
,
Radical
>*
RadicalFile
::
mapRadicalsByStrokes
(
int
max_strokes
)
const
{
QMultiMap
<
int
,
Radical
>
*
result
=
new
QMultiMap
<
int
,
Radical
>
();
foreach
(
const
Radical
&
rad
,
m_radicals
)
{
result
->
insert
(
m_radicals
[
rad
].
strokes
(),
m_radicals
[
rad
]
);
int
strokes
=
rad
.
strokes
();
if
(
(
max_strokes
>
0
)
&&
(
strokes
>
max_strokes
)
)
{
strokes
=
max_strokes
;
}
result
->
insert
(
strokes
,
rad
);
}
return
result
;
}
...
...
radselect/radicalfile.h
View file @
25f14794
...
...
@@ -25,7 +25,7 @@ class RadicalFile
QSet
<
Kanji
>
kanjiContainingRadicals
(
QSet
<
QString
>
&
radicalList
)
const
;
bool
loadRadicalFile
(
QString
&
radkfile
);
bool
loadKanjidic
(
const
QString
&
kanjidic
);
QMultiMap
<
int
,
Radical
>
*
mapRadicalsByStrokes
()
const
;
QMultiMap
<
int
,
Radical
>
*
mapRadicalsByStrokes
(
int
max_strokes
=
0
)
const
;
QSet
<
QString
>
radicalsInKanji
(
QSet
<
Kanji
>
&
kanjiList
)
const
;
private:
...
...
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