src/main.cpp

changeset 250
2837b549e616
parent 249
37d3c819cafa
child 251
94b0a30a1886
equal deleted inserted replaced
249:37d3c819cafa 250:2837b549e616
270 QAction* action = data.memberInstance(ui); 270 QAction* action = data.memberInstance(ui);
271 action->setChecked(renderPreferences->style == data.payload); 271 action->setChecked(renderPreferences->style == data.payload);
272 } 272 }
273 ui->actionDrawAxes->setChecked(renderPreferences->drawAxes); 273 ui->actionDrawAxes->setChecked(renderPreferences->drawAxes);
274 ui->actionWireframe->setChecked(renderPreferences->wireframe); 274 ui->actionWireframe->setChecked(renderPreferences->wireframe);
275 }; 275 }
276 276
277 static gl::RenderPreferences loadRenderPreferences() 277 static gl::RenderPreferences loadRenderPreferences()
278 { 278 {
279 return gl::RenderPreferences{ 279 return gl::RenderPreferences{
280 .style = setting<Setting::RenderStyle>(), 280 .style = setting<Setting::RenderStyle>(),
351 } 351 }
352 352
353 std::vector<int> rows(const QModelIndexList& indexList) 353 std::vector<int> rows(const QModelIndexList& indexList)
354 { 354 {
355 std::vector<int> result; 355 std::vector<int> result;
356 result.reserve(indexList.size()); 356 result.reserve(unsigned_cast(indexList.size()));
357 for (const QModelIndex& index : indexList) 357 for (const QModelIndex& index : indexList)
358 { 358 {
359 result.push_back(index.row()); 359 result.push_back(index.row());
360 } 360 }
361 return result; 361 return result;
465 &QItemSelectionModel::selectionChanged, 465 &QItemSelectionModel::selectionChanged,
466 [modelId, &documents]{ 466 [modelId, &documents]{
467 ModelData* data = findModelData(&documents, modelId); 467 ModelData* data = findModelData(&documents, modelId);
468 if (data != nullptr) { 468 if (data != nullptr) {
469 auto resolveIndex = [&data](const QModelIndex& index){ 469 auto resolveIndex = [&data](const QModelIndex& index){
470 return data->model->idAt(index.row()); 470 return data->model->idAt(unsigned_cast(index.row()));
471 }; 471 };
472 const auto selection = data->itemSelectionModel->selection(); 472 const auto selection = data->itemSelectionModel->selection();
473 const auto indices = fn::map<QSet<ModelId>>(selection.indexes(), resolveIndex); 473 const auto indices = fn::map<QSet<ModelId>>(selection.indexes(), resolveIndex);
474 data->canvas->setSelection(indices); 474 data->canvas->setSelection(indices);
475 } 475 }
604 QObject::connect(ui.actionDelete, &QAction::triggered, [&]{ 604 QObject::connect(ui.actionDelete, &QAction::triggered, [&]{
605 if (Model* model = currentModelBody(&ui, &documents)) { 605 if (Model* model = currentModelBody(&ui, &documents)) {
606 std::vector<int> selectedRows = rows(ui.modelListView->selectionModel()->selectedRows()); 606 std::vector<int> selectedRows = rows(ui.modelListView->selectionModel()->selectedRows());
607 std::sort(selectedRows.begin(), selectedRows.end(), std::greater<int>{}); 607 std::sort(selectedRows.begin(), selectedRows.end(), std::greater<int>{});
608 for (int row : selectedRows) { 608 for (int row : selectedRows) {
609 executeAction(model, DeleteFromModel{.position = row}); 609 executeAction(model, DeleteFromModel{.position = unsigned_cast(row)});
610 } 610 }
611 } 611 }
612 }); 612 });
613 QObject::connect(ui.actionDrawAxes, &QAction::triggered, [&](bool drawAxes){ 613 QObject::connect(ui.actionDrawAxes, &QAction::triggered, [&](bool drawAxes){
614 renderPreferences.drawAxes = drawAxes; 614 renderPreferences.drawAxes = drawAxes;

mercurial