ViewManager/ViewManager.py

changeset 2965
d133c7edd88a
parent 2886
dcaebdef6f4a
child 3013
fe886b7f8f40
equal deleted inserted replaced
2964:84b65fb9e780 2965:d133c7edd88a
265 265
266 def canCascade(self): 266 def canCascade(self):
267 """ 267 """
268 Public method to signal if cascading of managed windows is available. 268 Public method to signal if cascading of managed windows is available.
269 269
270 @return flag indicating cascading of windows is available 270 @ireturn flag indicating cascading of windows is available
271 @exception RuntimeError Not implemented 271 @exception RuntimeError Not implemented
272 """ 272 """
273 raise RuntimeError('Not implemented') 273 raise RuntimeError('Not implemented')
274 274
275 def canTile(self): 275 def canTile(self):
276 """ 276 """
277 Public method to signal if tiling of managed windows is available. 277 Public method to signal if tiling of managed windows is available.
278 278
279 @return flag indicating tiling of windows is available 279 @ireturn flag indicating tiling of windows is available
280 @exception RuntimeError Not implemented 280 @exception RuntimeError Not implemented
281 """ 281 """
282 raise RuntimeError('Not implemented') 282 raise RuntimeError('Not implemented')
283 283
284 def tile(self): 284 def tile(self):
299 299
300 def activeWindow(self): 300 def activeWindow(self):
301 """ 301 """
302 Public method to return the active (i.e. current) window. 302 Public method to return the active (i.e. current) window.
303 303
304 @return reference to the active editor 304 @ireturn reference to the active editor
305 @exception RuntimeError Not implemented 305 @exception RuntimeError Not implemented
306 """ 306 """
307 raise RuntimeError('Not implemented') 307 raise RuntimeError('Not implemented')
308 308
309 def _removeAllViews(self): 309 def _removeAllViews(self):
310 """ 310 """
311 Protected method to remove all views (i.e. windows) 311 Protected method to remove all views (i.e. windows).
312 312
313 @exception RuntimeError Not implemented 313 @exception RuntimeError Not implemented
314 """ 314 """
315 raise RuntimeError('Not implemented') 315 raise RuntimeError('Not implemented')
316 316
317 def _removeView(self, win): 317 def _removeView(self, win):
318 """ 318 """
319 Protected method to remove a view (i.e. window) 319 Protected method to remove a view (i.e. window).
320 320
321 @param win editor window to be removed 321 @param win editor window to be removed
322 @exception RuntimeError Not implemented 322 @exception RuntimeError Not implemented
323 """ 323 """
324 raise RuntimeError('Not implemented') 324 raise RuntimeError('Not implemented')
325 325
326 def _addView(self, win, fn=None, noName=""): 326 def _addView(self, win, fn=None, noName=""):
327 """ 327 """
328 Protected method to add a view (i.e. window) 328 Protected method to add a view (i.e. window).
329 329
330 @param win editor assembly to be added 330 @param win editor assembly to be added
331 @param fn filename of this editor 331 @param fn filename of this editor
332 @param noName name to be used for an unnamed editor (string) 332 @param noName name to be used for an unnamed editor (string)
333 @exception RuntimeError Not implemented 333 @exception RuntimeError Not implemented
334 """ 334 """
335 raise RuntimeError('Not implemented') 335 raise RuntimeError('Not implemented')
336 336
337 def _showView(self, win, fn=None): 337 def _showView(self, win, fn=None):
338 """ 338 """
339 Protected method to show a view (i.e. window) 339 Protected method to show a view (i.e. window).
340 340
341 @param win editor assembly to be shown 341 @param win editor assembly to be shown
342 @param fn filename of this editor 342 @param fn filename of this editor
343 @exception RuntimeError Not implemented 343 @exception RuntimeError Not implemented
344 """ 344 """
722 return tb 722 return tb
723 723
724 def __initContextMenuExporters(self): 724 def __initContextMenuExporters(self):
725 """ 725 """
726 Private method used to setup the Exporters sub menu. 726 Private method used to setup the Exporters sub menu.
727
728 @return reference to the generated menu (QMenu)
727 """ 729 """
728 menu = QMenu(QApplication.translate('ViewManager', "Export as")) 730 menu = QMenu(QApplication.translate('ViewManager', "Export as"))
729 731
730 import QScintilla.Exporters 732 import QScintilla.Exporters
731 supportedExporters = QScintilla.Exporters.getSupportedFormats() 733 supportedExporters = QScintilla.Exporters.getSupportedFormats()
2308 self.editUpperCaseAct.triggered[()].connect(self.esm.map) 2310 self.editUpperCaseAct.triggered[()].connect(self.esm.map)
2309 self.editActions.append(self.editUpperCaseAct) 2311 self.editActions.append(self.editUpperCaseAct)
2310 2312
2311 def initEditMenu(self): 2313 def initEditMenu(self):
2312 """ 2314 """
2313 Public method to create the Edit menu 2315 Public method to create the Edit menu.
2314 2316
2315 @return the generated menu 2317 @return the generated menu
2316 """ 2318 """
2317 autocompletionMenu = \ 2319 autocompletionMenu = \
2318 QMenu(QApplication.translate('ViewManager', '&Autocomplete'), self.ui) 2320 QMenu(QApplication.translate('ViewManager', '&Autocomplete'), self.ui)
2388 2390
2389 return menu 2391 return menu
2390 2392
2391 def initEditToolbar(self, toolbarManager): 2393 def initEditToolbar(self, toolbarManager):
2392 """ 2394 """
2393 Public method to create the Edit toolbar 2395 Public method to create the Edit toolbar.
2394 2396
2395 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager) 2397 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager)
2396 @return the generated toolbar 2398 @return the generated toolbar
2397 """ 2399 """
2398 tb = QToolBar(QApplication.translate('ViewManager', 'Edit'), self.ui) 2400 tb = QToolBar(QApplication.translate('ViewManager', 'Edit'), self.ui)
2771 self.replaceOpenFilesAct.triggered[()].connect(self.__replaceOpenFiles) 2773 self.replaceOpenFilesAct.triggered[()].connect(self.__replaceOpenFiles)
2772 self.searchActions.append(self.replaceOpenFilesAct) 2774 self.searchActions.append(self.replaceOpenFilesAct)
2773 2775
2774 def initSearchToolbars(self, toolbarManager): 2776 def initSearchToolbars(self, toolbarManager):
2775 """ 2777 """
2776 Public method to create the Search toolbars 2778 Public method to create the Search toolbars.
2777 2779
2778 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager) 2780 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager)
2779 @return a tuple of the generated toolbar (search, quicksearch) 2781 @return a tuple of the generated toolbar (search, quicksearch)
2780 """ 2782 """
2781 qtb = QToolBar(QApplication.translate('ViewManager', 'Quicksearch'), self.ui) 2783 qtb = QToolBar(QApplication.translate('ViewManager', 'Quicksearch'), self.ui)
3096 self.prevSplitAct.setEnabled(False) 3098 self.prevSplitAct.setEnabled(False)
3097 self.previewAct.setEnabled(True) 3099 self.previewAct.setEnabled(True)
3098 3100
3099 def initViewMenu(self): 3101 def initViewMenu(self):
3100 """ 3102 """
3101 Public method to create the View menu 3103 Public method to create the View menu.
3102 3104
3103 @return the generated menu 3105 @return the generated menu
3104 """ 3106 """
3105 menu = QMenu(QApplication.translate('ViewManager', '&View'), self.ui) 3107 menu = QMenu(QApplication.translate('ViewManager', '&View'), self.ui)
3106 menu.setTearOffEnabled(True) 3108 menu.setTearOffEnabled(True)
3121 3123
3122 return menu 3124 return menu
3123 3125
3124 def initViewToolbar(self, toolbarManager): 3126 def initViewToolbar(self, toolbarManager):
3125 """ 3127 """
3126 Public method to create the View toolbar 3128 Public method to create the View toolbar.
3127 3129
3128 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager) 3130 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager)
3129 @return the generated toolbar 3131 @return the generated toolbar
3130 """ 3132 """
3131 tb = QToolBar(QApplication.translate('ViewManager', 'View'), self.ui) 3133 tb = QToolBar(QApplication.translate('ViewManager', 'View'), self.ui)
3232 3234
3233 self.macroActGrp.setEnabled(False) 3235 self.macroActGrp.setEnabled(False)
3234 3236
3235 def initMacroMenu(self): 3237 def initMacroMenu(self):
3236 """ 3238 """
3237 Public method to create the Macro menu 3239 Public method to create the Macro menu.
3238 3240
3239 @return the generated menu 3241 @return the generated menu
3240 """ 3242 """
3241 menu = QMenu(QApplication.translate('ViewManager', "&Macros"), self.ui) 3243 menu = QMenu(QApplication.translate('ViewManager', "&Macros"), self.ui)
3242 menu.setTearOffEnabled(True) 3244 menu.setTearOffEnabled(True)
3493 3495
3494 self.bookmarkActGrp.setEnabled(False) 3496 self.bookmarkActGrp.setEnabled(False)
3495 3497
3496 def initBookmarkMenu(self): 3498 def initBookmarkMenu(self):
3497 """ 3499 """
3498 Public method to create the Bookmark menu 3500 Public method to create the Bookmark menu.
3499 3501
3500 @return the generated menu 3502 @return the generated menu
3501 """ 3503 """
3502 menu = QMenu(QApplication.translate('ViewManager', '&Bookmarks'), self.ui) 3504 menu = QMenu(QApplication.translate('ViewManager', '&Bookmarks'), self.ui)
3503 self.bookmarksMenu = QMenu(QApplication.translate('ViewManager', '&Bookmarks'), 3505 self.bookmarksMenu = QMenu(QApplication.translate('ViewManager', '&Bookmarks'),
3533 3535
3534 return menu 3536 return menu
3535 3537
3536 def initBookmarkToolbar(self, toolbarManager): 3538 def initBookmarkToolbar(self, toolbarManager):
3537 """ 3539 """
3538 Public method to create the Bookmark toolbar 3540 Public method to create the Bookmark toolbar.
3539 3541
3540 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager) 3542 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager)
3541 @return the generated toolbar 3543 @return the generated toolbar
3542 """ 3544 """
3543 tb = QToolBar(QApplication.translate('ViewManager', 'Bookmarks'), self.ui) 3545 tb = QToolBar(QApplication.translate('ViewManager', 'Bookmarks'), self.ui)
3626 self.autoSpellCheckAct.setEnabled(spellingAvailable) 3628 self.autoSpellCheckAct.setEnabled(spellingAvailable)
3627 3629
3628 def addToExtrasMenu(self, menu): 3630 def addToExtrasMenu(self, menu):
3629 """ 3631 """
3630 Public method to add some actions to the extras menu. 3632 Public method to add some actions to the extras menu.
3633
3634 @param menu reference to the menu to add actions to (QMenu)
3631 """ 3635 """
3632 self.__editSpellingMenu = QMenu(QApplication.translate('ViewManager', 3636 self.__editSpellingMenu = QMenu(QApplication.translate('ViewManager',
3633 "Edit Dictionary")) 3637 "Edit Dictionary"))
3634 self.__editProjectPwlAct = self.__editSpellingMenu.addAction( 3638 self.__editProjectPwlAct = self.__editSpellingMenu.addAction(
3635 QApplication.translate('ViewManager', "Project Word List"), 3639 QApplication.translate('ViewManager', "Project Word List"),
3651 menu.addMenu(self.__editSpellingMenu) 3655 menu.addMenu(self.__editSpellingMenu)
3652 menu.addSeparator() 3656 menu.addSeparator()
3653 3657
3654 def initSpellingToolbar(self, toolbarManager): 3658 def initSpellingToolbar(self, toolbarManager):
3655 """ 3659 """
3656 Public method to create the Spelling toolbar 3660 Public method to create the Spelling toolbar.
3657 3661
3658 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager) 3662 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager)
3659 @return the generated toolbar 3663 @return the generated toolbar
3660 """ 3664 """
3661 tb = QToolBar(QApplication.translate('ViewManager', 'Spelling'), self.ui) 3665 tb = QToolBar(QApplication.translate('ViewManager', 'Spelling'), self.ui)
3858 @param fn name of file to be opened (string) 3862 @param fn name of file to be opened (string)
3859 @param lineno line number to place the cursor at (integer) 3863 @param lineno line number to place the cursor at (integer)
3860 @param filetype type of the source file (string) 3864 @param filetype type of the source file (string)
3861 @param selStart start of an area to be selected (integer) 3865 @param selStart start of an area to be selected (integer)
3862 @param selEnd end of an area to be selected (integer) 3866 @param selEnd end of an area to be selected (integer)
3867 @param pos position within the line to place the cursor at (integer)
3863 """ 3868 """
3864 try: 3869 try:
3865 newWin, editor = self.getEditor(fn, filetype=filetype) 3870 newWin, editor = self.getEditor(fn, filetype=filetype)
3866 except (IOError, UnicodeDecodeError): 3871 except (IOError, UnicodeDecodeError):
3867 return 3872 return
4600 """ 4605 """
4601 self.activeWindow().unindentLineOrSelection() 4606 self.activeWindow().unindentLineOrSelection()
4602 4607
4603 def __editSmartIndent(self): 4608 def __editSmartIndent(self):
4604 """ 4609 """
4605 Private method to handle the smart indent action 4610 Private method to handle the smart indent action.
4606 """ 4611 """
4607 self.activeWindow().smartIndentLineOrSelection() 4612 self.activeWindow().smartIndentLineOrSelection()
4608 4613
4609 def __editToggleComment(self): 4614 def __editToggleComment(self):
4610 """ 4615 """
4692 self.activeWindow().autoCompleteFromAll() 4697 self.activeWindow().autoCompleteFromAll()
4693 4698
4694 def __editorAutoCompletionAPIsAvailable(self, available): 4699 def __editorAutoCompletionAPIsAvailable(self, available):
4695 """ 4700 """
4696 Private method to handle the availability of API autocompletion signal. 4701 Private method to handle the availability of API autocompletion signal.
4702
4703 @param available flag indicating the availability of API
4704 autocompletion (boolean)
4697 """ 4705 """
4698 self.autoCompleteFromAPIsAct.setEnabled(available) 4706 self.autoCompleteFromAPIsAct.setEnabled(available)
4699 4707
4700 def __editShowCallTips(self): 4708 def __editShowCallTips(self):
4701 """ 4709 """
4707 ## Below are the action and utility methods for the search menu 4715 ## Below are the action and utility methods for the search menu
4708 ################################################################## 4716 ##################################################################
4709 4717
4710 def textForFind(self, getCurrentWord=True): 4718 def textForFind(self, getCurrentWord=True):
4711 """ 4719 """
4712 Public method to determine the selection or the current word for the next 4720 Public method to determine the selection or the current word for the
4713 find operation. 4721 next find operation.
4714 4722
4715 @param getCurrentWord flag indicating to return the current word, if no selected 4723 @param getCurrentWord flag indicating to return the current word, if
4716 text was found (boolean) 4724 no selected text was found (boolean)
4717 @return selection or current word (string) 4725 @return selection or current word (string)
4718 """ 4726 """
4719 aw = self.activeWindow() 4727 aw = self.activeWindow()
4720 if aw is None: 4728 if aw is None:
4721 return "" 4729 return ""
4764 self.quickFindtextCombo.lastActive = self.activeWindow() 4772 self.quickFindtextCombo.lastActive = self.activeWindow()
4765 4773
4766 def __quickSearchEnter(self): 4774 def __quickSearchEnter(self):
4767 """ 4775 """
4768 Private slot to handle the incremental quick search return pressed 4776 Private slot to handle the incremental quick search return pressed
4769 (jump back to text) 4777 (jump back to text).
4770 """ 4778 """
4771 if self.quickFindtextCombo.lastActive: 4779 if self.quickFindtextCombo.lastActive:
4772 self.quickFindtextCombo.lastActive.setFocus() 4780 self.quickFindtextCombo.lastActive.setFocus()
4773 if self.__quickSearchToolbarVisibility is not None: 4781 if self.__quickSearchToolbarVisibility is not None:
4774 self.__quickSearchToolbar.setVisible(self.__quickSearchToolbarVisibility) 4782 self.__quickSearchToolbar.setVisible(self.__quickSearchToolbarVisibility)
4775 self.__quickSearchToolbarVisibility = None 4783 self.__quickSearchToolbarVisibility = None
4776 4784
4777 def __quickSearchEscape(self): 4785 def __quickSearchEscape(self):
4778 """ 4786 """
4779 Private slot to handle the incremental quick search escape pressed 4787 Private slot to handle the incremental quick search escape pressed
4780 (jump back to text) 4788 (jump back to text).
4781 """ 4789 """
4782 if self.quickFindtextCombo.lastActive: 4790 if self.quickFindtextCombo.lastActive:
4783 self.quickFindtextCombo.lastActive.setFocus() 4791 self.quickFindtextCombo.lastActive.setFocus()
4784 aw = self.activeWindow() 4792 aw = self.activeWindow()
4785 if aw and self.quickFindtextCombo.lastCursorPos: 4793 if aw and self.quickFindtextCombo.lastCursorPos:
5135 self.addSplit() 5143 self.addSplit()
5136 5144
5137 def __splitOrientation(self, checked): 5145 def __splitOrientation(self, checked):
5138 """ 5146 """
5139 Private method to handle the split orientation action. 5147 Private method to handle the split orientation action.
5148
5149 @param checked flag indicating the checked state of the action
5150 (boolean). True means splitting horizontally.
5140 """ 5151 """
5141 if checked: 5152 if checked:
5142 self.setSplitOrientation(Qt.Horizontal) 5153 self.setSplitOrientation(Qt.Horizontal)
5143 self.splitViewAct.setIcon( 5154 self.splitViewAct.setIcon(
5144 UI.PixmapCache.getIcon("splitHorizontal.png")) 5155 UI.PixmapCache.getIcon("splitHorizontal.png"))
5495 self.__editSpellingDictionary(pel) 5506 self.__editSpellingDictionary(pel)
5496 5507
5497 def __editSpellingDictionary(self, dictionaryFile): 5508 def __editSpellingDictionary(self, dictionaryFile):
5498 """ 5509 """
5499 Private slot to edit the given spelling dictionary. 5510 Private slot to edit the given spelling dictionary.
5511
5512 @param dictionaryFile file name of the dictionary to edit (string)
5500 """ 5513 """
5501 if os.path.exists(dictionaryFile): 5514 if os.path.exists(dictionaryFile):
5502 try: 5515 try:
5503 f = open(dictionaryFile, "r", encoding="utf-8") 5516 f = open(dictionaryFile, "r", encoding="utf-8")
5504 data = f.read() 5517 data = f.read()
5997 ################################################################## 6010 ##################################################################
5998 6011
5999 def getAPIsManager(self): 6012 def getAPIsManager(self):
6000 """ 6013 """
6001 Public method to get a reference to the APIs manager. 6014 Public method to get a reference to the APIs manager.
6015
6002 @return the APIs manager object (eric5.QScintilla.APIsManager) 6016 @return the APIs manager object (eric5.QScintilla.APIsManager)
6003 """ 6017 """
6004 return self.apisManager 6018 return self.apisManager
6005 6019
6006 ####################################################################### 6020 #######################################################################

eric ide

mercurial