mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
Beautiful big numbers
Можно включить более понятное отображение больших чисел на странице Статистика. Для этого устновите флажок "Beautiful big numbers on the statistics page" Небольшие исправления в диалоге выбора соединения (dlgSelectConnection.cpp)
This commit is contained in:
parent
f0f4f7a9b5
commit
4ffd790d48
7 changed files with 92 additions and 7 deletions
|
|
@ -124,15 +124,26 @@ void dlgSelectConnection::OnChangeServer(wxCommandEvent &ev)
|
|||
wxT(" WHERE datallowconn ORDER BY datname"));
|
||||
|
||||
item = 0;
|
||||
int item2 = -1;
|
||||
wxString v;
|
||||
while(set1.RowsLeft())
|
||||
{
|
||||
cbDatabase->Append(set1.GetVal(wxT("datname")));
|
||||
if (set1.GetVal(wxT("datname")) == olddatabase)
|
||||
v = set1.GetVal(wxT("datname"));
|
||||
cbDatabase->Append(v);
|
||||
if (v == olddatabase)
|
||||
item = cbDatabase->GetCount() - 1;
|
||||
else if (v.StartsWith("template") || v == "postgres")
|
||||
continue;
|
||||
else if (item2 == -1)
|
||||
item2 = cbDatabase->GetCount() - 1;
|
||||
|
||||
}
|
||||
|
||||
if (cbDatabase->GetCount())
|
||||
cbDatabase->SetSelection(item);
|
||||
if (item2>=0)
|
||||
cbDatabase->SetSelection(item2);
|
||||
else
|
||||
cbDatabase->SetSelection(item);
|
||||
|
||||
pgSetIterator set2(remoteServer->GetConnection(),
|
||||
wxT("SELECT DISTINCT usename\n")
|
||||
|
|
@ -144,7 +155,7 @@ void dlgSelectConnection::OnChangeServer(wxCommandEvent &ev)
|
|||
{
|
||||
cbUsername->Append(set2.GetVal(wxT("usename")));
|
||||
if (set2.GetVal(wxT("usename")) == oldusername)
|
||||
item = cbDatabase->GetCount() - 1;
|
||||
item = cbUsername->GetCount() - 1;
|
||||
}
|
||||
|
||||
if (cbUsername->GetCount())
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@
|
|||
#define chkShowUsersForPrivileges CTRL_CHECKBOX("chkShowUsersForPrivileges")
|
||||
#define chkShowDBnameTree CTRL_CHECKBOX("chkShowDBnameTree")
|
||||
#define txtAutoRowCount CTRL_TEXT("txtAutoRowCount")
|
||||
#define chkNumberPretty CTRL_CHECKBOX("chkNumberPretty")
|
||||
#define txtIndent CTRL_TEXT("txtIndent")
|
||||
#define chkSpacesForTabs CTRL_CHECKBOX("chkSpacesForTabs")
|
||||
#define cbCopyQuote CTRL_COMBOBOX("cbCopyQuote")
|
||||
|
|
@ -365,6 +366,7 @@ frmOptions::frmOptions(frmMain *parent)
|
|||
chkKeywordsInUppercase->SetValue(settings->GetSQLKeywordsInUppercase());
|
||||
chkASUTPstyle->SetValue(settings->GetASUTPstyle());
|
||||
chkHideQueryHistory->SetValue(settings->GetHideQueryHistory());
|
||||
chkNumberPretty->SetValue(settings->GetNumberPretty());
|
||||
cbLanguage->Append(_("Default"));
|
||||
int sel = 0;
|
||||
wxLanguage langId = settings->GetCanonicalLanguage();
|
||||
|
|
@ -882,6 +884,11 @@ void frmOptions::OnOK(wxCommandEvent &ev)
|
|||
changed = true;
|
||||
settings->SetHideQueryHistory(chkHideQueryHistory->GetValue());
|
||||
}
|
||||
if (settings->GetNumberPretty() != chkNumberPretty->GetValue())
|
||||
{
|
||||
changed = true;
|
||||
settings->SetNumberPretty(chkNumberPretty->GetValue());
|
||||
}
|
||||
|
||||
// Change the language last, as it will affect our tests for changes
|
||||
// in the display object types.
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ wxString generate_spaces(int length);
|
|||
wxString BoolToYesNo(bool value);
|
||||
wxString NumToStr(long value);
|
||||
wxString NumToStr(double value);
|
||||
wxString NumToStrHuman(wxLongLong value);
|
||||
wxString NumToStr(OID value);
|
||||
wxString NumToStr(wxLongLong value);
|
||||
wxString DateToStr(const wxDateTime &datetime);
|
||||
|
|
|
|||
|
|
@ -824,6 +824,16 @@ public:
|
|||
{
|
||||
WriteBool(wxT("HideQueryHistory"), newval);
|
||||
}
|
||||
bool GetNumberPretty() const
|
||||
{
|
||||
bool b;
|
||||
Read(wxT("NumberPretty"), &b, false);
|
||||
return b;
|
||||
}
|
||||
void SetNumberPretty(const bool newval)
|
||||
{
|
||||
WriteBool(wxT("NumberPretty"), newval);
|
||||
}
|
||||
bool GetVisibleDbNameTree() const
|
||||
{
|
||||
bool b;
|
||||
|
|
|
|||
|
|
@ -1561,11 +1561,39 @@ void pgDatabaseObject::DisplayStatistics(ctlListView *statistics, const wxString
|
|||
|
||||
if (stats)
|
||||
{
|
||||
bool pretty = settings->GetNumberPretty();
|
||||
int col;
|
||||
wxArrayInt a;
|
||||
int vmax = -1;
|
||||
int lt = -1;
|
||||
for (col = 0 ; col < stats->NumCols() ; col++)
|
||||
{
|
||||
if (!stats->ColName(col).IsEmpty())
|
||||
statistics->AppendItem(stats->ColName(col), stats->GetVal(col));
|
||||
if (!stats->ColName(col).IsEmpty()) {
|
||||
wxString name = stats->ColName(col);
|
||||
wxString vl = stats->GetVal(col);
|
||||
if (vl.IsNumber() && vl.Length()>0) {
|
||||
int l = vl.Length();
|
||||
if (l > vmax) vmax = l;
|
||||
a.Add(l);
|
||||
if (_("Live Tuples") == name) lt = a.GetCount() - 1;
|
||||
} else
|
||||
a.Add(-1);
|
||||
statistics->AppendItem(name, vl);
|
||||
}
|
||||
}
|
||||
if (vmax > 0 && pretty) {
|
||||
for (int i = 0; i < a.Count(); i++) {
|
||||
if (a[i] >= 0) {
|
||||
wxString str = statistics->GetItemText(i, 1);
|
||||
wxLongLong l = StrToLongLong(str);
|
||||
wxString h = NumToStrHuman(l);
|
||||
if (h.IsEmpty()) continue;
|
||||
str += generate_spaces(vmax - a[i] + 5) + h;
|
||||
if (lt == i) str[vmax + 2] = 'R';
|
||||
statistics->SetItem(i, 1, str);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
delete stats;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,6 +186,14 @@
|
|||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxCheckBox" name="chkNumberPretty">
|
||||
<label>Beautiful big numbers on the statistics page</label>
|
||||
<checked>0</checked>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
|
|
|
|||
|
|
@ -177,7 +177,27 @@ wxString NumToStr(double value)
|
|||
|
||||
return result;
|
||||
}
|
||||
wxString NumToStrHuman(wxLongLong value) {
|
||||
// billion
|
||||
long ddiv = 1000000000;
|
||||
wxLongLong r = 0;
|
||||
wxString s;
|
||||
while ((r=value/ddiv)==0) {
|
||||
ddiv = ddiv / 1000;
|
||||
if (ddiv == 0) return wxEmptyString;
|
||||
}
|
||||
if (ddiv == 1000000000) s = "Bi";
|
||||
else if (ddiv == 1000000) s = "Mi";
|
||||
else if (ddiv == 1000) s = "ths";
|
||||
else return wxEmptyString;
|
||||
|
||||
wxLongLong m = value % ddiv;
|
||||
m = m / (ddiv / 10);
|
||||
wxString rez;
|
||||
rez = NumToStr(r) + (m == 0 ? "": "." + NumToStr(m))+" "+s;
|
||||
|
||||
return rez;
|
||||
}
|
||||
|
||||
wxString NumToStr(wxLongLong value)
|
||||
{
|
||||
|
|
@ -611,7 +631,7 @@ wxString queryTokenizer::GetNextToken()
|
|||
if (foundQuote)
|
||||
str.Append(delimiter);
|
||||
}
|
||||
while (foundQuote & HasMoreTokens());
|
||||
while (foundQuote && HasMoreTokens());
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue