#include <vdktreeview.h>
Inheritance diagram for VDKTreeViewModel:

| VDKTreeViewModel::VDKTreeViewModel | ( | GType * | types, | |
| int | ncol | |||
| ) |
constructor
| types | a GType array | |
| ncol | the number of columns into the model |
| VDKTreeViewModel::~VDKTreeViewModel | ( | ) |
destructor
| GtkTreeStore* VDKTreeViewModel::GtkModel | ( | ) | [inline] |
Return underlying GtkTreeStore object
| 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::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:
|
GtkTreeIter iter;
model->PrependBlank();
model->SetData(&iter,...);
| 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::Clear | ( | ) |
Clears the tree store
| void VDKTreeViewModel::Remove | ( | GtkTreeIter * | i | ) |
Removes the row at iter
| i | the iter to be removed |
| 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. |
GtkTreeIter iter;
model->AppendBlank();
model->SetData(&iter, 0, "This is row 1", 1, FALSE, 2, NULL, -1);
| 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 |
GtkTreeIter *iter = model->PrependBlank();
model->SetCell(iter,0, "test");
model->SetCell(iter,1, "true");
Supported GType's:
| 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 |
Tip: Returned buffer address should be freed by user if not NULL.
//signal response method bool TvForm::OnTreeViewSelectRow(VDKObject* sender) { // gets selections treeview->GetSelections(); // disregard multiple selections if(treeview->Selections().size() == 1) { VDKTreeViewModel* model = treeview->Model; // gets iter position from selections list GtkTreeIter iter = treeview->Selections()[0]; char* firstname = model->GetCell(&iter,0); // extract from iter position at column 0 char* lastname = model->GetCell(&iter,1); if(firstname && lastname) // GetCell() returns NULL on failure { printf("\n[%s %s]",firstname,lastname); fflush(stdout); delete[] firstname; delete[] lastname; } } treeview->Selections().flush(); return true; }
| 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 |
| bool VDKTreeViewModel::HasChild | ( | ) |
Move iterator to root node
| iter | a not initialized iter address that will be filled with root node pointer |
GtkTreeIter iter;
if(model->Root(&iter))
{
char* cell = model->GetCell(&iter,0);
if(cell)
{
// ..
delete[] cell;
}
}
*/
bool Root(GtkTreeIter* iter);
bool Next(GtkTreeIter* iter);
bool HasChild(GtkTreeIter* iter)
{ return gtk_tree_model_iter_has_child (GTK_TREE_MODEL(model), iter); }
bool Child(GtkTreeIter* iter,GtkTreeIter* parent);
bool Find(GtkTreeIter* iter,int column, char* value);
};
class VDKTreeViewModelIterator
{
VDKTreeViewModel* model;
GtkTreeIter iter, *internal_iter;
public:
VDKTreeViewModelIterator(): model(NULL),internal_iter(NULL) {}
VDKTreeViewModelIterator(VDKTreeViewModel* model,GtkTreeIter* parent = NULL);
GtkTreeIter* current() { return internal_iter; }
operator int() { return internal_iter != NULL; }
| void VDKTreeViewModel::operator++ | ( | ) |
Incremental operator (postfix), visit next sibling node
| void VDKTreeViewModel::operator++ | ( | int | ) |
Incremental operator (infix), visit next sibling node
1.5.1