From 19d38607c4a5f5bd3d2a2654e09c70ea999bab9f Mon Sep 17 00:00:00 2001 From: lsv Date: Wed, 31 May 2023 16:28:12 +0500 Subject: [PATCH] Search only servers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Если текущий выделенный элемент является сервером, то при наборе символов поиск по дереву будет проводиться только на уровне серверов. --- ctl/ctlTree.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ctl/ctlTree.cpp b/ctl/ctlTree.cpp index 18b189d..a99d140 100644 --- a/ctl/ctlTree.cpp +++ b/ctl/ctlTree.cpp @@ -300,7 +300,29 @@ void ctlTree::OnChar(wxKeyEvent &event) if (!currItem.IsOk()) return; - wxTreeItemId matchItem = FindItem(currItem, m_findPrefix + (wxChar)keyCode); + wxTreeItemId matchItem; + wxTreeItemData* data = GetItemData(currItem); + // Set the item colour + if (data) + { + if (((pgObject*)data)->GetMetaType() == PGM_SERVER) + { + wxString prefix = m_findPrefix + (wxChar)keyCode; + wxTreeItemId id= GetNextSibling(currItem); + while (id.IsOk() && + ((GetItemText(id) == wxT("Dummy") && !GetItemData(id)) || + !((GetItemText(id).Lower().StartsWith(prefix)) + ) + )) + { + id = GetNextSibling(id); + } + if (id.IsOk()) matchItem = id; + } else + matchItem = FindItem(currItem, m_findPrefix + (wxChar)keyCode); + } + + if ( matchItem.IsOk() ) {