Back to index

salome-smesh  6.5.0
Public Member Functions | Private Attributes
StdMeshersGUI::LineDelegate Class Reference

#include <StdMeshersGUI_CartesianParamCreator.h>

List of all members.

Public Member Functions

 LineDelegate (QWidget *parent)
 ~LineDelegate ()
QWidget * createEditor (QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
void setEditorData (QWidget *editor, const QModelIndex &index) const
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const

Private Attributes

QTreeWidget * mySpacingTreeWdg
QListWidget * myCoordList

Detailed Description

Definition at line 103 of file StdMeshersGUI_CartesianParamCreator.h.


Constructor & Destructor Documentation

Definition at line 435 of file StdMeshersGUI_CartesianParamCreator.cxx.

                                             :
    QItemDelegate( parent ),
    mySpacingTreeWdg( qobject_cast<QTreeWidget*>( parent )),
    myCoordList( qobject_cast<QListWidget*>( parent ))
  {
  }

Definition at line 108 of file StdMeshersGUI_CartesianParamCreator.h.

{}

Member Function Documentation

QWidget * StdMeshersGUI::LineDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  opt,
const QModelIndex &  index 
) const

Definition at line 442 of file StdMeshersGUI_CartesianParamCreator.cxx.

  {
    QWidget* w = 0;
    if ( mySpacingTreeWdg )
    {
      if ( index.column() == 0 &&
           index.row() != mySpacingTreeWdg->topLevelItemCount()-1 )
      {
        SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox( parent );
        sb->setAcceptNames( false ); // No Notebook variables allowed
        sb->setFrame( false );
        w = sb;
      }
      if ( index.column() == 1 ) {
        w = new QLineEdit( parent );
      }
    }
    else
    {
      SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox( parent );
      sb->setAcceptNames( false ); // No Notebook variables allowed
      sb->setFrame( false );
      const double tol = 1e-5;
      double from = index.row() ? coordFromItem( myCoordList->item( index.row()-1 ))+tol : -1e+6;
      double to = index.row() == myCoordList->count()-1 ? 1e+6 : coordFromItem( myCoordList->item( index.row()+1 ))-tol;
      sb->RangeStepAndValidator( from, to, 0.01 );
      w = sb;
    }
    return w;
  }

Here is the call graph for this function:

void StdMeshersGUI::LineDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const

Definition at line 475 of file StdMeshersGUI_CartesianParamCreator.cxx.

  {
    if ( mySpacingTreeWdg && index.column() == 0 )
    {
      double t0, t1, t2=1.0; QString fun;
      QTreeWidgetItem* item = mySpacingTreeWdg->topLevelItem( index.row() );
      getFromItem( item, t0, t1, fun );
      if ( index.row() != mySpacingTreeWdg->topLevelItemCount()-1 )
      {
        item = mySpacingTreeWdg->topLevelItem( index.row()+1 );
        getFromItem( item, t1, t2, fun );
      }
      const double tol = 1e-3;
      SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( editor );
      sb->RangeStepAndValidator( t0 + tol, t2 - tol, 0.01 );
      sb->SetValue( t1 );
    }
    else
    {
      QItemDelegate::setEditorData( editor, index );
    }
  }

Here is the call graph for this function:

void StdMeshersGUI::LineDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const

Definition at line 497 of file StdMeshersGUI_CartesianParamCreator.cxx.

  {
    if ( mySpacingTreeWdg )
    {
      if ( index.column() == 0 )
      {
        if ( index.row() != mySpacingTreeWdg->topLevelItemCount()-1 )
        {
          SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( editor );
          double t0, t1, t = sb->GetValue(); QString fun;

          QTreeWidgetItem* item = mySpacingTreeWdg->topLevelItem( index.row() );
          getFromItem( item, t0, t1, fun );
          setToItem( t0, t, fun, item );

          item = mySpacingTreeWdg->topLevelItem( index.row() + 1 );
          getFromItem( item, t0, t1, fun );
          setToItem( t, t1, fun, item );
        }
      }
      else if ( !qobject_cast<QLineEdit*>(editor)->text().trimmed().isEmpty() )
      {
        QItemDelegate::setModelData( editor, model, index );
      }
    }
    else
    {
      SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( editor );
      coordToItem( sb->GetValue(), myCoordList->item( index.row() ));
    }
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 116 of file StdMeshersGUI_CartesianParamCreator.h.

Definition at line 115 of file StdMeshersGUI_CartesianParamCreator.h.


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