Back to index

salome-smesh  6.5.0
Public Member Functions | Private Attributes
StdMeshersGUI_DistrTableFrame::SpinBoxDelegate Class Reference

Custom item delegate (uses double spin box to edit table item) More...

Collaboration diagram for StdMeshersGUI_DistrTableFrame::SpinBoxDelegate:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SpinBoxDelegate (StdMeshersGUI_DistrTableFrame::Table *)
 ~SpinBoxDelegate ()
QWidget * createEditor (QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
void setEditorData (QWidget *, const QModelIndex &) const
void setModelData (QWidget *, QAbstractItemModel *, const QModelIndex &) const
void updateEditorGeometry (QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const

Private Attributes

StdMeshersGUI_DistrTableFrame::TablemyTable

Detailed Description

Custom item delegate (uses double spin box to edit table item)

Definition at line 83 of file StdMeshersGUI_DistrTable.cxx.


Constructor & Destructor Documentation

Definition at line 166 of file StdMeshersGUI_DistrTable.cxx.

  : QItemDelegate( parent ), myTable( parent )
{
}

Definition at line 172 of file StdMeshersGUI_DistrTable.cxx.

{
}

Member Function Documentation

QWidget * StdMeshersGUI_DistrTableFrame::SpinBoxDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  ,
const QModelIndex &  index 
) const

Definition at line 178 of file StdMeshersGUI_DistrTable.cxx.

{
  SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox( parent );
  
  sb->setAcceptNames(false); // No Notebook variables allowed
  double aMin = index.column() == StdMeshersGUI_DistrTableFrame::ArgColumn ? 
                  myTable->argMinimum( index.row() ) : 
                  myTable->funcMinimum( index.row() );
  double aMax = index.column() == StdMeshersGUI_DistrTableFrame::ArgColumn ? 
                  myTable->argMaximum( index.row() ) : 
                  myTable->funcMaximum( index.row() );
  double aStep = index.column() == StdMeshersGUI_DistrTableFrame::ArgColumn ? 
                     myTable->argStep( index.row() ) : 
                     myTable->funcStep( index.row() );
  sb->RangeStepAndValidator( aMin, aMax, aStep, "parametric_precision" );
  sb->setFrame(false);

  myTable->setEditor( index.row(), index.column(), sb );  
  return sb;
}

Here is the call graph for this function:

void StdMeshersGUI_DistrTableFrame::SpinBoxDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const

Definition at line 203 of file StdMeshersGUI_DistrTable.cxx.

{
  QString value = index.model()->data(index, Qt::DisplayRole).toString();
  SMESHGUI_SpinBox* sb = static_cast<SMESHGUI_SpinBox*>(editor);

  bool bOk = false;
  double v = value.toDouble( &bOk );
  if ( !bOk ) v = sb->minimum();

  sb->setValue( v );
}
void StdMeshersGUI_DistrTableFrame::SpinBoxDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const

Definition at line 217 of file StdMeshersGUI_DistrTable.cxx.

{
  SMESHGUI_SpinBox* sb = static_cast<SMESHGUI_SpinBox*>(editor);
  model->setData( index, QString::number( sb->value() ), Qt::DisplayRole );
}
void StdMeshersGUI_DistrTableFrame::SpinBoxDelegate::updateEditorGeometry ( QWidget *  editor,
const QStyleOptionViewItem &  option,
const QModelIndex &   
) const

Definition at line 226 of file StdMeshersGUI_DistrTable.cxx.

{
  editor->setGeometry( option.rect );
}

Member Data Documentation

Definition at line 100 of file StdMeshersGUI_DistrTable.cxx.


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