@@ -78,7 +78,7 @@ void Course::setId(int id)
7878/* !
7979 Sets the course name to \a name.
8080*/
81- void Course::setName (QString name)
81+ void Course::setName (const QString & name)
8282{
8383 m_name = name;
8484}
@@ -88,7 +88,7 @@ QString Course::getTitle() const
8888 return m_title;
8989}
9090
91- void Course::setTitle (QString title)
91+ void Course::setTitle (const QString & title)
9292{
9393 m_title = title;
9494}
@@ -125,15 +125,15 @@ Exercise Course::getExercise(const int id)
125125 If no such \l Exercise object is found in the \l Course object's collection,
126126 the function returns a new \l Exercise object instantiated by \l Exercise::Exercise().
127127*/
128- Exercise Course::getExercise (const Exercise ex)
128+ Exercise Course::getExercise (const Exercise & ex)
129129{
130130 return m_exercises.value (ex.getId (), Exercise ());
131131}
132132
133133/* !
134134 Adds parameter \a ex to the \l Course object's \l Exercise collection.
135135*/
136- void Course::addExercise (const Exercise ex)
136+ void Course::addExercise (const Exercise & ex)
137137{
138138 m_exercises.insert (ex.getId (), ex);
139139}
@@ -142,7 +142,7 @@ void Course::addExercise(const Exercise ex)
142142 Returns \c true if the \l Course object's collection contains an \l Exercise
143143 object with the same ID as that of parameter \a ex; otherwise returns \c false.
144144*/
145- bool Course::hasExercise (Exercise ex)
145+ bool Course::hasExercise (const Exercise & ex)
146146{
147147 return m_exercises.contains (ex.getId ());
148148}
@@ -153,7 +153,7 @@ bool Course::hasExercise(Exercise ex)
153153 The ID and name fields of the \l Course object are set to the values
154154 extracted from \a jsonCourse.
155155 */
156- Course Course::fromJson (const QJsonObject jsonCourse)
156+ Course Course::fromJson (const QJsonObject & jsonCourse)
157157{
158158 Course course;
159159 course.setTitle (jsonCourse[" title" ].toString ());
@@ -168,12 +168,12 @@ Course Course::fromJson(const QJsonObject jsonCourse)
168168 object includes setting the course name and ID to the values specified in \a
169169 settings. If \a settings doesn't contain the appropriate values, defaults are used.
170170 */
171- Course Course::fromQSettings (QSettings * settings)
171+ Course Course::fromQSettings (QSettings & settings)
172172{
173173 Course course;
174- course.setName (settings-> value (" courseName" , " " ).toString ());
175- course.setTitle (settings-> value (" courseTitle" , " " ).toString ());
176- course.setId (settings-> value (" courseId" , -1 ).toInt ());
174+ course.setName (settings. value (" courseName" , " " ).toString ());
175+ course.setTitle (settings. value (" courseTitle" , " " ).toString ());
176+ course.setId (settings. value (" courseId" , -1 ).toInt ());
177177 return course;
178178}
179179
@@ -182,11 +182,11 @@ Course Course::fromQSettings(QSettings *settings)
182182 the \l Course parameter \a c into the \l {http://doc.qt.io/qt-5/qsettings.html}
183183 {QSettings} object pointed to by parameter \a settings.
184184*/
185- void Course::toQSettings (QSettings * settings, Course c)
185+ void Course::toQSettings (QSettings & settings, const Course & c)
186186{
187- settings-> setValue (" courseName" , c.getName ());
188- settings-> setValue (" courseTitle" , c.getTitle ());
189- settings-> setValue (" courseId" , c.getId ());
187+ settings. setValue (" courseName" , c.getName ());
188+ settings. setValue (" courseTitle" , c.getTitle ());
189+ settings. setValue (" courseId" , c.getId ());
190190}
191191
192192/* !
@@ -197,19 +197,19 @@ void Course::toQSettings(QSettings *settings, Course c)
197197 list, they are preserved. Any new exercises from \a settings are added
198198 to the existing ones.
199199*/
200- void Course::exerciseListFromQSettings (QSettings * settings)
201- {
202- settings-> beginGroup (m_name);
203- QStringList exerciseList = settings-> childGroups ();
204- foreach ( QString exercise, exerciseList) {
205- settings-> beginGroup (exercise);
206- if (!QDir (settings-> value (" location" , " ?" ).toString ()).exists () ) {
207- settings-> endGroup ();
200+ void Course::exerciseListFromQSettings (QSettings & settings)
201+ {
202+ settings. beginGroup (m_name);
203+ QStringList exerciseList = settings. childGroups ();
204+ for ( const QString & exercise : exerciseList) {
205+ settings. beginGroup (exercise);
206+ if (!QDir (settings. value (" location" , " ?" ).toString ()).exists () ) {
207+ settings. endGroup ();
208208 continue ;
209209 }
210210 Exercise ex = Exercise::fromQSettings (settings, exercise);
211- settings-> endGroup ();
211+ settings. endGroup ();
212212 addExercise (ex);
213213 }
214- settings-> endGroup ();
214+ settings. endGroup ();
215215}
0 commit comments