Plugins/ViewManagerPlugins/Tabview/Tabview.py

changeset 4298
4e7a0e2c20fc
parent 4025
ffc69fe3a61d
child 4344
d096b2c767d8
equal deleted inserted replaced
4297:8ece10107224 4298:4e7a0e2c20fc
854 self.editorLineChanged.emit(fn, aw.getCursorPosition()[0] + 1) 854 self.editorLineChanged.emit(fn, aw.getCursorPosition()[0] + 1)
855 else: 855 else:
856 self.changeCaption.emit("") 856 self.changeCaption.emit("")
857 self.editorChangedEd.emit(aw) 857 self.editorChangedEd.emit(aw)
858 858
859 def _addView(self, win, fn=None, noName=""): 859 def _addView(self, win, fn=None, noName="", next=False):
860 """ 860 """
861 Protected method to add a view (i.e. window). 861 Protected method to add a view (i.e. window).
862 862
863 @param win editor assembly to be added 863 @param win editor assembly to be added
864 @param fn filename of this editor (string) 864 @param fn filename of this editor (string)
865 @param noName name to be used for an unnamed editor (string) 865 @param noName name to be used for an unnamed editor (string)
866 @param next flag indicating to add the view next to the current
867 view (bool)
866 """ 868 """
867 editor = win.getEditor() 869 editor = win.getEditor()
868 if fn is None: 870 if fn is None:
869 if not noName: 871 if not noName:
870 self.untitledCount += 1 872 self.untitledCount += 1
871 noName = self.tr("Untitled {0}").format(self.untitledCount) 873 noName = self.tr("Untitled {0}").format(self.untitledCount)
872 self.currentTabWidget.addTab(win, noName) 874 if next:
875 index = self.currentTabWidget.currentIndex() + 1
876 self.currentTabWidget.insertWidget(index, win, noName)
877 else:
878 self.currentTabWidget.addTab(win, noName)
873 editor.setNoName(noName) 879 editor.setNoName(noName)
874 else: 880 else:
875 if self.filenameOnly: 881 if self.filenameOnly:
876 txt = os.path.basename(fn) 882 txt = os.path.basename(fn)
877 else: 883 else:
878 txt = e5App().getObject("Project").getRelativePath(fn) 884 txt = e5App().getObject("Project").getRelativePath(fn)
879 if len(txt) > self.maxFileNameChars: 885 if len(txt) > self.maxFileNameChars:
880 txt = "...{0}".format(txt[-self.maxFileNameChars:]) 886 txt = "...{0}".format(txt[-self.maxFileNameChars:])
881 if not QFileInfo(fn).isWritable(): 887 if not QFileInfo(fn).isWritable():
882 txt = self.tr("{0} (ro)").format(txt) 888 txt = self.tr("{0} (ro)").format(txt)
883 self.currentTabWidget.addTab(win, txt) 889 if next:
890 index = self.currentTabWidget.currentIndex() + 1
891 self.currentTabWidget.insertWidget(index, win, txt)
892 else:
893 self.currentTabWidget.addTab(win, txt)
884 index = self.currentTabWidget.indexOf(win) 894 index = self.currentTabWidget.indexOf(win)
885 self.currentTabWidget.setTabToolTip(index, fn) 895 self.currentTabWidget.setTabToolTip(index, fn)
886 self.currentTabWidget.setCurrentWidget(win) 896 self.currentTabWidget.setCurrentWidget(win)
887 win.show() 897 win.show()
888 editor.setFocus() 898 editor.setFocus()

eric ide

mercurial