@@ -162,16 +162,14 @@ void CategoryFactory::reset()
162
162
163
163
void CategoryFactory::setParents ()
164
164
{
165
- for (std::vector<Category>::iterator iter = m_Categories.begin ();
166
- iter != m_Categories.end (); ++iter) {
167
- iter->setHasChildren (false );
165
+ for (auto & category : m_Categories) {
166
+ category.setHasChildren (false );
168
167
}
169
168
170
- for (std::vector<Category>::const_iterator categoryIter = m_Categories.begin ();
171
- categoryIter != m_Categories.end (); ++categoryIter) {
172
- if (categoryIter->parentID () != 0 ) {
169
+ for (const auto & category : m_Categories) {
170
+ if (category.parentID () != 0 ) {
173
171
std::map<int , unsigned int >::const_iterator iter =
174
- m_IDMap.find (categoryIter-> parentID ());
172
+ m_IDMap.find (category. parentID ());
175
173
if (iter != m_IDMap.end ()) {
176
174
m_Categories[iter->second ].setHasChildren (true );
177
175
}
@@ -195,17 +193,16 @@ void CategoryFactory::saveCategories()
195
193
}
196
194
197
195
categoryFile.resize (0 );
198
- for (std::vector<Category>::const_iterator iter = m_Categories.begin ();
199
- iter != m_Categories.end (); ++iter) {
200
- if (iter->ID () == 0 ) {
196
+ for (const auto & category : m_Categories) {
197
+ if (category.ID () == 0 ) {
201
198
continue ;
202
199
}
203
200
QByteArray line;
204
- line.append (QByteArray::number (iter-> ID ()))
201
+ line.append (QByteArray::number (category. ID ()))
205
202
.append (" |" )
206
- .append (iter-> name ().toUtf8 ())
203
+ .append (category. name ().toUtf8 ())
207
204
.append (" |" )
208
- .append (QByteArray::number (iter-> parentID ()))
205
+ .append (QByteArray::number (category. parentID ()))
209
206
.append (" \n " );
210
207
categoryFile.write (line);
211
208
}
@@ -219,11 +216,11 @@ void CategoryFactory::saveCategories()
219
216
}
220
217
221
218
nexusMapFile.resize (0 );
222
- for (auto iter = m_NexusMap. begin (); iter != m_NexusMap. end (); ++iter ) {
219
+ for (const auto & nexMap : m_NexusMap) {
223
220
QByteArray line;
224
- line.append (QByteArray::number (iter-> second .categoryID ())).append (" |" );
225
- line.append (iter-> second .name ().toUtf8 ()).append (" |" );
226
- line.append (QByteArray::number (iter-> second .ID ())).append (" \n " );
221
+ line.append (QByteArray::number (nexMap. second .categoryID ())).append (" |" );
222
+ line.append (nexMap. second .name ().toUtf8 ()).append (" |" );
223
+ line.append (QByteArray::number (nexMap. second .ID ())).append (" \n " );
227
224
nexusMapFile.write (line);
228
225
}
229
226
nexusMapFile.close ();
@@ -269,7 +266,7 @@ void CategoryFactory::addCategory(int id, const QString& name,
269
266
const std::vector<NexusCategory>& nexusCats,
270
267
int parentID)
271
268
{
272
- for (auto nexusCat : nexusCats) {
269
+ for (const auto & nexusCat : nexusCats) {
273
270
m_NexusMap.insert_or_assign (nexusCat.ID (), nexusCat);
274
271
m_NexusMap.at (nexusCat.ID ()).setCategoryID (id);
275
272
}
@@ -279,9 +276,9 @@ void CategoryFactory::addCategory(int id, const QString& name,
279
276
}
280
277
281
278
void CategoryFactory::setNexusCategories (
282
- std::vector<CategoryFactory::NexusCategory>& nexusCats)
279
+ const std::vector<CategoryFactory::NexusCategory>& nexusCats)
283
280
{
284
- for (auto nexusCat : nexusCats) {
281
+ for (const auto & nexusCat : nexusCats) {
285
282
m_NexusMap.emplace (nexusCat.ID (), nexusCat);
286
283
}
287
284
0 commit comments