Remove unnecessary tests for m_log from dataview sample.

The sample contained a lot of unnecessary checks for m_log, remove them to
make the code shorter and simpler to understand.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66008 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-11-03 23:48:23 +00:00
parent ab84bafe49
commit d632aa8157

View File

@ -408,6 +408,14 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
CreateStatusBar();
// redirect logs from our event handlers to text control
m_log = new wxTextCtrl( this, wxID_ANY, wxString(), wxDefaultPosition,
wxDefaultSize, wxTE_MULTILINE );
m_log->SetMinSize(wxSize(-1, 100));
m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_log));
wxLogMessage( "This is the log window" );
// first page of the notebook
// --------------------------
@ -507,12 +515,6 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
m_log = new wxTextCtrl( this, wxID_ANY, wxString(), wxDefaultPosition,
wxDefaultSize, wxTE_MULTILINE );
m_log->SetMinSize(wxSize(-1, 100));
m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_log));
wxLogMessage( "This is the log window" );
mainSizer->Add( m_notebook, 1, wxGROW );
mainSizer->Add( m_log, 0, wxGROW );
@ -960,9 +962,6 @@ void MyFrame::OnSetNinthCurrent(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnValueChanged( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, Item Id: %s; Column: %d",
title, event.GetColumn() );
@ -970,9 +969,6 @@ void MyFrame::OnValueChanged( wxDataViewEvent &event )
void MyFrame::OnActivated( wxDataViewEvent &event )
{
if(!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s", title );
@ -984,9 +980,6 @@ void MyFrame::OnActivated( wxDataViewEvent &event )
void MyFrame::OnSelectionChanged( wxDataViewEvent &event )
{
if(!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
if (title.empty())
title = "None";
@ -996,9 +989,6 @@ void MyFrame::OnSelectionChanged( wxDataViewEvent &event )
void MyFrame::OnExpanding( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, Item: %s", title );
}
@ -1011,9 +1001,6 @@ void MyFrame::OnStartEditing( wxDataViewEvent &event )
{
event.Veto();
if (!m_log)
return;
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING vetoed. Artist: %s", artist );
}
else
@ -1023,54 +1010,36 @@ void MyFrame::OnStartEditing( wxDataViewEvent &event )
void MyFrame::OnEditingStarted( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, Item: %s", title );
}
void MyFrame::OnEditingDone( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, Item: %s", title );
}
void MyFrame::OnExpanded( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, Item: %s", title );
}
void MyFrame::OnCollapsing( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, Item: %s", title );
}
void MyFrame::OnCollapsed( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title );
}
void MyFrame::OnContextMenu( wxDataViewEvent &event )
{
if (!m_log)
return;
wxString title = m_music_model->GetTitle( event.GetItem() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, Item: %s", title );
@ -1088,9 +1057,6 @@ void MyFrame::OnAttrHeaderClick( wxDataViewEvent &event )
// this column when it is clicked to take place
event.Skip();
if (!m_log)
return;
int pos = m_ctrl[1]->GetColumnPosition( event.GetDataViewColumn() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos );
@ -1103,9 +1069,6 @@ void MyFrame::OnHeaderClick( wxDataViewEvent &event )
// this column when it is clicked to take place
event.Skip();
if (!m_log)
return;
int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos );
@ -1114,9 +1077,6 @@ void MyFrame::OnHeaderClick( wxDataViewEvent &event )
void MyFrame::OnHeaderRightClick( wxDataViewEvent &event )
{
if(!m_log)
return;
int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos );
@ -1124,9 +1084,6 @@ void MyFrame::OnHeaderRightClick( wxDataViewEvent &event )
void MyFrame::OnSorted( wxDataViewEvent &event )
{
if(!m_log)
return;
int pos = m_ctrl[0]->GetColumnPosition( event.GetDataViewColumn() );
wxLogMessage( "wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, Column position: %d", pos );
@ -1134,9 +1091,6 @@ void MyFrame::OnSorted( wxDataViewEvent &event )
void MyFrame::OnRightClick( wxMouseEvent &event )
{
if(!m_log)
return;
wxLogMessage( "wxEVT_MOUSE_RIGHT_UP, Click Point is X: %d, Y: %d",
event.GetX(), event.GetY() );
}