src/main.cpp

changeset 336
e07425ac5834
parent 335
c5830bce1c23
child 337
5bb26aa33ad5
equal deleted inserted replaced
335:c5830bce1c23 336:e07425ac5834
469 } 469 }
470 }; 470 };
471 const auto executeAction = [&]( 471 const auto executeAction = [&](
472 Model* model, const ModelAction& action 472 Model* model, const ModelAction& action
473 ) { 473 ) {
474 /*
475 std::visit(overloaded{ 474 std::visit(overloaded{
476 [model](const AppendToModel& action){ 475 [model](const AppendToModel& action){
477 model->append(action.newElement); 476 QTextCursor cursor{model};
477 cursor.movePosition(QTextCursor::End);
478 const QString newText = modelElementToString(action.newElement);
479 // Make sure we have an empty line
480 if (not model->lastBlock().text().isEmpty()) {
481 cursor.insertBlock();
482 }
483 qDebug() << cursor.blockNumber();
484 cursor.insertText(newText);
478 }, 485 },
479 [model](const DeleteFromModel& action){ 486 [](const DeleteFromModel&){},
480 model->remove(action.position);
481 },
482 [model](const ModifyModel& action){ 487 [model](const ModifyModel& action){
483 model->assignAt(action.position, action.newElement); 488 QTextBlock block = model->findBlockByLineNumber((int) action.position);
489 if (block.isValid()) {
490 QTextCursor cursor{block};
491 cursor.select(QTextCursor::LineUnderCursor);
492 cursor.insertText(modelElementToString(action.newElement));
493 }
494 //model->assignAt(action.position, action.newElement);
484 }, 495 },
485 }, action); 496 }, action);
486 */
487 497
488 }; 498 };
489 const auto restoreSettings = [&]{ 499 const auto restoreSettings = [&]{
490 recentlyOpenedFiles = setting<Setting::RecentFiles>(); 500 recentlyOpenedFiles = setting<Setting::RecentFiles>();
491 renderPreferences = loadRenderPreferences(); 501 renderPreferences = loadRenderPreferences();

mercurial