Performance improvement and usability

Повышение производительности вывода результатов запроса и дерева объектов.
Мелкие исправления.
This commit is contained in:
lsv 2023-06-28 12:14:34 +05:00
parent 2a4b4dc878
commit debed953cf
5 changed files with 32 additions and 14 deletions

View file

@ -49,7 +49,8 @@ void ctlSQLGrid::setresizedpi() {
wxFont fntLabel(settings->GetSystemFont()); wxFont fntLabel(settings->GetSystemFont());
fntLabel.SetWeight(wxBOLD); fntLabel.SetWeight(wxBOLD);
SetLabelFont(fntLabel); SetLabelFont(fntLabel);
SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTER); SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_TOP);
SetRowLabelSize(FromDIP(50)); SetRowLabelSize(FromDIP(50));
} }
@ -903,7 +904,7 @@ void ctlSQLGrid::AutoSizeColumn(int col, bool setAsMin, bool doLimit)
void ctlSQLGrid::AutoSizeColumns(bool setAsMin) void ctlSQLGrid::AutoSizeColumns(bool setAsMin)
{ {
wxCoord newSize, oldSize, maxH=0; wxCoord newSize, oldSize, maxH=0, newSizeH=0;
wxCoord maxSize, totalSize = 0, availSize; wxCoord maxSize, totalSize = 0, availSize;
int col, nCols = GetNumberCols(); int col, nCols = GetNumberCols();
int row, nRows = GetNumberRows(); int row, nRows = GetNumberRows();
@ -933,6 +934,8 @@ void ctlSQLGrid::AutoSizeColumns(bool setAsMin)
wxSize size = GetBestSize(row, col); wxSize size = GetBestSize(row, col);
if ( size.x > newSize ) if ( size.x > newSize )
newSize = size.x; newSize = size.x;
if (size.y > newSizeH)
newSizeH = size.y;
} }
// get column's label width // get column's label width
wxCoord w, h; wxCoord w, h;
@ -959,7 +962,8 @@ void ctlSQLGrid::AutoSizeColumns(bool setAsMin)
} }
SetColLabelSize(maxH+ FromDIP(EXTRAEXTENT_HEIGHT)); SetColLabelSize(maxH+ FromDIP(EXTRAEXTENT_HEIGHT));
availSize = GetClientSize().GetWidth() - GetRowLabelSize(); availSize = GetClientSize().GetWidth() - GetRowLabelSize();
int newDef = GetDefaultRowSize()+FromDIP(1);
SetDefaultRowSize(newDef, true);
// Second pass: shrink wide columns if exceeded available width // Second pass: shrink wide columns if exceeded available width
if (totalSize > availSize) if (totalSize > availSize)
{ {

View file

@ -201,10 +201,14 @@ void ctlSQLResult::DisplayData(bool single)
table->initSort(); table->initSort();
SetSort(true); SetSort(true);
if (NumRows()<1000) { if (NumRows()<1000) {
int h, v;
GetDefaultCellAlignment(&h, &v);
for(int row = 0; row < NumRows(); ++row) { for(int row = 0; row < NumRows(); ++row) {
if (row%2==0) { if (row%2==0) {
wxGridCellAttr* pAttr = new wxGridCellAttr; wxGridCellAttr* pAttr = new wxGridCellAttr;
pAttr->SetBackgroundColour(wxColour(224,255,224)); pAttr->SetBackgroundColour(wxColour(224,255,224));
pAttr->SetAlignment(h,v);
SetRowAttr(row,pAttr); SetRowAttr(row,pAttr);
} }
@ -1068,7 +1072,7 @@ wxString sqlResultTable::GetValue(int row, int col)
{ {
if (use_map) row=maplines[row]; if (use_map) row=maplines[row];
thread->DataSet()->Locate(row + 1); thread->DataSet()->Locate(row + 1);
if (settings->GetIndicateNull() && thread->DataSet()->IsNull(col)) if (c_IndicateNull && thread->DataSet()->IsNull(col))
return wxT("<NULL>"); return wxT("<NULL>");
else else
{ {
@ -1077,14 +1081,14 @@ wxString sqlResultTable::GetValue(int row, int col)
wxString s = thread->DataSet()->GetVal(col); wxString s = thread->DataSet()->GetVal(col);
if(thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC && if(thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC &&
settings->GetDecimalMark().Length() > 0) !c_DecimalMark.IsEmpty())
{ {
decimalMark = settings->GetDecimalMark(); decimalMark = settings->GetDecimalMark();
s.Replace(wxT("."), decimalMark); s.Replace(wxT("."), decimalMark);
} }
if (thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC && if (thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC &&
settings->GetThousandsSeparator().Length() > 0) !c_ThousandsSeparator.IsEmpty())
{ {
/* Add thousands separator */ /* Add thousands separator */
size_t pos = s.find(decimalMark); size_t pos = s.find(decimalMark);
@ -1094,7 +1098,7 @@ wxString sqlResultTable::GetValue(int row, int col)
{ {
pos -= 3; pos -= 3;
if (pos > 1 || !s.StartsWith(wxT("-"))) if (pos > 1 || !s.StartsWith(wxT("-")))
s.insert(pos, settings->GetThousandsSeparator()); s.insert(pos, c_ThousandsSeparator);
} }
return s; return s;
} }
@ -1102,8 +1106,8 @@ wxString sqlResultTable::GetValue(int row, int col)
{ {
wxString data = thread->DataSet()->GetVal(col); wxString data = thread->DataSet()->GetVal(col);
if (data.Length() > (size_t)settings->GetMaxColSize()) if (data.Length() > (size_t) c_MaxColSize)
return thread->DataSet()->GetVal(col).Left(settings->GetMaxColSize()) + wxT(" (...)"); return thread->DataSet()->GetVal(col).Left(c_MaxColSize) + wxT(" (...)");
else else
return thread->DataSet()->GetVal(col); return thread->DataSet()->GetVal(col);
} }
@ -1121,6 +1125,10 @@ sqlResultTable::sqlResultTable()
colorder=NULL; colorder=NULL;
maplines=NULL; maplines=NULL;
use_map=false; use_map=false;
c_MaxColSize = settings->GetMaxColSize();
c_IndicateNull=settings->GetIndicateNull();
c_ThousandsSeparator = settings->GetThousandsSeparator();
c_DecimalMark = settings->GetDecimalMark();
} }
int sqlResultTable::GetNumberRows() int sqlResultTable::GetNumberRows()

View file

@ -198,14 +198,13 @@ int pgSet::ColNumber(const wxString &colname) const
{ {
int col; int col;
if (needColQuoting) col = PQfnumber(res, colname.mb_str(conv));
if (col < 0 && needColQuoting)
{ {
wxString quotedColName = colname; wxString quotedColName = colname;
quotedColName.Replace(wxT("\""), wxT("\"\"")); quotedColName.Replace(wxT("\""), wxT("\"\""));
col = PQfnumber(res, (wxT("\"") + quotedColName + wxT("\"")).mb_str(conv)); col = PQfnumber(res, (wxT("\"") + quotedColName + wxT("\"")).mb_str(conv));
} }
else
col = PQfnumber(res, colname.mb_str(conv));
if (col < 0) if (col < 0)
{ {

View file

@ -131,6 +131,9 @@ public:
private: private:
pgQueryThread *thread; pgQueryThread *thread;
bool c_IndicateNull;
int c_MaxColSize;
wxString c_ThousandsSeparator, c_DecimalMark;
}; };
#endif #endif

View file

@ -400,6 +400,7 @@ void pgObject::ShowDependency(pgDatabase *db, ctlListView *list, const wxString
wxString typestr = set->GetVal(wxT("type")); wxString typestr = set->GetVal(wxT("type"));
pgaFactory *depFactory = 0; pgaFactory *depFactory = 0;
int icon=-1;
switch ((wxChar)typestr.c_str()[0]) switch ((wxChar)typestr.c_str()[0])
{ {
case 'c': case 'c':
@ -429,6 +430,10 @@ void pgObject::ShowDependency(pgDatabase *db, ctlListView *list, const wxString
case 'v': case 'v':
depFactory = &viewFactory; depFactory = &viewFactory;
break; break;
case 'm':
depFactory = &viewFactory;
icon=viewFactory.GetMaterializedIconId();
break;
case 'x': case 'x':
depFactory = &extTableFactory; depFactory = &extTableFactory;
break; break;
@ -505,11 +510,10 @@ void pgObject::ShowDependency(pgDatabase *db, ctlListView *list, const wxString
refname += _refname; refname += _refname;
wxString typname; wxString typname;
int icon;
if (depFactory) if (depFactory)
{ {
typname = depFactory->GetTypeName(); typname = depFactory->GetTypeName();
icon = depFactory->GetIconId(); if (icon==-1) icon = depFactory->GetIconId();
} }
else else
{ {