fix #38. Add options "Quick jump to the root node" and "Auto save query text".

Первая предназначена для отключения/включения быстрого перемещения к корневым узлам.
Вторая для отключения/включения автоматического сохранения закладок в Query Tool.
После отключения авто сохранения возможно понадобиться вручную очистить каталог
с сохранёнными закладками %APPDATA%\postgresql\recovery
This commit is contained in:
lsv 2023-10-25 21:12:04 +05:00
parent 4d7ed843aa
commit bce303c437
9 changed files with 198 additions and 84 deletions

View file

@ -225,12 +225,13 @@ void ctlTree::OnMouse(wxMouseEvent& event)
wxPoint pt = event.GetPosition();
int flags = 0;
wxTreeItemId item = DoTreeHitTest(pt, flags);
if (event.LeftDown())
if (isJumpRoot) {
if (event.LeftDown())
{
if ((flags & wxTREE_HITTEST_ONITEMINDENT) == wxTREE_HITTEST_ONITEMINDENT) {
if (item) {
wxRect r;
wxTreeItemId itemParent=item;
wxTreeItemId itemParent = item;
GetBoundingRect(itemParent, r, false);
wxTreeItemId prev;
prev = GetVerticalItem(pt);
@ -245,46 +246,47 @@ void ctlTree::OnMouse(wxMouseEvent& event)
}
else {
if ((flags & wxTREE_HITTEST_ONITEMINDENT) == wxTREE_HITTEST_ONITEMINDENT && (item==GetSelection())) {
wxRect r;
GetBoundingRect(item, r, true);
r.width = r.x-19;
r.x = r.x - 19;
if (r.x < 10) return;
wxTreeItemId prev;
wxTreeItemId itemParent = item;
wxImageList *list=this->GetImageList();
wxClientDC dc(this);
bool ex = false;
while (!ex) {
//ex = true;
prev = itemParent;
itemParent = GetItemParent(itemParent);
//this->ScrollTo(itemParent);
if (!itemParent.IsOk()) break;
if ((flags & wxTREE_HITTEST_ONITEMINDENT) == wxTREE_HITTEST_ONITEMINDENT && (item == GetSelection())) {
wxRect r;
GetBoundingRect(item, r, true);
r.width = r.x - 19;
r.x = r.x - 19;
//if (r.x >= pt.x) ex = false;
int image = this->GetItemImage(itemParent);
if (image >= 0) {
dc.SetClippingRegion(r.x + 1 - 19, r.y + 1,
16, 16);
list->Draw(image, dc,
r.x + 1 - 19,
r.y + 1,
wxIMAGELIST_DRAW_TRANSPARENT
);
dc.DestroyClippingRegion();
if (r.x < 10) return;
wxTreeItemId prev;
wxTreeItemId itemParent = item;
wxImageList* list = this->GetImageList();
wxClientDC dc(this);
bool ex = false;
while (!ex) {
//ex = true;
prev = itemParent;
itemParent = GetItemParent(itemParent);
//this->ScrollTo(itemParent);
if (!itemParent.IsOk()) break;
r.x = r.x - 19;
//if (r.x >= pt.x) ex = false;
int image = this->GetItemImage(itemParent);
if (image >= 0) {
dc.SetClippingRegion(r.x + 1 - 19, r.y + 1,
16, 16);
list->Draw(image, dc,
r.x + 1 - 19,
r.y + 1,
wxIMAGELIST_DRAW_TRANSPARENT
);
dc.DestroyClippingRegion();
}
}
}
// dc.SetBrush(*wxRED);
// dc.SetPen(*wxTRANSPARENT_PEN);
// dc.DrawRectangle(r);
Update();
return;
// dc.SetBrush(*wxRED);
// dc.SetPen(*wxTRANSPARENT_PEN);
// dc.DrawRectangle(r);
Update();
return;
}
}
}
event.Skip();
}
event.Skip();
}
void ctlTree::OnChar(wxKeyEvent &event)
@ -352,6 +354,7 @@ void ctlTree::OnChar(wxKeyEvent &event)
ctlTree::ctlTree(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
: wxTreeCtrl(parent, id, pos, size, style), m_findTimer(NULL)
{
isJumpRoot = settings->GetJumpRoot();
}
ctlTree::~ctlTree()

View file

@ -133,6 +133,8 @@
#define chkKeywordsInUppercase CTRL_CHECKBOX("chkKeywordsInUppercase")
#define chkASUTPstyle CTRL_CHECKBOX("chkASUTPstyle")
#define chkHideQueryHistory CTRL_CHECKBOX("chkHideQueryHistory")
#define chkAutosaveQuery CTRL_CHECKBOX("chkAutosaveQuery")
#define chkJumpRoot CTRL_CHECKBOX("chkJumpRoot")
#define menus CTRL_TREE("menus")
#define pnlBrowserDisplay CTRL_PANEL("pnlBrowserDisplay")
#define pnlBrowserProperties CTRL_PANEL("pnlBrowserProperties")
@ -366,6 +368,8 @@ frmOptions::frmOptions(frmMain *parent)
chkKeywordsInUppercase->SetValue(settings->GetSQLKeywordsInUppercase());
chkASUTPstyle->SetValue(settings->GetASUTPstyle());
chkHideQueryHistory->SetValue(settings->GetHideQueryHistory());
chkAutosaveQuery->SetValue(settings->GetAutosaveQuery());
chkJumpRoot->SetValue(settings->GetJumpRoot());
chkNumberPretty->SetValue(settings->GetNumberPretty());
cbLanguage->Append(_("Default"));
int sel = 0;
@ -884,6 +888,16 @@ void frmOptions::OnOK(wxCommandEvent &ev)
changed = true;
settings->SetHideQueryHistory(chkHideQueryHistory->GetValue());
}
if (settings->GetAutosaveQuery() != chkAutosaveQuery->GetValue())
{
changed = true;
settings->SetAutosaveQuery(chkAutosaveQuery->GetValue());
}
if (settings->GetJumpRoot() != chkJumpRoot->GetValue())
{
changed = true;
settings->SetJumpRoot(chkJumpRoot->GetValue());
}
if (settings->GetNumberPretty() != chkNumberPretty->GetValue())
{
changed = true;

View file

@ -338,7 +338,7 @@ frmQuery::frmQuery(frmMain *form, const wxString &_title, pgConn *_conn, const w
mainForm = form;
conn = _conn;
autoSave = settings->GetAutosaveQuery();
loading = true;
closing = false;
@ -2455,24 +2455,25 @@ void frmQuery::SaveTempFile()
//if (filename.StartsWith(pref))
filename+=wxT(".a");
wxString tempDir = wxStandardPaths::Get().GetUserConfigDir() +wxFileName::GetPathSeparator()+"postgresql"+wxFileName::GetPathSeparator()+"recovery"+wxFileName::GetPathSeparator();
wxUtfFile file(tempDir+filename, wxFile::write, modeUnicode ? wxFONTENCODING_UTF8 : wxFONTENCODING_DEFAULT);
if (file.IsOpened())
{
int nl=sqlQuery->GetCurrentPos();
wxString strnl;
strnl=wxString::Format(_("%i@"), nl);
file.Write(strnl);
if ((file.Write(sqlQuery->GetText()) == 0) && (!modeUnicode))
wxMessageBox(_("Query text incomplete.\nQuery contained characters that could not be converted to the local charset.\nPlease correct the data or try using UTF8 instead."));
file.Close();
sqlQuery->SetChanged(false);
SqlBookUpdatePageTitle();
if (autoSave) {
wxUtfFile file(tempDir + filename, wxFile::write, modeUnicode ? wxFONTENCODING_UTF8 : wxFONTENCODING_DEFAULT);
if (file.IsOpened())
{
int nl = sqlQuery->GetCurrentPos();
wxString strnl;
strnl = wxString::Format(_("%i@"), nl);
file.Write(strnl);
if ((file.Write(sqlQuery->GetText()) == 0) && (!modeUnicode))
wxMessageBox(_("Query text incomplete.\nQuery contained characters that could not be converted to the local charset.\nPlease correct the data or try using UTF8 instead."));
file.Close();
sqlQuery->SetChanged(false);
SqlBookUpdatePageTitle();
}
else
{
wxLogError(__("Could not write the file %s: Errcode=%d."), filename.c_str(), wxSysErrorCode());
}
}
else
{
wxLogError(__("Could not write the file %s: Errcode=%d."), filename.c_str(), wxSysErrorCode());
}
}
@ -4370,7 +4371,7 @@ void frmQuery::fileMarkerActive(bool addOrRemove, const wxString &sqlTabName) {
wxString fn = tempDir + wxT("_active.") + tabname + ".a";
//if (sqlTabName.Right(1)=='*' ) tabname=
if (addOrRemove)
if (addOrRemove && autoSave)
{
//wxUtfFile file(fn, wxFile::write, wxFONTENCODING_UTF8);
wxFile file(fn, wxFile::write);

View file

@ -53,6 +53,7 @@ private:
wxString m_findPrefix;
ctlTreeFindTimer *m_findTimer;
friend class ctlTreeFindTimer;
bool isJumpRoot;
};

View file

@ -170,6 +170,7 @@ private:
gqbModel *model;
gqbController *controller;
bool firstTime;
bool autoSave;
bool gqbUpdateRunning;
wxTimer *adjustSizesTimer;

View file

@ -824,6 +824,26 @@ public:
{
WriteBool(wxT("HideQueryHistory"), newval);
}
bool GetAutosaveQuery() const
{
bool b;
Read(wxT("AutosaveQuery"), &b, true);
return b;
}
void SetAutosaveQuery(const bool newval)
{
WriteBool(wxT("AutosaveQuery"), newval);
}
bool GetJumpRoot() const
{
bool b;
Read(wxT("JumpRoot"), &b, true);
return b;
}
void SetJumpRoot(const bool newval)
{
WriteBool(wxT("JumpRoot"), newval);
}
bool GetNumberPretty() const
{
bool b;

View file

@ -379,6 +379,14 @@
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="chkJumpRoot">
<label>Quick jump to the root node</label>
<checked>0</checked>
</object>
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
<object class="sizeritem">
<object class="wxFlexGridSizer">
<cols>2</cols>
@ -598,6 +606,21 @@
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="stAutosaveQuery">
<label>Auto save query text</label>
</object>
<flag>wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="chkAutosaveQuery">
<label></label>
<checked>1</checked>
</object>
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
<border>4</border>
</object>
</object>
</object>
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>

View file

@ -35308,7 +35308,7 @@ static unsigned char xml_res_file_78[] = {
47,111,98,106,101,99,116,62,10,60,47,114,101,115,111,117,114,99,101,62,
10};
static size_t xml_res_size_79 = 69671;
static size_t xml_res_size_79 = 70799;
static unsigned char xml_res_file_79[] = {
60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101,
110,99,111,100,105,110,103,61,34,73,83,79,45,56,56,53,57,45,49,34,63,62,
@ -36150,7 +36150,25 @@ static unsigned char xml_res_file_79[] = {
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,
99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,
62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,70,108,101,
60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,67,104,101,
99,107,66,111,120,34,32,110,97,109,101,61,34,99,104,107,74,117,109,112,
82,111,111,116,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,81,117,105,99,107,32,106,
117,109,112,32,116,111,32,116,104,101,32,114,111,111,116,32,110,111,100,
101,60,47,108,97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,60,99,104,101,99,107,101,100,62,48,60,
47,99,104,101,99,107,101,100,62,10,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,
103,62,119,120,69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69,
70,84,124,119,120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,
101,114,62,52,60,47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,
101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,
34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,70,108,101,
120,71,114,105,100,83,105,122,101,114,34,62,10,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,99,111,108,115,62,50,
60,47,99,111,108,115,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
@ -36643,33 +36661,66 @@ static unsigned char xml_res_file_79[] = {
32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,60,47,
98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,
10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103,62,
119,120,69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69,70,84,
124,119,120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,60,47,98,
111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,
47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,114,
105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,80,97,110,101,
108,34,32,110,97,109,101,61,34,112,110,108,81,117,101,114,121,84,111,111,
108,67,111,108,111,117,114,115,34,62,10,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,60,104,105,100,100,101,110,62,49,60,47,104,105,100,
100,101,110,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,70,108,101,
120,71,114,105,100,83,105,122,101,114,34,62,10,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,60,99,111,108,115,62,49,60,47,99,111,
108,115,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,60,118,103,97,112,62,53,60,47,118,103,97,112,62,10,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,104,103,97,112,62,53,60,47,
104,103,97,112,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,60,103,114,111,119,97,98,108,101,99,111,108,115,62,48,60,47,103,
114,111,119,97,98,108,101,99,111,108,115,62,10,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,
32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,
97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,
101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,84,101,
120,116,34,32,110,97,109,101,61,34,115,116,65,117,116,111,115,97,118,101,
81,117,101,114,121,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,65,117,116,111,32,115,
97,118,101,32,113,117,101,114,121,32,116,101,120,116,60,47,108,97,98,101,
108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,60,102,108,97,103,62,119,120,65,76,73,71,
78,95,67,69,78,84,69,82,95,86,69,82,84,73,67,65,76,124,119,120,84,79,80,
124,119,120,76,69,70,84,124,119,120,82,73,71,72,84,60,47,102,108,97,103,
62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
60,98,111,114,100,101,114,62,52,60,47,98,111,114,100,101,114,62,10,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,
101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,
114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,
34,119,120,67,104,101,99,107,66,111,120,34,32,110,97,109,101,61,34,99,104,
107,65,117,116,111,115,97,118,101,81,117,101,114,121,34,62,10,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,108,97,
98,101,108,47,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,60,99,104,101,99,107,101,100,62,49,60,47,99,104,101,
99,107,101,100,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103,62,119,120,
69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69,70,84,124,119,
120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,
60,47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,
116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,
103,62,119,120,69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69,
70,84,124,119,120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,60,
47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101,
114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,80,97,
110,101,108,34,32,110,97,109,101,61,34,112,110,108,81,117,101,114,121,84,
111,111,108,67,111,108,111,117,114,115,34,62,10,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,60,104,105,100,100,101,110,62,49,60,47,104,
105,100,100,101,110,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,70,
108,101,120,71,114,105,100,83,105,122,101,114,34,62,10,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,99,111,108,115,62,49,60,47,
99,111,108,115,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,60,118,103,97,112,62,53,60,47,118,103,97,112,62,10,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,104,103,97,112,62,53,
60,47,104,103,97,112,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,60,103,114,111,119,97,98,108,101,99,111,108,115,62,48,60,
47,103,114,111,119,97,98,108,101,99,111,108,115,62,10,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99,
108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,
101,99,116,32,99,108,97,115,115,61,34,119,120,83,116,97,116,105,99,66,111,
120,83,105,122,101,114,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,70,111,114,101,

Binary file not shown.