3 #include "MonCreateListGroup.h"
4 #include "MonCreateHypothesis.h"
5 #include "MonCreateBoundaryDi.h"
10 #include "SalomeApp_Tools.h"
11 #include "HOMARDGUI_Utils.h"
12 #include "HomardQtCommun.h"
13 #include <utilities.h>
15 #include <SUIT_Desktop.h>
16 #include <SUIT_MessageBox.h>
17 #include <SUIT_ResourceMgr.h>
18 #include <SUIT_Session.h>
19 #include <SUIT_ViewManager.h>
21 // --------------------------------------------------------------------------------------------------------------
22 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal,
23 HOMARD::HOMARD_Gen_var myHomardGen, QString aCaseName, QStringList listeGroupesHypo) :
24 // --------------------------------------------------------------------------------------------------------------
26 QDialog(0), Ui_CreateListGroup(),
27 _aCaseName (aCaseName),
28 _listeGroupesHypo (listeGroupesHypo),
29 _parentHyp(parentHyp),
30 _parentBound(parentBound)
32 MESSAGE("Debut de MonCreateListGroup")
33 _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
39 // --------------------------------------------------------------------------------------------------------------
40 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound,
41 HOMARD::HOMARD_Gen_var myHomardGen, QString aCaseName, QStringList listeGroupesHypo) :
42 // --------------------------------------------------------------------------------------------------------------
44 QDialog(0), Ui_CreateListGroup(),
45 _aCaseName (aCaseName),
46 _listeGroupesHypo (listeGroupesHypo),
47 _parentHyp(parentHyp),
48 _parentBound(parentBound)
50 _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
55 // ------------------------------------------------------------------------
56 MonCreateListGroup::~MonCreateListGroup()
57 // ------------------------------------------------------------------------
59 // no need to delete child widgets, Qt does it all for us
61 // ------------------------------------------------------------------------
62 void MonCreateListGroup::InitConnect()
63 // ------------------------------------------------------------------------
65 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
66 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
67 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
68 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
70 // ------------------------------------------------------------------------
71 bool MonCreateListGroup::PushOnApply()
72 // ------------------------------------------------------------------------
73 // Appele lorsque l'un des boutons Ok ou Apply est presse
76 QStringList ListeGroup ;
77 for ( int row=0; row< TWGroupe->rowCount(); row++)
79 if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked )
80 ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) );
82 if ( _parentHyp ) { _parentHyp->setGroups(ListeGroup);};
83 if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
88 // ------------------------------------------------------------------------
89 void MonCreateListGroup::PushOnOK()
90 // ------------------------------------------------------------------------
92 if (PushOnApply()) this->close();
93 if ( _parentHyp ) { _parentHyp->raise(); _parentHyp->activateWindow(); };
94 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
96 // ------------------------------------------------------------------------
97 void MonCreateListGroup::PushOnHelp()
98 // ------------------------------------------------------------------------
100 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
102 // ------------------------------------------------------------------------
103 void MonCreateListGroup::InitGroupes()
104 // ------------------------------------------------------------------------
106 MESSAGE("Debut de MonCreateListGroup::InitGroupes ");
107 for ( int row=0; row< TWGroupe->rowCount(); row++)
108 TWGroupe->removeRow(row);
109 TWGroupe->setRowCount(0);
110 if (_aCaseName == QString("")) { return; };
111 HOMARD::HOMARD_Cas_var monCas= _myHomardGen->GetCas(_aCaseName.toStdString().c_str());
112 HOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
113 for ( int i = 0; i < _listeGroupesCas->length(); i++ )
115 TWGroupe->insertRow(i);
116 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
117 TWGroupe->item( i, 0 )->setFlags( 0 );
118 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
119 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
120 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
122 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
123 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
124 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
126 TWGroupe->resizeColumnsToContents();
127 TWGroupe->resizeRowsToContents();
128 TWGroupe->clearSelection();
129 // MESSAGE("Fin de MonCreateListGroup::InitGroupes ");