QScintilla/Editor.py

changeset 548
ac7af05dd54a
parent 547
cceececd1312
child 549
fe99d46d56c8
equal deleted inserted replaced
547:cceececd1312 548:ac7af05dd54a
2184 QMessageBox.Abort | \ 2184 QMessageBox.Abort | \
2185 QMessageBox.Discard | \ 2185 QMessageBox.Discard | \
2186 QMessageBox.Save), 2186 QMessageBox.Save),
2187 QMessageBox.Save) 2187 QMessageBox.Save)
2188 if res == QMessageBox.Save: 2188 if res == QMessageBox.Save:
2189 ok, newName = self.saveFile() 2189 ok = self.saveFile()
2190 if ok: 2190 if ok:
2191 self.vm.setEditorName(self, newName) 2191 self.vm.setEditorName(self, self.fileName)
2192 return ok 2192 return ok
2193 elif res == QMessageBox.Abort: 2193 elif res == QMessageBox.Abort:
2194 return False 2194 return False
2195 2195
2196 return True 2196 return True
2340 """ 2340 """
2341 Public slot to save the text to a file. 2341 Public slot to save the text to a file.
2342 2342
2343 @param saveas flag indicating a 'save as' action (boolean) 2343 @param saveas flag indicating a 'save as' action (boolean)
2344 @param path directory to save the file in (string) 2344 @param path directory to save the file in (string)
2345 @return tuple of two values (boolean, string) giving a success indicator and 2345 @return flag indicating success (boolean)
2346 the name of the saved file
2347 """ 2346 """
2348 if not saveas and not self.isModified(): 2347 if not saveas and not self.isModified():
2349 return (False, None) # do nothing if text wasn't changed 2348 return False # do nothing if text wasn't changed
2350 2349
2351 newName = None 2350 newName = None
2352 if saveas or self.fileName is None: 2351 if saveas or self.fileName is None:
2353 saveas = True 2352 saveas = True
2354 if not path and self.fileName is not None: 2353 if not path and self.fileName is not None:
2375 self.trUtf8("Save File"), 2374 self.trUtf8("Save File"),
2376 self.trUtf8("<p>The file <b>{0}</b> already exists." 2375 self.trUtf8("<p>The file <b>{0}</b> already exists."
2377 " Overwrite it?</p>").format(fn), 2376 " Overwrite it?</p>").format(fn),
2378 type_ = E5MessageBox.Warning) 2377 type_ = E5MessageBox.Warning)
2379 if not res: 2378 if not res:
2380 return (False, None) 2379 return False
2381 fn = Utilities.toNativeSeparators(fn) 2380 fn = Utilities.toNativeSeparators(fn)
2382 newName = fn 2381 newName = fn
2383 else: 2382 else:
2384 return (False, None) 2383 return False
2385 else: 2384 else:
2386 fn = self.fileName 2385 fn = self.fileName
2387 2386
2388 self.editorAboutToBeSaved.emit(self.fileName) 2387 self.editorAboutToBeSaved.emit(self.fileName)
2389 if self.writeFile(fn): 2388 if self.writeFile(fn):
2404 if newName is not None: 2403 if newName is not None:
2405 self.vm.addToRecentList(newName) 2404 self.vm.addToRecentList(newName)
2406 self.editorSaved.emit(self.fileName) 2405 self.editorSaved.emit(self.fileName)
2407 self.__autoSyntaxCheck() 2406 self.__autoSyntaxCheck()
2408 self.extractTasks() 2407 self.extractTasks()
2409 return (True, self.fileName) 2408 return True
2410 else: 2409 else:
2411 self.lastModified = QFileInfo(fn).lastModified() 2410 self.lastModified = QFileInfo(fn).lastModified()
2412 return (False, None) 2411 return False
2413 2412
2414 def saveFileAs(self, path = None, toProject = False): 2413 def saveFileAs(self, path = None, toProject = False):
2415 """ 2414 """
2416 Public slot to save a file with a new name. 2415 Public slot to save a file with a new name.
2417 2416
3969 3968
3970 def __contextSave(self): 3969 def __contextSave(self):
3971 """ 3970 """
3972 Private slot handling the save context menu entry. 3971 Private slot handling the save context menu entry.
3973 """ 3972 """
3974 ok, newName = self.saveFile() 3973 ok = self.saveFile()
3975 if ok: 3974 if ok:
3976 self.vm.setEditorName(self, newName) 3975 self.vm.setEditorName(self, self.fileName)
3977 3976
3978 def __contextSaveAs(self): 3977 def __contextSaveAs(self):
3979 """ 3978 """
3980 Private slot handling the save as context menu entry. 3979 Private slot handling the save as context menu entry.
3981 """ 3980 """

eric ide

mercurial