dataview sample: Added test for wxDataViewModel::Cleared functionality: Ctrl-W will clear MyMusicTreeModel. Ctrl-W can be pressed while editing some item (artist is editable)
This commit is contained in:
parent
8aae7ad937
commit
0199a8ce49
@ -84,6 +84,7 @@ private:
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
void OnGetPageInfo(wxCommandEvent& event);
|
||||
void OnDisable(wxCommandEvent& event);
|
||||
void OnClearMyMusicTreeModel(wxCommandEvent& event);
|
||||
void OnSetForegroundColour(wxCommandEvent& event);
|
||||
void OnIncIndent(wxCommandEvent& event);
|
||||
void OnDecIndent(wxCommandEvent& event);
|
||||
@ -400,6 +401,7 @@ enum
|
||||
ID_CLEARLOG = wxID_HIGHEST+1,
|
||||
ID_GET_PAGE_INFO,
|
||||
ID_DISABLE,
|
||||
ID_CLEAR_MODEL,
|
||||
ID_BACKGROUND_COLOUR,
|
||||
ID_FOREGROUND_COLOUR,
|
||||
ID_CUSTOM_HEADER_ATTR,
|
||||
@ -481,6 +483,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
|
||||
EVT_MENU( ID_GET_PAGE_INFO, MyFrame::OnGetPageInfo )
|
||||
EVT_MENU( ID_DISABLE, MyFrame::OnDisable )
|
||||
EVT_MENU( ID_CLEAR_MODEL, MyFrame::OnClearMyMusicTreeModel )
|
||||
EVT_MENU( ID_FOREGROUND_COLOUR, MyFrame::OnSetForegroundColour )
|
||||
EVT_MENU( ID_BACKGROUND_COLOUR, MyFrame::OnSetBackgroundColour )
|
||||
EVT_MENU( ID_CUSTOM_HEADER_ATTR, MyFrame::OnCustomHeaderAttr )
|
||||
@ -599,6 +602,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
file_menu->Append(ID_CLEARLOG, "&Clear log\tCtrl-L");
|
||||
file_menu->Append(ID_GET_PAGE_INFO, "Show current &page info");
|
||||
file_menu->AppendCheckItem(ID_DISABLE, "&Disable\tCtrl-D");
|
||||
file_menu->Append(ID_CLEAR_MODEL, "&Clear MyMusicTreeModel\tCtrl-W");
|
||||
file_menu->Append(ID_FOREGROUND_COLOUR, "Set &foreground colour...\tCtrl-S");
|
||||
file_menu->Append(ID_BACKGROUND_COLOUR, "Set &background colour...\tCtrl-B");
|
||||
file_menu->AppendCheckItem(ID_CUSTOM_HEADER_ATTR, "C&ustom header attributes");
|
||||
@ -1146,6 +1150,11 @@ void MyFrame::OnDisable(wxCommandEvent& event)
|
||||
m_ctrl[m_notebook->GetSelection()]->Enable(!event.IsChecked());
|
||||
}
|
||||
|
||||
void MyFrame::OnClearMyMusicTreeModel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_music_model->Clear();
|
||||
}
|
||||
|
||||
void MyFrame::OnSetForegroundColour(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
|
||||
|
@ -152,6 +152,21 @@ void MyMusicTreeModel::Delete( const wxDataViewItem &item )
|
||||
// notify control
|
||||
ItemDeleted( parent, item );
|
||||
}
|
||||
void MyMusicTreeModel::Clear()
|
||||
{
|
||||
m_pop = NULL;
|
||||
m_classical = NULL;
|
||||
m_ninth = NULL;
|
||||
|
||||
while (!m_root->GetChildren().IsEmpty())
|
||||
{
|
||||
MyMusicTreeModelNode* node = m_root->GetNthChild(0);
|
||||
m_root->GetChildren().Remove(node);
|
||||
delete node;
|
||||
}
|
||||
|
||||
Cleared();
|
||||
}
|
||||
|
||||
int MyMusicTreeModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
|
||||
unsigned int column, bool ascending ) const
|
||||
|
@ -136,6 +136,7 @@ public:
|
||||
void AddToClassical( const wxString &title, const wxString &artist,
|
||||
unsigned int year );
|
||||
void Delete( const wxDataViewItem &item );
|
||||
void Clear();
|
||||
|
||||
wxDataViewItem GetNinthItem() const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user