Added wxDataViewModel::GetChildren() (removed GetSibling() and GetFirstChild())
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -8,6 +8,7 @@ pure virtual functions in order to define a complete
|
||||
data model. In detail, you need to override
|
||||
\helpref{IsContainer}{wxdataviewmodeliscontainer},
|
||||
\helpref{GetParent}{wxdataviewmodelgetparent},
|
||||
\helpref{GetChildren}{wxdataviewmodelgetchildren},
|
||||
\helpref{GetColumnCount}{wxdataviewmodelgetcolumncount},
|
||||
\helpref{GetColumnType}{wxdataviewmodelgetcolumntype} and
|
||||
\helpref{GetValue}{wxdataviewmodelgetvalue} in order to
|
||||
@@ -125,17 +126,12 @@ Override this to indicate what type of data is stored in the
|
||||
column specified by {\it col}. This should return a string
|
||||
indicating the type of data as reported by \helpref{wxVariant}{wxvariant}.
|
||||
|
||||
\membersection{wxDataViewModel::GetFirstChild}\label{wxdataviewmodelgetfirstchild}
|
||||
\membersection{wxDataViewModel::GetChildren}\label{wxdataviewmodelgetfirstchild}
|
||||
|
||||
\constfunc{wxDataViewItem}{GetFirstChild}{\param{const wxDataViewItem\& }{parent}}
|
||||
\constfunc{unsigned int}{GetChildren}{\param{const wxDataViewItem\& }{item}, \param{wxDataViewItemArray\& }{children} }
|
||||
|
||||
To be removed.
|
||||
|
||||
\membersection{wxDataViewModel::GetNextSibling}\label{wxdataviewmodelgetnextsibling}
|
||||
|
||||
\constfunc{wxDataViewItem}{GetNextSibling}{\param{const wxDataViewItem\& }{item}}
|
||||
|
||||
To be removed.
|
||||
Override this so the control can query the child items of
|
||||
an item. Returns the number of items.
|
||||
|
||||
\membersection{wxDataViewModel::GetParent}\label{wxdataviewmodelgetparent}
|
||||
|
||||
|
@@ -138,8 +138,7 @@ public:
|
||||
// define hierachy
|
||||
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
|
||||
virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
|
||||
virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const = 0;
|
||||
virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const = 0;
|
||||
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
|
||||
|
||||
// delegated notifiers
|
||||
virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
|
||||
@@ -210,8 +209,7 @@ public:
|
||||
const wxDataViewItem &item, unsigned int col );
|
||||
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
|
||||
virtual bool IsContainer( const wxDataViewItem &item ) const;
|
||||
virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const;
|
||||
virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const;
|
||||
virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
|
||||
|
||||
private:
|
||||
wxDataViewItemArray m_hash;
|
||||
|
@@ -333,48 +333,36 @@ public:
|
||||
return node->IsContainer();
|
||||
}
|
||||
|
||||
virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const
|
||||
virtual unsigned int GetChildren( const wxDataViewItem &parent, wxDataViewItemArray &array ) const
|
||||
{
|
||||
MyMusicModelNode *node = (MyMusicModelNode*) parent.GetID();
|
||||
if (!node)
|
||||
return wxDataViewItem( (void*) m_root );
|
||||
{
|
||||
array.Add( wxDataViewItem( (void*) m_root ) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (node->GetChildCount() == 0)
|
||||
return wxDataViewItem( 0 );
|
||||
|
||||
if (node == m_classical)
|
||||
{
|
||||
MyMusicModel *model = (MyMusicModel*)(const MyMusicModel*) this;
|
||||
model->m_classicalMusicIsKnownToControl = true;
|
||||
}
|
||||
|
||||
MyMusicModelNode *first_child = node->GetChildren().Item( 0 );
|
||||
return wxDataViewItem( (void*) first_child );
|
||||
if (node->GetChildCount() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int count = node->GetChildren().GetCount();
|
||||
unsigned int pos;
|
||||
for (pos = 0; pos < count; pos++)
|
||||
{
|
||||
MyMusicModelNode *child = node->GetChildren().Item( pos );
|
||||
array.Add( wxDataViewItem( (void*) child ) );
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const
|
||||
{
|
||||
MyMusicModelNode *node = (MyMusicModelNode*) item.GetID();
|
||||
|
||||
// "MyMusic" has no siblings in our model
|
||||
if (node == m_root)
|
||||
return wxDataViewItem(0);
|
||||
|
||||
MyMusicModelNode *parent = node->GetParent();
|
||||
int pos = parent->GetChildren().Index( node );
|
||||
|
||||
// Something went wrong
|
||||
if (pos == wxNOT_FOUND)
|
||||
return wxDataViewItem(0);
|
||||
|
||||
// No more children
|
||||
if (pos == parent->GetChildCount()-1)
|
||||
return wxDataViewItem(0);
|
||||
|
||||
node = parent->GetChildren().Item( pos+1 );
|
||||
return wxDataViewItem( (void*) node );
|
||||
}
|
||||
|
||||
private:
|
||||
MyMusicModelNode* m_root;
|
||||
MyMusicModelNode* m_pop;
|
||||
|
@@ -307,29 +307,14 @@ bool wxDataViewIndexListModel::IsContainer( const wxDataViewItem &item ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewIndexListModel::GetFirstChild( const wxDataViewItem &parent ) const
|
||||
unsigned int wxDataViewIndexListModel::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
|
||||
{
|
||||
if (!parent.IsOk())
|
||||
{
|
||||
if (m_hash.GetCount() == 0)
|
||||
return wxDataViewItem(0);
|
||||
if (item.IsOk())
|
||||
return 0;
|
||||
|
||||
return wxDataViewItem( m_hash[0]);
|
||||
}
|
||||
|
||||
return wxDataViewItem(0);
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewIndexListModel::GetNextSibling( const wxDataViewItem &item ) const
|
||||
{
|
||||
if (!item.IsOk())
|
||||
return wxDataViewItem(0);
|
||||
|
||||
int pos = m_hash.Index( item.GetID() );
|
||||
if ((pos == wxNOT_FOUND) || (pos == (int) (m_hash.GetCount()-1)))
|
||||
return wxDataViewItem(0);
|
||||
|
||||
return wxDataViewItem( m_hash[pos+1] );
|
||||
children = m_hash;
|
||||
|
||||
return m_hash.GetCount();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -2380,17 +2380,19 @@ void wxDataViewCtrlInternal::BuildBranch( wxGtkTreeModelNode *node )
|
||||
{
|
||||
if (node->GetChildCount() == 0)
|
||||
{
|
||||
wxDataViewItem child = m_wx_model->GetFirstChild( node->GetItem() );
|
||||
while (child.IsOk())
|
||||
wxDataViewItemArray children;
|
||||
unsigned int count = m_wx_model->GetChildren( node->GetItem(), children );
|
||||
unsigned int pos;
|
||||
for (pos = 0; pos < count; pos++)
|
||||
{
|
||||
wxDataViewItem child = children[pos];
|
||||
|
||||
if (m_wx_model->IsContainer( child ))
|
||||
node->AddNode( new wxGtkTreeModelNode( node, child, this ) );
|
||||
else
|
||||
node->AddLeave( child.GetID() );
|
||||
|
||||
// Don't send any events here
|
||||
|
||||
child = m_wx_model->GetNextSibling( child );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user