When typing the second row is selected, so enter activates that command

This commit is contained in:
Paul Ebbers 2025-01-12 20:09:05 +01:00
parent de05468d5e
commit a88b74beb5

View File

@ -2,14 +2,14 @@ import FreeCAD as App
import FreeCADGui as Gui import FreeCADGui as Gui
import os import os
from PySide.QtCore import ( from PySide6.QtCore import (
Qt, Qt,
SIGNAL, SIGNAL,
QSize, QSize,
QIdentityProxyModel, QIdentityProxyModel,
QPoint, QPoint,
) )
from PySide.QtWidgets import ( from PySide6.QtWidgets import (
QTabWidget, QTabWidget,
QSlider, QSlider,
QSpinBox, QSpinBox,
@ -28,7 +28,7 @@ from PySide.QtWidgets import (
QApplication, QApplication,
QListWidget, QListWidget,
) )
from PySide.QtGui import ( from PySide6.QtGui import (
QIcon, QIcon,
QPixmap, QPixmap,
QColor, QColor,
@ -338,6 +338,8 @@ class SearchBox(QLineEdit):
return group return group
else: else:
subitems = filterGroups(group["subitems"]) subitems = filterGroups(group["subitems"])
# if len(subitems) == 0:
# self.index = 0
if len(subitems) > 0 or matches(group["text"]): if len(subitems) > 0 or matches(group["text"]):
return { return {
"id": group["id"], "id": group["id"],
@ -373,9 +375,10 @@ class SearchBox(QLineEdit):
self.proxyModel.setSourceModel(self.mdl) self.proxyModel.setSourceModel(self.mdl)
self.currentExtraInfo = None # Unset this so that the ExtraInfo can be updated self.currentExtraInfo = None # Unset this so that the ExtraInfo can be updated
# TODO: try to find the already-highlighted item # TODO: try to find the already-highlighted item
indexSelect = 1
nbRows = self.listView.model().rowCount() nbRows = self.listView.model().rowCount()
if nbRows > 0: if nbRows > 0:
index = self.listView.model().index(0, 0) index = self.listView.model().index(indexSelect, 0)
self.listView.setCurrentIndex(index) self.listView.setCurrentIndex(index)
self.setExtraInfo(index) self.setExtraInfo(index)
else: else: