// Created: 06/01/06
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
{
public:
MyMusicTreeModelNode( MyMusicTreeModelNode* parent,
- const wxString &title, const wxString &artist,
+ const wxString &title, const wxString &artist,
unsigned int year )
{
m_parent = parent;
m_artist = artist;
m_year = year;
m_quality = "good";
+
+ m_container = false;
}
MyMusicTreeModelNode( MyMusicTreeModelNode* parent,
m_title = branch;
m_year = -1;
+
+ m_container = true;
}
~MyMusicTreeModelNode()
}
bool IsContainer() const
- { return m_children.GetCount()>0; }
+ { return m_container; }
MyMusicTreeModelNode* GetParent()
{ return m_parent; }
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;
// 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 );
// 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
virtual bool SetValue( const wxVariant &variant,
const wxDataViewItem &item, unsigned int col );
+ virtual bool IsEnabled( const wxDataViewItem &item,
+ unsigned int col ) const;
+
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:
class MyListModel: public wxDataViewVirtualListModel
{
public:
+ enum
+ {
+ Col_EditableText,
+ Col_IconText,
+ Col_TextWithAttr,
+ Col_Custom,
+ Col_Max
+ };
+
MyListModel();
// helper methods to change the model
virtual unsigned int GetColumnCount() const
{
- return 3;
+ return Col_Max;
}
virtual wxString GetColumnType( unsigned int col ) const
{
- if (col == 1)
+ if (col == Col_IconText)
return wxT("wxDataViewIconText");
return wxT("string");
}
- virtual unsigned int GetRowCount()
- {
- return m_array.GetCount();
- }
-
virtual void GetValueByRow( wxVariant &variant,
unsigned int row, unsigned int col ) const;
- virtual bool GetAttrByRow( unsigned int row, unsigned int col, wxDataViewItemAttr &attr );
+ virtual bool GetAttrByRow( unsigned int row, unsigned int col,
+ wxDataViewItemAttr &attr ) const;
virtual bool SetValueByRow( const wxVariant &variant,
unsigned int row, unsigned int col );
private:
- wxArrayString m_array;
+ wxArrayString m_textColValues;
+ wxArrayString m_iconColValues;
wxIcon m_icon[2];
- int m_virtualItems;
};
+// ----------------------------------------------------------------------------
+// MyListStoreDerivedModel
+// ----------------------------------------------------------------------------
+
+class MyListStoreDerivedModel : public wxDataViewListStore
+{
+public:
+ virtual bool IsEnabledByRow(unsigned int row, unsigned int col) const;
+};