Tulip Plugins
Public Member Functions | Protected Member Functions
GraphTableModel Class Reference

The GraphTableModel class allows to visualize and edit a Tulip Graph object with Qt's model/view framework. You can only use this model only with TulipItemDelegate class instead you cannot see double values and histogram. More...

#include <GraphTableModel.h>

List of all members.

Public Member Functions

 GraphTableModel (tlp::Graph *graph, tlp::ElementType elementType=tlp::NODE, QObject *parent=0)
tlp::Graph * graph () const
void setGraph (tlp::Graph *newGraph)
 Change the displayed graph. Display the same type of elements than before (by default display nodes).
tlp::ElementType elementType () const
void setElementType (tlp::ElementType type)
 Change the kind of displayed elements.
Qt::Orientation orientation () const
void setOrientation (Qt::Orientation orientation)
GraphTableModelIndex element (const QModelIndex &modelIndex) const
 Convinience function. See the element(int row, int column,const QModelIndex& parent = QModelIndex()) function for more informations.
GraphTableModelIndex element (int row, int column, const QModelIndex &parent=QModelIndex()) const
 Return a structure containing the element and the property for a given position in the model.
unsigned int idForIndex (const QModelIndex &index) const
 Convinience function to get the id for an index call the idForIndex function with the right index in function of elements orientation in the model.
virtual unsigned int idForIndex (int index, const QModelIndex &parent=QModelIndex()) const
 Get the id at the given index. If the index is not valid return UINT_MAX.
virtual QList< int > indexesForIds (const std::set< unsigned int > &ids) const
 Retrieve the indexes of the given ids. If an id is not in the table it will be ignored.
tlp::PropertyInterface * propertyForIndex (const QModelIndex &index) const
 Convinience function to get the property for an index call the propertyForIndex function with the right index in function of properties orientation in the model.
virtual tlp::PropertyInterface * propertyForIndex (int index, const QModelIndex &parent=QModelIndex()) const
 Get the id property the given index. If the index is not valid or if the property is marked for deletion return NULL.
virtual QList< int > indexesForProperties (const std::set< tlp::PropertyInterface * > &properties) const
 Retrieve the indexes of the given properties. If a property is not in the table it will be ignored.
std::pair< QModelIndex,
QModelIndex > 
computeElementsArea (const std::set< unsigned int > &elementsIds) const
 Compute the area for the list of elements. Return top left and bottom right bounds.
std::pair< QModelIndex,
QModelIndex > 
computePropertiesArea (const std::set< tlp::PropertyInterface * > &properties) const
 Compute the area for the list of elements. Return top left and bottom right bounds.
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 Reimplementation of QAbstractTableModel::columnCount(). Return the size of the property table if the orientation of the model is equal to Qt::Vertical else return the size of the elements table.
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 Reimplementation of QAbstractTableModel::rowCount(). Return the size of the elements table if the orientation of the model is equal to Qt::Vertical else return the size of the properties table.
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
bool setAllElementsData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Convinience function.
virtual bool setAllElementsData (unsigned int propertyIndex, const QVariant &value, int role=Qt::EditRole)
 Set the given value to all the elements in the model. Call the setAllNodeValue or setAllEdgeValue in function of the kind of elements managed by the model.
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Qt::ItemFlags flags (const QModelIndex &index) const
void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
bool removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
bool removeColumns (const QModelIndexList &toRemove)
bool removeRows (const QModelIndexList &toRemove)
void addNode (tlp::Graph *, const tlp::node)
void addEdge (tlp::Graph *, const tlp::edge)
void delNode (tlp::Graph *, const tlp::node)
void delEdge (tlp::Graph *, const tlp::edge)
void addLocalProperty (tlp::Graph *, const std::string &)
void beforeDelLocalProperty (tlp::Graph *, const std::string &)
void addInheritedProperty (tlp::Graph *, const std::string &)
void beforeDelInheritedProperty (tlp::Graph *, const std::string &)
void afterSetNodeValue (tlp::PropertyInterface *, const tlp::node)
void afterSetEdgeValue (tlp::PropertyInterface *, const tlp::edge)
void afterSetAllNodeValue (tlp::PropertyInterface *)
void afterSetAllEdgeValue (tlp::PropertyInterface *)
void update ()
 Apply all the modifications occured in the graph on the model.

Protected Member Functions

virtual void updateElementsTable ()
 Fill the idTable.
virtual void updatePropertyTable ()
 Fill the propertyTable. For each property in the graph call the useProperty function to know if we add the property in the table.
virtual bool useProperty (tlp::PropertyInterface *property) const
 Return if the property must be integrated in the property table. This function is called before each insertion in the property table.
virtual void sortElements (tlp::PropertyInterface *property, Qt::SortOrder order)
 Sort elements according to a given property values.
virtual bool removeElements (int first, int last, const QModelIndex &parent=QModelIndex())
virtual bool removeProperties (int first, int last, const QModelIndex &parent=QModelIndex())

Detailed Description

The GraphTableModel class allows to visualize and edit a Tulip Graph object with Qt's model/view framework. You can only use this model only with TulipItemDelegate class instead you cannot see double values and histogram.


Constructor & Destructor Documentation

GraphTableModel::GraphTableModel ( tlp::Graph *  graph,
tlp::ElementType  elementType = tlp::NODE,
QObject *  parent = 0 
)

Member Function Documentation

void GraphTableModel::addEdge ( tlp::Graph *  ,
const tlp::edge   
)
void GraphTableModel::addInheritedProperty ( tlp::Graph *  ,
const std::string &   
)
void GraphTableModel::addLocalProperty ( tlp::Graph *  ,
const std::string &   
)
void GraphTableModel::addNode ( tlp::Graph *  ,
const tlp::node   
)
void GraphTableModel::afterSetAllEdgeValue ( tlp::PropertyInterface *  )
void GraphTableModel::afterSetAllNodeValue ( tlp::PropertyInterface *  )
void GraphTableModel::afterSetEdgeValue ( tlp::PropertyInterface *  ,
const tlp::edge   
)
void GraphTableModel::afterSetNodeValue ( tlp::PropertyInterface *  ,
const tlp::node   
)
void GraphTableModel::beforeDelInheritedProperty ( tlp::Graph *  ,
const std::string &   
)
void GraphTableModel::beforeDelLocalProperty ( tlp::Graph *  graph,
const std::string &  name 
)
int GraphTableModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Reimplementation of QAbstractTableModel::columnCount(). Return the size of the property table if the orientation of the model is equal to Qt::Vertical else return the size of the elements table.

pair< QModelIndex, QModelIndex > GraphTableModel::computeElementsArea ( const std::set< unsigned int > &  elementsIds) const

Compute the area for the list of elements. Return top left and bottom right bounds.

pair< QModelIndex, QModelIndex > GraphTableModel::computePropertiesArea ( const std::set< tlp::PropertyInterface * > &  properties) const

Compute the area for the list of elements. Return top left and bottom right bounds.

QVariant GraphTableModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const [virtual]
void GraphTableModel::delEdge ( tlp::Graph *  ,
const tlp::edge   
)
void GraphTableModel::delNode ( tlp::Graph *  ,
const tlp::node   
)
GraphTableModelIndex GraphTableModel::element ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const [inline]

Return a structure containing the element and the property for a given position in the model.

GraphTableModelIndex GraphTableModel::element ( const QModelIndex &  modelIndex) const [inline]

Convinience function. See the element(int row, int column,const QModelIndex& parent = QModelIndex()) function for more informations.

tlp::ElementType GraphTableModel::elementType ( ) const [inline]
Qt::ItemFlags GraphTableModel::flags ( const QModelIndex &  index) const
tlp::Graph* GraphTableModel::graph ( ) const [inline]
QVariant GraphTableModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const [virtual]
unsigned int GraphTableModel::idForIndex ( const QModelIndex &  index) const [inline]

Convinience function to get the id for an index call the idForIndex function with the right index in function of elements orientation in the model.

unsigned int GraphTableModel::idForIndex ( int  index,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

Get the id at the given index. If the index is not valid return UINT_MAX.

QList< int > GraphTableModel::indexesForIds ( const std::set< unsigned int > &  ids) const [virtual]

Retrieve the indexes of the given ids. If an id is not in the table it will be ignored.

QList< int > GraphTableModel::indexesForProperties ( const std::set< tlp::PropertyInterface * > &  properties) const [virtual]

Retrieve the indexes of the given properties. If a property is not in the table it will be ignored.

Qt::Orientation GraphTableModel::orientation ( ) const [inline]
tlp::PropertyInterface* GraphTableModel::propertyForIndex ( const QModelIndex &  index) const [inline]

Convinience function to get the property for an index call the propertyForIndex function with the right index in function of properties orientation in the model.

PropertyInterface * GraphTableModel::propertyForIndex ( int  index,
const QModelIndex &  parent = QModelIndex() 
) const [virtual]

Get the id property the given index. If the index is not valid or if the property is marked for deletion return NULL.

bool GraphTableModel::removeColumns ( int  column,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
bool GraphTableModel::removeColumns ( const QModelIndexList &  toRemove)
bool GraphTableModel::removeElements ( int  first,
int  last,
const QModelIndex &  parent = QModelIndex() 
) [protected, virtual]
bool GraphTableModel::removeProperties ( int  first,
int  last,
const QModelIndex &  parent = QModelIndex() 
) [protected, virtual]
bool GraphTableModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
bool GraphTableModel::removeRows ( const QModelIndexList &  toRemove)
int GraphTableModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const [virtual]

Reimplementation of QAbstractTableModel::rowCount(). Return the size of the elements table if the orientation of the model is equal to Qt::Vertical else return the size of the properties table.

bool GraphTableModel::setAllElementsData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [inline]

Convinience function.

bool GraphTableModel::setAllElementsData ( unsigned int  propertyIndex,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]

Set the given value to all the elements in the model. Call the setAllNodeValue or setAllEdgeValue in function of the kind of elements managed by the model.

bool GraphTableModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
) [virtual]
void GraphTableModel::setElementType ( tlp::ElementType  type)

Change the kind of displayed elements.

void GraphTableModel::setGraph ( tlp::Graph *  newGraph)

Change the displayed graph. Display the same type of elements than before (by default display nodes).

void GraphTableModel::setOrientation ( Qt::Orientation  orientation)
void GraphTableModel::sort ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)
void GraphTableModel::sortElements ( tlp::PropertyInterface *  property,
Qt::SortOrder  order 
) [protected, virtual]

Sort elements according to a given property values.

void GraphTableModel::update ( )

Apply all the modifications occured in the graph on the model.

void GraphTableModel::updateElementsTable ( ) [protected, virtual]

Fill the idTable.

void GraphTableModel::updatePropertyTable ( ) [protected, virtual]

Fill the propertyTable. For each property in the graph call the useProperty function to know if we add the property in the table.

bool GraphTableModel::useProperty ( tlp::PropertyInterface *  property) const [protected, virtual]

Return if the property must be integrated in the property table. This function is called before each insertion in the property table.