1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEGUI_OpenWith.cxx
25 // Author : Nicolas REJNERI
29 #include "SALOMEGUI_OpenWith.h"
32 #include <qcheckbox.h>
33 #include <qpushbutton.h>
38 #define SPACING_SIZE 6
39 #define MARGIN_SIZE 11
40 #define MIN_LISTBOX_WIDTH 150
41 #define MIN_LISTBOX_HEIGHT 100
44 * Constructs modal SALOMEGUI_OpenWith which is a child of 'parent', with the
47 SALOMEGUI_OpenWith::SALOMEGUI_OpenWith(QWidget* parent, const char* name)
48 : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
51 setName( "SALOMEGUI_OpenWith" );
52 setCaption( tr("OPEN_WITH_TLT") );
53 setSizeGripEnabled( TRUE );
55 QGridLayout* aTopLayout = new QGridLayout(this);
56 aTopLayout->setMargin(MARGIN_SIZE);
57 aTopLayout->setSpacing(SPACING_SIZE);
61 AllwaysCheckBox = new QCheckBox( this, "AllwaysCheckBox" );
62 AllwaysCheckBox->setText( tr( "MEN_COMPONENT_CHOICE1" ) );
64 QHBoxLayout* aBtnLayout = new QHBoxLayout;
65 aBtnLayout->setSpacing( SPACING_SIZE );
66 aBtnLayout->setMargin( 0 );
68 buttonOk = new QPushButton( this, "buttonOk" );
69 buttonOk->setText( tr( "BUT_OK" ) );
70 buttonOk->setAutoDefault( true );
71 buttonOk->setDefault( true );
73 buttonCancel = new QPushButton( this, "buttonCancel" );
74 buttonCancel->setText( tr( "BUT_CANCEL" ) );
75 buttonCancel->setAutoDefault( true );
77 aBtnLayout->addWidget( buttonOk );
78 aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
79 aBtnLayout->addWidget( buttonCancel );
81 ListComponent = new QListBox( this, "ListComponent" );
82 ListComponent->setVScrollBarMode(QListBox::AlwaysOn);
83 ListComponent->setMinimumSize(MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT);
84 ListComponent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
85 ListComponent->setSelectionMode(QListBox::Single);
87 aTopLayout->addWidget(ListComponent, 0, 0);
88 // aTopLayout->addWidget(AllwaysCheckBox, 1, 0);
89 aTopLayout->addLayout(aBtnLayout, 1, 0);
91 // signals and slots connections
92 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
93 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
94 connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ));
95 connect( ListComponent, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onDoubleClickEvent( QListBoxItem* ) ));
101 * Destroys the object and frees any allocated resources
103 SALOMEGUI_OpenWith::~SALOMEGUI_OpenWith()
108 Inserts new component into component list
110 void SALOMEGUI_OpenWith::addComponent(const QString& aComp)
112 ListComponent->insertItem(aComp);
116 Returns choosen component
118 QString SALOMEGUI_OpenWith::getComponent()
120 return ListComponent->currentText();
123 bool SALOMEGUI_OpenWith::getAlwaysFlag()
125 if ( AllwaysCheckBox )
126 return AllwaysCheckBox->isChecked();
129 void SALOMEGUI_OpenWith::onSelectionChanged()
134 void SALOMEGUI_OpenWith:: updateButtonState()
136 buttonOk->setEnabled( ListComponent->currentItem() >=0 &&
137 ListComponent->currentItem() < ListComponent->count() ) ;
140 void SALOMEGUI_OpenWith::onDoubleClickEvent( QListBoxItem* item )