Esempio n. 1
0
        public void RefreshItem(ITreeItem item)
        {
            var path = model.GetPathFromItem(item);

            if (path != null && path.Depth > 0 && !object.ReferenceEquals(item, collection.Collection))
            {
                Gtk.TreeIter iter;
                tree.Model.GetIter(out iter, path);
                tree.Model.EmitRowChanged(path, iter);
                tree.Model.EmitRowHasChildToggled(path, iter);
                cancelExpandCollapseEvents = true;
                if (item.Expanded)
                {
                    tree.CollapseRow(path);
                    tree.ExpandRow(path, false);
                    collection.ExpandItems(item, path);
                }
                else
                {
                    tree.CollapseRow(path);
                }
                cancelExpandCollapseEvents = false;
            }
            else
            {
                RefreshData();
            }
        }
Esempio n. 2
0
        public void ReloadItem(ITreeGridItem item, bool reloadChildren)
        {
            var tree = Tree;
            var path = model.GetPathFromItem(item);

            if (path != null && path.Depth > 0 && !ReferenceEquals(item, collection.Collection))
            {
                suppressExpandCollapseEvents++;
                var wasExpanded = tree.GetRowExpanded(path);

                Gtk.TreeIter iter;
                tree.Model.GetIter(out iter, path);
                if (item.Expandable)
                {
                    tree.Model.EmitRowChanged(path, iter);
                    if (reloadChildren || item.Expanded != wasExpanded)
                    {
                        tree.Model.EmitRowHasChildToggled(path, iter);
                        tree.CollapseRow(path);
                        if (item.Expanded)
                        {
                            tree.ExpandRow(path, false);
                            collection.ExpandItems((ITreeGridStore <ITreeGridItem>)item, path);
                        }
                    }
                }
                else if (wasExpanded)
                {
                    // it was expanded (and had children), but now it won't be.
                    // Gtk requires that we know at this time how many children we have to remove, but instead let's
                    // just delete this node and re-add it.
                    // EmitRowHasChildToggled should have done this IMO, but I guess it does not.
                    tree.Model.EmitRowDeleted(path);
                    tree.Model.EmitRowInserted(path, iter);
                }
                else
                {
                    tree.Model.EmitRowChanged(path, iter);
                }
                suppressExpandCollapseEvents--;
            }
            else
            {
                ReloadData();
            }
        }