1 # Copyright (C) 2006-2021 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from . import browser_session
22 from . import browser_catalog
25 class CatalogTool(QMainWindow):
28 Main window of Catalog Tool
30 def __init__(self,parent=None):
31 QMainWindow.__init__(self,parent)
38 cata=pilot.getRuntime().getBuiltinCatalog()
39 self.register(cata,"Builtin Catalog")
41 def createWidgets(self):
42 self.tabWidget = QTabWidget(self)
43 #self.currentPanel=None
44 #self.connect(self.tabWidget, SIGNAL('currentChanged(QWidget *)'),self.handlePanelChanged)
45 self.setCentralWidget(self.tabWidget)
48 def initActions(self):
50 self.impSessionAct=QAction('Import from session...',0,self)
51 self.impSessionAct.connect(self.impSessionAct,SIGNAL('activated()'), self.importFromSession)
52 self.actions.append(self.impSessionAct)
53 self.impProcAct=QAction('Import from proc...',0,self)
54 self.impProcAct.connect(self.impProcAct,SIGNAL('activated()'), self.importFromProc)
55 self.actions.append(self.impProcAct)
58 menubar = self.menuBar()
61 self.importMenu=QPopupMenu(self)
62 self.impSessionAct.addTo(self.importMenu)
63 self.impProcAct.addTo(self.importMenu)
64 menubar.insertItem('&Import',self.importMenu)
66 def importFromSession(self):
67 browser_session.MainBrowser(self,self.appli).show()
70 def importFromProc(self):
71 fn = QFileDialog.getOpenFileName(QString.null,QString.null,self)
73 self.statusBar().message('Loading aborted',2000)
76 cata=pilot.getRuntime().loadCatalog("proc",filename)
79 for name,node in list(cata._nodeMap.items()):
81 self.register(cata,filename)
83 def register(self,cata,name):
84 """Add a catalog in the catalog tool list"""
85 panel=browser_catalog.Browser(self,appli=self.appli)
87 self.tabWidget.addTab( panel,name)
88 self.tabWidget.showPage(panel)
90 def initToolbar(self):
92 #self.importAct.addTo(tb)
94 #self.toolbars['Import']=tb
96 def initStatusbar(self):
98 self.SBfile=QLabel(sb)
99 sb.addWidget(self.SBfile)
100 QWhatsThis.add(self.SBfile, """<p>Message""")
101 self.SBfile.setText("")