Project/ProjectOthersBrowser.py

changeset 500
c3abc7895a01
parent 476
121633976eca
child 501
5c615a85241a
equal deleted inserted replaced
499:622ab17a68d5 500:c3abc7895a01
32 from the project 32 from the project
33 @signal showMenu(string, QMenu) emitted when a menu is about to be shown. The name 33 @signal showMenu(string, QMenu) emitted when a menu is about to be shown. The name
34 of the menu and a reference to the menu are given. 34 of the menu and a reference to the menu are given.
35 """ 35 """
36 sourceFile = pyqtSignal(str) 36 sourceFile = pyqtSignal(str)
37 pixmapFile = pyqtSignal(str)
38 pixmapEditFile = pyqtSignal(str)
39 svgFile = pyqtSignal(str)
40 closeSourceWindow = pyqtSignal(str)
41 showMenu = pyqtSignal(str, QMenu)
37 42
38 def __init__(self, project, parent=None): 43 def __init__(self, project, parent=None):
39 """ 44 """
40 Constructor 45 Constructor
41 46
55 """ contained in the current project. Several actions can be""" 60 """ contained in the current project. Several actions can be"""
56 """ executed via the context menu. The entry which is registered""" 61 """ executed via the context menu. The entry which is registered"""
57 """ in the project is shown in a different colour.</p>""" 62 """ in the project is shown in a different colour.</p>"""
58 )) 63 ))
59 64
60 self.connect(project, SIGNAL("prepareRepopulateItem"), 65 project.prepareRepopulateItem.connect(self._prepareRepopulateItem)
61 self._prepareRepopulateItem) 66 project.completeRepopulateItem.connect(self._completeRepopulateItem)
62 self.connect(project, SIGNAL("completeRepopulateItem"),
63 self._completeRepopulateItem)
64 67
65 def _createPopupMenus(self): 68 def _createPopupMenus(self):
66 """ 69 """
67 Protected overloaded method to generate the popup menu. 70 Protected overloaded method to generate the popup menu.
68 """ 71 """
168 """ 171 """
169 Private slot called by the menu aboutToShow signal. 172 Private slot called by the menu aboutToShow signal.
170 """ 173 """
171 self._showContextMenu(self.menu) 174 self._showContextMenu(self.menu)
172 175
173 self.emit(SIGNAL("showMenu"), "Main", self.menu) 176 self.showMenu.emit("Main", self.menu)
174 177
175 def __showContextMenuMulti(self): 178 def __showContextMenuMulti(self):
176 """ 179 """
177 Private slot called by the multiMenu aboutToShow signal. 180 Private slot called by the multiMenu aboutToShow signal.
178 """ 181 """
179 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu) 182 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu)
180 183
181 self.emit(SIGNAL("showMenu"), "MainMulti", self.multiMenu) 184 self.showMenu.emit("MainMulti", self.multiMenu)
182 185
183 def __showContextMenuBack(self): 186 def __showContextMenuBack(self):
184 """ 187 """
185 Private slot called by the backMenu aboutToShow signal. 188 Private slot called by the backMenu aboutToShow signal.
186 """ 189 """
187 ProjectBaseBrowser._showContextMenuBack(self, self.backMenu) 190 ProjectBaseBrowser._showContextMenuBack(self, self.backMenu)
188 191
189 self.emit(SIGNAL("showMenu"), "MainBack", self.backMenu) 192 self.showMenu.emit("MainBack", self.backMenu)
190 193
191 def _showContextMenu(self, menu): 194 def _showContextMenu(self, menu):
192 """ 195 """
193 Protected slot called before the context menu is shown. 196 Protected slot called before the context menu is shown.
194 197
214 itmList = self.getSelectedItems() 217 itmList = self.getSelectedItems()
215 218
216 for itm in itmList: 219 for itm in itmList:
217 if isinstance(itm, ProjectBrowserFileItem): 220 if isinstance(itm, ProjectBrowserFileItem):
218 if itm.isPixmapFile(): 221 if itm.isPixmapFile():
219 self.emit(SIGNAL('pixmapEditFile'), itm.fileName()) 222 self.pixmapEditFile.emit(itm.fileName())
220 223
221 def _openItem(self): 224 def _openItem(self):
222 """ 225 """
223 Protected slot to handle the open popup menu entry. 226 Protected slot to handle the open popup menu entry.
224 """ 227 """
225 itmList = self.getSelectedItems() 228 itmList = self.getSelectedItems()
226 229
227 for itm in itmList: 230 for itm in itmList:
228 if isinstance(itm, ProjectBrowserFileItem): 231 if isinstance(itm, ProjectBrowserFileItem):
229 if itm.isPixmapFile(): 232 if itm.isPixmapFile():
230 self.emit(SIGNAL('pixmapFile'), itm.fileName()) 233 self.pixmapFile.emit(itm.fileName())
231 elif itm.isSvgFile(): 234 elif itm.isSvgFile():
232 self.emit(SIGNAL('svgFile'), itm.fileName()) 235 self.svgFile.emit(itm.fileName())
233 else: 236 else:
234 type_ = mimetypes.guess_type(itm.fileName())[0] 237 type_ = mimetypes.guess_type(itm.fileName())[0]
235 if type_ is None or type_.split("/")[0] == "text": 238 if type_ is None or type_.split("/")[0] == "text":
236 self.sourceFile.emit(itm.fileName()) 239 self.sourceFile.emit(itm.fileName())
237 else: 240 else:
244 itmList = self.getSelectedItems() 247 itmList = self.getSelectedItems()
245 248
246 for itm in itmList[:]: 249 for itm in itmList[:]:
247 if isinstance(itm, ProjectBrowserFileItem): 250 if isinstance(itm, ProjectBrowserFileItem):
248 fn = itm.fileName() 251 fn = itm.fileName()
249 self.emit(SIGNAL('closeSourceWindow'), fn) 252 self.closeSourceWindow.emit(fn)
250 self.project.removeFile(fn) 253 self.project.removeFile(fn)
251 else: 254 else:
252 dn = itm.dirName() 255 dn = itm.dirName()
253 self.project.removeDirectory(dn) 256 self.project.removeDirectory(dn)
254 257
290 names) 293 names)
291 294
292 if dlg.exec_() == QDialog.Accepted: 295 if dlg.exec_() == QDialog.Accepted:
293 for itm, fn2, fn in zip(items[:], fullNames, names): 296 for itm, fn2, fn in zip(items[:], fullNames, names):
294 if isinstance(itm, ProjectBrowserFileItem): 297 if isinstance(itm, ProjectBrowserFileItem):
295 self.emit(SIGNAL('closeSourceWindow'), fn2) 298 self.closeSourceWindow.emit(fn2)
296 self.project.deleteFile(fn) 299 self.project.deleteFile(fn)
297 elif isinstance(itm, ProjectBrowserDirectoryItem): 300 elif isinstance(itm, ProjectBrowserDirectoryItem):
298 self.project.deleteDirectory(fn2) 301 self.project.deleteDirectory(fn2)
299 302
300 def __refreshItem(self): 303 def __refreshItem(self):

eric ide

mercurial