Begin yet another model refactor

Use native ListModel which require a lot of changes, but should be
much faster than the old way which exponentially slowed down to a crawl.
Also fix some popup bugs (leave/forget).

Not working yet: side pane keyboard controls, proper highlight,
room & member filtering, local echo replacement
This commit is contained in:
miruka
2019-12-02 16:29:29 -04:00
parent 2ce5e20efa
commit 9990fecc74
49 changed files with 826 additions and 781 deletions

View File

@@ -3,41 +3,16 @@
import QtQuick 2.12
import io.thp.pyotherside 1.5
import CppUtils 0.1
import "Privates"
Python {
id: py
Component.onCompleted: {
for (var func in privates.eventHandlers) {
if (! privates.eventHandlers.hasOwnProperty(func)) continue
setHandler(func.replace(/^on/, ""), privates.eventHandlers[func])
}
addImportPath("src")
addImportPath("qrc:/src")
importNames("backend.qml_bridge", ["BRIDGE"], () => {
loadSettings(() => {
callCoro("saved_accounts.any_saved", [], any => {
if (any) { py.callCoro("load_saved_accounts", []) }
py.startupAnyAccountsSaved = any
py.ready = true
})
})
})
}
property bool ready: false
property bool startupAnyAccountsSaved: false
readonly property QtObject privates: QtObject {
readonly property var pendingCoroutines: ({})
readonly property EventHandlers eventHandlers: EventHandlers {}
function makeFuture(callback) {
return Qt.createComponent("Future.qml")
.createObject(py, {bridge: py})
.createObject(py, { bridge: py })
}
}
@@ -47,15 +22,10 @@ Python {
}
function callSync(name, args=[]) {
return call_sync("BRIDGE.backend." + name, args)
}
function callCoro(name, args=[], onSuccess=null, onError=null) {
let uuid = name + "." + CppUtils.uuid()
privates.pendingCoroutines[uuid] = {onSuccess, onError}
Globals.pendingCoroutines[uuid] = {onSuccess, onError}
let future = privates.makeFuture()
@@ -75,7 +45,7 @@ Python {
callCoro("get_client", [accountId], () => {
let uuid = accountId + "." + name + "." + CppUtils.uuid()
privates.pendingCoroutines[uuid] = {onSuccess, onError}
Globals.pendingCoroutines[uuid] = {onSuccess, onError}
let call_args = [accountId, name, uuid, args]