MCPcopy Create free account
hub / github.com/KDE/labplot / moveElementBefore

Method moveElementBefore

tests/backend/Worksheet/WorksheetElementTest.cpp:673–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671 } while (false)
672
673void WorksheetElementTest::moveElementBefore() {
674 Project project;
675
676 AspectTreeModel treemodel(&project, this);
677
678 auto* ws = new Worksheet(QStringLiteral("Worksheet"));
679 project.addChild(ws);
680
681 auto* lFirst = new TextLabel(QStringLiteral("first"));
682 ws->addChild(lFirst);
683
684 auto* lSecond = new TextLabel(QStringLiteral("second"));
685 ws->addChild(lSecond);
686
687 auto* lThird = new TextLabel(QStringLiteral("third"));
688 ws->addChild(lThird);
689
690 auto children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
691
692 // First is background
693 QCOMPARE(children.at(1)->name(), lFirst->name());
694 QCOMPARE(children.at(2)->name(), lSecond->name());
695 QCOMPARE(children.at(3)->name(), lThird->name());
696
697 QAction action;
698 action.setData(2); // behind lSecond
699 lThird->execMoveBehind(&action);
700
701 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
702 QCOMPARE(children.at(1)->name(), lFirst->name());
703 QCOMPARE(children.at(2)->name(), lThird->name());
704 QCOMPARE(children.at(3)->name(), lSecond->name());
705
706 lThird->undoStack()->undo();
707
708 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
709 QCOMPARE(children.at(1)->name(), lFirst->name());
710 QCOMPARE(children.at(2)->name(), lSecond->name());
711 QCOMPARE(children.at(3)->name(), lThird->name());
712
713 action.setData(1);
714 lThird->execMoveBehind(&action);
715
716 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
717 QCOMPARE(children.at(1)->name(), lThird->name());
718 QCOMPARE(children.at(2)->name(), lFirst->name());
719 QCOMPARE(children.at(3)->name(), lSecond->name());
720
721 action.setData(1);
722 lSecond->execMoveBehind(&action);
723
724 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
725 QCOMPARE(children.at(1)->name(), lSecond->name());
726 QCOMPARE(children.at(2)->name(), lThird->name());
727 QCOMPARE(children.at(3)->name(), lFirst->name());
728
729 lSecond->undoStack()->undo();
730

Callers

nothing calls this directly

Calls 7

execMoveBehindMethod · 0.80
addChildMethod · 0.45
nameMethod · 0.45
setDataMethod · 0.45
undoMethod · 0.45
undoStackMethod · 0.45
redoMethod · 0.45

Tested by

no test coverage detected