diff --git a/internal/binding/parser/class.go b/internal/binding/parser/class.go index 1a13a2b5..9ecbf86b 100755 --- a/internal/binding/parser/class.go +++ b/internal/binding/parser/class.go @@ -124,12 +124,14 @@ func (c *Class) IsSubClassOf(class string) bool { func (c *Class) isSubClass() bool { return c.Fullname != "" } func (c *Class) HasFunctionWithName(n string) bool { - for _, f := range c.Functions { - if strings.ToLower(f.Name) != strings.ToLower(n) { - continue - } + return c.HasFunctionWithNameAndOverloadNumber(n, "") +} - return true +func (c *Class) HasFunctionWithNameAndOverloadNumber(n string, num string) bool { + for _, f := range c.Functions { + if strings.ToLower(f.Name) == strings.ToLower(n) && f.OverloadNumber == num { + return true + } } return false diff --git a/internal/examples/quick/hotreload/hotreload.go b/internal/examples/quick/hotreload/hotreload.go new file mode 100755 index 00000000..7500790d --- /dev/null +++ b/internal/examples/quick/hotreload/hotreload.go @@ -0,0 +1,43 @@ +package main + +import ( + "os" + "path/filepath" + + "github.com/therecipe/qt/core" + "github.com/therecipe/qt/quick" + "github.com/therecipe/qt/widgets" +) + +func initQQuickView(path string) *quick.QQuickView { + + var view = quick.NewQQuickView(nil) + + var watcher = core.NewQFileSystemWatcher2([]string{filepath.Dir(path)}, nil) + + var reload = func(p string) { + println("changed:", p) + view.SetSource(core.NewQUrl()) + view.Engine().ClearComponentCache() + view.SetSource(core.NewQUrl3(path, 0)) + } + + //watcher.ConnectFileChanged(reload) + watcher.ConnectDirectoryChanged(reload) + + return view +} + +func main() { + + var path = filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "therecipe", "qt", "internal", "examples", "quick", "hotreload", "qml", "hotreload.qml") + + widgets.NewQApplication(len(os.Args), os.Args) + + var view = initQQuickView(path) + view.SetSource(core.NewQUrl3(path, 0)) + view.SetResizeMode(quick.QQuickView__SizeRootObjectToView) + view.Show() + + widgets.QApplication_Exec() +} diff --git a/internal/examples/quick/hotreload/qml/hotreload.qml b/internal/examples/quick/hotreload/qml/hotreload.qml new file mode 100755 index 00000000..d1f1a0d1 --- /dev/null +++ b/internal/examples/quick/hotreload/qml/hotreload.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { + id: page + width: 320; height: 480 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } +} diff --git a/internal/moc/moc.go b/internal/moc/moc.go index 05c99626..d08bfc4b 100755 --- a/internal/moc/moc.go +++ b/internal/moc/moc.go @@ -352,7 +352,7 @@ func (m *appMoc) generate() error { f.Name = strings.Replace(f.Name, bcf.ClassName(), c.Name, -1) f.Fullname = strings.Replace(f.Fullname, bcf.ClassName(), c.Name, -1) - if !c.HasFunctionWithName(f.Name) { + if !c.HasFunctionWithNameAndOverloadNumber(f.Name, f.OverloadNumber) { c.Functions = append(c.Functions, &f) } } diff --git a/internal/utils/walk.go b/internal/utils/walk.go old mode 100644 new mode 100755