Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
Standard model to store hierarchical data.
- data TreeStore a
- treeStoreNew :: Forest a -> IO (TreeStore a)
- treeStoreNewDND :: Forest a -> Maybe (DragSourceIface TreeStore a) -> Maybe (DragDestIface TreeStore a) -> IO (TreeStore a)
- treeStoreDefaultDragSourceIface :: DragSourceIface TreeStore row
- treeStoreDefaultDragDestIface :: DragDestIface TreeStore row
- treeStoreGetValue :: TreeStore a -> TreePath -> IO a
- treeStoreGetTree :: TreeStore a -> TreePath -> IO (Tree a)
- treeStoreLookup :: TreeStore a -> TreePath -> IO (Maybe (Tree a))
- treeStoreSetValue :: TreeStore a -> TreePath -> a -> IO ()
- treeStoreInsert :: TreeStore a -> TreePath -> Int -> a -> IO ()
- treeStoreInsertTree :: TreeStore a -> TreePath -> Int -> Tree a -> IO ()
- treeStoreInsertForest :: TreeStore a -> TreePath -> Int -> Forest a -> IO ()
- treeStoreRemove :: TreeStore a -> TreePath -> IO Bool
- treeStoreClear :: TreeStore a -> IO ()
- treeStoreChange :: TreeStore a -> TreePath -> (a -> a) -> IO Bool
- treeStoreChangeM :: TreeStore a -> TreePath -> (a -> IO a) -> IO Bool
Types
A store for hierarchical data.
Constructors
treeStoreNew :: Forest a -> IO (TreeStore 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 TreeStore maintains the initially given Forest and aligns the
TreePath
bits to fit in 96-bit lengthTreeIter
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.
:: Forest a | the inital tree stored in this model |
-> Maybe (DragSourceIface TreeStore a) | an optional interface for drags |
-> Maybe (DragDestIface TreeStore a) | an optional interface to handle drops |
-> IO (TreeStore a) |
Create a new list store.
- In addition to
treeStoreNew
, this function takes an two interfaces to implement user-defined drag-and-drop functionality.
Implementation of Interfaces
treeStoreDefaultDragSourceIface :: DragSourceIface TreeStore row Source
Default drag functions for
TreeStore
. 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.
treeStoreDefaultDragDestIface :: DragDestIface TreeStore row Source
Default drop functions for TreeStore
. 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
treeStoreGetValue :: TreeStore a -> TreePath -> IO a Source
Extract one node from the current model. Fails if the given
TreePath
refers to a non-existent node.
treeStoreGetTree :: TreeStore a -> TreePath -> IO (Tree a) Source
Extract a subtree from the current model. Fails if the given
TreePath
refers to a non-existent node.
treeStoreLookup :: TreeStore a -> TreePath -> IO (Maybe (Tree a)) Source
Extract a subtree from the current model. Like treeStoreGetTree
but returns Nothing
if the path refers to a non-existant node.
treeStoreSetValue :: TreeStore a -> TreePath -> a -> IO () Source
Set a node in the store.
:: TreeStore a | the store |
-> TreePath |
|
-> Int |
|
-> a | the value to be inserted |
-> IO () |
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
treeStoreInsert
.
:: TreeStore a | the store |
-> TreePath |
|
-> Int |
|
-> Tree a | the value to be inserted |
-> IO () |
Insert a node into the store.
:: TreeStore a | the store |
-> TreePath |
|
-> Int |
|
-> Forest a | the list of trees to be inserted |
-> IO () |
Insert nodes into the store.
- The given list of nodes is inserted into given parent at
pos
. If the parent existed, the function returnsJust path
wherepath
is the position of the newly inserted elements. Ifpos
is negative or greater or equal to the number of children of the node atpath
, the new nodes are appended to the list.
treeStoreRemove :: TreeStore a -> TreePath -> IO 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.
treeStoreClear :: TreeStore a -> IO () Source
treeStoreChange :: TreeStore a -> TreePath -> (a -> a) -> IO Bool Source
Change a node in the store.
- Returns
True
if the node was found. For a monadic version, seetreeStoreChangeM
.
treeStoreChangeM :: TreeStore a -> TreePath -> (a -> IO a) -> IO Bool Source
Change a node in the store.
- Returns
True
if the node was found. For a purely functional version, seetreeStoreChange
.