Re: [pgadmin-hackers] Updated copy patch

2006-05-02 Thread Dave Page
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Edward Di Geronimo Jr.
> Sent: 01 May 2006 18:53
> To: pgadmin-hackers
> Subject: [pgadmin-hackers] Updated copy patch
> 
> Here's an update to the results copying patch I sent last 
> night. This patch makes the column headers back to what we 
> agreed on when I did the grid work, and fixes the column size 
> retention which last night's patch broke.

Thanks Ed - all features work as expected and Andreas' speed
improvements remain. Patch applied.

Regards, Dave

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [pgadmin-hackers] Updated copy patch

2006-05-01 Thread Edward Di Geronimo Jr.

Quoting Andreas Pflug <[EMAIL PROTECTED]>:


Though advised differently, the patch starts with removing the ListView
stuff, so I won't look any further at this version. Use the macro, it
won't hurt.


The grid allows basic functionality that everyone who uses a database  
except for you considers essential. The ListView offers exactly zero  
advantages over the grid. Due to wxWidgets sucking and not having any  
design consistency across different object, it would take require  
adding another 100 lines or so of code to a file that's only about 350  
lines long to support both.


You and I also both know that if the ListView code stays in, you will  
make every effort to break the grid code every chance you get.


Ed



This message was sent using IMP, the Internet Messaging Program.



---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


Re: [pgadmin-hackers] Updated copy patch

2006-05-01 Thread Andreas Pflug
Though advised differently, the patch starts with removing the ListView 
stuff, so I won't look any further at this version. Use the macro, it 
won't hurt.


Regards,
Andreas


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[pgadmin-hackers] Updated copy patch

2006-05-01 Thread Edward Di Geronimo Jr.
Here's an update to the results copying patch I sent last night. This  
patch makes the column headers back to what we agreed on when I did  
the grid work, and fixes the column size retention which last night's  
patch broke.


Ed


This message was sent using IMP, the Internet Messaging Program.

Index: ctl/ctlSQLResult.cpp
===
--- ctl/ctlSQLResult.cpp	(revision 5099)
+++ ctl/ctlSQLResult.cpp	(working copy)
@@ -21,22 +21,16 @@
 
 
 ctlSQLResult::ctlSQLResult(wxWindow *parent, pgConn *_conn, wxWindowID id, const wxPoint& pos, const wxSize& size)
-#if USE_LISTVIEW
-: wxListView(parent, id, pos, size, wxLC_VIRTUAL | wxLC_REPORT | wxSUNKEN_BORDER)
-#else
 : ctlSQLGrid(parent, id, pos, size)
-#endif
 {
 conn=_conn;
 thread=0;
 
-#if !USE_LISTVIEW
-CreateGrid(0, 0);
+SetTable(new sqlResultTable(), true);
 EnableEditing(false);
 SetSizer(new wxBoxSizer(wxVERTICAL));
 
 Connect(wxID_ANY, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEventHandler(ctlSQLResult::OnGridSelect));
-#endif
 }
 
 
@@ -65,57 +59,6 @@
 }
 
 
-#if USE_LISTVIEW
-void ctlSQLResult::SelectAll()
-{
-	for (int i = 0; i < GetItemCount(); i++)
-		Select(i);
-}
-
-
-wxString ctlSQLResult::GetExportLine(int row)
-{
-   if (GetColumnCount() <= 1)
-return OnGetItemText(row, 1);
-
-wxString str;
-int col;
-for (col=1 ; col < GetColumnCount() ; col++)
-{
-if (col > 1)
-str.Append(settings->GetCopyColSeparator());
-
-wxString text=OnGetItemText(row, col);
-
-		bool needQuote  = false;
-		if (settings->GetCopyQuoting() == 1)
-		{
-			/* Quote strings only */
-			switch (colTypClasses.Item(col))
-			{
-			case PGTYPCLASS_NUMERIC:
-			case PGTYPCLASS_BOOL:
-break;
-			default:
-needQuote=true;
-break;
-			}
-		}
-		else if (settings->GetCopyQuoting() == 2)
-			/* Quote everything */
-			needQuote = true;
-
-		if (needQuote)
-str.Append(settings->GetCopyQuoteChar());
-str.Append(text);
-if (needQuote)
-str.Append(settings->GetCopyQuoteChar());
-}
-return str;
-}
-#endif
-
-
 bool ctlSQLResult::IsColText(int col)
 {
 	switch (colTypClasses.Item(col))
@@ -131,32 +74,18 @@
 
 int ctlSQLResult::Execute(const wxString &query, int resultToRetrieve)
 {
-Abort();
-
 colSizes.Empty();
 colHeaders.Empty();
 int i;
 
-#if USE_LISTVIEW
-wxListItem item;
-item.SetMask(wxLIST_MASK_TEXT|wxLIST_MASK_WIDTH);
-
-for (i=0 ; i < GetColumnCount() ; i++)
-{
-GetColumn(i, item);
-colHeaders.Add(item.GetText());
-colSizes.Add(item.GetWidth());
-}
-
-ClearAll();
-
-#else
 for (i=0 ; i < GetNumberCols() ; i++)
 {
 colHeaders.Add(GetColLabelValue(i));
 colSizes.Add(GetColSize(i));
 }
 
+Abort();
+
 int num;
 num = GetNumberRows();
 if (num)
@@ -164,10 +93,7 @@
 num = GetNumberCols();
 if (num)
 DeleteCols(0, num);
-maxRows = 0;
-#endif
 
-
 colNames.Empty();
 colTypes.Empty();
 colTypClasses.Empty();
@@ -180,6 +106,7 @@
 return -1;
 }
 
+((sqlResultTable *)GetTable())->SetThread(thread);
 thread->Run();
 return RunStatus();
 }
@@ -189,6 +116,7 @@
 {
 if (thread)
 {
+((sqlResultTable *)GetTable())->SetThread(0);
 thread->Delete();
 delete thread;
 }
@@ -208,8 +136,27 @@
 
 	rowcountSuppressed = single;
 Freeze();
-	SetItemCount(NumRows());
 
+/*
+ * Resize and repopulate by informing itto delete all the rows and
+ * columns, then append the correct number of them. Probably is a
+ * better way to do this.
+ */
+wxGridTableMessage *msg;
+sqlResultTable *table = (sqlResultTable *)GetTable();
+msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows());
+ProcessTableMessage(*msg);
+delete msg;
+msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols());
+ProcessTableMessage(*msg);
+delete msg;
+msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, NumRows());
+ProcessTableMessage(*msg);
+delete msg;
+msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_APPENDED, thread->DataSet()->NumCols());
+ProcessTableMessage(*msg);
+delete msg;
+
 	if (single)
 {
 int w, h;
@@ -221,24 +168,11 @@
 colNames.Add(thread->DataSet()->ColName(0));
 colTypes.Add(wxT(""));
 colTypClasses.Add(0L);
-
-
-InsertColumn(0, thread->DataSet()->ColName(0), wxLIST_FORMAT_LEFT, w);
+SetColSize(0, w);
 }
 	else
 {
 wxString colName, colType;
-colTypes.Add(wxT(""));
-colTypClasses.Add(0L);
-
-		wxString rowname=_("Row");
-		size_t rowcolsize=NumToStr(NumRows()).Length();
-		if (rowname.Length() > rowcolsize)
-			rowcolsiz