From 183a800f45d3d52f7a4c60db51f3b366637b86dd Mon Sep 17 00:00:00 2001 From: lsv Date: Fri, 24 Oct 2025 15:12:01 +0500 Subject: [PATCH] Extended use shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Быстрый поиск по F4 выполняется теперь не только по посещенным узлам, но и не явно по серверам и их хостам. В выпадающем списке сервера не указываются, поиск производится при наборе фразы. --- ctl/ctlShortCut.cpp | 26 ++++++++++++++++++++++++-- frm/events.cpp | 9 ++++++--- include/ctl/ctlShortCut.h | 7 +++++-- include/frm/frmMain.h | 3 +++ pgAdmin3.cpp | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 7 deletions(-) diff --git a/ctl/ctlShortCut.cpp b/ctl/ctlShortCut.cpp index de2fcab..3adf598 100644 --- a/ctl/ctlShortCut.cpp +++ b/ctl/ctlShortCut.cpp @@ -16,7 +16,7 @@ ctlShortCut::ctlShortCut(frmMain* main,wxWindow* parent, wxWindowID id, const wx Create(parent, id, wxEmptyString, pos, sz, style); //comboCustom->Create(panel, wxID_ANY, wxEmptyString); txt->Create(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, style); - txt->SetFont(settings->GetSystemFont()); + txt->SetFont(settings->GetSystemFont()); //txt->SetBackgroundColour(*wxWHITE); pop = new wxVListBoxComboPopup(); ///UseAltPopupWindow(false); @@ -83,6 +83,20 @@ wxArrayString ctlShortCut::BuildList(wxString& find, bool full) { } } + // check servers list + for (int i = 0; iservers_find_list.Count(); i++) { + wxString t = viewText(frm->servers_find_list[i]); + if (t.Find(find) != wxNOT_FOUND) { + //wxString t2=frm->servers_find_list[i].BeforeFirst('(').Trim(); + wxString t2=frm->servers_find_list[i]; + if (full) + { + if (find.Length() == t.length()) rez.Add(t2); + } + else + rez.Add(t2); + } + } if (rez.Count() > 0|| full) return rez; return frm->shortcut; @@ -118,8 +132,16 @@ void ctlShortCut::OnTEXT(wxCommandEvent& event) { if (!IsPopupShown() && ( true) ) { wxString s = txt->GetValue(); SetText(s,false); - if (pop->GetCount() > 0) { + if (pop->GetCount() > 0 && s.Length()>0) { Popup(); + #ifdef __LINUX__ + //wxCommandEvent event(wxEVT_COMBOBOX_DROPDOWN,GetId() ); + //event.SetEventObject( this ); + //wxPostEvent(GetParent(), event); + //this->AddPendingEvent(event); + #else + //Popup(); + #endif } //int e = txt->SetSelection(0, 1); // diff --git a/frm/events.cpp b/frm/events.cpp index e7cc8c7..131c8f9 100644 --- a/frm/events.cpp +++ b/frm/events.cpp @@ -867,12 +867,15 @@ void frmMain::OnShortCut(wxCommandEvent& event) path = select_shortcut.SubString(1, select_shortcut.Length() - 1); add = true; } - else path = select_shortcut.substr(4); + else path = select_shortcut; if (!SetCurrentNode(GetBrowser()->GetRootItem(), path)) { - wxMessageBox(_("The specified object couldn't be found in the tree.")); - return; + path = path.substr(4).BeforeFirst('(').Trim(); + if (!SetCurrentNode(GetBrowser()->GetRootItem(), path)) { + wxMessageBox(_("The specified object couldn't be found in the tree.")); + return; + } } if (add) { int p = shortcut.Index(path); diff --git a/include/ctl/ctlShortCut.h b/include/ctl/ctlShortCut.h index 06de736..49c429b 100644 --- a/include/ctl/ctlShortCut.h +++ b/include/ctl/ctlShortCut.h @@ -34,7 +34,7 @@ public: int idx=0; wxString si = ss.substr(0, 4).Trim(); - if (si.ToInt(&idx)) { + if (si.ToInt(&idx) && idx>=0) { dc.DrawBitmap(imageList->GetBitmap(idx),wxPoint(rect.x,rect.y)); } ; @@ -55,7 +55,10 @@ public: dc.GetTextExtent(pref, &lineWidth, &lineHeight); r.width = lineWidth; r.height = lineHeight; - dc.DrawRoundedRectangle(r, 3); + { + wxDCPenChanger npen(dc, *wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxPENSTYLE_SOLID)); + dc.DrawRoundedRectangle(r, 3); + } } dc.GetTextExtent(src, &w1, &h1); dc.DrawText(src, diff --git a/include/frm/frmMain.h b/include/frm/frmMain.h index 023e8b3..708d1f9 100644 --- a/include/frm/frmMain.h +++ b/include/frm/frmMain.h @@ -206,7 +206,10 @@ public: public: frmLog* Logfrm; + // select node full path wxArrayString shortcut; + // all servers info for find . Append only start pgadmin3 + wxArrayString servers_find_list; wxString select_shortcut; private: wxAuiManager manager; diff --git a/pgAdmin3.cpp b/pgAdmin3.cpp index 86d436e..ad750db 100644 --- a/pgAdmin3.cpp +++ b/pgAdmin3.cpp @@ -933,6 +933,39 @@ bool pgAdmin3::OnInit() winMain->Show(); SetTopWindow(winMain); + // Append all server for shortcut + wxTreeItemIdValue foldercookie; + ctlTree *browser=winMain->GetBrowser(); + wxTreeItemId folderitem = browser->GetFirstChild(browser->GetRootItem(), foldercookie); + while (folderitem) + { + if (browser->ItemHasChildren(folderitem)) + { + wxTreeItemIdValue servercookie; + wxTreeItemId serveritem = browser->GetFirstChild(folderitem, servercookie); + while (serveritem) + { + pgServer *server = (pgServer *)browser->GetItemData(serveritem); + if (server != NULL && server->IsCreatedBy(serverFactory)) { + wxString path=server->GetFullName(); + wxTreeItemId node=serveritem; + + wxTreeItemId parent = browser->GetItemParent(node); + while (parent.IsOk()) + { + path = browser->GetItemText(parent).BeforeFirst('(').Trim() + wxT("/") + path; + parent = browser->GetItemParent(parent); + } + path=wxString::Format("%4d%s",-1,path); + + winMain->servers_find_list.Add(path); + + } + serveritem = browser->GetNextChild(folderitem, servercookie); + } + } + folderitem = browser->GetNextChild(browser->GetRootItem(), foldercookie); + } wxString str; if (cmdParser.Found(wxT("s"), &str))