mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-08-19 14:22:47 -06:00
Add new feature frmLog
Для окна состояние выполняется: set log_min_messages = FATAL Для Log view добавлена: подержка быстрой навигации: Shift+KeyUP,KeyDOWN переход на запись с тем же sql_state, Alt+KeyUP,KeyDOWN - переход на запись с другим sql_state Добавлена колонка Server - сервер с которого получен лог.
This commit is contained in:
parent
592cd1110b
commit
4db8267ae6
11 changed files with 196 additions and 44 deletions
|
|
@ -132,8 +132,15 @@ void MyDataViewCtrl::ViewGroup(bool view) {
|
|||
void MyDataViewCtrl::AddRow(wxString csvtext) {
|
||||
StorageModel* m = dynamic_cast<StorageModel*>(GetModel());
|
||||
wxDataViewItem select;
|
||||
if (HasSelection()) select = GetSelection();
|
||||
|
||||
if (HasSelection()) {
|
||||
//select = GetSelection();
|
||||
if (GetSelectedItemsCount() == 1) {
|
||||
wxDataViewItemArray sel;
|
||||
GetSelections(sel);
|
||||
if (sel.size()>0) select = sel[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (m->Prepend(csvtext)) {
|
||||
if (!select.IsOk()) return;
|
||||
|
|
@ -396,11 +403,93 @@ void MyDataViewCtrl::OnEVT_DATAVIEW_COLUMN_HEADER_CLICK(wxDataViewEvent& event)
|
|||
|
||||
event.Skip(true);
|
||||
}
|
||||
void MyDataViewCtrl::OnKEY_UP(wxKeyEvent& event) {
|
||||
// goto next state code
|
||||
int go = 0;
|
||||
if (event.GetKeyCode() == WXK_DOWN) {
|
||||
go = 1;
|
||||
}
|
||||
if (event.GetKeyCode() == WXK_UP) {
|
||||
go = -1;
|
||||
}
|
||||
bool reverse = false;
|
||||
int currrow = -1;
|
||||
wxDataViewItem item;
|
||||
//find next state != current state
|
||||
if ((event.GetModifiers() & wxMOD_ALT) == wxMOD_ALT) {
|
||||
reverse = true;
|
||||
item = this->GetCurrentItem();
|
||||
}
|
||||
//find next state == current state
|
||||
if ((event.GetModifiers() & wxMOD_SHIFT) == wxMOD_SHIFT) {
|
||||
item = this->GetCurrentItem();
|
||||
}
|
||||
if (item.IsOk() && (go != 0)) {
|
||||
|
||||
|
||||
StorageModel* m = dynamic_cast<StorageModel*>(GetModel());
|
||||
Storage* sta = m->getStorage();
|
||||
wxVariant v, t;
|
||||
|
||||
int r = m->GetRow(item);
|
||||
if (r != -1) {
|
||||
m->GetValueByRow(v, r, 0);
|
||||
}
|
||||
else return;
|
||||
int cnt = m->GetRowCount();
|
||||
wxDataViewIconText ic;
|
||||
ic << v;
|
||||
wxString str = ic.GetText();
|
||||
|
||||
for (;;) {
|
||||
r = r + go;
|
||||
if (r < 0 || r >= cnt) break;
|
||||
m->GetValueByRow(t, r, 0);
|
||||
ic << t;
|
||||
bool rez = ic.GetText() == str;
|
||||
if (reverse) rez = !rez;
|
||||
if (rez)
|
||||
{
|
||||
item = m->GetItem(r);
|
||||
this->SetCurrentItem(item);
|
||||
EnsureVisible(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
event.Skip(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
void MyDataViewCtrl::OnKEY_DOWN(wxKeyEvent& event) {
|
||||
if ((event.GetModifiers() & wxMOD_CONTROL) == wxMOD_CONTROL) {
|
||||
modctrl = true;
|
||||
}
|
||||
else modctrl = false;
|
||||
int go = 0;
|
||||
if (event.GetKeyCode() == WXK_DOWN) {
|
||||
go = 1;
|
||||
}
|
||||
if (event.GetKeyCode() == WXK_UP) {
|
||||
go = -1;
|
||||
}
|
||||
bool reverse = false;
|
||||
int currrow = -1;
|
||||
wxDataViewItem item;
|
||||
//find next state != current state
|
||||
if ((event.GetModifiers() & wxMOD_ALT) == wxMOD_ALT) {
|
||||
reverse = true;
|
||||
item = this->GetCurrentItem();
|
||||
}
|
||||
//find next state == current state
|
||||
if ((event.GetModifiers() & wxMOD_SHIFT) == wxMOD_SHIFT) {
|
||||
item = this->GetCurrentItem();
|
||||
}
|
||||
if (item.IsOk() && (go != 0)) {
|
||||
event.Skip(false);
|
||||
return;
|
||||
}
|
||||
|
||||
event.Skip(true);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,6 +341,9 @@ wxString Storage::get_field(Line& l, MyConst::colField col) {
|
|||
case MyConst::colField::logbtype:
|
||||
return l.text.substr(l.logbtype.s, l.logbtype.l);
|
||||
break;
|
||||
case MyConst::colField::logSERVER:
|
||||
return l.text.substr(l.logSERVER.s, l.logSERVER.l);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -434,6 +437,9 @@ Line Storage::getLineParse(const wxString& str, bool csv) {
|
|||
wxString logType = tk.GetNextToken();
|
||||
st.logbtype = { static_cast<unsigned short int>(t.Len()),static_cast<unsigned short int>(logType.Len()) };
|
||||
t += logType;
|
||||
logCursorpos = GetHost();
|
||||
st.logSERVER = { static_cast<unsigned short int>(t.Len()),static_cast<unsigned short int>(logCursorpos.Len()) };
|
||||
t += logCursorpos;
|
||||
//fields.Add(logType);
|
||||
//st.logType = { t.Len(),logType.Len() };
|
||||
//t += logType;
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_LogTime),
|
||||
StorageModel::Col_LogTime,
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_LogTime] = MyConst::colField::logtime;
|
||||
|
|
@ -278,7 +278,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_User),
|
||||
StorageModel::Col_User,
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_User] = MyConst::colField::loguser;
|
||||
|
|
@ -287,7 +287,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_Db),
|
||||
StorageModel::Col_Db,
|
||||
30,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_Db] = MyConst::colField::logdb;
|
||||
|
|
@ -296,7 +296,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_PID),
|
||||
StorageModel::Col_PID,
|
||||
60,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_PID] = MyConst::colField::logpid;
|
||||
|
|
@ -305,7 +305,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_Host),
|
||||
StorageModel::Col_Host,
|
||||
90,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_Host] = MyConst::colField::loghost;
|
||||
|
|
@ -314,7 +314,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_App),
|
||||
StorageModel::Col_App,
|
||||
100,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_App] = MyConst::colField::logappname;
|
||||
|
|
@ -323,7 +323,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_Hint),
|
||||
StorageModel::Col_Hint,
|
||||
90,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_Hint] = MyConst::colField::logHint;
|
||||
|
|
@ -332,7 +332,7 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_Detail),
|
||||
StorageModel::Col_Detail,
|
||||
60,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_Detail] = MyConst::colField::logDetail;
|
||||
|
|
@ -342,10 +342,19 @@ void StorageModel::BuildColumns(MyDataViewCtrl* ctrl) {
|
|||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_Message),
|
||||
StorageModel::Col_Message,
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_LEFT,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_Message] = MyConst::colField::logMessage;
|
||||
ctrl->AppendColumn(
|
||||
new wxDataViewColumn("Server",
|
||||
new MyCustomRendererText(wxDATAVIEW_CELL_EDITABLE, StorageModel::Col_Server),
|
||||
StorageModel::Col_Server,
|
||||
wxCOL_WIDTH_AUTOSIZE,
|
||||
wxALIGN_NOT,
|
||||
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE
|
||||
));
|
||||
colmap[StorageModel::Col_Server] = MyConst::colField::logSERVER;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -368,6 +377,7 @@ StorageModel::StorageModel(MyDataViewCtrl* view) :
|
|||
bool StorageModel::setFilter(int col, wxString val, int flags, MyDataViewCtrl* view) {
|
||||
|
||||
bool r = store->SetFilter(colmap[col], val, flags);
|
||||
m_view->UnselectAll();
|
||||
Reset(store->getCountFilter());
|
||||
if (col != -1) {
|
||||
wxDataViewColumn* vc = view->GetColumn(col);
|
||||
|
|
@ -382,6 +392,7 @@ int StorageModel::testFilter(int col, int position = 0) {
|
|||
}
|
||||
void StorageModel::ApplyFilter() {
|
||||
store->ApplyFilter();
|
||||
m_view->UnselectAll();
|
||||
Reset(store->getCountFilter());
|
||||
}
|
||||
|
||||
|
|
@ -406,6 +417,8 @@ bool StorageModel::Prepend(const wxString& text)
|
|||
IncCountFreq(StorageModel::Col_Hint, store->GetFieldStorage(row, MyConst::colField::logHint, false));
|
||||
val = store->GetFieldStorage(row, MyConst::colField::logSqlstate, false);
|
||||
IncCountFreq(StorageModel::Col_ToggleIconText, val);
|
||||
val = store->GetFieldStorage(row, MyConst::colField::logSERVER, false);
|
||||
IncCountFreq(StorageModel::Col_Server, val);
|
||||
|
||||
|
||||
if (store->ApplyFilter(row)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue