Esempio n. 1
0
        private void AddNodeToModel(Node node, TreePath path)
        {
            // First reorder the child if necessary
            if (path == null && IsSorted)
            {
                Comparison <Node> sorter = Sorter;

                for (int i = 0; i < node.Parent.Count; ++i)
                {
                    Node child = node.Parent[i];

                    if (node != child && sorter(node, child) < 0)
                    {
                        node.Parent.Move(node, i);
                        break;
                    }
                }
            }

            if (path == null)
            {
                path = node.Path;
            }

            //Console.WriteLine("Row inserted: {0}, {1}", path, node);
            d_adapter.EmitRowInserted(path.Copy(), node.Iter);

            TreePath children = path.Copy();

            children.Down();

            if (IsSorted)
            {
                node.Sort(Sorter);
            }

            // Then also its children
            foreach (Node child in node)
            {
                AddNodeToModel(child, children);
                children.Next();
            }
        }