mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-09-04 06:04:50 -06:00
bug fix
bug plan fix Add copy sql html format
This commit is contained in:
parent
dfa337816c
commit
0b39fb9f92
8 changed files with 95 additions and 19 deletions
Binary file not shown.
|
|
@ -22,6 +22,7 @@
|
|||
#include "dlg/dlgFindReplace.h"
|
||||
#include "frm/menu.h"
|
||||
#include "utils/sysProcess.h"
|
||||
#include <wx/clipbrd.h>
|
||||
|
||||
wxString ctlSQLBox::sqlKeywords;
|
||||
static const wxString s_leftBrace(_T("([{"));
|
||||
|
|
@ -1183,7 +1184,75 @@ void ctlSQLBox::OnMarginClick(wxStyledTextEvent &event)
|
|||
|
||||
event.Skip();
|
||||
}
|
||||
void ctlSQLBox::Copy() {
|
||||
wxString selText = GetSelectedText();
|
||||
if (!selText.IsEmpty())
|
||||
{
|
||||
wxColor frColor[40];
|
||||
wxString str;
|
||||
wxColour frc = settings->GetSQLBoxColourForeground();
|
||||
if (settings->GetSQLBoxUseSystemForeground())
|
||||
{
|
||||
frc = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 34; ++ i )
|
||||
{
|
||||
frColor[i]=StyleGetForeground(i);
|
||||
if (i > 0 && i < 12)
|
||||
//StyleSetForeground(i, settings->GetSQLBoxColour(i));
|
||||
frColor[i]=StyleGetForeground(i);
|
||||
else
|
||||
frColor[i]=frc;
|
||||
|
||||
//StyleSetBackground(i, bgColor);
|
||||
//StyleSetFont(i, fntSQLBox);
|
||||
}
|
||||
//<h1 style="color:blue;">
|
||||
int endp=GetSelectionEnd();
|
||||
int startp=GetSelectionStart();
|
||||
wxString prevColor=wxEmptyString;
|
||||
wxString tColor;
|
||||
wxFont fntSQLBox = settings->GetSQLFont();
|
||||
wxString fontName = fntSQLBox.GetFaceName();
|
||||
|
||||
str=wxT("<font face=\"")+fontName+wxT("\">");
|
||||
int k=0;
|
||||
int l=1;
|
||||
while (startp<endp) {
|
||||
int st = GetStyleAt(startp);
|
||||
if (st<34) tColor=frColor[st].GetAsString(wxC2S_HTML_SYNTAX);
|
||||
if (prevColor!=tColor) {
|
||||
str=str+wxT("</font><font color=\"")+tColor+wxT("\">");
|
||||
prevColor=tColor;
|
||||
}
|
||||
//str.append(str[k].GetValue());
|
||||
l=1;
|
||||
if (!selText[k].IsAscii()) l++;
|
||||
str+=selText[k];
|
||||
if (str.EndsWith(wxT("\r\n"))) str+=wxT("<br>");
|
||||
startp=startp+l;
|
||||
k++;
|
||||
}
|
||||
str=str+wxT("</font>");
|
||||
|
||||
|
||||
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
wxDataObjectComposite* dataobj = new wxDataObjectComposite();
|
||||
dataobj->Add(new wxTextDataObject(selText));
|
||||
dataobj->Add(new wxHTMLDataObject(str));
|
||||
wxTheClipboard->SetData(dataobj);
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
|
||||
} else wxStyledTextCtrl::Copy();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
extern "C" char *tab_complete(const char *allstr, const int startptr, const int endptr, void *dbptr);
|
||||
void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
||||
|
|
|
|||
|
|
@ -638,12 +638,14 @@ int recurse(ctlSQLGrid *g, int pos,int row, double &transfer) {
|
|||
return row;
|
||||
}
|
||||
void ctlSQLGrid::SetRowGroup(int row) { };
|
||||
bool ctlSQLGrid::FullArrayCollapseRowsPlan()
|
||||
bool ctlSQLGrid::FullArrayCollapseRowsPlan(bool clear)
|
||||
{
|
||||
//wxString colKey = wxString::Format(wxT("%d:"), col) + GetColLabelValue(col);
|
||||
wxString text;
|
||||
//for(int row = 0; row < GetNumberRows(); ++row)
|
||||
|
||||
if (grp) { delete grp;}
|
||||
if (clear) { grp=NULL; return true;}
|
||||
grp = new GroupRows(this);
|
||||
double transfersum=0;
|
||||
int r= recurse(this,0,0,transfersum);
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ void ctlSQLResult::DisplayData(bool single)
|
|||
if (c==wxT("QUERY PLAN")) {
|
||||
//
|
||||
table->isplan=true;
|
||||
FullArrayCollapseRowsPlan();
|
||||
};
|
||||
FullArrayCollapseRowsPlan(false);
|
||||
} else FullArrayCollapseRowsPlan(true);
|
||||
|
||||
if (single)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1041,7 +1041,8 @@ wxString dlgFunction::GetSql()
|
|||
name = name + wxT("(") + GetArgs(false, true) + wxT(")");
|
||||
|
||||
if (cbOwner->GetCurrentSelection() > 0)
|
||||
AppendOwnerNew(sql, wxT("FUNCTION ") + name);
|
||||
if (!isProcedure) AppendOwnerNew(sql, wxT("FUNCTION ") + name);
|
||||
else AppendOwnerNew(sql, wxT("PROCEDURE ") + name);
|
||||
}
|
||||
|
||||
if (false)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public:
|
|||
void Create(wxWindow *parent, wxWindowID id = -1, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = 0);
|
||||
void HighlightBrace(int lb, int rb);
|
||||
void SetDatabase(pgConn *db);
|
||||
|
||||
void Copy();
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
void OnAutoComplete(wxCommandEvent &event);
|
||||
void OnSearchReplace(wxCommandEvent &event);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
void OnLabelDoubleClick(wxGridEvent &event);
|
||||
void OnLabelClick(wxGridEvent &event);
|
||||
void OnCellRightClick(wxGridEvent &event);
|
||||
bool FullArrayCollapseRowsPlan();
|
||||
bool FullArrayCollapseRowsPlan(bool clear);
|
||||
void AutoSizeColumn(int col, bool setAsMin = false, bool doLimit = true);
|
||||
void AutoSizeColumns(bool setAsMin);
|
||||
wxString GetRowLabelValue( int row );
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ wxString pgTable::GetSql(ctlTree *browser)
|
|||
wxString colDetails, conDetails;
|
||||
wxString prevComment;
|
||||
wxString cols_sql = wxEmptyString;
|
||||
|
||||
wxString cols_type = wxEmptyString;
|
||||
wxString columnPrivileges;
|
||||
|
||||
if (sql.IsNull())
|
||||
|
|
@ -357,16 +357,17 @@ wxString pgTable::GetSql(ctlTree *browser)
|
|||
int lastRealCol = 0;
|
||||
int currentCol = 0;
|
||||
pgColumn *column;
|
||||
|
||||
// Iterate the columns to find the last 'real' one
|
||||
while ((column = (pgColumn *)colIt1.GetNextObject()) != 0)
|
||||
{
|
||||
if (currentCol==0) {cols_type+=column->GetDisplayName()+wxT(" ")+column->GetQuotedTypename();
|
||||
} else cols_type+=wxT(", ")+column->GetDisplayName()+wxT(" ")+column->GetQuotedTypename();
|
||||
currentCol++;
|
||||
|
||||
//AppendIfFilled(cols_type,wxT(","),cols_type);
|
||||
if (column->GetInheritedCount() == 0)
|
||||
lastRealCol = currentCol;
|
||||
}
|
||||
|
||||
cols_type=wxT("-- (")+cols_type+wxT(")");
|
||||
// Now build the actual column list
|
||||
int colCount = 0;
|
||||
while ((column = (pgColumn *)colIt2.GetNextObject()) != 0)
|
||||
|
|
@ -725,7 +726,9 @@ wxString pgTable::GetSql(ctlTree *browser)
|
|||
AppendStuffNoSql(sql, browser, partitionFactory);
|
||||
}
|
||||
*/
|
||||
sql+=cols_type;
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
|
@ -1260,6 +1263,9 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics)
|
|||
// Add the statistics view columns
|
||||
statistics->ClearAll();
|
||||
statistics->AddColumn(_("Table Name"));
|
||||
if (hasSize)
|
||||
statistics->AddColumn(_("Size"), 50);
|
||||
|
||||
statistics->AddColumn(_("Tuples inserted"));
|
||||
statistics->AddColumn(_("Tuples updated"));
|
||||
statistics->AddColumn(_("Tuples deleted"));
|
||||
|
|
@ -1283,8 +1289,6 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics)
|
|||
statistics->AddColumn(_("Analyze counter"));
|
||||
statistics->AddColumn(_("Autoanalyze counter"));
|
||||
}
|
||||
if (hasSize)
|
||||
statistics->AddColumn(_("Size"), 50);
|
||||
|
||||
wxString sql = wxT("SELECT st.relname, n_tup_ins, n_tup_upd, n_tup_del");
|
||||
if (GetConnection()->BackendMinimumVersion(8, 3))
|
||||
|
|
@ -1311,11 +1315,13 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics)
|
|||
int i;
|
||||
while (!stats->Eof())
|
||||
{
|
||||
i = 4;
|
||||
i = 5;
|
||||
statistics->InsertItem(pos, stats->GetVal(wxT("relname")), PGICON_STATISTICS);
|
||||
statistics->SetItem(pos, 1, stats->GetVal(wxT("n_tup_ins")));
|
||||
statistics->SetItem(pos, 2, stats->GetVal(wxT("n_tup_upd")));
|
||||
statistics->SetItem(pos, 3, stats->GetVal(wxT("n_tup_del")));
|
||||
if (hasSize)
|
||||
statistics->SetItem(pos, 1, stats->GetVal(wxT("size")));
|
||||
statistics->SetItem(pos, 2, stats->GetVal(wxT("n_tup_ins")));
|
||||
statistics->SetItem(pos, 3, stats->GetVal(wxT("n_tup_upd")));
|
||||
statistics->SetItem(pos, 4, stats->GetVal(wxT("n_tup_del")));
|
||||
if (GetConnection()->BackendMinimumVersion(8, 3))
|
||||
{
|
||||
statistics->SetItem(pos, i++, stats->GetVal(wxT("n_tup_hot_upd")));
|
||||
|
|
@ -1336,15 +1342,13 @@ void pgTableCollection::ShowStatistics(frmMain *form, ctlListView *statistics)
|
|||
statistics->SetItem(pos, i++, stats->GetVal(wxT("analyze_count")));
|
||||
statistics->SetItem(pos, i++, stats->GetVal(wxT("autoanalyze_count")));
|
||||
}
|
||||
if (hasSize)
|
||||
statistics->SetItem(pos, i, stats->GetVal(wxT("size")));
|
||||
stats->MoveNext();
|
||||
pos++;
|
||||
}
|
||||
|
||||
delete stats;
|
||||
}
|
||||
|
||||
statistics->SetColumnWidth(0,wxLIST_AUTOSIZE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue