ViewManager/ViewManager.py

changeset 5588
6ba512d9f46a
parent 5389
9b1c800daff3
child 5674
a0ad2dcb27f9
equal deleted inserted replaced
5587:ea526b78ee6c 5588:6ba512d9f46a
382 @param win editor window to be removed 382 @param win editor window to be removed
383 @exception RuntimeError Not implemented 383 @exception RuntimeError Not implemented
384 """ 384 """
385 raise RuntimeError('Not implemented') 385 raise RuntimeError('Not implemented')
386 386
387 def _addView(self, win, fn=None, noName="", next=False): 387 def _addView(self, win, fn=None, noName="", addNext=False):
388 """ 388 """
389 Protected method to add a view (i.e. window). 389 Protected method to add a view (i.e. window).
390 390
391 @param win editor assembly to be added 391 @param win editor assembly to be added
392 @param fn filename of this editor 392 @param fn filename of this editor
393 @param noName name to be used for an unnamed editor (string) 393 @param noName name to be used for an unnamed editor (string)
394 @param next flag indicating to add the view next to the current 394 @param addNext flag indicating to add the view next to the current
395 view (bool) 395 view (bool)
396 @exception RuntimeError Not implemented 396 @exception RuntimeError Not implemented
397 """ 397 """
398 raise RuntimeError('Not implemented') 398 raise RuntimeError('Not implemented')
399 399
507 """ 507 """
508 Public slot used to move to the previous split. 508 Public slot used to move to the previous split.
509 """ 509 """
510 pass 510 pass
511 511
512 def eventFilter(self, object, event): 512 def eventFilter(self, qobject, event):
513 """ 513 """
514 Public method called to filter an event. 514 Public method called to filter an event.
515 515
516 @param object object, that generated the event (QObject) 516 @param qobject object, that generated the event (QObject)
517 @param event the event, that was generated by object (QEvent) 517 @param event the event, that was generated by object (QEvent)
518 @return flag indicating if event was filtered out 518 @return flag indicating if event was filtered out
519 """ 519 """
520 return False 520 return False
521 521
4259 # set the cwd of the dialog based on the following search criteria: 4259 # set the cwd of the dialog based on the following search criteria:
4260 # 1: Directory of currently active editor 4260 # 1: Directory of currently active editor
4261 # 2: Directory of currently active project 4261 # 2: Directory of currently active project
4262 # 3: CWD 4262 # 3: CWD
4263 import QScintilla.Lexers 4263 import QScintilla.Lexers
4264 filter = self._getOpenFileFilter() 4264 fileFilter = self._getOpenFileFilter()
4265 progs = E5FileDialog.getOpenFileNamesAndFilter( 4265 progs = E5FileDialog.getOpenFileNamesAndFilter(
4266 self.ui, 4266 self.ui,
4267 QCoreApplication.translate('ViewManager', "Open files"), 4267 QCoreApplication.translate('ViewManager', "Open files"),
4268 self._getOpenStartDir(), 4268 self._getOpenStartDir(),
4269 QScintilla.Lexers.getOpenFileFiltersList(True, True), 4269 QScintilla.Lexers.getOpenFileFiltersList(True, True),
4270 filter)[0] 4270 fileFilter)[0]
4271 for prog in progs: 4271 for prog in progs:
4272 self.openFiles(prog) 4272 self.openFiles(prog)
4273 4273
4274 def openFiles(self, prog): 4274 def openFiles(self, prog):
4275 """ 4275 """
4430 editor.refreshCoverageAnnotations() 4430 editor.refreshCoverageAnnotations()
4431 4431
4432 self.__setSbFile() 4432 self.__setSbFile()
4433 4433
4434 def openSourceFile(self, fn, lineno=-1, filetype="", 4434 def openSourceFile(self, fn, lineno=-1, filetype="",
4435 selStart=0, selEnd=0, pos=0, next=False): 4435 selStart=0, selEnd=0, pos=0, addNext=False):
4436 """ 4436 """
4437 Public slot to display a file in an editor. 4437 Public slot to display a file in an editor.
4438 4438
4439 @param fn name of file to be opened (string) 4439 @param fn name of file to be opened (string)
4440 @param lineno line number to place the cursor at (integer) or 4440 @param lineno line number to place the cursor at (integer) or
4442 placed at the next line greater than the current one) 4442 placed at the next line greater than the current one)
4443 @param filetype type of the source file (string) 4443 @param filetype type of the source file (string)
4444 @param selStart start of an area to be selected (integer) 4444 @param selStart start of an area to be selected (integer)
4445 @param selEnd end of an area to be selected (integer) 4445 @param selEnd end of an area to be selected (integer)
4446 @param pos position within the line to place the cursor at (integer) 4446 @param pos position within the line to place the cursor at (integer)
4447 @param next flag indicating to add the file next to the current 4447 @param addNext flag indicating to add the file next to the current
4448 editor (bool) 4448 editor (bool)
4449 """ 4449 """
4450 try: 4450 try:
4451 newWin, editor = self.getEditor(fn, filetype=filetype, next=next) 4451 newWin, editor = self.getEditor(fn, filetype=filetype,
4452 addNext=addNext)
4452 except (IOError, UnicodeDecodeError): 4453 except (IOError, UnicodeDecodeError):
4453 return 4454 return
4454 4455
4455 if newWin: 4456 if newWin:
4456 self._modificationStatusChanged(editor.isModified(), editor) 4457 self._modificationStatusChanged(editor.isModified(), editor)
4731 # only return names of existing files 4732 # only return names of existing files
4732 filenames.append(fn) 4733 filenames.append(fn)
4733 4734
4734 return filenames 4735 return filenames
4735 4736
4736 def getEditor(self, fn, filetype="", next=False): 4737 def getEditor(self, fn, filetype="", addNext=False):
4737 """ 4738 """
4738 Public method to return the editor displaying the given file. 4739 Public method to return the editor displaying the given file.
4739 4740
4740 If there is no editor with the given file, a new editor window is 4741 If there is no editor with the given file, a new editor window is
4741 created. 4742 created.
4742 4743
4743 @param fn filename to look for 4744 @param fn filename to look for
4744 @param filetype type of the source file (string) 4745 @param filetype type of the source file (string)
4745 @param next flag indicating that if a new editor needs to be created, 4746 @param addNext flag indicating that if a new editor needs to be
4746 it should be added next to the current editor (bool) 4747 created, it should be added next to the current editor (bool)
4747 @return tuple of two values giving a flag indicating a new window 4748 @return tuple of two values giving a flag indicating a new window
4748 creation and a reference to the editor displaying this file 4749 creation and a reference to the editor displaying this file
4749 """ 4750 """
4750 newWin = False 4751 newWin = False
4751 editor = self.activeWindow() 4752 editor = self.activeWindow()
4765 self.editorOpened.emit(fn) 4766 self.editorOpened.emit(fn)
4766 self.editorOpenedEd.emit(editor) 4767 self.editorOpenedEd.emit(editor)
4767 newWin = True 4768 newWin = True
4768 4769
4769 if newWin: 4770 if newWin:
4770 self._addView(assembly, fn, next=next) 4771 self._addView(assembly, fn, addNext=addNext)
4771 else: 4772 else:
4772 self._showView(editor.parent(), fn) 4773 self._showView(editor.parent(), fn)
4773 4774
4774 return (newWin, editor) 4775 return (newWin, editor)
4775 4776
6607 6608
6608 @param editor editor that sent the signal 6609 @param editor editor that sent the signal
6609 """ 6610 """
6610 self.breakpointToggled.emit(editor) 6611 self.breakpointToggled.emit(editor)
6611 6612
6612 def getActions(self, type): 6613 def getActions(self, actionSetType):
6613 """ 6614 """
6614 Public method to get a list of all actions. 6615 Public method to get a list of all actions.
6615 6616
6616 @param type string denoting the action set to get. 6617 @param actionSetType string denoting the action set to get.
6617 It must be one of "edit", "file", "search", 6618 It must be one of "edit", "file", "search", "view", "window",
6618 "view", "window", "macro", "bookmark" or 6619 "macro", "bookmark" or "spelling".
6619 "spelling".
6620 @return list of all actions (list of E5Action) 6620 @return list of all actions (list of E5Action)
6621 """ 6621 """
6622 try: 6622 try:
6623 return self.__actions[type][:] 6623 return self.__actions[actionSetType][:]
6624 except KeyError: 6624 except KeyError:
6625 return [] 6625 return []
6626 6626
6627 def __editorCommand(self, cmd): 6627 def __editorCommand(self, cmd):
6628 """ 6628 """
6793 project.getHash(), 6793 project.getHash(),
6794 project.getRelativeUniversalPath(fileName), 6794 project.getRelativeUniversalPath(fileName),
6795 message 6795 message
6796 ) 6796 )
6797 6797
6798 def receive(self, hash, fileName, command): 6798 def receive(self, projectHash, fileName, command):
6799 """ 6799 """
6800 Public slot to handle received editor commands. 6800 Public slot to handle received editor commands.
6801 6801
6802 @param hash hash of the project (string) 6802 @param projectHash hash of the project (string)
6803 @param fileName project relative file name of the editor (string) 6803 @param fileName project relative file name of the editor (string)
6804 @param command command string (string) 6804 @param command command string (string)
6805 """ 6805 """
6806 project = e5App().getObject("Project") 6806 project = e5App().getObject("Project")
6807 if hash == project.getHash(): 6807 if projectHash == project.getHash():
6808 fn = project.getAbsoluteUniversalPath(fileName) 6808 fn = project.getAbsoluteUniversalPath(fileName)
6809 editor = self.getOpenEditor(fn) 6809 editor = self.getOpenEditor(fn)
6810 if editor: 6810 if editor:
6811 editor.receive(command) 6811 editor.receive(command)
6812 6812

eric ide

mercurial