in an object type independent way - ie. in pgObject for example. Not
sure how feasible that is though...

Hello,

It could take a look at my patch?

I thought of other ways to implement, but I ended up with this.

Thanks.

>From d85df2b2543a2974cdd1b8679938cce32991f1b9 Mon Sep 17 00:00:00 2001
From: viniciussantos <[email protected]>
Date: Sun, 29 May 2011 22:08:52 -0300
Subject: [PATCH] UpdateObjects implementation.

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

diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index 0e6b078..92b5d7b 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -369,6 +369,7 @@ void frmMain::OnTreeSelChanged(wxTreeEvent &event)
 
 void frmMain::execSelChange(wxTreeItemId item, bool currentNode)
 {
+       static bool refresh = true;
        if (currentNode)
        {
                properties->ClearAll();
@@ -390,6 +391,17 @@ void frmMain::execSelChange(wxTreeItemId item, bool 
currentNode)
        }
        else
        {
+               //Update objects by clicking, if the option is checked.
+               if (settings->GetUpdateObjects() && refresh 
+                       && currentObject->GetTypeName() != wxT("Server")
+                       && currentObject->GetTypeName() != wxT("Servers")
+                       && currentObject->GetTypeName() != wxT("Databases"))
+               {
+                       refresh = false;
+                       Refresh(currentObject);
+                       refresh = true;
+               }
+               
                if (currentNode)
                {
                        properties->Freeze();
diff --git a/pgadmin/frm/frmOptions.cpp b/pgadmin/frm/frmOptions.cpp
index 22e4c43..478ceb9 100644
--- a/pgadmin/frm/frmOptions.cpp
+++ b/pgadmin/frm/frmOptions.cpp
@@ -100,6 +100,7 @@
 #define pickerSQLColour11           CTRL_COLOURPICKER("pickerSQLColour11")
 #define pickerSQLCaretColour               
CTRL_COLOURPICKER("pickerSQLCaretColour")
 #define chkKeywordsInUppercase      CTRL_CHECKBOX("chkKeywordsInUppercase")
+#define chkUpdateObjects                       
CTRL_CHECKBOX("chkUpdateObjects")
 
 BEGIN_EVENT_TABLE(frmOptions, pgDialog)
        EVT_MENU(MNU_HELP,                                            
frmOptions::OnHelp)
@@ -265,6 +266,7 @@ frmOptions::frmOptions(frmMain *parent)
        pickerEnterprisedbPath->SetPath(settings->GetEnterprisedbPath());
        pickerGPDBPath->SetPath(settings->GetGPDBPath());
        chkIgnoreVersion->SetValue(settings->GetIgnoreVersion());
+       chkUpdateObjects->SetValue(settings->GetUpdateObjects());
 
        // Get back the colours
        pickerIdleProcessColour->SetColour(settings->GetIdleProcessColour());
@@ -619,6 +621,7 @@ void frmOptions::OnOK(wxCommandEvent &ev)
 
 
        settings->SetIgnoreVersion(chkIgnoreVersion->GetValue());
+       settings->SetUpdateObjects(chkUpdateObjects->GetValue());
 
        if (chkResetHints->GetValue())
                frmHint::ResetHints();
diff --git a/pgadmin/include/utils/sysSettings.h 
b/pgadmin/include/utils/sysSettings.h
index e21406a..9d6b016 100644
--- a/pgadmin/include/utils/sysSettings.h
+++ b/pgadmin/include/utils/sysSettings.h
@@ -668,6 +668,16 @@ public:
        {
                WriteBool(wxT("IgnoreVersion"), newval);
        }
+       bool GetUpdateObjects() const
+       {
+               bool b;
+               Read(wxT("UpdateObjects"), &b, false);
+               return b;
+       }
+       void SetUpdateObjects(const bool newval)
+       {
+               WriteBool(wxT("UpdateObjects"), newval);
+       }               
 
        // Functions for storing settings
        bool Write(const wxString &key, const wxString &value)
diff --git a/pgadmin/ui/frmOptions.xrc b/pgadmin/ui/frmOptions.xrc
index 73a25f3..605e307 100644
--- a/pgadmin/ui/frmOptions.xrc
+++ b/pgadmin/ui/frmOptions.xrc
@@ -282,6 +282,13 @@
                   
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
                   <border>4</border>
                 </object>
+                <object class="sizeritem">
+                  <object class="wxCheckBox" name="chkUpdateObjects">
+                    <label>Update objects by clicking</label>
+                  </object>
+                  
<flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>                                      
               </object>
             </object>
           </object>
-- 
1.7.3.1.msysgit.0

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

Reply via email to