C++ (Qt)struct CTreeItem { QString m_name; // имя ... // .. еще данные айтема QVector<CTreeItem> m_child; // чайлдво CTreeItem * m_parent; // ???};
C++ (Qt)struct Data{ // bla bla bla}; class Item{ Parent m_parent; // например, Parent = Item * Children m_children; // например, Children = QVector< Item * > Data m_data; // bla bla bla}
void CTreeItem::CopyFrom( const CTreeItem & other, CTreeItem * parent );
C++ (Qt)*theTargetItem = *theSourceItem;theTargetItem->m_parent = newParent;
auto subtree = item->clone(); parent->addItem(subtree);
auto subtree = item->clone(newParent);
std::unique_ptr<Item> subtree = item->clone(); parent->addItem(std::move(subtree));
C++ (Qt)struct CTreeItem { CTreeItem( CTreeItem * parent ); virtual ~CTreeItem( void ) ; // qDeleteAll(m_child) CTreeItem * Clone( CTreeItem * parent ) const; // data CTreeItem * m_parent; QVector<CTreeItem *> m_child; QString m_name; int m_flags; ... // more data private: CTreeItem( const CTreeItem & ); CTreeItem & operator = ( const CTreeItem & );};
TreeItem *item = getItem();
std::unique_ptr<TreeItem> tree = getTree();
ObserverPointer<TreeItem> node = getNode();