src/main.cpp

changeset 299
cf9a854b56a9
parent 296
38f6fad61bad
child 309
d862721d19a3
--- a/src/main.cpp	Tue Jun 28 19:36:03 2022 +0300
+++ b/src/main.cpp	Tue Jun 28 19:43:55 2022 +0300
@@ -398,6 +398,17 @@
 	return subWindow;
 }
 
+static QSet<ModelId> resolveIdsFromSelection(const ModelData* data)
+{
+	const auto selection = data->itemSelectionModel->selection();
+	QSet<ModelId> selectedIndexes;
+	for (const QModelIndex& qindex : selection.indexes()) {
+		const std::size_t row = unsigned_cast(qindex.row());
+		selectedIndexes.insert(data->model->idAt(row));
+	}
+	return selectedIndexes;
+}
+
 int main(int argc, char *argv[])
 {
 	doQtRegistrations();
@@ -513,12 +524,7 @@
 				[modelId, &documents, &toolWidgets]{
 				ModelData* data = findModelData(&documents, modelId);
 				if (data != nullptr) {
-					auto resolveIndex = [&data](const QModelIndex& index){
-						return data->model->idAt(unsigned_cast(index.row()));
-					};
-					const auto selection = data->itemSelectionModel->selection();
-					const auto indices = fn::map<QSet<ModelId>>(selection.indexes(), resolveIndex);
-					data->canvas->setSelection(indices);
+					data->canvas->setSelection(resolveIdsFromSelection(data));
 					/*
 					if (indices.size() == 1) {
 						opt<std::size_t> index = data->model->find(*indices.begin());

mercurial