src/document.cpp

changeset 63
f7dd937667a5
parent 51
1a9eac27698d
child 73
97df974b5ed5
--- a/src/document.cpp	Thu Feb 27 23:07:40 2020 +0200
+++ b/src/document.cpp	Fri Feb 28 19:24:33 2020 +0200
@@ -58,17 +58,12 @@
 	connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged,
 		[&](const QItemSelection& selected, const QItemSelection& deselected)
 	{
-		QSet<ldraw::Id> selectedIds;
-		QSet<ldraw::Id> deselectedIds;
-		for (const QModelIndex& index : selected.indexes())
+		auto resolveIndex = [this](const QModelIndex& index){ return this->model->resolve(index); };
+		auto resolve = [resolveIndex](const QItemSelection& selection)
 		{
-			selectedIds.insert(this->model->resolve(index));
-		}
-		for (const QModelIndex& index : deselected.indexes())
-		{
-			deselectedIds.insert(this->model->resolve(index));
-		}
-		this->renderer->handleSelectionChange(selectedIds, deselectedIds);
+			return fn::map<QSet<ldraw::Id>>(selection.indexes(), resolveIndex);
+		};
+		this->renderer->handleSelectionChange(resolve(selected), resolve(deselected));
 	});
 }
 

mercurial