Salome HOME
Update copyrights 2014.
[modules/jobmanager.git] / src / wrappers / BL_MainWindows_SALOME.cxx
1 // Copyright (C) 2009-2014  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, or (at your option) any later version.
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.h>
22
23 BL::MainWindows_SALOME::MainWindows_SALOME(const QString & module_name) :
24   SalomeApp_Module(module_name)
25 {
26   DEBTRACE("Creating BL::MainWindows_SALOME");
27   _actionId = 190;
28   _currentViewId = -1;
29   _svm = 0;
30 }
31
32 void 
33 BL::MainWindows_SALOME::initialize(SalomeApp_Application * appli)
34 {
35   DEBTRACE("Initialize BL::MainWindows_SALOME");
36   BL_ASSERT(appli);
37   _appli = appli;
38 }
39
40
41 void
42 BL::MainWindows_SALOME::createView()
43 {
44   DEBTRACE("BL::MainWindows_SALOME CreateView");
45   QString vmType = "JobManager View";
46
47   // Get JobManager View Manager
48   _svm = _appli->getViewManager( vmType, true );
49   if (!_svm) {
50     // view manager not found
51     QTextEdit* w = new QTextEdit;
52     _svm = _appli->createViewManager( vmType, w );
53   }
54
55   // Create a view
56   _viewWin = _svm->getActiveView();
57   _viewWin->setClosable( false );
58   _currentViewId = _viewWin->getId();
59   DEBTRACE("End of BL::MainWindows_SALOME CreateView");
60 }
61
62 bool
63 BL::MainWindows_SALOME::restoreViewFocus()
64 {
65   bool result = false;
66   SUIT_ViewWindow* resWnd = 0;
67
68   // Search window
69   QList<SUIT_ViewWindow*> wndlist = _appli->desktop()->windows();
70   SUIT_ViewWindow* wnd;
71   for (int i = 0; i < wndlist.size(); ++i) 
72    {
73     wnd = wndlist.at(i);
74     if (_currentViewId == wnd->getId()) {resWnd = wnd;}
75     if (resWnd) {break;}
76    }
77
78   if (resWnd)
79    {
80     wnd->setFocus();
81     result = true;
82    }
83   return result;
84 }
85
86 QString  
87 BL::MainWindows_SALOME::engineIOR() const
88 {
89   DEBTRACE("Entering in BL::SalomeGui::engineIOR");
90   QString anEngineIOR = SalomeApp_Engine_i::EngineIORForComponent( "JOBMANAGER", true ).c_str();
91   return anEngineIOR;
92 }
93
94 void 
95 BL::MainWindows_SALOME::viewManagers(QStringList& list) const
96 {
97   DEBTRACE("Entering in BL::SalomeGui::viewManagers");
98   if (_svm)
99     list.append(_svm->getType());
100 }
101
102
103 BL::MainWindows_SALOME::~MainWindows_SALOME()
104 {
105   DEBTRACE("Destroying BL::MainWindows_SALOME");
106 }
107
108 QMainWindow * 
109 BL::MainWindows_SALOME::getDockParent()
110 {
111   return _appli->desktop();
112 }
113
114 QMainWindow * 
115 BL::MainWindows_SALOME::getTabParent()
116 {
117   return _viewWin;
118 }
119
120 QAction* 
121 BL::MainWindows_SALOME::createAction(const QString& toolTip,
122                                      const QIcon& icon,
123                                      const QString& menu,
124                                      const QString& status,
125                                      const int accel,
126                                      QObject* parent,
127                                      bool checkable,
128                                      QObject* receiver,
129                                      const char* member,
130                                      const QString & shortCut)
131 {
132   return SalomeApp_Module::createAction(getActionId(), toolTip, icon, menu, status, accel, parent, checkable, receiver, member, shortCut);
133 }
134
135 int
136 BL::MainWindows_SALOME::createTopMenu(const QString & menu_name)
137 {
138   return createMenu(menu_name, -1, -1, 30 );
139 }
140
141 void 
142 BL::MainWindows_SALOME::addActionToMenu(QAction * action, int menu_id)
143 {
144   createMenu(action, menu_id);
145 }