gi-gtk-hs-0.3.18: A wrapper for gi-gtk, adding a few more idiomatic API parts on top

Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
Language | Haskell2010

Data.GI.Gtk.ModelView.ForestStore

Contents

- Types
- Constructors
- Implementation of Interfaces
- Methods

Description

Standard model to store hierarchical data.

Synopsis

- newtype ForestStore a = ForestStore (ManagedPtr (CustomStore (IORef (Store a)) a))
- forestStoreNew :: MonadIO m => Forest a -> m (ForestStore a)
- forestStoreNewDND :: MonadIO m => Forest a -> Maybe (DragSourceIface ForestStore a) -> Maybe (DragDestIface ForestStore a) -> m (ForestStore a)
- forestStoreDefaultDragSourceIface :: DragSourceIface ForestStore row
- forestStoreDefaultDragDestIface :: DragDestIface ForestStore row
- forestStoreGetValue :: (Applicative m, MonadIO m) => ForestStore a -> TreePath -> m a
- forestStoreGetTree :: MonadIO m => ForestStore a -> TreePath -> m (Tree a)
- forestStoreGetForest :: MonadIO m => ForestStore a -> m (Forest a)
- forestStoreLookup :: MonadIO m => ForestStore a -> TreePath -> m (Maybe (Tree a))
- forestStoreSetValue :: MonadIO m => ForestStore a -> TreePath -> a -> m ()
- forestStoreInsert :: MonadIO m => ForestStore a -> TreePath -> Int -> a -> m ()
- forestStoreInsertTree :: MonadIO m => ForestStore a -> TreePath -> Int -> Tree a -> m ()
- forestStoreInsertForest :: MonadIO m => ForestStore a -> TreePath -> Int -> Forest a -> m ()
- forestStoreRemove :: MonadIO m => ForestStore a -> TreePath -> m Bool
- forestStoreClear :: MonadIO m => ForestStore a -> m ()
- forestStoreChange :: MonadIO m => ForestStore a -> TreePath -> (a -> a) -> m Bool
- forestStoreChangeM :: MonadIO m => ForestStore a -> TreePath -> (a -> m a) -> m Bool

# Types

newtype ForestStore a Source #

A store for hierarchical data.

Constructors

ForestStore (ManagedPtr (CustomStore (IORef (Store a)) a)) |

#### Instances

Instances details

IsTypedTreeModel ForestStore Source # |
Instance details Defined in Data.GI.Gtk.ModelView.ForestStore Methods dummy :: ForestStore a -> a
GObject (ForestStore a) Source # |
Instance details Defined in Data.GI.Gtk.ModelView.ForestStore
TypedObject (ForestStore a) Source # |
Instance details Defined in Data.GI.Gtk.ModelView.ForestStore Methods glibType :: IO GType Source #
HasParentTypes (ForestStore a) Source # |
Instance details Defined in Data.GI.Gtk.ModelView.ForestStore
type ParentTypes (ForestStore a) Source # |
Instance details Defined in Data.GI.Gtk.ModelView.ForestStore type ParentTypes (ForestStore a) = '[TreeModel]

# Constructors

forestStoreNew :: MonadIO m => Forest a -> m (ForestStore a) Source #

Create a new list store.

- The given rose tree determines the initial content and may be the empty list. Each `Tree` in the forest corresponds to one top-level node.
- The ForestStore maintains the initially given Forest and aligns the `TreePath` bits to fit in 96-bit length `TreeIter` storage.
- Additionally, a cache is used to achieve higher performance if operating on recently used TreePaths.
- Note: due to the limited amount of bits available in TreeIter storage, only limited depth forests can be used with this implementation, the result of too deep Forests is an undefined behaviour while trying to retrieve the deeply nested nodes. For example: assuming the average requiement is 8 bits per tree level (max number of children at the level is 255), then we can only use 12 levels deep trees (96/8) - any further levels in a TreePath will not be encoded in the corresponding TreeIter storage.

forestStoreNewDND Source #

Arguments

:: MonadIO m |
=> Forest a | the inital tree stored in this model
-> Maybe (DragSourceIface ForestStore a) | an optional interface for drags
-> Maybe (DragDestIface ForestStore a) | an optional interface to handle drops
-> m (ForestStore a) |

Create a new list store.

- In addition to `forestStoreNew`, this function takes an two interfaces to implement user-defined drag-and-drop functionality.

# Implementation of Interfaces

forestStoreDefaultDragSourceIface :: DragSourceIface ForestStore row Source #

Default drag functions for `ForestStore`. These functions allow the rows of the model to serve as drag source. Any row is allowed to be dragged and the data set in the `SelectionDataM` object is set with `treeSetRowDragData`, i.e. it contains the model and the `TreePath` to the row.

forestStoreDefaultDragDestIface :: DragDestIface ForestStore row Source #

Default drop functions for `ForestStore`. These functions accept a row and insert the row into the new location if it is dragged into a tree view that uses the same model.

# Methods

forestStoreGetValue :: (Applicative m, MonadIO m) => ForestStore a -> TreePath -> m a Source #

Extract one node from the current model. Fails if the given `TreePath` refers to a non-existent node.

forestStoreGetTree :: MonadIO m => ForestStore a -> TreePath -> m (Tree a) Source #

Extract a subtree from the current model. Fails if the given `TreePath` refers to a non-existent node.

forestStoreGetForest :: MonadIO m => ForestStore a -> m (Forest a) Source #

Extract the forest from the current model.

forestStoreLookup :: MonadIO m => ForestStore a -> TreePath -> m (Maybe (Tree a)) Source #

Extract a subtree from the current model. Like `forestStoreGetTree` but returns `Nothing` if the path refers to a non-existant node.

forestStoreSetValue :: MonadIO m => ForestStore a -> TreePath -> a -> m () Source #

Set a node in the store.

forestStoreInsert Source #

Arguments

:: MonadIO m |
=> ForestStore a | the store
-> TreePath | `path` - the position of the parent
-> Int | `pos` - the index of the new tree
-> a | the value to be inserted
-> m () |

Insert a single node into the store.

- This function inserts a single node without children into the tree. Its arguments are similar to those of `forestStoreInsert`.

forestStoreInsertTree Source #

Arguments

:: MonadIO m |
=> ForestStore a | the store
-> TreePath | `path` - the position of the parent
-> Int | `pos` - the index of the new tree
-> Tree a | the value to be inserted
-> m () |

Insert a node into the store.

forestStoreInsertForest Source #

Arguments

:: MonadIO m |
=> ForestStore a | the store
-> TreePath | `path` - the position of the parent
-> Int | `pos` - the index of the new tree
-> Forest a | the list of trees to be inserted
-> m () |

Insert nodes into the store.

- The given list of nodes is inserted into given parent at `pos`. If the parent existed, the function returns `Just path` where `path` is the position of the newly inserted elements. If `pos` is negative or greater or equal to the number of children of the node at `path`, the new nodes are appended to the list.

forestStoreRemove :: MonadIO m => ForestStore a -> TreePath -> m Bool Source #

Remove a node from the store.

- The node denoted by the path is removed, along with all its children. The function returns `True` if the given node was found.

forestStoreClear :: MonadIO m => ForestStore a -> m () Source #

forestStoreChange :: MonadIO m => ForestStore a -> TreePath -> (a -> a) -> m Bool Source #

Change a node in the store.

- Returns `True` if the node was found. For a monadic version, see `forestStoreChangeM`.

forestStoreChangeM :: MonadIO m => ForestStore a -> TreePath -> (a -> m a) -> m Bool Source #

Change a node in the store.

- Returns `True` if the node was found. For a purely functional version, see `forestStoreChange`.