Exemplo n.º 1
0
def test_listdata_flags():
    e = easymodel.ListItemData(list(range(3)), editable=True)
    s = easymodel.ListItemData(list(range(3)), editable=False)
    default = QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
    for i in range(3):
        assert e.flags(i) == default | QtCore.Qt.ItemIsEditable
        assert s.flags(i) == default
Exemplo n.º 2
0
def test_model_headerdata(stub_model):
    m = stub_model[0]
    for i in range(10):
        assert m.headerData(i, QtCore.Qt.Horizontal, DR) == str(i + 1)
        assert m.headerData(i, QtCore.Qt.Vertical, DR) == str(i + 1)

    rootdata = easymodel.ListItemData(['Sec1', 'Head2', 'Chap3'])
    root = easymodel.TreeItem(rootdata)
    m2 = easymodel.TreeModel(root)

    assert m2.headerData(0, QtCore.Qt.Horizontal, DR) == 'Sec1'
    assert m2.headerData(1, QtCore.Qt.Horizontal, DR) == 'Head2'
    assert m2.headerData(2, QtCore.Qt.Horizontal, DR) == 'Chap3'
    assert m2.headerData(3, QtCore.Qt.Horizontal, DR) == '4'
    assert m2.headerData(99, QtCore.Qt.Horizontal, DR) == '100'
    assert m2.headerData(3, QtCore.Qt.Vertical, DR) == '4'
    assert m2.headerData(99, QtCore.Qt.Vertical, DR) == '100'
Exemplo n.º 3
0
def model():
    rootdata = easymodel.ListItemData(['Column0', 'Column1'])
    root = easymodel.TreeItem(rootdata)
    # Create a new model with the root
    model = easymodel.TreeModel(root)
    datal0r0 = easymodel.ListItemData(['l0r0c0', 'l0r0c1'])
    datal0r1 = easymodel.ListItemData(['l0r1c0', 'l0r1c1'])
    datal1r0 = easymodel.ListItemData(['l1r0c0', 'l1r0c1'])
    datal1r1 = easymodel.ListItemData(['l1r1c0', 'l1r1c1'])
    datal2r0 = easymodel.ListItemData(['l2r0c0', 'l2r0c1'])
    datal2r1 = easymodel.ListItemData(['l2r1c0', 'l2r1c1'])
    iteml0r0 = easymodel.TreeItem(datal0r0, parent=root)
    easymodel.TreeItem(datal0r1, parent=root)
    iteml1r0 = easymodel.TreeItem(datal1r0, parent=iteml0r0)
    easymodel.TreeItem(datal1r1, parent=iteml0r0)
    easymodel.TreeItem(datal2r0, parent=iteml1r0)
    easymodel.TreeItem(datal2r1, parent=iteml1r0)
    return model
Exemplo n.º 4
0
def str_list_data():
    """Item data with a string list. ['a', 'b', 'hallo']"""
    return easymodel.ListItemData(['a', 'b', 'hallo'])
Exemplo n.º 5
0
def test_listdata_set_data_false_role():
    data = easymodel.ListItemData(['1', 2], editable=True)
    assert data.set_data(0, 0, QtCore.Qt.DecorationRole) is False
    assert data.set_data(0, 'a', QtCore.Qt.DecorationRole) is False
Exemplo n.º 6
0
def test_treeitem_internal_data(stub_tree):
    for i in stub_tree[1:-1]:
        assert i.internal_data() is None
    l = [1, 2, 3]
    data = easymodel.ListItemData(l)
    assert easymodel.TreeItem(data).internal_data() is l
Exemplo n.º 7
0
def mix_list_data():
    """Item data with a mixed list. ['a', None, False, 1, [1, '2']]"""
    return easymodel.ListItemData(['a', None, False, 1, [1, '2']])
Exemplo n.º 8
0
def int_list_data():
    """Item data with an in list. [1, 2, 3, 4, 5, 6]"""
    return easymodel.ListItemData([1, 2, 3, 4, 5, 6])