forked from go-qml/qml
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gomodelindex.go
94 lines (78 loc) · 2.28 KB
/
gomodelindex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package qml
// #cgo CPPFLAGS: -I../cpp
// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing
// #cgo LDFLAGS: -lstdc++
// #cgo pkg-config: Qt5Core Qt5Widgets Qt5Quick
//
// #include <stdlib.h>
// #include "goitemmodel_api.h"
//
import "C"
import "unsafe"
type qModelIndex struct {
ptr uintptr
engine *Engine
}
func mkModelIndex(ptr uintptr, engine *Engine) ModelIndex {
if ptr == 0 {
return nil
}
return &qModelIndex{
ptr: ptr,
engine: engine,
}
}
type ModelIndex interface {
// ModelIndex can only be created from a ItemModel
internal_ModelIndex()
Child(row, col int) ModelIndex
Sibling(row, col int) ModelIndex
Column() int
Row() int
Data(role Role) interface{}
Flags() ItemFlags
InternalId() uintptr
InternalPointer() uintptr
IsValid() bool
Model() ItemModel
Parent() ModelIndex
}
func (i *qModelIndex) internal_ModelIndex() {}
func (i *qModelIndex) Child(row, col int) ModelIndex {
return mkModelIndex(uintptr(C.modelIndexChild(unsafe.Pointer(i.ptr), C.int(row), C.int(col))), i.engine)
}
func (i *qModelIndex) Sibling(row, col int) ModelIndex {
return mkModelIndex(uintptr(C.modelIndexSibling(unsafe.Pointer(i.ptr), C.int(row), C.int(col))), i.engine)
}
func (i *qModelIndex) Column() int {
return int(C.modelIndexColumn(unsafe.Pointer(i.ptr)))
}
func (i *qModelIndex) Row() int {
return int(C.modelIndexRow(unsafe.Pointer(i.ptr)))
}
func (i *qModelIndex) Data(role Role) interface{} {
var dvalue C.DataValue
C.modelIndexData(unsafe.Pointer(i.ptr), C.int(role), &dvalue)
return unpackDataValue(&dvalue, i.engine)
}
func (i *qModelIndex) Flags() ItemFlags {
return ItemFlags(C.modelIndexFlags(unsafe.Pointer(i.ptr)))
}
func (i *qModelIndex) InternalId() uintptr {
return uintptr(C.modelIndexInternalId(unsafe.Pointer(i.ptr)))
}
func (i *qModelIndex) InternalPointer() uintptr {
return uintptr(C.modelIndexInternalPointer(unsafe.Pointer(i.ptr)))
}
func (i *qModelIndex) IsValid() bool {
if i == nil || i.ptr == 0 {
return false
}
return bool(C.modelIndexIsValid(unsafe.Pointer(i.ptr)))
}
func (i *qModelIndex) Model() ItemModel {
return itemModelFromCPP(uintptr(C.modelIndexModel(unsafe.Pointer(i.ptr))), i.engine)
}
func (i *qModelIndex) Parent() ModelIndex {
return mkModelIndex(uintptr(C.modelIndexParent(unsafe.Pointer(i.ptr))), i.engine)
}