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

Method moveElementAfter

tests/backend/Worksheet/WorksheetElementTest.cpp:744–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742}
743
744void WorksheetElementTest::moveElementAfter() {
745 Project project;
746
747 AspectTreeModel treemodel(&project, this);
748
749 auto* ws = new Worksheet(QStringLiteral("Worksheet"));
750 project.addChild(ws);
751
752 auto* lFirst = new TextLabel(QStringLiteral("first"));
753 ws->addChild(lFirst);
754
755 auto* lSecond = new TextLabel(QStringLiteral("second"));
756 ws->addChild(lSecond);
757
758 auto* lThird = new TextLabel(QStringLiteral("third"));
759 ws->addChild(lThird);
760
761 auto children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
762
763 // First is background
764 QCOMPARE(children.at(1)->name(), lFirst->name());
765 QCOMPARE(children.at(2)->name(), lSecond->name());
766 QCOMPARE(children.at(3)->name(), lThird->name());
767
768 QAction action;
769 action.setData(3);
770 lFirst->execMoveInFrontOf(&action);
771
772 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
773 QCOMPARE(children.at(1)->name(), lSecond->name());
774 QCOMPARE(children.at(2)->name(), lThird->name());
775 QCOMPARE(children.at(3)->name(), lFirst->name());
776
777 lThird->undoStack()->undo();
778
779 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
780 QCOMPARE(children.at(1)->name(), lFirst->name());
781 QCOMPARE(children.at(2)->name(), lSecond->name());
782 QCOMPARE(children.at(3)->name(), lThird->name());
783
784 action.setData(400); // higher than maximum, it will be limited automatically
785 lFirst->execMoveInFrontOf(&action);
786
787 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
788 QCOMPARE(children.at(1)->name(), lSecond->name());
789 QCOMPARE(children.at(2)->name(), lThird->name());
790 QCOMPARE(children.at(3)->name(), lFirst->name());
791
792 action.setData(2); // in front of lThird
793 lSecond->execMoveInFrontOf(&action);
794
795 children = ws->children<AbstractAspect>(AbstractAspect::ChildIndexFlag::IncludeHidden);
796 QCOMPARE(children.at(1)->name(), lThird->name());
797 QCOMPARE(children.at(2)->name(), lSecond->name());
798 QCOMPARE(children.at(3)->name(), lFirst->name());
799
800 lSecond->undoStack()->undo();
801

Callers

nothing calls this directly

Calls 7

execMoveInFrontOfMethod · 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