2525
2626#include < Qt>
2727#include < QDialogButtonBox>
28+ #include < QFontInfo>
2829#include < QHeaderView>
2930#include < QLatin1Char>
3031#include < QTreeWidget>
3536#include " core/georeferencing.h"
3637#include " core/map.h"
3738#include " core/objects/object.h"
39+ #include " core/symbols/symbol.h"
3840#include " core/symbols/text_symbol.h"
3941#include " undo/undo_manager.h"
4042
@@ -86,14 +88,14 @@ void MapInformation::retrieveInformation()
8688
8789 for (int i = 0 ; i < map_information.colors_num ; ++i)
8890 {
89- auto map_color = map->getMapColor (i);
91+ const auto * map_color = map->getMapColor (i);
9092 if (map_color)
9193 {
9294 ColorUsage color = {};
9395 color.name = map_color->getName ();
9496 for (int j = 0 ; j < map_information.symbols_num ; ++j)
9597 {
96- auto symbol = map->getSymbol (j);
98+ const auto * symbol = map->getSymbol (j);
9799 if (symbol->getType ())
98100 {
99101 if (symbol->containsColor (map_color))
@@ -106,39 +108,38 @@ void MapInformation::retrieveInformation()
106108 }
107109 }
108110
109- const UndoManager & undo_manager = map->undoManager ();
111+ const auto & undo_manager = map->undoManager ();
110112 map_information.undo_steps_num = undo_manager.canUndo () ? undo_manager.undoStepCount () : 0 ;
111113 map_information.redo_steps_num = undo_manager.canRedo () ? undo_manager.redoStepCount () : 0 ;
112114
113115 int i = 0 ;
114- for (auto & name : {tr (" Point symbols" ), tr (" Line symbols" ), tr (" Area symbols" ), tr (" Text symbols" ), tr (" Combined symbols" ), tr (" Undefined symbols" )})
116+ for (auto & name : {tr (" Point symbols" ), tr (" Line symbols" ), tr (" Area symbols" ), tr (" Text symbols" ), tr (" Combined symbols" ), tr (" Undefined symbols" )})
115117 map_information.map_objects [i++].category .name = name;
116118
117119 for (i = 0 ; i < map_information.map_parts_num ; ++i)
118120 {
119- const auto map_part = map->getPart (i);
121+ const auto * map_part = map->getPart (i);
120122 const auto map_part_objects = map_part->getNumObjects ();
121- ItemNum map_part_info = {map_part->getName (), map_part_objects};
122- map_information.map_parts .push_back (map_part_info);
123+ map_information.map_parts .push_back ({map_part->getName (), map_part_objects});
123124 map_information.map_objects_num += map_part_objects;
124125
125126 for (int j = 0 ; j < map_part_objects; ++j)
126127 {
127- const auto * symbol = map_part->getObject (j)->getSymbol ();
128+ const auto * symbol = map_part->getObject (j)->getSymbol ();
128129 addSymbol (symbol);
129130 }
130131 }
131- for (auto & map_object : map_information.map_objects )
132+ for (auto & map_object : map_information.map_objects )
132133 {
133134 if (map_object.category .num > 1 )
134135 {
135- auto & objects_vector = map_object.objects ;
136- sort (begin (objects_vector), end (objects_vector), [](const SymbolNum & sym1, const SymbolNum & sym2) { return Symbol::lessByNumber (sym1.symbol , sym2.symbol ); });
136+ auto & objects_vector = map_object.objects ;
137+ sort (begin (objects_vector), end (objects_vector), [](const SymbolNum& sym1, const SymbolNum& sym2) { return Symbol::lessByNumber (sym1.symbol , sym2.symbol ); });
137138 }
138139 }
139140 for (i = 0 ; i < map_information.symbols_num ; ++i)
140141 {
141- auto symbol = map->getSymbol (i);
142+ const auto * symbol = map->getSymbol (i);
142143 if (symbol->getType () == Symbol::Text)
143144 {
144145 addFont (symbol);
@@ -157,9 +158,9 @@ void MapInformation::addSymbol(const Symbol* symbol)
157158 break ;
158159 }
159160 const bool undefined_object = map->findSymbolIndex (symbol) < 0 ;
160- auto & object_category = map_information.map_objects [symbol_index];
161- auto & objects_vector = object_category.objects ;
162- auto found = std::find_if (begin (objects_vector), end (objects_vector), [&symbol](const SymbolNum & sym_count) { return sym_count.symbol == symbol; });
161+ auto & object_category = map_information.map_objects [symbol_index];
162+ auto & objects_vector = object_category.objects ;
163+ auto found = std::find_if (begin (objects_vector), end (objects_vector), [&symbol](const SymbolNum& sym_count) { return sym_count.symbol == symbol; });
163164 if (found != std::end (objects_vector))
164165 {
165166 ++found->num ;
@@ -169,7 +170,7 @@ void MapInformation::addSymbol(const Symbol* symbol)
169170 std::vector<QString> colors;
170171 for (int i = 0 ; i < map_information.colors_num ; ++i)
171172 {
172- auto map_color = map->getMapColor (i);
173+ const auto * map_color = map->getMapColor (i);
173174 if (map_color && symbol->containsColor (map_color))
174175 {
175176 colors.push_back ({map_color->getName ()});
@@ -180,14 +181,13 @@ void MapInformation::addSymbol(const Symbol* symbol)
180181 ++object_category.category .num ;
181182}
182183
183- void MapInformation::addFont (Symbol* symbol)
184+ void MapInformation::addFont (const Symbol* symbol)
184185{
185- TextSymbol *text_symbol = symbol->asText ();
186- auto font_family = text_symbol->getFontFamily ();
187- auto font_info = QFontInfo (text_symbol->getQFont ());
188- auto font_family_substituted = font_info.family ();
189- auto &font_names = map_information.font_names ;
190- auto found = std::find_if (begin (font_names), end (font_names), [&font_family](const FontNum &font_count) { return font_count.name == font_family; });
186+ const auto * text_symbol = symbol->asText ();
187+ const auto & font_family = text_symbol->getFontFamily ();
188+ const auto font_family_substituted = QFontInfo (text_symbol->getQFont ()).family ();
189+ auto & font_names = map_information.font_names ;
190+ auto found = std::find_if (begin (font_names), end (font_names), [&font_family](const FontNum& font_count) { return font_count.name == font_family; });
191191 if (found != std::end (font_names))
192192 {
193193 ++found->num ;
@@ -210,7 +210,7 @@ void MapInformation::buildTree()
210210 addTreeItem (1 , tr (" Coordinate reference system" ), map_information.map_crs );
211211
212212 addTreeItem (0 , tr (" Map parts" ), tr (" %n part(s)" , nullptr , map_information.map_parts_num ));
213- for (const auto & map_part : map_information.map_parts )
213+ for (const auto & map_part : map_information.map_parts )
214214 {
215215 addTreeItem (1 , map_part.name , tr (" %n object(s)" , nullptr , map_part.num ));
216216 }
@@ -221,27 +221,27 @@ void MapInformation::buildTree()
221221
222222 if (map_information.undo_steps_num || map_information.redo_steps_num )
223223 {
224- QString s = map_information.undo_steps_num ? tr (" Undo" ) : tr (" Redo" );
225- QString n = QString::fromLatin1 (" %1" ).arg (map_information.undo_steps_num ? map_information.undo_steps_num : map_information.redo_steps_num );
224+ QString undo_redo_type = map_information.undo_steps_num ? tr (" Undo" ) : tr (" Redo" );
225+ QString undo_redo_num = QString::fromLatin1 (" %1" ).arg (map_information.undo_steps_num ? map_information.undo_steps_num : map_information.redo_steps_num );
226226 if (map_information.undo_steps_num && map_information.redo_steps_num )
227227 {
228- s .append (QLatin1Char (' /' )).append (tr (" Redo" ));
229- n .append (QString::fromLatin1 (" /%1" ).arg (map_information.redo_steps_num ));
228+ undo_redo_type .append (QLatin1Char (' /' )).append (tr (" Redo" ));
229+ undo_redo_num .append (QString::fromLatin1 (" /%1" ).arg (map_information.redo_steps_num ));
230230 }
231- s .append (QLatin1Char (' ' )).append (tr (" steps" ));
232- n .append (QLatin1Char (' ' )).append (map_information.undo_steps_num + map_information.redo_steps_num > 1 ? tr (" steps" ) : tr (" step" ));
233- addTreeItem (0 , s, n );
231+ undo_redo_type .append (QLatin1Char (' ' )).append (tr (" steps" ));
232+ undo_redo_num .append (QLatin1Char (' ' )).append (map_information.undo_steps_num + map_information.redo_steps_num > 1 ? tr (" steps" ) : tr (" step" ));
233+ addTreeItem (0 , undo_redo_type, undo_redo_num );
234234 }
235235
236236 addTreeItem (0 , tr (" Colors" ), tr (" %n color(s)" , nullptr , map_information.colors_num ));
237237 if (map_information.colors_num )
238238 {
239- for (const auto & color : map_information.colors )
239+ for (const auto & color : map_information.colors )
240240 {
241241 addTreeItem (1 , color.name );
242242 if (color.symbols .size ())
243243 {
244- for (const auto & symbol : color.symbols )
244+ for (const auto & symbol : color.symbols )
245245 {
246246 addTreeItem (2 , symbol);
247247 }
@@ -250,24 +250,24 @@ void MapInformation::buildTree()
250250 }
251251
252252 addTreeItem (0 , tr (" Fonts" ), tr (" %n font(s)" , nullptr , map_information.fonts_num ));
253- for (const auto & font_name : map_information.font_names )
253+ for (const auto & font_name : map_information.font_names )
254254 {
255255 addTreeItem (1 , (font_name.name == font_name.name_substitute ? font_name.name : font_name.name + tr (" (substituted by " ) + font_name.name_substitute + QLatin1Char (' )' )),
256256 tr (" %n symbol(s)" , nullptr , font_name.num ));
257257 }
258258
259259 addTreeItem (0 , tr (" Objects" ), tr (" %n object(s)" , nullptr , map_information.map_objects_num ));
260- for (const auto & map_object : map_information.map_objects )
260+ for (const auto & map_object : map_information.map_objects )
261261 {
262262 if (map_object.category .num )
263263 {
264264 addTreeItem (1 , map_object.category .name , tr (" %n object(s)" , nullptr , map_object.category .num ));
265- for (const auto & object : map_object.objects )
265+ for (const auto & object : map_object.objects )
266266 {
267267 addTreeItem (2 , object.name , tr (" %n object(s)" , nullptr , object.num ));
268268 if (object.colors .size ())
269269 {
270- for (const auto & color : object.colors )
270+ for (const auto & color : object.colors )
271271 {
272272 addTreeItem (3 , color);
273273 }
@@ -287,14 +287,14 @@ void MapInformation::addTreeItem(const int level, const QString item, const QStr
287287 for (; tree_depth > level; --tree_depth)
288288 tree_item_hierarchy.pop_back ();
289289
290- QTreeWidgetItem * tree_item;
290+ QTreeWidgetItem* tree_item;
291291 if (tree_depth)
292292 tree_item = new QTreeWidgetItem (tree_item_hierarchy.back ());
293293 else
294294 tree_item = new QTreeWidgetItem (map_info_tree);
295295 tree_item->setText (0 , item);
296296 tree_item->setText (1 , value);
297- tree_item_hierarchy.push_back (tree_item); // always store last tree item
297+ tree_item_hierarchy.emplace_back (tree_item); // always store last tree item
298298}
299299
300300inline
0 commit comments