Hi, I didn't have a lot of time tonight, so I did this before working on bigger patches.
This patch tries to select the last value of the comboboxes in the server connection dialog when a user selects another server. Path attached. And you can see it at http://github.com/gleu/pgadmin3/commit/8c358a7ead668bc7b2f7c845ab83b4b3c8f4d1aa (or grab my ticket232 branch). Comments? -- Guillaume http://www.postgresql.fr http://dalibo.com
>From 8c358a7ead668bc7b2f7c845ab83b4b3c8f4d1aa Mon Sep 17 00:00:00 2001 From: Guillaume Lelarge <guilla...@lelarge.info> Date: Thu, 9 Sep 2010 23:26:23 +0200 Subject: [PATCH] Select old values when connecting to another server When a user selects another server, the database and user comboboxes are cleared and filled again with the new values. The last selected item for both comboboxes should be selected if they are still present. Implements #232. --- pgadmin/dlg/dlgSelectConnection.cpp | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pgadmin/dlg/dlgSelectConnection.cpp b/pgadmin/dlg/dlgSelectConnection.cpp index f541583..cd18599 100644 --- a/pgadmin/dlg/dlgSelectConnection.cpp +++ b/pgadmin/dlg/dlgSelectConnection.cpp @@ -87,9 +87,17 @@ wxString dlgSelectConnection::GetHelpPage() const void dlgSelectConnection::OnChangeServer(wxCommandEvent& ev) { + int item; + wxString olddatabase, oldusername; + if (!GetServer()) return; + // Keep old value for these comboboxes so that we can restore them if needed + olddatabase = cbDatabase->GetValue(); + oldusername = cbUsername->GetValue(); + + // Clear the comboboxes cbDatabase->Clear(); cbUsername->Clear(); cbRolename->Clear(); @@ -115,22 +123,32 @@ void dlgSelectConnection::OnChangeServer(wxCommandEvent& ev) wxT(" FROM pg_database db\n") wxT(" WHERE datallowconn ORDER BY datname")); + item = 0; while(set1.RowsLeft()) + { cbDatabase->Append(set1.GetVal(wxT("datname"))); + if (set1.GetVal(wxT("datname")) == olddatabase) + item = cbDatabase->GetCount() - 1; + } if (cbDatabase->GetCount()) - cbDatabase->SetSelection(0); + cbDatabase->SetSelection(item); pgSetIterator set2(remoteServer->GetConnection(), wxT("SELECT DISTINCT usename\n") wxT("FROM pg_user db\n") wxT("ORDER BY usename")); + item = 0; while(set2.RowsLeft()) + { cbUsername->Append(set2.GetVal(wxT("usename"))); + if (set2.GetVal(wxT("usename")) == oldusername) + item = cbDatabase->GetCount() - 1; + } if (cbUsername->GetCount()) - cbUsername->SetSelection(0); + cbUsername->SetSelection(item); if (remoteServer->GetConnection()->BackendMinimumVersion(8, 1)) { -- 1.7.0.4
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers