void MyMusicTreeModel::AddToClassical( const wxString &title, const wxString &artist, unsigned int year ) { if (!m_classical) { wxASSERT(m_root); // it was removed: restore it m_classical = new MyMusicTreeModelNode( m_root, "Classical music" ); m_root->Append( m_classical ); // notify control wxDataViewItem child( (void*) m_classical ); wxDataViewItem parent( (void*) m_root ); ItemAdded( parent, child ); } // add to the classical music node a new node: MyMusicTreeModelNode *child_node = new MyMusicTreeModelNode( m_classical, title, artist, year ); m_classical->Append( child_node ); // FIXME: what's m_classicalMusicIsKnownToControl for? if (m_classicalMusicIsKnownToControl) { // notify control wxDataViewItem child( (void*) child_node ); wxDataViewItem parent( (void*) m_classical ); ItemAdded( parent, child ); } }
wxDataViewItem TreeListModel::InsertItem(const wxDataViewItem& insertBeforeMe, const wxVector<wxVariant>& data, wxClientData *clientData) { wxDataViewItem ch = DoInsertItem(insertBeforeMe, data, false, clientData); if ( ch.IsOk() ) { TreeListModel_Item* node = reinterpret_cast<TreeListModel_Item*>(ch.GetID()); ItemAdded(wxDataViewItem(node->GetParent()), ch); } return ch; }
void ContentManager::AddItem(ContentItemNew* ContentItem) { // First add our item ITEM_LOCK; ContentItem->SetItemObserver(this); contentItems.push_back(ContentItem); ITEM_UNLOCK; // Now lets notify that we added a item ItemAdded(ContentItem); }
void TreeListModel::DoChangeItemType(const wxDataViewItem& item, bool changeToContainer) { TreeListModel_Item* node = reinterpret_cast<TreeListModel_Item*>(item.GetID()); if ( !node ) return; if ( ( changeToContainer && !node->IsContainer()) || // change an item from non-container to container type ( !changeToContainer && node->IsContainer()) ) { // change an item from container to non-container type #if defined(__WXGTK__) || defined(__WXMAC__) // change the item to container type: // 1st we need to delete it ItemDeleted(wxDataViewItem(node->GetParent()), item); // update the node type node->SetIsContainer(changeToContainer); ItemAdded(wxDataViewItem(node->GetParent()), item); #else node->SetIsContainer(changeToContainer); #endif } }
wxDataViewItem TreeListModel::AppendItem(const wxDataViewItem &parent, const wxVector<wxVariant>& data, wxClientData *clientData) { wxDataViewItem ch = DoAppendItem(parent, data, false, clientData); ItemAdded(parent, ch); return ch; }
wxTreeListModelNode* wxTreeListModel::InsertItem(Node* parent, Node* previous, const wxString& text, int imageClosed, int imageOpened, wxClientData* data) { wxCHECK_MSG( parent, NULL, "Must have a valid parent (maybe GetRootItem()?)" ); wxCHECK_MSG( previous, NULL, "Must have a valid previous item (maybe wxTLI_FIRST/LAST?)" ); if ( m_isFlat && parent != m_root ) { // Not flat any more, this is a second level child. m_isFlat = false; } wxScopedPtr<Node> newItem(new Node(parent, text, imageClosed, imageOpened, data)); // FIXME-VC6: This compiler refuses to compare "Node* previous" with // wxTLI_XXX without some help. const wxTreeListItem previousItem(previous); // If we have no children at all, then inserting as last child is the same // as inserting as the first one so check for it here too. if ( previousItem == wxTLI_FIRST || (previousItem == wxTLI_LAST && !parent->GetChild()) ) { parent->InsertChild(newItem.get()); } else // Not the first item, find the previous one. { if ( previousItem == wxTLI_LAST ) { previous = parent->GetChild(); // Find the last child. for ( ;; ) { Node* const next = previous->GetNext(); if ( !next ) break; previous = next; } } else // We already have the previous item. { // Just check it's under the correct parent. wxCHECK_MSG( previous->GetParent() == parent, NULL, "Previous item is not under the right parent" ); } previous->InsertNext(newItem.get()); } ItemAdded(ToDVI(parent), ToDVI(newItem.get())); // The item was successfully inserted in the tree and so will be deleted by // it, we can detach it now. return newItem.release(); }