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