SHAPER  9.12.0
XGUI_DataModel Class Reference

This is a data model for Object Browser (QTreeView). More...

Inheritance diagram for XGUI_DataModel:
Inheritance graph

Signals

void beforeTreeRebuild ()
 Signal send before tree rebuild. More...
 
void treeRebuilt ()
 Signal about tree had been rebuilt. More...
 

Public Member Functions

 XGUI_DataModel (QObject *theParent)
 Constructor. More...
 
virtual ~XGUI_DataModel ()
 Destructor. More...
 
void setRoot (ModuleBase_ITreeNode *theRoot)
 
ModuleBase_ITreeNoderoot () const
 
virtual void processEvent (const std::shared_ptr< Events_Message > &theMessage)
 Event Listener method. More...
 
virtual ObjectPtr object (const QModelIndex &theIndex) const
 Returns an object by the given Model index. More...
 
virtual QModelIndex objectIndex (const ObjectPtr theObject, int theColumn=1) const
 Returns index of the object. More...
 
virtual void clear ()
 Clear internal data. More...
 
virtual void rebuildDataTree ()
 Rebuild data tree. More...
 
virtual QVariant data (const QModelIndex &theIndex, int theRole) const
 Returns the data stored under the given role for the item referred to by the index. More...
 
virtual QVariant headerData (int theSection, Qt::Orientation theOrient, int theRole=Qt::DisplayRole) const
 Returns the data for the given role and section in the header with the specified orientation. More...
 
virtual int rowCount (const QModelIndex &theParent=QModelIndex()) const
 Returns the number of rows under the given parent. More...
 
virtual int columnCount (const QModelIndex &theParent=QModelIndex()) const
 Returns the number of columns for the children of the given parent. More...
 
virtual QModelIndex index (int theRow, int theColumn, const QModelIndex &theParent=QModelIndex()) const
 Returns the index of the item in the model specified by the given row, column and parent index. More...
 
virtual QModelIndex parent (const QModelIndex &theIndex) const
 Returns the parent of the model item with the given index. More...
 
virtual bool hasChildren (const QModelIndex &theParent=QModelIndex()) const
 Returns true if parent has any children; otherwise returns false. More...
 
virtual bool insertRows (int theRow, int theCount, const QModelIndex &theParent=QModelIndex())
 Inserts count rows into the model before the given row. More...
 
virtual bool removeRows (int theRow, int theCount, const QModelIndex &theParent=QModelIndex())
 Removes count rows starting with the given row under parent parent from the model. More...
 
virtual Qt::ItemFlags flags (const QModelIndex &theIndex) const
 Returns the item flags for the given index. More...
 
virtual bool canDropMimeData (const QMimeData *theData, Qt::DropAction theAction, int theRow, int theColumn, const QModelIndex &theParent) const override
 Returns true if a model can accept a drop of the data (used for drag and drop functionality). More...
 
virtual QMimeData * mimeData (const QModelIndexList &indexes) const override
 Converts the dragged items information into mime data format (to be encoded in dropMimeData) More...
 
virtual bool dropMimeData (const QMimeData *theData, Qt::DropAction theAction, int theRow, int theColumn, const QModelIndex &theParent) override
 Performs a drag and drop of Part feature operation when it is droped. More...
 
QModelIndex documentRootIndex (DocumentPtr theDoc, int theColumn=1) const
 Returns an index which is root of the given document. More...
 
bool hasHiddenState (const QModelIndex &theIndex)
 Returns true if the data model item has Hidden visual state. More...
 
bool hasIndex (const QModelIndex &theIndex) const
 Returns true if the given index exists in data tree. More...
 
bool hasNode (ModuleBase_ITreeNode *theNode) const
 Returns true if the given node is a parto of the data tree. More...
 
DocumentPtr document (const QModelIndex &theIndex) const
 Returns document of the given index. More...
 
QModelIndex getIndex (ModuleBase_ITreeNode *theNode, int thCol) const
 Returns index for the node and column. More...
 
virtual Qt::DropActions supportedDropActions () const override
 Allows to support drag and drop of some model items. More...
 
virtual EVENTS_EXPORT bool groupMessages ()
 Listener that needs mostly grouped messages received returns true in this method. More...
 

Protected Member Functions

void groupWhileFlush (const std::shared_ptr< Events_Message > &theMessage)
 Allows to group messages while they are flushed (for flush for groupMessages=true listeners) More...
 
EVENTS_EXPORT void flushGrouped (const Events_ID &theID)
 Sends myGroups on flush finish. More...
 

Detailed Description

This is a data model for Object Browser (QTreeView).

It uses XML file for definition of data tree. Some tips about organization of the model:

  • Non Valid Index - root index
  • An index with internal Id == -1 is a folder of root document
  • An index which contains internal pointer as ModelAPI_Object its the object
  • An index which contains internal pointer as ModelAPI_Document is a folder which belongs to this document

Constructor & Destructor Documentation

◆ XGUI_DataModel()

XGUI_DataModel::XGUI_DataModel ( QObject theParent)

Constructor.

Parameters
theParenta parent object

◆ ~XGUI_DataModel()

XGUI_DataModel::~XGUI_DataModel ( )
virtual

Destructor.

Member Function Documentation

◆ processEvent()

void XGUI_DataModel::processEvent ( const std::shared_ptr< Events_Message > &  theMessage)
virtual

Event Listener method.

Parameters
theMessagean event message

Implements Events_Listener.

◆ object()

ObjectPtr XGUI_DataModel::object ( const QModelIndex &  theIndex) const
virtual

Returns an object by the given Model index.

Returns 0 if the given index is not index of an object

◆ objectIndex()

QModelIndex XGUI_DataModel::objectIndex ( const ObjectPtr  theObject,
int  theColumn = 1 
) const
virtual

Returns index of the object.

Parameters
theObjectobject to find

◆ clear()

void XGUI_DataModel::clear ( )
virtual

Clear internal data.

◆ rebuildDataTree()

void XGUI_DataModel::rebuildDataTree ( )
virtual

Rebuild data tree.

◆ data()

QVariant XGUI_DataModel::data ( const QModelIndex &  theIndex,
int  theRole 
) const
virtual

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

Parameters
theIndexa model index
theRolea data role (see Qt::ItemDataRole)

◆ headerData()

QVariant XGUI_DataModel::headerData ( int  theSection,
Qt::Orientation  theOrient,
int  theRole = Qt::DisplayRole 
) const
virtual

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

Parameters
theSectiona section
theOrientan orientation
theRolea data role (see Qt::ItemDataRole)

◆ rowCount()

int XGUI_DataModel::rowCount ( const QModelIndex &  theParent = QModelIndex()) const
virtual

Returns the number of rows under the given parent.

When the parent is valid it means that rowCount is returning the number of children of parent.

Parameters
theParenta parent model index

◆ columnCount()

int XGUI_DataModel::columnCount ( const QModelIndex &  theParent = QModelIndex()) const
virtual

Returns the number of columns for the children of the given parent.

It has a one column

Parameters
theParenta parent model index

◆ index()

QModelIndex XGUI_DataModel::index ( int  theRow,
int  theColumn,
const QModelIndex &  theParent = QModelIndex() 
) const
virtual

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

Parameters
theRowa row
theColumna column
theParenta parent model index

◆ parent()

QModelIndex XGUI_DataModel::parent ( const QModelIndex &  theIndex) const
virtual

Returns the parent of the model item with the given index.

If the item has no parent, an invalid QModelIndex is returned.

Parameters
theIndexa model index

◆ hasChildren()

bool XGUI_DataModel::hasChildren ( const QModelIndex &  theParent = QModelIndex()) const
virtual

Returns true if parent has any children; otherwise returns false.

Parameters
theParenta parent model index

◆ insertRows()

bool XGUI_DataModel::insertRows ( int  theRow,
int  theCount,
const QModelIndex &  theParent = QModelIndex() 
)
virtual

Inserts count rows into the model before the given row.

Items in the new row will be children of the item represented by the parent model index.

Parameters
theRowa start row
theCounta nember of rows to insert
theParenta parent model index

◆ removeRows()

bool XGUI_DataModel::removeRows ( int  theRow,
int  theCount,
const QModelIndex &  theParent = QModelIndex() 
)
virtual

Removes count rows starting with the given row under parent parent from the model.

Parameters
theRowa start row
theCounta nember of rows to remove
theParenta parent model index

◆ flags()

Qt::ItemFlags XGUI_DataModel::flags ( const QModelIndex &  theIndex) const
virtual

Returns the item flags for the given index.

Parameters
theIndexa model index

◆ canDropMimeData()

bool XGUI_DataModel::canDropMimeData ( const QMimeData *  theData,
Qt::DropAction  theAction,
int  theRow,
int  theColumn,
const QModelIndex &  theParent 
) const
overridevirtual

Returns true if a model can accept a drop of the data (used for drag and drop functionality).

◆ mimeData()

QMimeData * XGUI_DataModel::mimeData ( const QModelIndexList &  indexes) const
overridevirtual

Converts the dragged items information into mime data format (to be encoded in dropMimeData)

◆ dropMimeData()

bool XGUI_DataModel::dropMimeData ( const QMimeData *  theData,
Qt::DropAction  theAction,
int  theRow,
int  theColumn,
const QModelIndex &  theParent 
)
overridevirtual

Performs a drag and drop of Part feature operation when it is droped.

◆ documentRootIndex()

QModelIndex XGUI_DataModel::documentRootIndex ( DocumentPtr  theDoc,
int  theColumn = 1 
) const

Returns an index which is root of the given document.

Parameters
theDoca document

◆ hasHiddenState()

bool XGUI_DataModel::hasHiddenState ( const QModelIndex &  theIndex)

Returns true if the data model item has Hidden visual state.

Parameters
theIndexa tree model item
Returns
boolean value

◆ hasIndex()

bool XGUI_DataModel::hasIndex ( const QModelIndex &  theIndex) const

Returns true if the given index exists in data tree.

Parameters
theIndexan index to check

◆ hasNode()

bool XGUI_DataModel::hasNode ( ModuleBase_ITreeNode theNode) const

Returns true if the given node is a parto of the data tree.

Parameters
theNodea node to check

◆ document()

DocumentPtr XGUI_DataModel::document ( const QModelIndex &  theIndex) const

Returns document of the given index.

Parameters
theIndexan index to check

◆ getIndex()

QModelIndex XGUI_DataModel::getIndex ( ModuleBase_ITreeNode theNode,
int  thCol 
) const

Returns index for the node and column.

Parameters
theNodea node
thCola column

◆ supportedDropActions()

virtual Qt::DropActions XGUI_DataModel::supportedDropActions ( ) const
inlineoverridevirtual

Allows to support drag and drop of some model items.

◆ beforeTreeRebuild

void XGUI_DataModel::beforeTreeRebuild ( )
signal

Signal send before tree rebuild.

◆ treeRebuilt

void XGUI_DataModel::treeRebuilt ( )
signal

Signal about tree had been rebuilt.

◆ groupMessages()

virtual EVENTS_EXPORT bool Events_Listener::groupMessages ( )
inlinevirtualinherited

Listener that needs mostly grouped messages received returns true in this method.

In this case during the message is flushed, all the new messages are grouped, not sended immideately and then sent in the end of flush.

Reimplemented in SketchSolver_Manager, and SketchPlugin_OverConstraintsResolver.

◆ groupWhileFlush()

void Events_Listener::groupWhileFlush ( const std::shared_ptr< Events_Message > &  theMessage)
protectedinherited

Allows to group messages while they are flushed (for flush for groupMessages=true listeners)

◆ flushGrouped()

void Events_Listener::flushGrouped ( const Events_ID theID)
protectedinherited

Sends myGroups on flush finish.