diff --git a/gui/main.qml b/gui/main.qml index fe39cc0..2f79439 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -97,27 +97,18 @@ ApplicationWindow { function buildSessionTree() { console.log("buildSessionTree: sessions count = " + ollie.sessions.length) - // Save expanded state before clearing - var expandedSessions = {} - for (var ei = 0; ei < sessionTreeModel.count; ++ei) { - var eitem = sessionTreeModel.get(ei) - if (eitem.type === "session" && eitem.expanded) - expandedSessions[eitem.id] = true - } sessionTreeModel.clear() var sessions = ollie.sessions for (var i = 0; i < sessions.length; ++i) { var sess = sessions[i] var sid = sess.id || "" console.log(" session[" + i + "] = " + sid) - // Preserve previous expanded state; also auto-expand active session - var expanded = expandedSessions[sid] || (sid === ollie.activeSessionId) - // Add session node + // Add session node (always expanded for full overview) sessionTreeModel.append({ type: "session", id: sid, level: 0, - expanded: expanded, + expanded: true, state: sess.state || "", model: sess.model || "", displayName: sid @@ -538,38 +529,23 @@ ApplicationWindow { return 28 } visible: height > 0 - - // Click disambiguation: timer-based single vs double click - property int _clickCount: 0 - Timer { - id: clickTimer - interval: 300 - repeat: false - onTriggered: { - parent._clickCount = 0 - if (type === "session" && index !== renamingIndex) { - toggleExpand(index) - } else if (type === "agent") { - activateAgent(parentId, agentId) - } - } - } + property int modelIndex: index MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton hoverEnabled: false - onClicked: function() { + onClicked: { if (renamingIndex >= 0) return - parent._clickCount++ - if (parent._clickCount === 1) { - clickTimer.start() - } else if (parent._clickCount === 2) { - clickTimer.stop() - parent._clickCount = 0 - if (type === "session") { - startRename(index) - } + if (type === "session") { + toggleExpand(parent.modelIndex) + } else if (type === "agent") { + activateAgent(parentId, agentId) + } + } + onDoubleClicked: { + if (type === "session") { + startRename(parent.modelIndex) } } } @@ -599,8 +575,8 @@ ApplicationWindow { TextField { anchors.fill: parent - text: (index === renamingIndex) ? renamingText : "" - visible: index === renamingIndex + text: (modelIndex === renamingIndex) ? renamingText : "" + visible: modelIndex === renamingIndex verticalAlignment: Text.AlignVCenter font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize color: theme.textColor @@ -610,7 +586,7 @@ ApplicationWindow { radius: 2 } onTextChanged: { - if (index === renamingIndex) { + if (modelIndex === renamingIndex) { renamingText = text } } @@ -631,7 +607,7 @@ ApplicationWindow { color: theme.textColor font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize verticalAlignment: Text.AlignVCenter - visible: index !== renamingIndex + visible: modelIndex !== renamingIndex } }