X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03dfc8f515662f12c7a13f66bf9064d5c5985c8a..5078fef715268169f8e1ab0c58dd983acb8767e3:/samples/dataview/mymodels.h diff --git a/samples/dataview/mymodels.h b/samples/dataview/mymodels.h index 42d81638d4..ba4397c1f1 100644 --- a/samples/dataview/mymodels.h +++ b/samples/dataview/mymodels.h @@ -21,7 +21,7 @@ class MyMusicTreeModelNode { public: MyMusicTreeModelNode( MyMusicTreeModelNode* parent, - const wxString &title, const wxString &artist, + const wxString &title, const wxString &artist, unsigned int year ) { m_parent = parent; @@ -30,6 +30,8 @@ public: m_artist = artist; m_year = year; m_quality = "good"; + + m_container = false; } MyMusicTreeModelNode( MyMusicTreeModelNode* parent, @@ -39,6 +41,8 @@ public: m_title = branch; m_year = -1; + + m_container = true; } ~MyMusicTreeModelNode() @@ -53,7 +57,7 @@ public: } bool IsContainer() const - { return m_children.GetCount()>0; } + { return m_container; } MyMusicTreeModelNode* GetParent() { return m_parent; } @@ -74,6 +78,17 @@ public: // public to avoid getters/setters int m_year; wxString m_quality; + // TODO/FIXME: + // the GTK version of wxDVC (in particular wxDataViewCtrlInternal::ItemAdded) + // needs to know in advance if a node is or _will be_ a container. + // Thus implementing: + // bool IsContainer() const + // { return m_children.GetCount()>0; } + // doesn't work with wxGTK when MyMusicTreeModel::AddToClassical is called + // AND the classical node was removed (a new node temporary without children + // would be added to the control) + bool m_container; + private: MyMusicTreeModelNode *m_parent; MyMusicTreeModelNodePtrArray m_children; @@ -109,11 +124,12 @@ public: // helper method for wxLog wxString GetTitle( const wxDataViewItem &item ) const; + wxString GetArtist( const wxDataViewItem &item ) const; int GetYear( const wxDataViewItem &item ) const; // helper methods to change the model - void AddToClassical( const wxString &title, const wxString &artist, + void AddToClassical( const wxString &title, const wxString &artist, unsigned int year ); void Delete( const wxDataViewItem &item ); @@ -125,7 +141,7 @@ public: // override sorting to always sort branches ascendingly int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int column, bool ascending ); + unsigned int column, bool ascending ) const; // implementation of base class virtuals to define model @@ -149,7 +165,7 @@ public: virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; virtual bool IsContainer( const wxDataViewItem &item ) const; - virtual unsigned int GetChildren( const wxDataViewItem &parent, + virtual unsigned int GetChildren( const wxDataViewItem &parent, wxDataViewItemArray &array ) const; private: