def openFile(self, fileName=None): if fileName == None: # prompt open dialog if filename is not specified fileName = QtGui.QFileDialog.getOpenFileName( self, self.tr("Open Source File"), "", PROJECT_ALIAS + " (*" + USER_CODE_EXT + ");;" "C Source File (*.c);;C++ Source File (*.cpp);;Text File (*.txt);;All files (*.*)" ) if fileName == "": return False #check if it's already opened for i in range(self.count()): child = self.widget(i) if fileName == child.currentFile(): # file already opened self.setCurrentIndex(i) return True child = CppEditor(self, fileName, self.sampleProjects) tabtext = os.path.basename(str(fileName)) if tabtext.lower().find( USER_CODE_EXT) == len(tabtext) - len(USER_CODE_EXT): tabtext = tabtext[:tabtext.lower().find(USER_CODE_EXT)] self.addTab(child, tabtext) self.setCurrentIndex(self.count() - 1) self.setTabToolTip(self.currentIndex(), child.currentFile()) self.Outline.update(child.text()) return True
def openFile(self, fileName=None): if fileName == None: # prompt open dialog if filename is not specified fileName = QtGui.QFileDialog.getOpenFileName( self, self.tr("Open Source File"), "", PROJECT_ALIAS + " (*" + USER_CODE_EXT + ");;" "C Source File (*.c);;C++ Source File (*.cpp);;Text File (*.txt);;All files (*.*)" ) if fileName == "": return False #check if it's already opened for i in range(self.count()): child = self.widget(i) if fileName == child.currentFile(): # file already opened self.setCurrentIndex(i) return True child = CppEditor(self, fileName, self.sampleProjects) tabtext = os.path.basename( str(fileName) ) if tabtext.lower().find(USER_CODE_EXT) == len(tabtext) - len(USER_CODE_EXT): tabtext = tabtext[:tabtext.lower().find(USER_CODE_EXT)] self.addTab(child, tabtext) self.setCurrentIndex(self.count()-1) self.setTabToolTip(self.currentIndex(), child.currentFile()) self.Outline.update(child.text()) return True
def newFile(self): child = CppEditor(self, None, self.sampleProjects) self.addTab(child, PROJECT_NONAME + " * ") self.setCurrentIndex(self.count() - 1) self.setTabToolTip(self.currentIndex(), child.currentFile()) self.Outline.update(child.text())
def newFile(self): child = CppEditor(self, None, self.sampleProjects) self.addTab(child, PROJECT_NONAME + " * ") self.setCurrentIndex(self.count()-1) self.setTabToolTip(self.currentIndex(), child.currentFile()) self.Outline.update(child.text())