--- a/ViewManager/ViewManager.py Thu Jan 18 11:10:57 2018 +0100 +++ b/ViewManager/ViewManager.py Thu Jan 18 18:57:40 2018 +0100 @@ -11,7 +11,7 @@ import os -from PyQt5.QtCore import pyqtSignal, QSignalMapper, QTimer, \ +from PyQt5.QtCore import pyqtSignal, pyqtSlot, QSignalMapper, QTimer, \ QFileInfo, QRegExp, Qt, QCoreApplication from PyQt5.QtGui import QColor, QKeySequence, QPalette, QPixmap from PyQt5.QtWidgets import QLineEdit, QToolBar, QWidgetAction, QDialog, \ @@ -383,15 +383,22 @@ """ raise RuntimeError('Not implemented') - def _addView(self, win, fn=None, noName="", addNext=False): + def _addView(self, win, fn=None, noName="", addNext=False, indexes=None): """ Protected method to add a view (i.e. window). @param win editor assembly to be added + @type EditorAssembly @param fn filename of this editor - @param noName name to be used for an unnamed editor (string) + @type str + @param noName name to be used for an unnamed editor + @type str @param addNext flag indicating to add the view next to the current - view (bool) + view + @type bool + @param indexes of the editor, first the split view index, second the + index within the view + @type tuple of two int @exception RuntimeError Not implemented """ raise RuntimeError('Not implemented') @@ -471,14 +478,38 @@ """ pass - def removeSplit(self): - """ - Public method used to remove the current split view. - - @return Flag indicating successful deletion + @pyqtSlot() + def removeSplit(self, index=-1): + """ + Public method used to remove the current split view or a split view + by index. + + @param index index of the split to be removed (-1 means to + delete the current split) + @type int + @return flag indicating successful deletion + @rtype bool """ return False + def splitCount(self): + """ + Public method to get the number of split views. + + @return number of split views + @rtype int + """ + return 0 + + def setSplitCount(self, count): + """ + Public method to set the number of split views. + + @param count number of split views + @type int + """ + pass + def getSplitOrientation(self): """ Public method to get the orientation of the split view. @@ -4537,24 +4568,37 @@ self.__setSbFile() def openSourceFile(self, fn, lineno=-1, filetype="", - selStart=0, selEnd=0, pos=0, addNext=False): + selStart=0, selEnd=0, pos=0, addNext=False, + indexes=None): """ Public slot to display a file in an editor. - @param fn name of file to be opened (string) - @param lineno line number to place the cursor at (integer) or - list of line numbers (list of integers) (cursor will be - placed at the next line greater than the current one) - @param filetype type of the source file (string) - @param selStart start of an area to be selected (integer) - @param selEnd end of an area to be selected (integer) - @param pos position within the line to place the cursor at (integer) + @param fn name of file to be opened + @type str + @param lineno line number to place the cursor at or list of line + numbers (cursor will be placed at the next line greater than + the current one) + @type int or list of int + @param filetype type of the source file + @type str + @param selStart start of an area to be selected + @type int + @param selEnd end of an area to be selected + @type int + @param pos position within the line to place the cursor at + @type int @param addNext flag indicating to add the file next to the current - editor (bool) + editor + @type bool + @param indexes of the editor, first the split view index, second the + index within the view + @type tuple of two int + @return reference to the opened editor + @rtype Editor """ try: newWin, editor = self.getEditor(fn, filetype=filetype, - addNext=addNext) + addNext=addNext, indexes=indexes) except (IOError, UnicodeDecodeError): return @@ -4588,6 +4632,8 @@ # insert filename into list of recently opened files self.addToRecentList(fn) + return editor + def __connectEditor(self, editor): """ Private method to establish all editor connections. @@ -4623,19 +4669,29 @@ lambda: self.editorLanguageChanged.emit(editor)) editor.textChanged.connect(lambda: self.editorTextChanged.emit(editor)) - def newEditorView(self, fn, caller, filetype=""): + def newEditorView(self, fn, caller, filetype="", indexes=None): """ Public method to create a new editor displaying the given document. @param fn filename of this view + @type str @param caller reference to the editor calling this method - @param filetype type of the source file (string) + @type Editor + @param filetype type of the source file + @type str + @param indexes of the editor, first the split view index, second the + index within the view + @type tuple of two int + @return reference to the new editor object + @rtype Editor """ editor, assembly = self.cloneEditor(caller, filetype, fn) - self._addView(assembly, fn, caller.getNoName()) + self._addView(assembly, fn, caller.getNoName(), indexes=indexes) self._modificationStatusChanged(editor.isModified(), editor) self._checkActions(editor) + + return editor def cloneEditor(self, caller, filetype, fn): """ @@ -4839,7 +4895,7 @@ return filenames - def getEditor(self, fn, filetype="", addNext=False): + def getEditor(self, fn, filetype="", addNext=False, indexes=None): """ Public method to return the editor displaying the given file. @@ -4847,11 +4903,18 @@ created. @param fn filename to look for - @param filetype type of the source file (string) + @type str + @param filetype type of the source file + @type str @param addNext flag indicating that if a new editor needs to be - created, it should be added next to the current editor (bool) + created, it should be added next to the current editor + @type bool + @param indexes of the editor, first the split view index, second the + index within the view + @type tuple of two int @return tuple of two values giving a flag indicating a new window creation and a reference to the editor displaying this file + @rtype tuple of (bool, Editor) """ newWin = False editor = self.activeWindow() @@ -4873,7 +4936,7 @@ newWin = True if newWin: - self._addView(assembly, fn, addNext=addNext) + self._addView(assembly, fn, addNext=addNext, indexes=indexes) else: self._showView(editor.parent(), fn) @@ -4923,6 +4986,20 @@ count += 1 return count + def getOpenEditorsForSession(self): + """ + Public method to get a lists of all open editors. + + The returned list contains one list per split view. If the view manager + cannot split the view, only one list of editors is returned. + + Note: This method should be implemented by subclasses. + + @return list of list of editor references + @rtype list of list of Editor + """ + return [self.editors] + def getActiveName(self): """ Public method to retrieve the filename of the active window.