Thread: SVN Commit by dpage: r4644 - in trunk/pgadmin3: . src/dlg src/include

SVN Commit by dpage: r4644 - in trunk/pgadmin3: . src/dlg src/include

From
svn@pgadmin.org
Date:
Author: dpage
Date: 2005-11-03 09:16:13 +0000 (Thu, 03 Nov 2005)
New Revision: 4644

Modified:
   trunk/pgadmin3/CHANGELOG.txt
   trunk/pgadmin3/src/dlg/dlgType.cpp
   trunk/pgadmin3/src/include/dlgType.h
Log:
Honour type length/precision when creating composite types, per Ivan

Modified: trunk/pgadmin3/CHANGELOG.txt
===================================================================
--- trunk/pgadmin3/CHANGELOG.txt    2005-11-03 08:35:11 UTC (rev 4643)
+++ trunk/pgadmin3/CHANGELOG.txt    2005-11-03 09:16:13 UTC (rev 4644)
@@ -17,6 +17,7 @@
 </ul>
 <br>
 <ul>
+    <li>2005-11-03 DP  1.4RC2 Honour type length/precision when creating composite types, per Ivan
     <li>2005-11-02 AP  1.4RC2 Fix crash in trigger property (r: Oriza Triznyak)
     <li>2005-11-01 AP  1.4RC2 Fix function return type array (r: Andras Voros)
     <li>2005-11-01 AP  1.4RC2 Fix query tool connect annoyance (r: Florian Pflug)

Modified: trunk/pgadmin3/src/dlg/dlgType.cpp
===================================================================
--- trunk/pgadmin3/src/dlg/dlgType.cpp    2005-11-03 08:35:11 UTC (rev 4643)
+++ trunk/pgadmin3/src/dlg/dlgType.cpp    2005-11-03 09:16:13 UTC (rev 4644)
@@ -274,8 +274,14 @@
 void dlgType::OnVarAdd(wxCommandEvent &ev)
 {
     wxString name=txtMembername->GetValue().Strip(wxString::both);
+
     wxString type=cbDatatype->GetValue();

+    if ((txtLength->GetValue() != wxT("") && txtLength->IsEnabled()) && (txtPrecision->GetValue() != wxT("") &&
txtPrecision->IsEnabled()))
+        type += wxT("(") + txtLength->GetValue() + wxT(", ") + txtPrecision->GetValue() + wxT(")");
+    else if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled())
+        type += wxT("(") + txtLength->GetValue() + wxT(")");
+
     if (!name.IsEmpty())
     {
         long pos=lstMembers->FindItem(-1, name);
@@ -284,11 +290,26 @@
             pos = lstMembers->GetItemCount();
             lstMembers->InsertItem(pos, name, 0);
             memberTypes.Add(GetTypeInfo(cbDatatype->GetGuessedSelection()));
+
+            if ((txtLength->GetValue() != wxT("") && txtLength->IsEnabled()) && (txtPrecision->GetValue() != wxT("")
&&txtPrecision->IsEnabled())) 
+                memberSizes.Add(wxT("(") + txtLength->GetValue() + wxT(", ") + txtPrecision->GetValue() + wxT(")"));
+            else if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled())
+                memberSizes.Add(wxT("(") + txtLength->GetValue() + wxT(")"));
+            else
+                memberSizes.Add(wxT(""));
         }
         else
         {
             memberTypes.Insert(GetTypeInfo(cbDatatype->GetGuessedSelection()), pos);
             memberTypes.RemoveAt(pos+1);
+
+            if ((txtLength->GetValue() != wxT("")  && txtLength->IsEnabled()) && (txtPrecision->GetValue() != wxT("")
&&txtPrecision->IsEnabled())) 
+                memberSizes.Insert(wxT("(") + txtLength->GetValue() + wxT(", ") + txtPrecision->GetValue() + wxT(")"),
pos);
+            else if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled())
+                memberSizes.Insert(wxT("(") + txtLength->GetValue() + wxT(")"), pos);
+            else
+                memberSizes.Insert(wxT(""), pos);
+            memberSizes.RemoveAt(pos+1);
         }
         lstMembers->SetItem(pos, 1, type);
     }
@@ -305,6 +326,7 @@
     {
         lstMembers->DeleteItem(pos);
         memberTypes.RemoveAt(pos);
+        memberSizes.RemoveAt(pos);
     }
     CheckChange();
 }
@@ -388,7 +410,8 @@
                 if (i)
                     sql += wxT(", ");
                 sql += qtIdent(lstMembers->GetItemText(i)) + wxT(" ")
-                    + memberTypes.Item(i).AfterFirst(':');
+                    + memberTypes.Item(i).AfterFirst(':')
+                    + memberSizes.Item(i);
             }
         }
         sql += wxT(");\n");

Modified: trunk/pgadmin3/src/include/dlgType.h
===================================================================
--- trunk/pgadmin3/src/include/dlgType.h    2005-11-03 08:35:11 UTC (rev 4643)
+++ trunk/pgadmin3/src/include/dlgType.h    2005-11-03 09:16:13 UTC (rev 4644)
@@ -42,7 +42,7 @@

     void showDefinition(bool isComposite);

-    wxArrayString memberTypes;
+    wxArrayString memberTypes, memberSizes;

     DECLARE_EVENT_TABLE();
 };