Em 10/08/2011 07:34, Dave Page escreveu:
Please see about fixing those issues, and then I can give it a more in
depth review.
I fixed the items in question, and performed some more tests.

Apparently it's OK.

If any bugs or any suggestions, please let me know.

The new patch is attached.

Thank you.
>From 6727404ebd0aaf4d7283796058501d51e76675a1 Mon Sep 17 00:00:00 2001
From: Vinicius Santos <vinicius.santos.li...@gmail.com>
Date: Thu, 11 Aug 2011 00:14:23 -0300
Subject: [PATCH] Implement Refresh on click.

---
 pgadmin/frm/events.cpp              |   44 +++++++++++++++++++++++++++++++++++
 pgadmin/frm/frmOptions.cpp          |    3 ++
 pgadmin/include/utils/sysSettings.h |   10 ++++++++
 pgadmin/ui/frmOptions.xrc           |   19 +++++++++++++++
 4 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index f725d39..b746d4a 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -388,6 +388,7 @@ void frmMain::ResetLists()
 
 void frmMain::execSelChange(wxTreeItemId item, bool currentNode)
 {
+       static bool refresh = true;
        if (currentNode)
        {
                ResetLists();
@@ -406,6 +407,49 @@ void frmMain::execSelChange(wxTreeItemId item, bool 
currentNode)
        }
        else
        {
+               int settingRefreshOnClick = settings->GetRefreshOnClick();
+               if ( settingRefreshOnClick != 0
+                       && refresh
+                       && currentObject->GetTypeName() != wxT("Server")
+                       && currentObject->GetTypeName() != wxT("Servers"))
+               {
+                       refresh = false;
+                       
+                       if (settingRefreshOnClick == 1 )
+                       {
+                               //We can not update the schema, because it 
would cause an update to the entire tree.
+                               if (currentObject->GetTypeName() != 
wxT("Schema") && !currentObject->IsCollection())
+                               {
+                                       wxTreeItemId currentItem = 
currentObject->GetId();
+                                       
+
+                                       pgObject *newData = 
currentObject->Refresh(browser, currentItem);
+
+                                       if (newData != 0)
+                                       {
+                                               wxLogInfo(wxT("Replacing with 
new node %s %s for refresh"), newData->GetTypeName().c_str(), 
newData->GetQuotedFullIdentifier().c_str());
+
+                                               
browser->DeleteChildren(currentItem);
+                                               newData->SetId(currentItem);    
// not done automatically
+                                               
browser->SetItemData(currentItem, newData);
+
+                                               // Update the node text if this 
is an object, as it may have been renamed
+                                               if (!newData->IsCollection())
+                                                       
browser->SetItemText(currentItem, newData->GetDisplayName());
+
+                                               delete currentObject;
+                                               currentObject = newData;
+                                       }
+                                       else
+                                               browser->Delete(currentItem);
+                               }
+                       }
+                       else
+                               Refresh(currentObject);
+
+                       refresh = true;
+               }
+
                if (currentNode)
                {
                        properties->Freeze();
diff --git a/pgadmin/frm/frmOptions.cpp b/pgadmin/frm/frmOptions.cpp
index 92f9b75..4ef39c3 100644
--- a/pgadmin/frm/frmOptions.cpp
+++ b/pgadmin/frm/frmOptions.cpp
@@ -101,6 +101,7 @@
 #define pickerSQLColour11           CTRL_COLOURPICKER("pickerSQLColour11")
 #define pickerSQLCaretColour               
CTRL_COLOURPICKER("pickerSQLCaretColour")
 #define chkKeywordsInUppercase      CTRL_CHECKBOX("chkKeywordsInUppercase")
+#define cbRefreshOnClick                       
CTRL_COMBOBOX("cbRefreshOnClick")
 
 BEGIN_EVENT_TABLE(frmOptions, pgDialog)
        EVT_MENU(MNU_HELP,                                            
frmOptions::OnHelp)
@@ -243,6 +244,7 @@ frmOptions::frmOptions(frmMain *parent)
        chkSpacesForTabs->SetValue(settings->GetSpacesForTabs());
        cbCopyQuote->SetSelection(settings->GetCopyQuoting());
        cbCopyQuoteChar->SetValue(settings->GetCopyQuoteChar());
+       cbRefreshOnClick->SetSelection(settings->GetRefreshOnClick());
 
        wxString copySeparator = settings->GetCopyColSeparator();
        if (copySeparator == wxT("\t"))
@@ -553,6 +555,7 @@ void frmOptions::OnOK(wxCommandEvent &ev)
        settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue());
        
settings->SetHistoryMaxQueries(StrToLong(txtHistoryMaxQueries->GetValue()));
        
settings->SetHistoryMaxQuerySize(StrToLong(txtHistoryMaxQuerySize->GetValue()));
+       settings->SetRefreshOnClick(cbRefreshOnClick->GetSelection());
 
        wxString copySeparator = cbCopySeparator->GetValue();
        if (copySeparator == _("Tab"))
diff --git a/pgadmin/include/utils/sysSettings.h 
b/pgadmin/include/utils/sysSettings.h
index 6528a5f..9dff7b4 100644
--- a/pgadmin/include/utils/sysSettings.h
+++ b/pgadmin/include/utils/sysSettings.h
@@ -669,6 +669,16 @@ public:
                WriteBool(wxT("IgnoreVersion"), newval);
        }
 
+       int GetRefreshOnClick() const
+       {
+               int i;
+               Read(wxT("RefreshOnClick"), &i, 0);
+               return i;
+       }
+       void SetRefreshOnClick(const int newval)
+       {
+               WriteInt(wxT("RefreshOnClick"), newval);
+       }
        bool GetShowNotices() const
        {
                bool b;
diff --git a/pgadmin/ui/frmOptions.xrc b/pgadmin/ui/frmOptions.xrc
index 78f2430..a44eb44 100644
--- a/pgadmin/ui/frmOptions.xrc
+++ b/pgadmin/ui/frmOptions.xrc
@@ -332,6 +332,25 @@
                   
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
                   <border>4</border>
                 </object>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stRefreshOnClick">
+                    <label>Refresh on click:</label>
+                  </object>
+                  <flag>wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxComboBox" name="cbRefreshOnClick">
+                    <content>
+                      <item>None</item>
+                      <item>Refresh object on click</item>
+                      <item>Refresh object and children on click</item>
+                    </content>
+                    <style>wxCB_READONLY|wxCB_DROPDOWN</style>
+                  </object>
+                  
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
               </object>
             </object>
           </object>
-- 
1.7.4.msysgit.0

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to