Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GCompris
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
27
Issues
27
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
GCompris
Commits
505fc748
Commit
505fc748
authored
Apr 05, 2020
by
Johnny Jazeix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, hide datasets if not in range of difficulty
parent
d29d5f21
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
src/core/ActivityInfo.cpp
src/core/ActivityInfo.cpp
+11
-1
src/core/Dataset.cpp
src/core/Dataset.cpp
+12
-1
src/core/Dataset.h
src/core/Dataset.h
+9
-1
src/core/DialogChooseLevel.qml
src/core/DialogChooseLevel.qml
+2
-1
No files found.
src/core/ActivityInfo.cpp
View file @
505fc748
...
...
@@ -234,12 +234,18 @@ void ActivityInfo::setLevels(const QStringList &levels)
void
ActivityInfo
::
fillDatasets
(
QQmlEngine
*
engine
)
{
quint32
levelMin
=
ApplicationSettings
::
getInstance
()
->
filterLevelMin
();
quint32
levelMax
=
ApplicationSettings
::
getInstance
()
->
filterLevelMax
();
for
(
const
QString
&
level
:
m_levels
)
{
QString
url
=
QString
(
"qrc:/gcompris/src/activities/%1/resource/%2/Data.qml"
).
arg
(
m_name
.
split
(
'/'
)[
0
]).
arg
(
level
);
QQmlComponent
componentRoot
(
engine
,
QUrl
(
url
));
QObject
*
objectRoot
=
componentRoot
.
create
();
if
(
objectRoot
!=
nullptr
)
{
Dataset
*
dataset
=
qobject_cast
<
Dataset
*>
(
objectRoot
);
if
(
levelMin
>
dataset
->
difficulty
()
||
levelMax
<
dataset
->
difficulty
())
{
dataset
->
setEnabled
(
false
);
}
m_datasets
[
level
]
=
dataset
;
}
else
{
qDebug
()
<<
"ERROR: failed to load "
<<
m_name
<<
" "
<<
componentRoot
.
errors
();
...
...
@@ -304,10 +310,14 @@ void ActivityInfo::enableDatasetsBetweenDifficulties(quint32 levelMin, quint32 l
Dataset
*
dataset
=
it
.
value
();
if
(
levelMin
<=
dataset
->
difficulty
()
&&
dataset
->
difficulty
()
<=
levelMax
)
{
newLevels
<<
it
.
key
();
dataset
->
setEnabled
(
true
);
}
else
{
dataset
->
setEnabled
(
false
);
}
}
setCurrentLevels
(
newLevels
);
ApplicationSettings
::
getInstance
()
->
setCurrentLevels
(
m_name
,
m_
l
evels
,
false
);
ApplicationSettings
::
getInstance
()
->
setCurrentLevels
(
m_name
,
m_
currentL
evels
,
false
);
}
Dataset
*
ActivityInfo
::
getDataset
(
const
QString
&
name
)
const
{
...
...
src/core/Dataset.cpp
View file @
505fc748
...
...
@@ -23,7 +23,8 @@
Dataset
::
Dataset
(
QObject
*
parent
)
:
QObject
(
parent
),
m_objective
(
""
),
m_difficulty
(
0
)
m_difficulty
(
0
),
m_enabled
(
true
)
{
}
...
...
@@ -57,3 +58,13 @@ void Dataset::setData(const QVariant &data)
m_data
=
data
;
emit
dataChanged
();
}
bool
Dataset
::
enabled
()
const
{
return
m_enabled
;
}
void
Dataset
::
setEnabled
(
const
bool
&
enabled
)
{
m_enabled
=
enabled
;
emit
enabledChanged
();
}
src/core/Dataset.h
View file @
505fc748
...
...
@@ -56,6 +56,10 @@ class Dataset : public QObject {
* Content of the dataset (json array).
*/
Q_PROPERTY
(
QVariant
data
READ
data
WRITE
setData
NOTIFY
dataChanged
)
/**
* If the dataset is enabled.
*/
Q_PROPERTY
(
bool
enabled
READ
enabled
WRITE
setEnabled
NOTIFY
enabledChanged
)
public:
/// @cond INTERNAL_DOCS
...
...
@@ -66,17 +70,21 @@ public:
quint32
difficulty
()
const
;
void
setDifficulty
(
const
quint32
&
);
QVariant
data
()
const
;
void
setData
(
const
QVariant
&
data
);
void
setData
(
const
QVariant
&
);
bool
enabled
()
const
;
void
setEnabled
(
const
bool
&
);
signals:
void
objectiveChanged
();
void
difficultyChanged
();
void
dataChanged
();
void
enabledChanged
();
private:
QString
m_objective
;
quint32
m_difficulty
;
QVariant
m_data
;
bool
m_enabled
;
};
#endif // DATASET_H
src/core/DialogChooseLevel.qml
View file @
505fc748
...
...
@@ -122,7 +122,7 @@ Rectangle {
difficultiesModel
=
[]
for
(
var
level
in
currentActivity
.
levels
)
{
var
data
=
currentActivity
.
getDataset
(
currentActivity
.
levels
[
level
])
difficultiesModel
.
push
({
"
level
"
:
currentActivity
.
levels
[
level
],
"
objective
"
:
data
.
objective
,
"
difficulty
"
:
data
.
difficulty
,
"
selectedInConfig
"
:
(
chosenLevels
.
indexOf
(
currentActivity
.
levels
[
level
])
!=
-
1
)})
difficultiesModel
.
push
({
"
level
"
:
currentActivity
.
levels
[
level
],
"
enabled
"
:
data
.
enabled
,
"
objective
"
:
data
.
objective
,
"
difficulty
"
:
data
.
difficulty
,
"
selectedInConfig
"
:
(
chosenLevels
.
indexOf
(
currentActivity
.
levels
[
level
])
!=
-
1
)})
}
difficultiesRepeater
.
model
=
difficultiesModel
...
...
@@ -277,6 +277,7 @@ Rectangle {
id
:
difficultiesRepeater
delegate
:
Row
{
height
:
objective
.
height
visible
:
modelData
.
enabled
Image
{
id
:
difficultyIcon
source
:
"
qrc:/gcompris/src/core/resource/difficulty
"
+
...
...
Write
Preview
Markdown
is supported
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