Exemplo n.º 1
0
def test_reset_layered_props(qApp):
    """ Item.write was not explicitly requesting non-layered prop values. """
    document = Document()
    person = Person()
    layer = Layer(name='Layer 1', active=True, storeGeometry=True)
    document.addItems(person, layer)
    person.setItemPos(QPointF(10, 10))
    assert layer.active() == True
    assert person.pos() == QPointF(10, 10)
    
    document.resetAll() # was throwing exception in commands.py
    assert person.itemPos() == QPointF()
    assert person.pos() == QPointF()
Exemplo n.º 2
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']