Thread: More data edit grid fixes

More data edit grid fixes

From
"Edward Di Geronimo Jr."
Date:
Here's two more minor fixes to the edit data grid.

First is related to the copy changes I recently made. Since I modified
the code to copy the cell the cursor is on if there is no highlight,
this change makes the Copy button in the toolbar enabled at all times.

The other is related to editing text cells. It looks like someone
half-implemented a check to only update the database if the contents of
the cell actually changed. This fix finishes that work. This
functionality was already in place for numeric cells.

Ed
Index: src/frm/frmEditGrid.cpp
===================================================================
--- src/frm/frmEditGrid.cpp    (revision 4990)
+++ src/frm/frmEditGrid.cpp    (working copy)
@@ -131,7 +131,7 @@
     toolBar->Realize();
     toolBar->EnableTool(MNU_SAVE, false);
     toolBar->EnableTool(MNU_UNDO, false);
-    toolBar->EnableTool(MNU_COPY, false);
+    toolBar->EnableTool(MNU_COPY, true);
     toolBar->EnableTool(MNU_DELETE, false);

     wxAcceleratorEntry entries[5];
@@ -663,7 +663,6 @@
             }
         }
         toolBar->EnableTool(MNU_DELETE, enable);
-        toolBar->EnableTool(MNU_COPY,  enable);
     }
     event.Skip();
 }
@@ -991,6 +990,7 @@
 protected:
     int textlen;
     bool isMultiLine;
+    wxString m_startValue;
 };


@@ -1015,6 +1015,7 @@

 void sqlGridTextEditor::BeginEdit(int row, int col, wxGrid *grid)
 {
+    m_startValue = grid->GetTable()->GetValue(row, col);
     wxGridCellTextEditor::BeginEdit(row, col, grid);
     ((ctlSQLGrid*)grid)->ResizeEditor(row, col);
 }
@@ -1024,7 +1025,9 @@
 {
     bool changed = false;
     wxString value = Text()->GetValue();
-    changed = true;
+
+    if (value != m_startValue)
+        changed = true;

     if (changed)
         grid->GetTable()->SetValue(row, col, value);

Re: More data edit grid fixes

From
"Dave Page"
Date:

> -----Original Message-----
> From: pgadmin-hackers-owner@postgresql.org
> [mailto:pgadmin-hackers-owner@postgresql.org] On Behalf Of
> Edward Di Geronimo Jr.
> Sent: 07 February 2006 21:38
> To: pgadmin-hackers@postgresql.org
> Subject: [pgadmin-hackers] More data edit grid fixes
>
> Here's two more minor fixes to the edit data grid.
>
> First is related to the copy changes I recently made. Since I
> modified
> the code to copy the cell the cursor is on if there is no highlight,
> this change makes the Copy button in the toolbar enabled at all times.
>
> The other is related to editing text cells. It looks like someone
> half-implemented a check to only update the database if the
> contents of
> the cell actually changed. This fix finishes that work. This
> functionality was already in place for numeric cells.

Thanks Ed, patch applied. I also modified the status message displayed
when data is copied so it doesn't imply that full rows were copied.

Regards, Dave.