mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
252 lines
8.8 KiB
Go
252 lines
8.8 KiB
Go
|
package qt6
|
||
|
|
||
|
/*
|
||
|
|
||
|
#include "gen_qstringlistmodel.h"
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
*/
|
||
|
import "C"
|
||
|
|
||
|
import (
|
||
|
"runtime"
|
||
|
"unsafe"
|
||
|
)
|
||
|
|
||
|
type QStringListModel struct {
|
||
|
h *C.QStringListModel
|
||
|
*QAbstractListModel
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) cPointer() *C.QStringListModel {
|
||
|
if this == nil {
|
||
|
return nil
|
||
|
}
|
||
|
return this.h
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) UnsafePointer() unsafe.Pointer {
|
||
|
if this == nil {
|
||
|
return nil
|
||
|
}
|
||
|
return unsafe.Pointer(this.h)
|
||
|
}
|
||
|
|
||
|
func newQStringListModel(h *C.QStringListModel) *QStringListModel {
|
||
|
if h == nil {
|
||
|
return nil
|
||
|
}
|
||
|
return &QStringListModel{h: h, QAbstractListModel: UnsafeNewQAbstractListModel(unsafe.Pointer(h))}
|
||
|
}
|
||
|
|
||
|
func UnsafeNewQStringListModel(h unsafe.Pointer) *QStringListModel {
|
||
|
return newQStringListModel((*C.QStringListModel)(h))
|
||
|
}
|
||
|
|
||
|
// NewQStringListModel constructs a new QStringListModel object.
|
||
|
func NewQStringListModel() *QStringListModel {
|
||
|
ret := C.QStringListModel_new()
|
||
|
return newQStringListModel(ret)
|
||
|
}
|
||
|
|
||
|
// NewQStringListModel2 constructs a new QStringListModel object.
|
||
|
func NewQStringListModel2(strings []string) *QStringListModel {
|
||
|
strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings))))
|
||
|
defer C.free(unsafe.Pointer(strings_CArray))
|
||
|
for i := range strings {
|
||
|
strings_i_ms := C.struct_miqt_string{}
|
||
|
strings_i_ms.data = C.CString(strings[i])
|
||
|
strings_i_ms.len = C.size_t(len(strings[i]))
|
||
|
defer C.free(unsafe.Pointer(strings_i_ms.data))
|
||
|
strings_CArray[i] = strings_i_ms
|
||
|
}
|
||
|
strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)}
|
||
|
defer runtime.KeepAlive(unsafe.Pointer(strings_ma))
|
||
|
ret := C.QStringListModel_new2(strings_ma)
|
||
|
return newQStringListModel(ret)
|
||
|
}
|
||
|
|
||
|
// NewQStringListModel3 constructs a new QStringListModel object.
|
||
|
func NewQStringListModel3(parent *QObject) *QStringListModel {
|
||
|
ret := C.QStringListModel_new3(parent.cPointer())
|
||
|
return newQStringListModel(ret)
|
||
|
}
|
||
|
|
||
|
// NewQStringListModel4 constructs a new QStringListModel object.
|
||
|
func NewQStringListModel4(strings []string, parent *QObject) *QStringListModel {
|
||
|
strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings))))
|
||
|
defer C.free(unsafe.Pointer(strings_CArray))
|
||
|
for i := range strings {
|
||
|
strings_i_ms := C.struct_miqt_string{}
|
||
|
strings_i_ms.data = C.CString(strings[i])
|
||
|
strings_i_ms.len = C.size_t(len(strings[i]))
|
||
|
defer C.free(unsafe.Pointer(strings_i_ms.data))
|
||
|
strings_CArray[i] = strings_i_ms
|
||
|
}
|
||
|
strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)}
|
||
|
defer runtime.KeepAlive(unsafe.Pointer(strings_ma))
|
||
|
ret := C.QStringListModel_new4(strings_ma, parent.cPointer())
|
||
|
return newQStringListModel(ret)
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) MetaObject() *QMetaObject {
|
||
|
return UnsafeNewQMetaObject(unsafe.Pointer(C.QStringListModel_MetaObject(this.h)))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Metacast(param1 string) unsafe.Pointer {
|
||
|
param1_Cstring := C.CString(param1)
|
||
|
defer C.free(unsafe.Pointer(param1_Cstring))
|
||
|
return (unsafe.Pointer)(C.QStringListModel_Metacast(this.h, param1_Cstring))
|
||
|
}
|
||
|
|
||
|
func QStringListModel_Tr(s string) string {
|
||
|
s_Cstring := C.CString(s)
|
||
|
defer C.free(unsafe.Pointer(s_Cstring))
|
||
|
var _ms C.struct_miqt_string = C.QStringListModel_Tr(s_Cstring)
|
||
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
||
|
C.free(unsafe.Pointer(_ms.data))
|
||
|
return _ret
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) RowCount() int {
|
||
|
return (int)(C.QStringListModel_RowCount(this.h))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Sibling(row int, column int, idx *QModelIndex) *QModelIndex {
|
||
|
_ret := C.QStringListModel_Sibling(this.h, (C.int)(row), (C.int)(column), idx.cPointer())
|
||
|
_goptr := newQModelIndex(_ret)
|
||
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
||
|
return _goptr
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Data(index *QModelIndex) *QVariant {
|
||
|
_ret := C.QStringListModel_Data(this.h, index.cPointer())
|
||
|
_goptr := newQVariant(_ret)
|
||
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
||
|
return _goptr
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) SetData(index *QModelIndex, value *QVariant) bool {
|
||
|
return (bool)(C.QStringListModel_SetData(this.h, index.cPointer(), value.cPointer()))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) ClearItemData(index *QModelIndex) bool {
|
||
|
return (bool)(C.QStringListModel_ClearItemData(this.h, index.cPointer()))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Flags(index *QModelIndex) ItemFlag {
|
||
|
return (ItemFlag)(C.QStringListModel_Flags(this.h, index.cPointer()))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) InsertRows(row int, count int) bool {
|
||
|
return (bool)(C.QStringListModel_InsertRows(this.h, (C.int)(row), (C.int)(count)))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) RemoveRows(row int, count int) bool {
|
||
|
return (bool)(C.QStringListModel_RemoveRows(this.h, (C.int)(row), (C.int)(count)))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) MoveRows(sourceParent *QModelIndex, sourceRow int, count int, destinationParent *QModelIndex, destinationChild int) bool {
|
||
|
return (bool)(C.QStringListModel_MoveRows(this.h, sourceParent.cPointer(), (C.int)(sourceRow), (C.int)(count), destinationParent.cPointer(), (C.int)(destinationChild)))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Sort(column int) {
|
||
|
C.QStringListModel_Sort(this.h, (C.int)(column))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) StringList() []string {
|
||
|
var _ma *C.struct_miqt_array = C.QStringListModel_StringList(this.h)
|
||
|
_ret := make([]string, int(_ma.len))
|
||
|
_outCast := (*[0xffff]C.struct_miqt_string)(unsafe.Pointer(_ma.data)) // hey ya
|
||
|
for i := 0; i < int(_ma.len); i++ {
|
||
|
var _lv_ms C.struct_miqt_string = _outCast[i]
|
||
|
_lv_ret := C.GoStringN(_lv_ms.data, C.int(int64(_lv_ms.len)))
|
||
|
C.free(unsafe.Pointer(_lv_ms.data))
|
||
|
_ret[i] = _lv_ret
|
||
|
}
|
||
|
C.free(unsafe.Pointer(_ma))
|
||
|
return _ret
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) SetStringList(strings []string) {
|
||
|
strings_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(strings))))
|
||
|
defer C.free(unsafe.Pointer(strings_CArray))
|
||
|
for i := range strings {
|
||
|
strings_i_ms := C.struct_miqt_string{}
|
||
|
strings_i_ms.data = C.CString(strings[i])
|
||
|
strings_i_ms.len = C.size_t(len(strings[i]))
|
||
|
defer C.free(unsafe.Pointer(strings_i_ms.data))
|
||
|
strings_CArray[i] = strings_i_ms
|
||
|
}
|
||
|
strings_ma := &C.struct_miqt_array{len: C.size_t(len(strings)), data: unsafe.Pointer(strings_CArray)}
|
||
|
defer runtime.KeepAlive(unsafe.Pointer(strings_ma))
|
||
|
C.QStringListModel_SetStringList(this.h, strings_ma)
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) SupportedDropActions() DropAction {
|
||
|
return (DropAction)(C.QStringListModel_SupportedDropActions(this.h))
|
||
|
}
|
||
|
|
||
|
func QStringListModel_Tr2(s string, c string) string {
|
||
|
s_Cstring := C.CString(s)
|
||
|
defer C.free(unsafe.Pointer(s_Cstring))
|
||
|
c_Cstring := C.CString(c)
|
||
|
defer C.free(unsafe.Pointer(c_Cstring))
|
||
|
var _ms C.struct_miqt_string = C.QStringListModel_Tr2(s_Cstring, c_Cstring)
|
||
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
||
|
C.free(unsafe.Pointer(_ms.data))
|
||
|
return _ret
|
||
|
}
|
||
|
|
||
|
func QStringListModel_Tr3(s string, c string, n int) string {
|
||
|
s_Cstring := C.CString(s)
|
||
|
defer C.free(unsafe.Pointer(s_Cstring))
|
||
|
c_Cstring := C.CString(c)
|
||
|
defer C.free(unsafe.Pointer(c_Cstring))
|
||
|
var _ms C.struct_miqt_string = C.QStringListModel_Tr3(s_Cstring, c_Cstring, (C.int)(n))
|
||
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
||
|
C.free(unsafe.Pointer(_ms.data))
|
||
|
return _ret
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) RowCount1(parent *QModelIndex) int {
|
||
|
return (int)(C.QStringListModel_RowCount1(this.h, parent.cPointer()))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Data2(index *QModelIndex, role int) *QVariant {
|
||
|
_ret := C.QStringListModel_Data2(this.h, index.cPointer(), (C.int)(role))
|
||
|
_goptr := newQVariant(_ret)
|
||
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
||
|
return _goptr
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) SetData3(index *QModelIndex, value *QVariant, role int) bool {
|
||
|
return (bool)(C.QStringListModel_SetData3(this.h, index.cPointer(), value.cPointer(), (C.int)(role)))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) InsertRows3(row int, count int, parent *QModelIndex) bool {
|
||
|
return (bool)(C.QStringListModel_InsertRows3(this.h, (C.int)(row), (C.int)(count), parent.cPointer()))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) RemoveRows3(row int, count int, parent *QModelIndex) bool {
|
||
|
return (bool)(C.QStringListModel_RemoveRows3(this.h, (C.int)(row), (C.int)(count), parent.cPointer()))
|
||
|
}
|
||
|
|
||
|
func (this *QStringListModel) Sort2(column int, order SortOrder) {
|
||
|
C.QStringListModel_Sort2(this.h, (C.int)(column), (C.int)(order))
|
||
|
}
|
||
|
|
||
|
// Delete this object from C++ memory.
|
||
|
func (this *QStringListModel) Delete() {
|
||
|
C.QStringListModel_Delete(this.h)
|
||
|
}
|
||
|
|
||
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
||
|
// from C++ memory once it is unreachable from Go memory.
|
||
|
func (this *QStringListModel) GoGC() {
|
||
|
runtime.SetFinalizer(this, func(this *QStringListModel) {
|
||
|
this.Delete()
|
||
|
runtime.KeepAlive(this.h)
|
||
|
})
|
||
|
}
|