Public Types | Public Slots | Public Member Functions | Private Slots | Private Member Functions | Private Attributes

conan::ObjectModel Class Reference

A read-only model for displaying one or more object hierarchies. More...

#include <ObjectModel.h>

List of all members.

Public Types

enum  Columns { kObject, kAddress, kColumnCount }

Public Slots

void SlotRefresh ()
 The complete object hierarchy is refreshed. Note the modelReset signal is emitted.

Public Member Functions

 ObjectModel (QObject *inParent=0)
void AddRootObject (const QObject *inObject)
 Adds the object hierarchy of inObject to the model.
void RemoveRootObject (const QObject *inObject)
 Removes the object hierarchy of inObject from the model.
void RemoveAllRootObjects ()
 Removes all the object hierarchies from the model.
void DiscoverRootObjects ()
 Finds all top level widgets and adds them to the model. Note the modelReset signal is emitted.
template<typename Pred >
QModelIndex FindObject (Pred inPred, const QModelIndex &inStart=QModelIndex()) const
 Finds the object whose class, name or address matches the given value.
const QObject * GetObject (const QModelIndex &inIndex) const
 Returns the object wrapped by the item with the given index.
QString GetClass (const QModelIndex &inIndex) const
 Returns the class name of the object wrapped by the item with the given index.
QString GetObjectName (const QModelIndex &inIndex) const
 Returns the object name of the object wrapped by the item with the given index.
QString GetAddress (const QModelIndex &inIndex) const
 Returns the object address of the object wrapped by the item with the given index.
virtual int rowCount (const QModelIndex &inParent=QModelIndex()) const
 Returns the number of rows under the given parent.
virtual int columnCount (const QModelIndex &inParent=QModelIndex()) const
 Returns the number of columns of the model.
virtual Qt::ItemFlags flags (const QModelIndex &inIndex) const
 Returns the item flags for the given index. Only items whose objects have not been detroyed are enabled and selectable.
virtual QVariant data (const QModelIndex &inIndex, int inRole) const
 Returns the data stored under the given role for the item referred to by the index.
virtual QVariant headerData (int inSection, Qt::Orientation inOrientation, int inRole=Qt::DisplayRole) const
 Returns the data for the given role and section in the header with the specified orientation.
virtual QModelIndex index (int inRow, int inColumn, const QModelIndex &inParent=QModelIndex()) const
 Returns the index of the item in the model specified by the given row, column and parent index.
virtual QModelIndex parent (const QModelIndex &inIndex) const
 Returns the parent of the model item with the given index, or QModelIndex() if it has no parent.
virtual void sort (int inColumn, Qt::SortOrder inOrder=Qt::AscendingOrder)
 Sorts the model by the given column in the given order.

Private Slots

void SlotSort ()
 Sorts the model using the current sort settings mSortColumn and mSortOrder.

Private Member Functions

const ObjectItemGetItem (const QModelIndex &inIndex) const
 Returns the item referred to by the given index.

Private Attributes

RootItemmRoot
 The root item of the model that contains all object hierarchies.
int mSortColumn
 The primary sort column.
Qt::SortOrder mSortOrder
 The current sort order (ascending or descending).

Detailed Description

A read-only model for displaying one or more object hierarchies.

Note that this model is static. It does not update automatically when objects are created or destroyed. However, it does detect when objects are destroyed and marks the corresponding items disabled and non-selectable. The function SlotRefresh is provided to manually update all object hierarchies.


Member Enumeration Documentation

Enumerator:
kObject 
kAddress 
kColumnCount 

Constructor & Destructor Documentation

conan::ObjectModel::ObjectModel ( QObject *  inParent = 0  ) 

Member Function Documentation

void conan::ObjectModel::AddRootObject ( const QObject *  inObject  ) 

Adds the object hierarchy of inObject to the model.

int conan::ObjectModel::columnCount ( const QModelIndex &  inParent = QModelIndex ()  )  const [virtual]

Returns the number of columns of the model.

QVariant conan::ObjectModel::data ( const QModelIndex &  inIndex,
int  inRole 
) const [virtual]

Returns the data stored under the given role for the item referred to by the index.

void conan::ObjectModel::DiscoverRootObjects (  ) 

Finds all top level widgets and adds them to the model. Note the modelReset signal is emitted.

template<typename Pred >
QModelIndex conan::ObjectModel::FindObject ( Pred  inPred,
const QModelIndex &  inStart = QModelIndex () 
) const

Finds the object whose class, name or address matches the given value.

Parameters:
[in] inPred A unary predicate function object that defines the matching criterion
[in] inStart The item to start searching from (note that the search wraps)
Returns:
The item that wraps the found object
Qt::ItemFlags conan::ObjectModel::flags ( const QModelIndex &  inIndex  )  const [virtual]

Returns the item flags for the given index. Only items whose objects have not been detroyed are enabled and selectable.

QString conan::ObjectModel::GetAddress ( const QModelIndex &  inIndex  )  const

Returns the object address of the object wrapped by the item with the given index.

QString conan::ObjectModel::GetClass ( const QModelIndex &  inIndex  )  const

Returns the class name of the object wrapped by the item with the given index.

const ObjectItem * conan::ObjectModel::GetItem ( const QModelIndex &  inIndex  )  const [private]

Returns the item referred to by the given index.

const QObject * conan::ObjectModel::GetObject ( const QModelIndex &  inIndex  )  const

Returns the object wrapped by the item with the given index.

QString conan::ObjectModel::GetObjectName ( const QModelIndex &  inIndex  )  const

Returns the object name of the object wrapped by the item with the given index.

QVariant conan::ObjectModel::headerData ( int  inSection,
Qt::Orientation  inOrientation,
int  inRole = Qt::DisplayRole 
) const [virtual]

Returns the data for the given role and section in the header with the specified orientation.

QModelIndex conan::ObjectModel::index ( int  inRow,
int  inColumn,
const QModelIndex &  inParent = QModelIndex () 
) const [virtual]

Returns the index of the item in the model specified by the given row, column and parent index.

The internal pointer of an index is set to the corresponding parent ObjectItem.

QModelIndex conan::ObjectModel::parent ( const QModelIndex &  inIndex  )  const [virtual]

Returns the parent of the model item with the given index, or QModelIndex() if it has no parent.

void conan::ObjectModel::RemoveAllRootObjects (  ) 

Removes all the object hierarchies from the model.

void conan::ObjectModel::RemoveRootObject ( const QObject *  inObject  ) 

Removes the object hierarchy of inObject from the model.

int conan::ObjectModel::rowCount ( const QModelIndex &  inParent = QModelIndex ()  )  const [virtual]

Returns the number of rows under the given parent.

void conan::ObjectModel::SlotRefresh (  )  [slot]

The complete object hierarchy is refreshed. Note the modelReset signal is emitted.

void conan::ObjectModel::SlotSort (  )  [private, slot]

Sorts the model using the current sort settings mSortColumn and mSortOrder.

void conan::ObjectModel::sort ( int  inColumn,
Qt::SortOrder  inOrder = Qt::AscendingOrder 
) [virtual]

Sorts the model by the given column in the given order.


Member Data Documentation

The root item of the model that contains all object hierarchies.

The primary sort column.

Qt::SortOrder conan::ObjectModel::mSortOrder [private]

The current sort order (ascending or descending).


The documentation for this class was generated from the following files: