Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

VDKTreeViewModel Class Reference

Provides a wrapper for GtkTreeModel basically it stores data to be viewed with a VDKTreeView. More...

#include <vdktreeview.h>

Inheritance diagram for VDKTreeViewModel:

VDKNotCopyAble List of all members.

Public Methods


Detailed Description

Provides a wrapper for GtkTreeModel basically it stores data to be viewed with a VDKTreeView.


Constructor & Destructor Documentation

VDKTreeViewModel::VDKTreeViewModel GType *    types,
int    ncol
 

constructor

Parameters:
types  a GType array
ncol  the number of columns into the model

VDKTreeViewModel::~VDKTreeViewModel  
 

destructor


Member Function Documentation

GtkTreeIter * VDKTreeViewModel::AppendBlank GtkTreeIter *    parent = NULL
 

Appends a new blank tree row

Parameters:
parent  if not NULL the row will appended as a child otherwise it will be appended as a sibling. TIP:
  • appending all rows as sibling will degenerate the tree into a list
  • always make a iterator copy using returned address that points to an internally handled iterator, there is no guarantee that will remain valid.
          GtkTreeIter iter = *model->AppendBlank();
          model->SetData(&iter,...);
    

void VDKTreeViewModel::Clear  
 

Clears the tree store

bool VDKTreeViewModel::Find GtkTreeIter *    iter,
int    column,
char *    value
 

Executes a linear search (deep first on childs), returns true if <value> found

Parameters:
iter  a GtkTreeIter address to be filled with iter data if <value> 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:
  • G_TYPE_CHAR
  • G_TYPE_STRING
  • G_TYPE_BOOLEAN
  • G_TYPE_INT
  • G_TYPE_UINT
  • G_TYPE_LONG
  • G_TYPE_ULONG
  • G_TYPE_FLOAT
  • G_TYPE_DOUBLE

char * VDKTreeViewModel::GetCell GtkTreeIter *    node,
int    column
 

Get data from a cell, data type will be converted into their string representation accordlying with GType.

Parameters:
node  iterator to be retrieved
column  cell column
Supported GType's:
  • G_TYPE_CHAR
  • G_TYPE_STRING
  • G_TYPE_BOOLEAN
  • G_TYPE_INT
  • G_TYPE_UINT
  • G_TYPE_LONG
  • G_TYPE_ULONG
  • G_TYPE_FLOAT
  • G_TYPE_DOUBLE
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;
           }
         }
      return true;
   }

void VDKTreeViewModel::GetTuple GtkTreeIter *    node,
VDKTreeViewModelTuple   tuple
 

Gets and fill a tuple with row data converted into their string representation

Parameters:
node  iterator to be retrieved
tuple  a tuple reference (tuple can be empty since it will be resized and filled by the method

GtkTreeStore* VDKTreeViewModel::GtkModel   [inline]
 

Return underlying GtkTreeStore object

bool VDKTreeViewModel::HasChild GtkTreeIter *    iter [inline]
 

Returns true if iter has a child

Parameters:
iter 

GtkTreeIter * VDKTreeViewModel::InsertTuple VDKTreeViewModelTuple   tuple,
GtkTreeIter *    parent = NULL,
bool    recurse = false
 

Insert a tuple into model, tuple will be inserted in order.

Parameters:
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
Returns newly inserted iter

GtkTreeIter * VDKTreeViewModel::Next  
 

Move iterator forward at present level

GtkTreeIter * VDKTreeViewModel::PrependBlank GtkTreeIter *    parent = NULL
 

Prepends a new blank tree row

Parameters:
parent  if not NULL the row will prepended as a child otherwise it will be prepended as a sibling. TIP:
  • prepending all rows as sibling will degenerate the tree into a list
  • always make a iterator copy using returned address that points to an internally handled iterator, there is no guarantee that will remain valid.
          GtkTreeIter iter = *model->AppendBlank();
          model->SetData(&iter,...);
    

void VDKTreeViewModel::Remove GtkTreeIter *    i
 

Removes the row at iter

Parameters:
i  the iter to be removed

GtkTreeIter * VDKTreeViewModel::Root  
 

Move iterator to root node

  • always make a iterator copy using returned address that points to an internally handled iterator, there is no guarantee that will remain valid.
          GtkTreeIter iter = *model->AppendBlank();
          model->SetData(&iter,...);
    

void VDKTreeViewModel::SetCell GtkTreeIter *    node,
int    column,
const char *    value
 

Sets data into a cell

Parameters:
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:
  • G_TYPE_CHAR
  • G_TYPE_STRING
  • G_TYPE_BOOLEAN
  • G_TYPE_INT
  • G_TYPE_UINT
  • G_TYPE_LONG
  • G_TYPE_ULONG
  • G_TYPE_FLOAT
  • G_TYPE_DOUBLE

void VDKTreeViewModel::SetData GtkTreeIter *    node,
...   
 

Sets data into a row

Parameters:
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);


The documentation for this class was generated from the following files:
Generated on Sat May 4 22:00:29 2002 for vdk 2.0.1 by doxygen1.2.15