gui: make session tree fully expanded by default and responsive
- Remove 300ms click delay (timer-based single/double-click disambiguation) - Use native QML onDoubleClicked for rename instead of timer hack - Capture model index as delegate property to fix rename targeting all nodes - Remove dead rename code that was orphaned by the timer removal - Clean up Escape shortcut handler
This commit is contained in:
parent
120e4a4bd6
commit
b13dc6064b
58
gui/main.qml
58
gui/main.qml
|
|
@ -97,27 +97,18 @@ ApplicationWindow {
|
||||||
|
|
||||||
function buildSessionTree() {
|
function buildSessionTree() {
|
||||||
console.log("buildSessionTree: sessions count = " + ollie.sessions.length)
|
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()
|
sessionTreeModel.clear()
|
||||||
var sessions = ollie.sessions
|
var sessions = ollie.sessions
|
||||||
for (var i = 0; i < sessions.length; ++i) {
|
for (var i = 0; i < sessions.length; ++i) {
|
||||||
var sess = sessions[i]
|
var sess = sessions[i]
|
||||||
var sid = sess.id || ""
|
var sid = sess.id || ""
|
||||||
console.log(" session[" + i + "] = " + sid)
|
console.log(" session[" + i + "] = " + sid)
|
||||||
// Preserve previous expanded state; also auto-expand active session
|
// Add session node (always expanded for full overview)
|
||||||
var expanded = expandedSessions[sid] || (sid === ollie.activeSessionId)
|
|
||||||
// Add session node
|
|
||||||
sessionTreeModel.append({
|
sessionTreeModel.append({
|
||||||
type: "session",
|
type: "session",
|
||||||
id: sid,
|
id: sid,
|
||||||
level: 0,
|
level: 0,
|
||||||
expanded: expanded,
|
expanded: true,
|
||||||
state: sess.state || "",
|
state: sess.state || "",
|
||||||
model: sess.model || "",
|
model: sess.model || "",
|
||||||
displayName: sid
|
displayName: sid
|
||||||
|
|
@ -538,38 +529,23 @@ ApplicationWindow {
|
||||||
return 28
|
return 28
|
||||||
}
|
}
|
||||||
visible: height > 0
|
visible: height > 0
|
||||||
|
property int modelIndex: index
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
hoverEnabled: false
|
hoverEnabled: false
|
||||||
onClicked: function() {
|
onClicked: {
|
||||||
if (renamingIndex >= 0) return
|
if (renamingIndex >= 0) return
|
||||||
parent._clickCount++
|
if (type === "session") {
|
||||||
if (parent._clickCount === 1) {
|
toggleExpand(parent.modelIndex)
|
||||||
clickTimer.start()
|
} else if (type === "agent") {
|
||||||
} else if (parent._clickCount === 2) {
|
activateAgent(parentId, agentId)
|
||||||
clickTimer.stop()
|
}
|
||||||
parent._clickCount = 0
|
}
|
||||||
if (type === "session") {
|
onDoubleClicked: {
|
||||||
startRename(index)
|
if (type === "session") {
|
||||||
}
|
startRename(parent.modelIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -599,8 +575,8 @@ ApplicationWindow {
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
text: (index === renamingIndex) ? renamingText : ""
|
text: (modelIndex === renamingIndex) ? renamingText : ""
|
||||||
visible: index === renamingIndex
|
visible: modelIndex === renamingIndex
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize
|
font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
|
|
@ -610,7 +586,7 @@ ApplicationWindow {
|
||||||
radius: 2
|
radius: 2
|
||||||
}
|
}
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (index === renamingIndex) {
|
if (modelIndex === renamingIndex) {
|
||||||
renamingText = text
|
renamingText = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -631,7 +607,7 @@ ApplicationWindow {
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize
|
font.pointSize: theme.fontSize > 0 ? theme.fontSize : Qt.application.font.pointSize
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
visible: index !== renamingIndex
|
visible: modelIndex !== renamingIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue