Salome HOME
a3fc934326a6484025304841419845b2ee453ba0
[modules/jobmanager.git] / src / wrappers / BL_MainWindows_SALOME.cxx
1 // Copyright (C) 2009-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "BL_MainWindows_SALOME.hxx"
21 #include <SalomeApp_Engine_i.hxx>
22
23 BL::MainWindows_SALOME::MainWindows_SALOME(const QString & module_name) :
24   SalomeApp_Module(module_name),
25   LightApp_Module(module_name)
26 {
27   DEBTRACE("Creating BL::MainWindows_SALOME");
28   _actionId = 190;
29   _currentViewId = -1;
30   _svm = 0;
31 }
32
33 void 
34 BL::MainWindows_SALOME::initialize(SalomeApp_Application * appli)
35 {
36   DEBTRACE("Initialize BL::MainWindows_SALOME");
37   BL_ASSERT(appli);
38   _appli = appli;
39 }
40
41
42 void
43 BL::MainWindows_SALOME::createView()
44 {
45   DEBTRACE("BL::MainWindows_SALOME CreateView");
46   QString vmType = "JobManager View";
47
48   // Get JobManager View Manager
49   _svm = _appli->getViewManager( vmType, true );
50   if (!_svm) {
51     // view manager not found
52     QTextEdit* w = new QTextEdit;
53     _svm = _appli->createViewManager( vmType, w );
54   }
55
56   // Create a view
57   _viewWin = _svm->getActiveView();
58   _viewWin->setClosable( false );
59   _currentViewId = _viewWin->getId();
60   DEBTRACE("End of BL::MainWindows_SALOME CreateView");
61 }
62
63 bool
64 BL::MainWindows_SALOME::restoreViewFocus()
65 {
66   bool result = false;
67   SUIT_ViewWindow* resWnd = 0;
68
69   // Search window
70   QList<SUIT_ViewWindow*> wndlist = _appli->desktop()->windows();
71   SUIT_ViewWindow* wnd;
72   for (int i = 0; i < wndlist.size(); ++i) 
73    {
74     wnd = wndlist.at(i);
75     if (_currentViewId == wnd->getId()) {resWnd = wnd;}
76     if (resWnd) {break;}
77    }
78
79   if (resWnd)
80    {
81     wnd->setFocus();
82     result = true;
83    }
84   return result;
85 }
86
87 QString  
88 BL::MainWindows_SALOME::engineIOR() const
89 {
90   DEBTRACE("Entering in BL::SalomeGui::engineIOR");
91   QString anEngineIOR = SalomeApp_Engine_i::EngineIORForComponent( "JOBMANAGER", true ).c_str();
92   return anEngineIOR;
93 }
94
95 void 
96 BL::MainWindows_SALOME::viewManagers(QStringList& list) const
97 {
98   DEBTRACE("Entering in BL::SalomeGui::viewManagers");
99   if (_svm)
100     list.append(_svm->getType());
101 }
102
103
104 BL::MainWindows_SALOME::~MainWindows_SALOME()
105 {
106   DEBTRACE("Destroying BL::MainWindows_SALOME");
107 }
108
109 QMainWindow * 
110 BL::MainWindows_SALOME::getDockParent()
111 {
112   return _appli->desktop();
113 }
114
115 QMainWindow * 
116 BL::MainWindows_SALOME::getTabParent()
117 {
118   return _viewWin;
119 }
120
121 QAction* 
122 BL::MainWindows_SALOME::createAction(const QString& toolTip,
123                                      const QIcon& icon,
124                                      const QString& menu,
125                                      const QString& status,
126                                      const int accel,
127                                      QObject* parent,
128                                      bool checkable,
129                                      QObject* receiver,
130                                      const char* member,
131                                      const QString & shortCut)
132 {
133   return SalomeApp_Module::createAction(getActionId(), toolTip, icon, menu, status, accel, parent, checkable, receiver, member, shortCut);
134 }
135
136 int
137 BL::MainWindows_SALOME::createTopMenu(const QString & menu_name)
138 {
139   return createMenu(menu_name, -1, -1, 30 );
140 }
141
142 void 
143 BL::MainWindows_SALOME::addActionToMenu(QAction * action, int menu_id)
144 {
145   createMenu(action, menu_id);
146 }