|
vdk 2.4.0
|
Provides a wrapper for GtkTreeModel basically it stores data to be viewed with a VDKTreeView. More...
#include <vdktreeview.h>


Public Member Functions | |
| GtkTreeStore * | GtkModel () |
| VDKTreeViewModel (GType *types, int ncol) | |
| ~VDKTreeViewModel () | |
| void | AppendBlank (GtkTreeIter *iter, GtkTreeIter *parent=NULL) |
| void | PrependBlank (GtkTreeIter *iter, GtkTreeIter *parent=NULL) |
| void | InsertTuple (GtkTreeIter *iter, VDKTreeViewModelTuple &tuple, GtkTreeIter *parent=NULL, bool recurse=false) |
| void | Clear () |
| void | Remove (GtkTreeIter *i) |
| void | SetData (GtkTreeIter *node,...) |
| void | SetCell (GtkTreeIter *node, int column, const char *value) |
| char * | GetCell (GtkTreeIter *node, int column) |
| void | GetTuple (GtkTreeIter *node, VDKTreeViewModelTuple &tuple) |
| bool | HasChild () |
| void | operator++ () |
| void | operator++ (int) |
Provides a wrapper for GtkTreeModel basically it stores data to be viewed with a VDKTreeView.
| VDKTreeViewModel::VDKTreeViewModel | ( | GType * | types, |
| int | ncol | ||
| ) |
constructor
| types | a GType array |
| ncol | the number of columns into the model |
| VDKTreeViewModel::~VDKTreeViewModel | ( | ) |
destructor
| void VDKTreeViewModel::AppendBlank | ( | GtkTreeIter * | iter, |
| GtkTreeIter * | parent = NULL |
||
| ) |
Appends a new blank tree row
| iter | a not initialized iter address that will be filled with newly constructed tree row |
| parent | if not NULL the row will appended as a child otherwise it will be appended as a sibling. TIP:
|
| void VDKTreeViewModel::Clear | ( | ) |
Clears the tree store
| char * VDKTreeViewModel::GetCell | ( | GtkTreeIter * | node, |
| int | column | ||
| ) |
Get data from a cell, data type will be converted into their string representation accordlying with GType.
| node | iterator to be retrieved |
| column | cell column |
Supported GType's:
Tip: Returned buffer address should be freed by user if not NULL.
| void VDKTreeViewModel::GetTuple | ( | GtkTreeIter * | node, |
| VDKTreeViewModelTuple & | tuple | ||
| ) |
Gets and fill a tuple with row data converted into their string representation
| node | iterator to be retrieved |
| tuple | a tuple reference (tuple can be empty since it will be resized and filled by the method |
|
inline |
Return underlying GtkTreeStore object
| bool VDKTreeViewModel::HasChild | ( | ) |
Move iterator to root node
\param iter a not initialized iter address that will be filled with root node pointer
\code
GtkTreeIter iter;
if(model->Root(&iter))
{
char* cell = model->GetCell(&iter,0);
if(cell)
{
// ..
delete[] cell;
}
}
/
bool Root(GtkTreeIter* iter); /*! Move iterator forward at present level
| iter | a not initialized iter address that will be filled with next node pointer */ bool Next(GtkTreeIter* iter); /*! Returns true if iter has a child |
| iter | */ bool HasChild(GtkTreeIter* iter) { return gtk_tree_model_iter_has_child (GTK_TREE_MODEL(model), iter); } /*! Return the child of a parent node |
| iter | a not initialized iter address that will be filled with child node pointer |
| parent | a valid iter address of the parent node |
Returns true if <parent> has a child, <iter> left undefined otherwise */ bool Child(GtkTreeIter* iter,GtkTreeIter* parent); /*! Executes a linear search (deep first on childs), returns true if
found
| iter | a GtkTreeIter address to be filled with iter data if |
found
| column | to be scanned to execute search |
| value | a string representation of a GType value that will be converted into a GType accordlying with the model Supported GType's:
|
Returns true if found */ bool Find(GtkTreeIter* iter,int column, char* value);
};
/*! Provides an iterator on VDKTreeViewModel */ class VDKTreeViewModelIterator { VDKTreeViewModel* model; GtkTreeIter iter, internal_iter; public: VDKTreeViewModelIterator(): model(NULL),internal_iter(NULL) {} /! Constructor
| model | |
| parent | if NULL makes an iterator on top level nodes, otherwise makes an iterator on parent childs */ VDKTreeViewModelIterator(VDKTreeViewModel* model,GtkTreeIter* parent = NULL); /*! return node presently visited */ GtkTreeIter* current() { return internal_iter; } /*! Returns true if presently visited node is valid */ operator int() { return internal_iter != NULL; } /*! Returns true if presently visited node has a child. TIP: Since iterator incremental operator skips on next sibling node, you can use this to visit all tree nodes on depth-first strategy using recursion. See example below taken from /testvdk/treeviewcompo.cc: void
TreeViewComponent::recurse(GtkTreeIter* iter)
{
VDKTreeViewModel* model = tree->Model;
VDKTreeViewModelIterator ti(model,iter);
for(;ti;ti++)
{
PrintRow(ti.current()); // uses presently pointed node
if(ti.HasChild())
recurse (ti.current());
}
}
bool
TreeViewComponent::OnTrasverseClicked (VDKObject* sender)
{
recurse(NULL);
return true;
}
|
| void VDKTreeViewModel::InsertTuple | ( | GtkTreeIter * | iter, |
| VDKTreeViewModelTuple & | tuple, | ||
| GtkTreeIter * | parent = NULL, |
||
| bool | recurse = false |
||
| ) |
Insert a tuple into model, tuple will be inserted in order.
| iter | a not initialized iter address that will be filled with newly constructed tree row |
| tuple | to be inserted |
| parent | if is NULL tuple will be inserted in order into top level nodes list otherwise will be inserted in order into parent children list |
| recurse | if true scans children/sibling list recursively to search insertion position |
| void VDKTreeViewModel::operator++ | ( | ) |
Incremental operator (postfix), visit next sibling node
| void VDKTreeViewModel::operator++ | ( | int | ) |
Incremental operator (infix), visit next sibling node
| void VDKTreeViewModel::PrependBlank | ( | GtkTreeIter * | iter, |
| GtkTreeIter * | parent = NULL |
||
| ) |
Prepends a new blank tree row
| iter | a not initialized iter address that will be filled with newly constructed tree row |
| parent | if not NULL the row will prepended as a child otherwise it will be prepended as a sibling. TIP:
|
| void VDKTreeViewModel::Remove | ( | GtkTreeIter * | i | ) |
Removes the row at iter
| i | the iter to be removed |
| void VDKTreeViewModel::SetCell | ( | GtkTreeIter * | node, |
| int | column, | ||
| const char * | value | ||
| ) |
Sets data into a cell
| node | the iterator to be set |
| column | cell column |
| value | a string representation of GType value that will be converted into a GType accordlying with the model |
Supported GType's:
| void VDKTreeViewModel::SetData | ( | GtkTreeIter * | node, |
| ... | |||
| ) |
Sets data into a row
| node | the iterator to be set |
| a | list of pairs <column ordinal number,type value> the list must be -1 terminated. |