396 SubWindow* subWindow = new SubWindow{args..., nullptr}; |
396 SubWindow* subWindow = new SubWindow{args..., nullptr}; |
397 mdiArea->addSubWindow(subWindow); |
397 mdiArea->addSubWindow(subWindow); |
398 return subWindow; |
398 return subWindow; |
399 } |
399 } |
400 |
400 |
401 static QSet<ModelId> resolveIdsFromSelection(const ModelData* data) |
401 static QSet<ElementId> resolveIdsFromSelection(const ModelData* data) |
402 { |
402 { |
403 const auto selection = data->itemSelectionModel->selection(); |
403 const auto selection = data->itemSelectionModel->selection(); |
404 QSet<ModelId> selectedIndexes; |
404 QSet<ElementId> selectedIndexes; |
405 for (const QModelIndex& qindex : selection.indexes()) { |
405 for (const QModelIndex& qindex : selection.indexes()) { |
406 const std::size_t row = unsigned_cast(qindex.row()); |
406 const std::size_t row = unsigned_cast(qindex.row()); |
407 selectedIndexes.insert(data->model->idAt(row)); |
407 selectedIndexes.insert(data->model->idAt(row)); |
408 } |
408 } |
409 return selectedIndexes; |
409 return selectedIndexes; |
546 mainWindow.statusBar()->showMessage(newStatusText); |
546 mainWindow.statusBar()->showMessage(newStatusText); |
547 }); |
547 }); |
548 QObject::connect( |
548 QObject::connect( |
549 data->tools.get(), |
549 data->tools.get(), |
550 &EditTools::select, |
550 &EditTools::select, |
551 [modelId, &documents](const QSet<ModelId>& indices, bool retain) { |
551 [modelId, &documents](const QSet<ElementId>& indices, bool retain) { |
552 ModelData* data = findModelData(&documents, modelId); |
552 ModelData* data = findModelData(&documents, modelId); |
553 if (data != nullptr) { |
553 if (data != nullptr) { |
554 if (not retain) { |
554 if (not retain) { |
555 data->itemSelectionModel->clear(); |
555 data->itemSelectionModel->clear(); |
556 } |
556 } |
557 for (const ModelId id : indices) { |
557 for (const ElementId id : indices) { |
558 opt<int> index = data->model->find(id); |
558 opt<int> index = data->model->find(id); |
559 if (index.has_value()) { |
559 if (index.has_value()) { |
560 const QModelIndex qindex = data->model->index(*index); |
560 const QModelIndex qindex = data->model->index(*index); |
561 data->itemSelectionModel->select(qindex, QItemSelectionModel::Select); |
561 data->itemSelectionModel->select(qindex, QItemSelectionModel::Select); |
562 } |
562 } |