]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARDGUI/MonCreateListGroup.cxx
Salome HOME
version 5_1_4 HOMARD_SRC
[modules/homard.git] / src / HOMARDGUI / MonCreateListGroup.cxx
1 using namespace std;
2
3 #include "MonCreateListGroup.h"
4 #include "MonCreateHypothesis.h"
5 #include "MonCreateBoundaryDi.h"
6
7 #include <QFileDialog>
8 #include <QMessageBox>
9
10 #include "SalomeApp_Tools.h"
11 #include "HOMARDGUI_Utils.h"
12 #include "HomardQtCommun.h"
13 #include <utilities.h>
14
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>
20
21 // --------------------------------------------------------------------------------------------------------------
22 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal, 
23                                        HOMARD::HOMARD_Gen_var myHomardGen, QString aCaseName,  QStringList listeGroupesHypo) : 
24 // --------------------------------------------------------------------------------------------------------------
25 //
26     QDialog(0), Ui_CreateListGroup(),
27     _aCaseName (aCaseName),
28     _listeGroupesHypo (listeGroupesHypo),
29     _parentHyp(parentHyp),
30     _parentBound(parentBound)
31 {
32     MESSAGE("Debut de  MonCreateListGroup")
33      _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
34     setupUi(this);
35     setModal(modal);
36     InitConnect();
37     InitGroupes();
38 }
39 // --------------------------------------------------------------------------------------------------------------
40 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound,  
41                                        HOMARD::HOMARD_Gen_var myHomardGen, QString aCaseName,  QStringList listeGroupesHypo) : 
42 // --------------------------------------------------------------------------------------------------------------
43 //
44     QDialog(0), Ui_CreateListGroup(),
45     _aCaseName (aCaseName),
46     _listeGroupesHypo (listeGroupesHypo),
47     _parentHyp(parentHyp),
48     _parentBound(parentBound)
49 {
50     _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
51     setupUi(this);
52     InitConnect();
53 }
54
55 // ------------------------------------------------------------------------
56 MonCreateListGroup::~MonCreateListGroup()
57 // ------------------------------------------------------------------------
58 {
59     // no need to delete child widgets, Qt does it all for us
60 }
61 // ------------------------------------------------------------------------
62 void MonCreateListGroup::InitConnect()
63 // ------------------------------------------------------------------------
64 {
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() ) );
69 }
70 // ------------------------------------------------------------------------
71 bool MonCreateListGroup::PushOnApply()
72 // ------------------------------------------------------------------------
73 // Appele lorsque l'un des boutons Ok ou Apply est presse
74 //
75 {
76   QStringList ListeGroup ;
77   for ( int row=0; row< TWGroupe->rowCount(); row++)
78   {
79       if ( TWGroupe->item( row, 0 )->checkState() ==  Qt::Checked )
80           ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) );
81   }
82   if ( _parentHyp )   { _parentHyp->setGroups(ListeGroup);};
83   if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
84   return true;
85 }
86
87
88 // ------------------------------------------------------------------------
89 void MonCreateListGroup::PushOnOK()
90 // ------------------------------------------------------------------------
91 {
92      if (PushOnApply()) this->close();
93      if ( _parentHyp )   { _parentHyp->raise(); _parentHyp->activateWindow(); };
94      if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
95 }
96 // ------------------------------------------------------------------------
97 void MonCreateListGroup::PushOnHelp()
98 // ------------------------------------------------------------------------
99 {
100   HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
101 }
102 // ------------------------------------------------------------------------
103 void MonCreateListGroup::InitGroupes()
104 // ------------------------------------------------------------------------
105 {
106   MESSAGE("Debut de 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++ )
114   {
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 );}
121     else
122       {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
123     TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i])));
124     TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
125   }
126   TWGroupe->resizeColumnsToContents();
127   TWGroupe->resizeRowsToContents();
128   TWGroupe->clearSelection();
129   MESSAGE("Fin de InitGroupes ");
130 }
131