def test_undo_add_remove_layered_item_props(qtbot, qApp): document = Document() male = Person(name='Male', kind='male') female = Person(name='Female', kind='female') marriage = Marriage(personA=male, personB=female) divorcedEvent = Event(parent=marriage, uniqueId='divorced', date=QDate(1900, 1, 1)) layer = Layer(name='Layer 1') document.addItems(male, female, marriage, layer) # unlayered = { 'male': QPointF(-100, -50), 'maleDetails': QPointF(100, 100), 'female': QPointF(100, -50), 'femaleDetails': QPointF(-100,-200), 'marriageSep': QPointF(100, 0), 'marriageDetails': QPointF(-25, 0), } layered = { 'male': QPointF(-200, -150), 'maleDetails': QPointF(-100, -100), 'female': QPointF(100, 50), 'femaleDetails': QPointF(100, 200), 'marriageSep': QPointF(100, 0), 'marriageDetails': QPointF(25, -100), } # layered layer.setItemProperty(male.id, 'itemPos', layered['male']) layer.setItemProperty(male.detailsText.id, 'itemPos', layered['maleDetails']) layer.setItemProperty(female.id, 'itemPos', layered['female']) layer.setItemProperty(female.detailsText.id, 'itemPos', layered['femaleDetails']) layer.setItemProperty(marriage.detailsText.id, 'itemPos', layered['marriageDetails']) layer.setItemProperty(marriage.separationIndicator.id, 'itemPos', layered['marriageSep']) # unlayered male.setItemPos(unlayered['male'], undo=False) male.detailsText.setItemPos(unlayered['maleDetails'], undo=False) female.setItemPos(unlayered['female'], undo=False) female.detailsText.setItemPos(unlayered['femaleDetails'], undo=False) # marriage.setDivorced(True, undo=False) marriage.separationIndicator.setItemPos(unlayered['marriageSep'], undo=False) marriage.detailsText.setItemPos(unlayered['marriageDetails'], undo=False) assert len(document.items()) == 22 document.selectAll() qtbot.clickYesAfter(lambda: document.removeSelection()) assert len(document.items()) == 0 commands.stack().undo() assert len(document.items()) == 22 commands.stack().redo() assert len(document.items()) == 0
def test_layered_properties(qApp): """ Ensure correct layered prop updates for marriage+marriage-indicators. """ document = Document() male = Person(name='Male', kind='male') female = Person(name='Female', kind='female') marriage = Marriage(personA=male, personB=female) divorcedEvent = Event(parent=marriage, uniqueId='divorced', date=QDate(1900, 1, 1)) layer = Layer(name='Layer 1') document.addItems(male, female, marriage, layer) # unlayered = { 'male': QPointF(-100, -50), 'maleDetails': QPointF(100, 100), 'female': QPointF(100, -50), 'femaleDetails': QPointF(-100,-200), 'marriageSep': QPointF(100, 0), 'marriageDetails': QPointF(-25, 0), } layered = { 'male': QPointF(-200, -150), 'maleDetails': QPointF(-100, -100), 'female': QPointF(100, 50), 'femaleDetails': QPointF(100, 200), 'marriageSep': QPointF(100, 0), 'marriageDetails': QPointF(25, -100), } # layered layer.setItemProperty(male.id, 'itemPos', layered['male']) layer.setItemProperty(male.detailsText.id, 'itemPos', layered['maleDetails']) layer.setItemProperty(female.id, 'itemPos', layered['female']) layer.setItemProperty(female.detailsText.id, 'itemPos', layered['femaleDetails']) layer.setItemProperty(marriage.detailsText.id, 'itemPos', layered['marriageDetails']) layer.setItemProperty(marriage.separationIndicator.id, 'itemPos', layered['marriageSep']) # unlayered male.setItemPos(unlayered['male'], undo=False) male.detailsText.setItemPos(unlayered['maleDetails'], undo=False) female.setItemPos(unlayered['female'], undo=False) female.detailsText.setItemPos(unlayered['femaleDetails'], undo=False) # marriage.setDivorced(True, undo=False) marriage.separationIndicator.setItemPos(unlayered['marriageSep'], undo=False) marriage.detailsText.setItemPos(unlayered['marriageDetails'], undo=False) assert male.pos() == unlayered['male'] assert male.detailsText.pos() == unlayered['maleDetails'] assert female.pos() == unlayered['female'] assert female.detailsText.pos() == unlayered['femaleDetails'] assert marriage.detailsText.pos() == unlayered['marriageDetails'] assert marriage.separationIndicator.pos() == unlayered['marriageSep'] layer.setActive(True) assert male.pos() == layered['male'] assert male.detailsText.pos() == layered['maleDetails'] assert female.pos() == layered['female'] assert female.detailsText.pos() == layered['femaleDetails'] assert marriage.detailsText.pos() == layered['marriageDetails'] assert marriage.separationIndicator.pos() == layered['marriageSep'] layer.setActive(False) assert male.pos() == unlayered['male'] assert male.detailsText.pos() == unlayered['maleDetails'] assert female.pos() == unlayered['female'] assert female.detailsText.pos() == unlayered['femaleDetails'] assert marriage.detailsText.pos() == unlayered['marriageDetails'] assert marriage.separationIndicator.pos() == unlayered['marriageSep'] layer.resetItemProperty(male.prop('itemPos')) layer.resetItemProperty(male.detailsText.prop('itemPos')) layer.resetItemProperty(female.prop('itemPos')) layer.resetItemProperty(female.detailsText.prop('itemPos')) layer.resetItemProperty(marriage.detailsText.prop('itemPos')) layer.resetItemProperty(marriage.separationIndicator.prop('itemPos')) layer.setActive(True) assert male.pos() == unlayered['male'] assert male.detailsText.pos() == unlayered['maleDetails'] assert female.pos() == unlayered['female'] assert female.detailsText.pos() == unlayered['femaleDetails'] assert marriage.detailsText.pos() == unlayered['marriageDetails'] assert marriage.separationIndicator.pos() == unlayered['marriageSep']