1 module dqml.qmodelindex;
2 
3 import dqml.global;
4 import dqml.dothersideinterface;
5 import dqml.qvariant;
6 
7 
8 class QModelIndex
9 {
10     this()
11     {
12         this.vptr = dos_qmodelindex_create();
13     }
14 
15     this(void* vptr, Ownership ownership)
16     {
17         this.vptr = ownership == Ownership.Take ? vptr :  dos_qmodelindex_create_qmodelindex(vptr);
18     }
19 
20     ~this()
21     {
22         dos_qmodelindex_delete(this.vptr);
23     }
24 
25     public void* voidPointer()
26     {
27         return this.vptr;
28     }
29 
30     public int row()
31     {
32         return dos_qmodelindex_row(this.vptr);
33     }
34 
35     public int column()
36     {
37         return dos_qmodelindex_column(this.vptr);
38     }
39 
40     public bool isValid()
41     {
42         return dos_qmodelindex_isValid(this.vptr);
43     }
44 
45     public QVariant data(int role)
46     {
47         void* data = dos_qmodelindex_data(this.vptr, role);
48         return new QVariant(data, Ownership.Take);
49     }
50 
51     public QModelIndex parent()
52     {
53         void* parent = dos_qmodelindex_parent(this.vptr);
54         return new QModelIndex(parent, Ownership.Take);
55     }
56 
57     public QModelIndex child(int row, int column)
58     {
59         void* child = dos_qmodelindex_child(this.vptr, row, column);
60         return new QModelIndex(child, Ownership.Take);
61     }
62 
63     public QModelIndex sibling(int row, int column)
64     {
65         void* sibling = dos_qmodelindex_sibling(this.vptr, row, column);
66         return new QModelIndex(sibling, Ownership.Take);
67     }
68 
69     private void* vptr = null;
70 }