77#include < QMimeData>
88#include < QMessageBox>
99#include < QApplication>
10+ #include < unordered_map>
1011
1112DbStructureModel::DbStructureModel (DBBrowserDB& db, QObject* parent)
1213 : QAbstractItemModel(parent),
@@ -303,7 +304,7 @@ bool DbStructureModel::dropMimeData(const QMimeData* data, Qt::DropAction action
303304void DbStructureModel::buildTree (QTreeWidgetItem* parent, const std::string& schema)
304305{
305306 // Build a map from object type to tree node to simplify finding the correct tree node later
306- QMap <std::string, QTreeWidgetItem*> typeToParentItem;
307+ std::unordered_map <std::string, QTreeWidgetItem*> typeToParentItem;
307308
308309 // Get object map for the given schema
309310 objectMap objmap = m_db.schemata [schema];
@@ -312,22 +313,22 @@ void DbStructureModel::buildTree(QTreeWidgetItem* parent, const std::string& sch
312313 QTreeWidgetItem* itemTables = new QTreeWidgetItem (parent);
313314 itemTables->setIcon (ColumnName, QIcon (QString (" :/icons/table" )));
314315 itemTables->setText (ColumnName, tr (" Tables (%1)" ).arg (objmap.values (" table" ).count ()));
315- typeToParentItem.insert (" table" , itemTables);
316+ typeToParentItem.insert ({ " table" , itemTables} );
316317
317318 QTreeWidgetItem* itemIndices = new QTreeWidgetItem (parent);
318319 itemIndices->setIcon (ColumnName, QIcon (QString (" :/icons/index" )));
319320 itemIndices->setText (ColumnName, tr (" Indices (%1)" ).arg (objmap.values (" index" ).count ()));
320- typeToParentItem.insert (" index" , itemIndices);
321+ typeToParentItem.insert ({ " index" , itemIndices} );
321322
322323 QTreeWidgetItem* itemViews = new QTreeWidgetItem (parent);
323324 itemViews->setIcon (ColumnName, QIcon (QString (" :/icons/view" )));
324325 itemViews->setText (ColumnName, tr (" Views (%1)" ).arg (objmap.values (" view" ).count ()));
325- typeToParentItem.insert (" view" , itemViews);
326+ typeToParentItem.insert ({ " view" , itemViews} );
326327
327328 QTreeWidgetItem* itemTriggers = new QTreeWidgetItem (parent);
328329 itemTriggers->setIcon (ColumnName, QIcon (QString (" :/icons/trigger" )));
329330 itemTriggers->setText (ColumnName, tr (" Triggers (%1)" ).arg (objmap.values (" trigger" ).count ()));
330- typeToParentItem.insert (" trigger" , itemTriggers);
331+ typeToParentItem.insert ({ " trigger" , itemTriggers} );
331332
332333 // Get all database objects and sort them by their name
333334 QMultiMap<std::string, sqlb::ObjectPtr> dbobjs;
@@ -338,7 +339,7 @@ void DbStructureModel::buildTree(QTreeWidgetItem* parent, const std::string& sch
338339 for (auto it : dbobjs)
339340 {
340341 // Object node
341- QTreeWidgetItem* item = addNode (typeToParentItem.value (sqlb::Object::typeToString (it->type ())), it, schema);
342+ QTreeWidgetItem* item = addNode (typeToParentItem.at (sqlb::Object::typeToString (it->type ())), it, schema);
342343
343344 // If it is a table or view add the field nodes, add an extra node for the browsable section
344345 if (it->type () == sqlb::Object::Types::Table || it->type () == sqlb::Object::Types::View)
0 commit comments