Back to index

salome-gui  6.5.0
Public Member Functions | Protected Member Functions | Private Attributes
SalomeApp_ListViewItem Class Reference

#include <SalomeApp_ListView.h>

List of all members.

Public Member Functions

 SalomeApp_ListViewItem (SalomeApp_ListView *)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListView *, SalomeApp_ListViewItem *)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListView *, const QStringList &, const bool=false)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListViewItem *, const QStringList &, const bool=false)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListView *, SalomeApp_ListViewItem *, const QString &, const bool=false)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListViewItem *, SalomeApp_ListViewItem *, const QString &, const bool=false)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListView *, SalomeApp_ListViewItem *, const QString &theName, const QString &theValue, const bool=false)
 Constructor.
 SalomeApp_ListViewItem (SalomeApp_ListViewItem *, SalomeApp_ListViewItem *, const QString &, const QString &, const bool=false)
 Constructor.
 ~SalomeApp_ListViewItem ()
 Destructor.
QString fullName ()
void openAllLevels ()
 expands all entities beginning from this level
virtual void updateAllLevels ()
 update all entites beginning from this level
bool isEditable () const
void setEditable (bool theEditable)
 Sets editable flag fo the entity.
bool isAccepted () const
void setAccepted (bool theAccepted)
 Sets entitiy accepted or not after editing.
virtual QString getName () const
virtual UpdateType setName (const QString &theName)
 Sets text in the first column.
virtual QString getValue () const
virtual UpdateType setValue (const QString &theValue)
 Sets text in the second column.
SalomeApp_EntityEditstartEditing ()
 Creates control for editing and fills it with values.
virtual void fillWidgetWithValues (SalomeApp_EntityEdit *theWidget)
 Fills widget with initial values (list or single value)
virtual UpdateType finishEditing (SalomeApp_EntityEdit *theWidget)
 Finishes editing of entity.
virtual int getEditingType ()
virtual void setEditingType (const int)
virtual int getEditedColumn ()
virtual int getValueType ()
virtual void setValueType (const int)
 Sets type of edited value.
virtual int getUserType ()
 Sets type of edited value.
virtual void setUserType (const int)
 Sets type of edited value.
virtual int getButtons ()
virtual void setButtons (const int)
 Sets buttons for editing widget (Apply (V), Cancel (X))
QString tipText ()
QRect tipRect ()
 Calculates rectangle which should contain item's tip.
QRect textRect (const int column) const
 Calculates rect of item text in viewport coordinates.
QRect itemRect (const int column) const
 Calculates rect of item data in viewport coordinates.

Protected Member Functions

void init ()
 Initialization.
int depth () const
 Returns the depth of this item.

Private Attributes

bool myEditable
bool myAccepted
int myEditingType
int myValueType
int myButtons
int myUserType

Detailed Description

Definition at line 240 of file SalomeApp_ListView.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 422 of file SalomeApp_ListView.cxx.

                                                                         :
QTreeWidgetItem( parent )
{
  init();
}

Here is the call graph for this function:

Constructor.

Definition at line 431 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem( parent, after )
{
  init();
}

Here is the call graph for this function:

SalomeApp_ListViewItem::SalomeApp_ListViewItem ( SalomeApp_ListView parent,
const QStringList &  theStrings,
const bool  theEditable = false 
)

Constructor.

Definition at line 441 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem(parent, theStrings)
{
  init();
  setEditable(theEditable);
}

Here is the call graph for this function:

SalomeApp_ListViewItem::SalomeApp_ListViewItem ( SalomeApp_ListViewItem parent,
const QStringList &  theString,
const bool  theEditable = false 
)

Constructor.

Definition at line 453 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem(parent, theString)
{
  init();
  setEditable(theEditable);
}

Here is the call graph for this function:

SalomeApp_ListViewItem::SalomeApp_ListViewItem ( SalomeApp_ListView parent,
SalomeApp_ListViewItem after,
const QString &  theName,
const bool  theEditable = false 
)

Constructor.

Definition at line 479 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem(parent, after)
{
  setData(0,Qt::DisplayRole,QVariant(theName));
  init();
  setEditable(theEditable);
}

Here is the call graph for this function:

SalomeApp_ListViewItem::SalomeApp_ListViewItem ( SalomeApp_ListViewItem parent,
SalomeApp_ListViewItem after,
const QString &  theName,
const bool  theEditable = false 
)

Constructor.

Definition at line 465 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem(parent, after)
{
  setData(0,Qt::DisplayRole,QVariant(theName));
  init();
  setEditable(theEditable);
}

Here is the call graph for this function:

SalomeApp_ListViewItem::SalomeApp_ListViewItem ( SalomeApp_ListView parent,
SalomeApp_ListViewItem after,
const QString &  theName,
const QString &  theValue,
const bool  theEditable = false 
)

Constructor.

Definition at line 509 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem(parent, after)
{
  setData(0,Qt::DisplayRole,QVariant(theName));
  setData(1,Qt::DisplayRole,QVariant(theValue));
  init();
  setEditable(theEditable);
}

Here is the call graph for this function:

SalomeApp_ListViewItem::SalomeApp_ListViewItem ( SalomeApp_ListViewItem parent,
SalomeApp_ListViewItem after,
const QString &  theName,
const QString &  theValue,
const bool  theEditable = false 
)

Constructor.

Definition at line 493 of file SalomeApp_ListView.cxx.

                                                                              :
QTreeWidgetItem(parent, after)
{
  setData(0,Qt::DisplayRole,QVariant(theName));
  setData(1,Qt::DisplayRole,QVariant(theValue));
  init();
  setEditable(theEditable);
}

Here is the call graph for this function:

Destructor.

Definition at line 525 of file SalomeApp_ListView.cxx.

{
}

Member Function Documentation

int SalomeApp_ListViewItem::depth ( ) const [protected]

Returns the depth of this item.

Definition at line 545 of file SalomeApp_ListView.cxx.

{
  int aDepth = 0;
  QTreeWidgetItem* aParent = parent();
  while ( aParent ) {
    aParent = aParent->parent();
    aDepth++;
  }
  return aDepth;
}

Here is the caller graph for this function:

Fills widget with initial values (list or single value)

Definition at line 784 of file SalomeApp_ListView.cxx.

{
  int anEditColumn = getEditedColumn();
  if (theWidget && anEditColumn >= 0 && !text(anEditColumn).isEmpty())
    theWidget->insertItem(text(anEditColumn), true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Finishes editing of entity.

Definition at line 794 of file SalomeApp_ListView.cxx.

{
  UpdateType aNeedsUpdate = utCancel;
  try {
    if (theWidget) {
      int anEditColumn = getEditedColumn();
      switch (anEditColumn) {
      case 0:
        aNeedsUpdate = setName(theWidget->getText());
        break;
      case 1:
        aNeedsUpdate = setValue(theWidget->getText());
        break;
      default:
        break;
      }
    }
  }
  catch (...) {
    MESSAGE( "System error has been caught - SalomeApp_ListViewItem::finishEditing" )
  }
  return aNeedsUpdate;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
full path to the entity from the root

Definition at line 601 of file SalomeApp_ListView.cxx.

{
  QString aFullName = getName();
  SalomeApp_ListViewItem* aParent = (SalomeApp_ListViewItem*)parent();
  while(aParent != NULL) {
    aFullName = aParent->getName() + QString(".") + aFullName;
    aParent = (SalomeApp_ListViewItem*)(aParent->parent());
  }
  return aFullName;
}

Here is the call graph for this function:

Returns:
buttons for editing widget (Apply (V), Cancel (X)) default is both buttons

Definition at line 740 of file SalomeApp_ListView.cxx.

{
  return myButtons;
}

Here is the caller graph for this function:

Return values:
editedcolumn, default is last column negative value means there are no editable columns

Definition at line 698 of file SalomeApp_ListView.cxx.

{
  return treeWidget()->columnCount()-1;
}

Here is the caller graph for this function:

Return values:
typeof edit control (default is edit box)
  • 0 - edit box
  • 1 - combo box
  • 2 - editable combo box

Definition at line 679 of file SalomeApp_ListView.cxx.

{
  return myEditingType;
}

Here is the caller graph for this function:

QString SalomeApp_ListViewItem::getName ( ) const [virtual]
Returns:
text in the first column

Definition at line 559 of file SalomeApp_ListView.cxx.

{
  return ( treeWidget()->columnCount() > 0 ) ? text(0) : QString("");
}

Here is the caller graph for this function:

Sets type of edited value.

Definition at line 723 of file SalomeApp_ListView.cxx.

{
  return myUserType;
}
QString SalomeApp_ListViewItem::getValue ( ) const [virtual]
Returns:
text in the second column

Definition at line 580 of file SalomeApp_ListView.cxx.

{
  return ( treeWidget()->columnCount() > 1 ) ? text(1) : QString("");
}

Here is the caller graph for this function:

Return values:
typeof edited value (string, int, double) default is string

Definition at line 707 of file SalomeApp_ListView.cxx.

{
  return myValueType;
}

Here is the caller graph for this function:

Initialization.

Definition at line 532 of file SalomeApp_ListView.cxx.

Here is the caller graph for this function:

Returns:
true if entitiy is accepted after editing

Definition at line 660 of file SalomeApp_ListView.cxx.

{
  return myAccepted;
}

Here is the caller graph for this function:

Returns:
true if entity is editable

Definition at line 644 of file SalomeApp_ListView.cxx.

{
  return myEditable;
}

Here is the caller graph for this function:

QRect SalomeApp_ListViewItem::itemRect ( const int  column) const

Calculates rect of item data in viewport coordinates.

Definition at line 893 of file SalomeApp_ListView.cxx.

{
  QRect aItemRect = treeWidget()->visualItemRect( this );
  if ( !aItemRect.isValid() )
    return aItemRect;

  QFont aFont(treeWidget()->font());
  QFontMetrics fm(aFont);

  int decorWidth  = ( treeWidget()->rootIsDecorated() ) ?
                    ( treeWidget()->indentation() * (depth() + 1) ) :
                    ( treeWidget()->indentation() *  depth() );
  int pixmapWidth = ( !icon(column).isNull() ) ?
                      treeWidget()->iconSize().width() + 2 :
                      0;
  int prevWidth = 0;
  for (int i = 0; i < column; i++)
    prevWidth += treeWidget()->header()->sectionSize(i);
  int ix = prevWidth;
  int iy = aItemRect.y();
  int iw = pixmapWidth +
           2 +
           ((column == 0) ? decorWidth : 0) +
           fm.width(text(column));
  int ih = aItemRect.height();
  ix -= treeWidget()->contentsRect().left();

  QRect theResult(QPoint(ix, iy), QSize(iw, ih));
  return theResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

expands all entities beginning from this level

Definition at line 615 of file SalomeApp_ListView.cxx.

{
  setExpanded(true);
  QTreeWidgetItemIterator it( this );
  SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)(*it);
  while( aChild ) {
    aChild->openAllLevels();
    ++it;
    aChild = (SalomeApp_ListViewItem*)(*it);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Sets entitiy accepted or not after editing.

Definition at line 668 of file SalomeApp_ListView.cxx.

{
  myAccepted = theAccepted;
}

Here is the caller graph for this function:

void SalomeApp_ListViewItem::setButtons ( const int  buttons) [virtual]

Sets buttons for editing widget (Apply (V), Cancel (X))

Definition at line 748 of file SalomeApp_ListView.cxx.

{
  myButtons = buttons;
}

Sets editable flag fo the entity.

Definition at line 652 of file SalomeApp_ListView.cxx.

{
  myEditable = theEditable;
}

Here is the caller graph for this function:

void SalomeApp_ListViewItem::setEditingType ( const int  type) [virtual]
Return values:
typeof edit control (negative value means none)
  • 0 - edit box
  • 1 - combo box
  • 2 - editable combo box

Definition at line 690 of file SalomeApp_ListView.cxx.

{
  myEditingType = type;
}
UpdateType SalomeApp_ListViewItem::setName ( const QString &  theName) [virtual]

Sets text in the first column.

Definition at line 567 of file SalomeApp_ListView.cxx.

{
  UpdateType aNeedsUpdate = utCancel;
  if (treeWidget()->columnCount() > 0) {
    setText(0, theName);
    aNeedsUpdate = utNone;
  }
  return aNeedsUpdate;
}

Here is the caller graph for this function:

void SalomeApp_ListViewItem::setUserType ( const int  userType) [virtual]

Sets type of edited value.

Definition at line 731 of file SalomeApp_ListView.cxx.

{
  myUserType = userType;
}
UpdateType SalomeApp_ListViewItem::setValue ( const QString &  theValue) [virtual]

Sets text in the second column.

Definition at line 588 of file SalomeApp_ListView.cxx.

{
  UpdateType aNeedsUpdate = utCancel;
  if (treeWidget()->columnCount() > 1) {
    setText(1, theValue);
    aNeedsUpdate = utNone;
  }
  return aNeedsUpdate;
}

Here is the caller graph for this function:

void SalomeApp_ListViewItem::setValueType ( const int  valueType) [virtual]

Sets type of edited value.

Definition at line 715 of file SalomeApp_ListView.cxx.

{
  myValueType = valueType;
}

Creates control for editing and fills it with values.

Definition at line 756 of file SalomeApp_ListView.cxx.

{
  SalomeApp_EntityEdit* aWidget = 0;
  QTreeWidget* aListView = treeWidget();
  if (aListView) {
    if (!isEditable())
      return 0;
    int anEditType   = getEditingType();
    int aValueType   = getValueType();
    int aButtons     = getButtons();
    int anEditColumn = getEditedColumn();
    if (anEditColumn < 0 || anEditType < 0)
      return 0;
    aWidget = new SalomeApp_EntityEdit(aListView->viewport(),
                                 anEditType,
                                 aValueType,
                                 aButtons & SalomeApp_EntityEdit::btApply,
                                 aButtons & SalomeApp_EntityEdit::btCancel);
    computeEditGeometry(this, aWidget);

    fillWidgetWithValues(aWidget);
  }
  return aWidget;
}

Here is the call graph for this function:

Here is the caller graph for this function:

QRect SalomeApp_ListViewItem::textRect ( const int  column) const

Calculates rect of item text in viewport coordinates.

Definition at line 856 of file SalomeApp_ListView.cxx.

{
  QRect aItemRect = treeWidget()->visualItemRect( this );
  if ( !aItemRect.isValid() )
    return aItemRect;

  QFont aFont(treeWidget()->font());
  QFontMetrics fm(aFont);

  int decorWidth  = ( treeWidget()->rootIsDecorated() ) ?
                    ( treeWidget()->indentation() * (depth() + 1) ) :
                    ( treeWidget()->indentation() *  depth() );
  int pixmapWidth = ( !icon(column).isNull() ) ?
                      treeWidget()->iconSize().width() + 2 :
                      1;
  int prevWidth = 0;
  for (int i = 0; i < column; i++)
    prevWidth += treeWidget()->header()->sectionSize(i);
  int ix = prevWidth   +
           pixmapWidth +
           ((column == 0) ? decorWidth : 0);
  int iy = aItemRect.y();
  int iw = fm.width(text(column));
  int ih = aItemRect.height();
  if (!icon(column).isNull()) {
    iy += 1;
    ih -= 2;
  }
  ix -= treeWidget()->contentsRect().left();

  QRect theResult(QPoint(ix, iy), QSize(iw, ih));
  return theResult;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Calculates rectangle which should contain item's tip.

Definition at line 821 of file SalomeApp_ListView.cxx.

{
  QRect aRect = QRect(-1, -1, -1, -1);
  QRect aItemRect = treeWidget()->visualItemRect(this);
  if ( !aItemRect.isValid() )
    return aItemRect;

  QString aTip = tipText();
  if (!aTip.isEmpty()) {
    QRect aRect0 = textRect(0);
    QFont aFont(treeWidget()->font());
    QFontMetrics fm(aFont);
    int iw = fm.width(aTip);
    aRect = QRect(QPoint(aRect0.x() < 0 ? 0 : aRect0.x(),
                         aRect0.y()),
                  QSize (iw,
                         aRect0.height()));
  }
  return aRect;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns:
text for tooltip

Definition at line 845 of file SalomeApp_ListView.cxx.

{
  QString aText = getName();
  if (!getValue().isEmpty())
    aText += QString(" : ") + getValue();
  return aText;
}

Here is the call graph for this function:

Here is the caller graph for this function:

update all entites beginning from this level

Definition at line 630 of file SalomeApp_ListView.cxx.

{
  QTreeWidgetItemIterator it( this );
  SalomeApp_ListViewItem* aChild = (SalomeApp_ListViewItem*)(*it);
  while( aChild ) {
    aChild->updateAllLevels();
    ++it;
    aChild = (SalomeApp_ListViewItem*)(*it);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 336 of file SalomeApp_ListView.h.

Definition at line 339 of file SalomeApp_ListView.h.

Definition at line 335 of file SalomeApp_ListView.h.

Definition at line 337 of file SalomeApp_ListView.h.

Definition at line 340 of file SalomeApp_ListView.h.

Definition at line 338 of file SalomeApp_ListView.h.


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