Version: 6.3.1
Public Slots | Public Member Functions | Private Types | Private Member Functions | Private Attributes

LightApp_ModuleDlg Class Reference

A dialog box allowing to select study operation to be performed on the module activating. More...

#include <LightApp_ModuleDlg.h>

Inheritance diagram for LightApp_ModuleDlg:
Inheritance graph

Public Slots

void accept ()
 Called when any dialog button (except Cancel) is clicked.

Public Member Functions

 LightApp_ModuleDlg (QWidget *, const QString &, const QPixmap &=QPixmap())
 Constructor.
 ~LightApp_ModuleDlg ()
 Destructor.
int addButton (const QString &, const int=-1)
 Add operation button to the dialog box.

Private Types

typedef QMap< QPushButton *, int > ButtonMap

Private Member Functions

QPushButton * findButton (const int) const
 Search button with the specified identifier.

Private Attributes

ButtonMap myButtons
QHBoxLayout * myButtonLayout

Detailed Description

The dialog box is shown when the user tries to activate any module while there is no opened study. The dialog box proposes user to select one of the possible operations which should be done before module activating, for example, create new study or open study from the file. The available operations are assigned by adding the buttons with the unique identifier to the dialog box. When the user clicks any operation button, the dialog box sets its identifier as the return code and closes.

The typical usage of the dialog box:

  LightApp_ModuleDlg dlg( desktop() );
  dlg.addButton( "New study", NewStudyId );
  dlg.addButton( "Open study...", OpenStudyId );
  int ret = dlg.exec();
  switch( ret ) {
  case NewStudyId:
    // create new study
    createNewStudy();
    break;
  case OpenStudyId:
    // open study from the file
    // ... show dialog box to choose the file
    QString fileName = QFileDialog::getOpenFileName( desktop(), "Open File" );
    if ( !fileName.isEmpty() )
      openStudy( fileName );
    break;
  default:
    // operation is cancelled
    break;
  }
See also:
addButton()

Member Typedef Documentation

typedef QMap<QPushButton*,int> LightApp_ModuleDlg.ButtonMap [private]

Constructor & Destructor Documentation

LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget parent,
const QString &  component,
const QPixmap &  icon = QPixmap() 
)
Parameters:
parentparent widget
componentmodule name
iconmodule icon

References default_icon, and myButtonLayout.

LightApp_ModuleDlg::~LightApp_ModuleDlg ( )

Member Function Documentation

int LightApp_ModuleDlg::addButton ( const QString &  button,
const int  id = -1 
)

If the parameter id is equal to -1, then the button identifier is generated automatically.

Parameters:
buttonbutton text
idbutton identifier
Returns:
button identifier

References accept(), findButton(), myButtonLayout, and myButtons.

void LightApp_ModuleDlg::accept ( ) [slot]

Closes the dialog and sets its result code to the identifier of the button clicked by the user.

References myButtons.

QPushButton * LightApp_ModuleDlg::findButton ( const int  id) const [private]
Parameters:
idbutton identifier
Returns:
button or 0 if id is invalid

References myButtons.


Field Documentation

QHBoxLayout* LightApp_ModuleDlg.myButtonLayout [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS