Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SUIT_DataObject Class Reference

Data object representing the data instance in the tree-like hierarchy. More...

#include <SUIT_DataObject.h>

Inheritance diagram for SUIT_DataObject:
Inheritance graph

Classes

class  Signal
 Watcher class, responsible for the emitting signals on behalf of the data objects. More...
 

Public Types

enum  ColorRole {
  Text, Base, Foreground, Background,
  Highlight, HighlightedText
}
 Color role. More...
 
enum  { NameId, VisibilityId }
 Column id. More...
 

Public Member Functions

 SUIT_DataObject (SUIT_DataObject *=0)
 Constructor. More...
 
virtual ~SUIT_DataObject ()
 Destructor. More...
 
SUIT_DataObjectroot () const
 Get the root object. More...
 
SUIT_DataObjectlastChild () const
 Get the last child object. More...
 
SUIT_DataObjectfirstChild () const
 Get the first child object. More...
 
int childCount () const
 Get the number of the child objects. More...
 
int childPos (const SUIT_DataObject *) const
 Get the index of the specified object in the child list. More...
 
void moveChildPos (SUIT_DataObject *, int)
 Moves the child position from current to new one. More...
 
SUIT_DataObjectchildObject (const int) const
 Get child object by the specified index. More...
 
int level () const
 Get the object level in the tree structure. More...
 
int position () const
 Get the position of the data object in its parent's children list. More...
 
void setPosition (int)
 Sets new position of the object in parent's list. More...
 
SUIT_DataObjectnextBrother () const
 Get the next sibling data object in the children list. More...
 
SUIT_DataObjectprevBrother () const
 Get the previous sibling data object in the children list. More...
 
bool autoDeleteChildren () const
 Get "auto-delete children" flag. More...
 
virtual void setAutoDeleteChildren (const bool)
 Set "auto-delete children" flag. More...
 
virtual void children (DataObjectList &, const bool=false) const
 Get all children. More...
 
virtual DataObjectList children (const bool=false)
 Get all children. . More...
 
void appendChild (SUIT_DataObject *)
 Add new child object to the end of the children list. More...
 
virtual void insertChild (SUIT_DataObject *, int)
 Insert new child object to the list of the children. More...
 
virtual void removeChild (SUIT_DataObject *, const bool=false)
 Remove the specified child object reference. More...
 
bool replaceChild (SUIT_DataObject *, SUIT_DataObject *, const bool=false)
 Replace the specified child object by another object. More...
 
void reparentChildren (const SUIT_DataObject *)
 Change the parent for all children from specified object to this one. More...
 
virtual SUIT_DataObjectparent () const
 Get the parent object. More...
 
virtual void setParent (SUIT_DataObject *)
 Change the parent object. More...
 
virtual void assignParent (SUIT_DataObject *)
 
void insertChildAtPos (SUIT_DataObject *obj, int position)
 Insert new child object into the list of the children (faster version of insertChild without signal). More...
 
bool modified ()
 
virtual void setModified (bool modified)
 Sets modification state of the object. More...
 
virtual QString name () const
 Get data object name. More...
 
virtual QString text (const int=NameId) const
 Get object text data for the specified column. More...
 
virtual QPixmap icon (const int=NameId) const
 Get data object icon for the specified column. More...
 
virtual QColor color (const ColorRole, const int=NameId) const
 Get data object color for the specified column. More...
 
virtual QString toolTip (const int=NameId) const
 Get data object tooltip for the specified column. More...
 
virtual QString statusTip (const int=NameId) const
 Get data object status tip for the specified column. More...
 
virtual QString whatsThis (const int=NameId) const
 Get data object "what's this" information for the specified column. More...
 
virtual QFont font (const int=NameId) const
 Get data object font for the specified column. More...
 
virtual int alignment (const int=NameId) const
 Get data object text alignment for the specified column. More...
 
virtual bool expandable () const
 
virtual bool isVisible () const
 Check if the object is visible. More...
 
virtual bool isDraggable () const
 Check if the object is draggable. More...
 
virtual bool isDropAccepted () const
 Check if the drop operation for this object is possible. More...
 
virtual bool isEnabled () const
 Check if this object is enabled. More...
 
virtual bool isSelectable () const
 Check if this object is selectable. More...
 
virtual bool isCheckable (const int=NameId) const
 Check if this object is checkable for the specified column. More...
 
virtual bool renameAllowed (const int=NameId) const
 Check if this object is can't be renamed in place. More...
 
virtual bool setName (const QString &name)
 Set name of the this object. More...
 
virtual bool isOn (const int=NameId) const
 Get the checked state of the object (if it is checkable) for the specified column. More...
 
virtual void setOn (const bool, const int=NameId)
 Set the checked state of the object (if it is checkable) for the specified column. More...
 
virtual bool isOpen () const
 Get the "opened" state of the object. More...
 
virtual void setOpen (const bool)
 Set the "opened" state of the object. More...
 
virtual void update ()
 Updates necessary internal fields of data object. More...
 
virtual bool customSorting (const int=NameId) const
 Check if the specified column supports custom sorting. More...
 
virtual bool compare (const QVariant &, const QVariant &, const int=NameId) const
 Compares data from two items for sorting purposes. More...
 
virtual SUIT_DataObjectKeykey () const
 Get the object unique indentification key. More...
 
virtual int groupId () const
 return unique group identificator More...
 
virtual QVariant customData (Qtx::CustomDataType)
 return custom data for data object. More...
 
void deleteLater ()
 Schedule this object for the late deleting. More...
 
void dump (const int indent=2) const
 Dump the object tree recursively to the standard output. More...
 

Static Public Member Functions

static Signalsignal ()
 Get global signal handler. More...
 
static bool connect (const char *, QObject *, const char *)
 Connect to the signal handlerx. More...
 
static bool disconnect (const char *, QObject *, const char *)
 Disconnect from the signal handler. More...
 

Private Attributes

SUIT_DataObjectmyParent
 
bool myOpen
 
bool myCheck
 
bool myAutoDel
 
DataObjectList myChildren
 
bool _modified
 

Static Private Attributes

static SignalmySignal = 0
 

Friends

class SUIT_DataObject::Signal
 
class SUIT_DataObjectIterator
 

Detailed Description

Data object represents uniform data tree structure recommended to use in the SUIT-based applications.

Member Enumeration Documentation

anonymous enum
Enumerator
NameId 

name column

VisibilityId 

visibility state column

Enumerator
Text 

editor foreground (text) color

Base 

editor background color

Foreground 

foreground (text) color

Background 

background color

Highlight 

highlight background color

HighlightedText 

highlighted foreground (text) color

Constructor & Destructor Documentation

SUIT_DataObject::SUIT_DataObject ( SUIT_DataObject p = 0)

Creates the data object with the specified parent. To create the top-level object, pass 0 as parameter.

Parameters
pparent object

References SUIT_DataObject::Signal::emitCreated(), setParent(), and signal().

SUIT_DataObject::~SUIT_DataObject ( )
virtual

Destroys all the children if "auto-delete children" flag is set.

References autoDeleteChildren(), SUIT_DataObject::Signal::emitDestroyed(), if(), myChildren, myParent, removeChild(), and signal().

Member Function Documentation

int SUIT_DataObject::alignment ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns default alignment which is Qt:AlignLeft.

The parameter id specifies the column identificator (to display, for example, in the tree view widget).

Parameters
idcolumn id
Returns
object text alignment flags for the specified column
void SUIT_DataObject::appendChild ( SUIT_DataObject obj)
Parameters
objchild object being added

References insertChild(), and myChildren.

void SUIT_DataObject::assignParent ( SUIT_DataObject p)
virtual

References myParent.

bool SUIT_DataObject::autoDeleteChildren ( ) const
Returns
true if the object should delete all its children on destroying
See Also
setAutoDeleteChildren()

References myAutoDel.

int SUIT_DataObject::childCount ( ) const
Returns
number of the children

References myChildren.

SUIT_DataObject * SUIT_DataObject::childObject ( const int  idx) const
Parameters
idxchild object index
Returns
child object or 0 if index is out of range

References myChildren.

int SUIT_DataObject::childPos ( const SUIT_DataObject obj) const
Parameters
objchild object
Returns
subobject position or -1 if it does not belong to this object

References myChildren.

void SUIT_DataObject::children ( DataObjectList lst,
const bool  rec = false 
) const
virtual

If parameter rec is true then function collects all the children recursively.

Parameters
lstreturning list of children
recif true collect all children recursively

References myChildren.

DataObjectList SUIT_DataObject::children ( const bool  rec = false)
virtual

If parameter rec is true then function collects all the children recursively.

Parameters
recif true collect all children recursively
Returns
list of children

References children().

QColor SUIT_DataObject::color ( const ColorRole  ,
const int  = NameId 
) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns null color.

The parameter id specifies the column identificator

Parameters
rolecolor role
idcolumn id
Returns
object color for the specified column

Reimplemented in SalomeApp_RootObject, SALOME_PYQT_BorrowedDataObjectLight, LightApp_DataObject, SALOME_PYQT_DataObjectLight, and SalomeApp_DataObject.

bool SUIT_DataObject::compare ( const QVariant &  ,
const QVariant &  ,
const int  = NameId 
) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns false ("Name" column does not require custom sorting).

This method is called only for those columns for which customSorting() method returns true.

Parameters
leftfirst data to compare
rightsecond data to compare
idcolumn id
Returns
result of the comparison
See Also
customSorting()

Reimplemented in SalomeApp_DataObject, and LightApp_DataObject.

bool SUIT_DataObject::connect ( const char *  sig,
QObject reciever,
const char *  slot 
)
static
Parameters
sigsignal name
recieversignal receiver object
slotslot name
Returns
true if connection is successfull

References signal().

QVariant SUIT_DataObject::customData ( Qtx::CustomDataType  )
virtual

Reimplemented in LightApp_DataObject.

bool SUIT_DataObject::customSorting ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns false ("Name" column does not require custom sorting).

Parameters
idcolumn id
Returns
true if column sorting should be customized
See Also
compare()

Reimplemented in SalomeApp_DataObject, and LightApp_DataObject.

void SUIT_DataObject::deleteLater ( )

The object will be deleted when control returns to the event loop. Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.

References SUIT_DataObject::Signal::deleteLater(), parent(), removeChild(), and signal().

bool SUIT_DataObject::disconnect ( const char *  sig,
QObject reciever,
const char *  slot 
)
static
Parameters
sigsignal name
recieversignal receiver object
slotslot name
Returns
true if disconnection is successfull

References signal().

void SUIT_DataObject::dump ( const int  indent = 2) const
Parameters
indentcurrent indentation level

References myChildren, and name().

bool SUIT_DataObject::expandable ( ) const
virtual

Reimplemented in SalomeApp_DataObject.

SUIT_DataObject * SUIT_DataObject::firstChild ( ) const
Returns
first child object or 0 if there are no children
See Also
lastChild()

References myChildren.

QFont SUIT_DataObject::font ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns application default font.

The parameter id specifies the column identificator

Parameters
idcolumn id
Returns
object font for the specified column

Reimplemented in SalomeApp_DataObject.

int SUIT_DataObject::groupId ( ) const
virtual

Groups of data objects are used for column information search. Each column of data model has one or several registered group id If object has the same group id as one of registered, the information will be shown; the custom id of column will be passed into data() method in order to identify column from point of view of data object

Reimplemented in LightApp_DataObject.

QPixmap SUIT_DataObject::icon ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns null pixmap.

The parameter id specifies the column identificator

Parameters
idcolumn id
Returns
object icon for the specified column

Reimplemented in SalomeApp_SavePointObject, SalomeApp_RootObject, SalomeApp_ModuleObject, LightApp_ModuleObject, SalomeApp_DataObject, SALOME_PYQT_BorrowedDataObjectLight, CAM_ModuleObject, and SALOME_PYQT_DataObjectLight.

void SUIT_DataObject::insertChild ( SUIT_DataObject obj,
int  position 
)
virtual
Parameters
objchild object being added
positionchild position

Reimplemented in LightApp_ModuleObject.

References SUIT_DataObject::Signal::emitInserted(), myChildren, position(), setParent(), and signal().

void SUIT_DataObject::insertChildAtPos ( SUIT_DataObject obj,
int  position 
)
Parameters
objchild object being added
positionchild position

References assignParent(), myChildren, and position().

bool SUIT_DataObject::isCheckable ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns false (all objects are not checkable).

Parameters
idcolumn id
Returns
true if the item can be checked or unchecked by the user
See Also
isOn(), setOn()
bool SUIT_DataObject::isDraggable ( ) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns false (all objects could not be dragged).

Returns
true if it is possible to drag this object

Reimplemented in LightApp_DataObject.

bool SUIT_DataObject::isDropAccepted ( ) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns false (drop operation is not allowed).

Returns
true if it is possible to drop one or more objects (currently selected) to this object

Reimplemented in LightApp_DataObject.

bool SUIT_DataObject::isEnabled ( ) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns true (all objects are enabled).

Returns
true if the user can interact with the item
bool SUIT_DataObject::isOn ( const int  id = NameId) const
virtual

Default implementation supports the checked state for the first ("Name") column only.

Parameters
idcolumn id
Returns
checked state of the object for the specified column
See Also
setOn(), isCheckable()

References myCheck, and NameId.

bool SUIT_DataObject::isOpen ( ) const
virtual
Returns
"opened" state of the object
See Also
setOpen()

References myOpen.

bool SUIT_DataObject::isSelectable ( ) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns true (all objects are selectable).

Returns
true if the item can be selected
bool SUIT_DataObject::isVisible ( ) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns true (all objects are visible by default).

Returns
true if this object is displayable or false otherwise

Reimplemented in SalomeApp_DataObject, and LightApp_DataObject.

SUIT_DataObjectKey * SUIT_DataObject::key ( ) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns 0.

Returns
object key

Reimplemented in LightApp_DataObject.

SUIT_DataObject * SUIT_DataObject::lastChild ( ) const
Returns
last child object or 0 if there are no children
See Also
firstChild()

References myChildren.

int SUIT_DataObject::level ( ) const

Root object has level 0.

Returns
object level.

References parent().

bool SUIT_DataObject::modified ( )
inline
void SUIT_DataObject::moveChildPos ( SUIT_DataObject theObj,
int  theNewPos 
)
Parameters
theObjchild object
theNewPoschild objectnew position in the children list

References myChildren.

QString SUIT_DataObject::name ( ) const
virtual

This method should be re-implemented in the subclasses. Default implementation returns null string.

Returns
object name

Reimplemented in SalomeApp_SavePointRootObject, SalomeApp_SavePointObject, SalomeApp_RootObject, SalomeApp_ModuleObject, LightApp_ModuleObject, SALOME_PYQT_BorrowedDataObjectLight, SalomeApp_DataObject, CAM_ModuleObject, and SALOME_PYQT_DataObjectLight.

SUIT_DataObject * SUIT_DataObject::nextBrother ( ) const
Returns
child object or 0 if there is no next sibling
See Also
prevBrother()

References childObject(), childPos(), and myParent.

SUIT_DataObject * SUIT_DataObject::parent ( ) const
virtual
Returns
parent object or 0 if this is top-level item

References myParent.

int SUIT_DataObject::position ( ) const
Returns
data object position

References childPos(), and myParent.

SUIT_DataObject * SUIT_DataObject::prevBrother ( ) const
Returns
child object or 0 if there is no previous sibling
See Also
nextBrother()

References childObject(), childPos(), and myParent.

void SUIT_DataObject::removeChild ( SUIT_DataObject obj,
const bool  del = false 
)
virtual
Parameters
objchild object being removed
delif true, the child object is destroyed

References deleteLater(), SUIT_DataObject::Signal::emitRemoved(), myChildren, setParent(), and signal().

bool SUIT_DataObject::renameAllowed ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns false (all objects can not be renamed).

Parameters
idcolumn id
Returns
true if the item can be renamed by the user in place (e.g. in the Object browser)

Reimplemented in LightApp_DataObject.

void SUIT_DataObject::reparentChildren ( const SUIT_DataObject obj)
Parameters
objobject which children to be reparented

References children().

bool SUIT_DataObject::replaceChild ( SUIT_DataObject src,
SUIT_DataObject trg,
const bool  del = false 
)
Parameters
srcchild object being replaced
trgnew child object
delif true, the previous object is destroyed
Returns
true if the object has been replaced

References childPos(), deleteLater(), insertChild(), and removeChild().

SUIT_DataObject * SUIT_DataObject::root ( ) const
Returns
root object of the data tree

References parent(), and root().

void SUIT_DataObject::setAutoDeleteChildren ( const bool  on)
virtual

If this flag is on (default), the object will delete all its children on destroying.

Parameters
onnew flag value
See Also
autoDeleteChildren()

References myAutoDel.

void SUIT_DataObject::setModified ( bool  modified)
virtual

When the object has been modified (modified is set to true) a signal is emitted to notify the tree model and eventually redraw the data object.

Parameters
modifiedmodified state

References _modified, SUIT_DataObject::Signal::emitModified(), modified(), and signal().

bool SUIT_DataObject::setName ( const QString &  name)
virtual

This method can be re-implemented in the subclasses. Default implementation returns false.

Returns
true if rename operation finished successfully, false otherwise.

Reimplemented in LightApp_DataObject, SALOME_PYQT_BorrowedDataObjectLight, and SALOME_PYQT_DataObjectLight.

void SUIT_DataObject::setOn ( const bool  on,
const int  id = NameId 
)
virtual

Default implementation supports the checked state for the first ("Name") column only.

Parameters
onnew checked state of the object for the specified column
idcolumn id
See Also
isOn(), isCheckable()

References myCheck, and NameId.

void SUIT_DataObject::setOpen ( const bool  on)
virtual
Parameters
onnew "opened" state of the object
See Also
isOpen()

References myOpen.

void SUIT_DataObject::setParent ( SUIT_DataObject p)
virtual
Parameters
pnew parent object

References appendChild(), myParent, parent(), and removeChild().

void SUIT_DataObject::setPosition ( int  theNewPos)

References moveChildPos(), myParent, and position().

SUIT_DataObject::Signal * SUIT_DataObject::signal ( )
static
Returns
the only instance of the signal handler

References mySignal.

QString SUIT_DataObject::statusTip ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns null string.

The parameter id specifies the column identificator

Parameters
idcolumn id
Returns
object status tip for the specified column
QString SUIT_DataObject::text ( const int  id = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns null string.

Column with id = 0 (NameId) is supposed to be used to get the object name (as it does the default implementation).

Parameters
idcolumn id
Returns
object text data

Reimplemented in SalomeApp_RootObject, LightApp_DataObject, and SalomeApp_DataObject.

References name(), and NameId.

QString SUIT_DataObject::toolTip ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns null string.

The parameter id specifies the column identificator (to display, for example, in the tree view widget).

Parameters
idcolumn id
Returns
object tooltip for the specified column

Reimplemented in SalomeApp_SavePointRootObject, SalomeApp_SavePointObject, SalomeApp_RootObject, SalomeApp_ModuleObject, LightApp_ModuleObject, SalomeApp_DataObject, SALOME_PYQT_BorrowedDataObjectLight, CAM_ModuleObject, and SALOME_PYQT_DataObjectLight.

void SUIT_DataObject::update ( )
virtual
QString SUIT_DataObject::whatsThis ( const int  = NameId) const
virtual

This method can be re-implemented in the subclasses. Default implementation returns null string.

The parameter id specifies the column identificator

Parameters
idcolumn id
Returns
object "what's this" information for the specified column

Friends And Related Function Documentation

friend class SUIT_DataObject::Signal
friend
friend class SUIT_DataObjectIterator
friend

Member Data Documentation

bool SUIT_DataObject::_modified
private
bool SUIT_DataObject::myAutoDel
private
bool SUIT_DataObject::myCheck
private
DataObjectList SUIT_DataObject::myChildren
private
bool SUIT_DataObject::myOpen
private
SUIT_DataObject* SUIT_DataObject::myParent
private
SUIT_DataObject::Signal * SUIT_DataObject::mySignal = 0
staticprivate

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