231 |
231 |
232 file = QFile(fileName) |
232 file = QFile(fileName) |
233 if not file.open(QFile.WriteOnly): |
233 if not file.open(QFile.WriteOnly): |
234 E5MessageBox.warning( |
234 E5MessageBox.warning( |
235 self, self.trUtf8("Save Snapshot"), |
235 self, self.trUtf8("Save Snapshot"), |
236 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
236 self.trUtf8("Cannot write file '{0}:\n{1}.") |
237 .format(fileName, file.errorString())) |
237 .format(fileName, file.errorString())) |
238 return False |
238 return False |
239 |
239 |
240 ok = self.__snapshot.save(file) |
240 ok = self.__snapshot.save(file) |
241 file.close() |
241 file.close() |
242 |
242 |
243 if not ok: |
243 if not ok: |
244 E5MessageBox.warning( |
244 E5MessageBox.warning( |
245 self, self.trUtf8("Save Snapshot"), |
245 self, self.trUtf8("Save Snapshot"), |
246 self.trUtf8("Cannot write file '{0}:\n{1}.")\ |
246 self.trUtf8("Cannot write file '{0}:\n{1}.") |
247 .format(fileName, file.errorString())) |
247 .format(fileName, file.errorString())) |
248 |
248 |
249 return ok |
249 return ok |
250 |
250 |
251 def __autoIncFilename(self): |
251 def __autoIncFilename(self): |
252 """ |
252 """ |
254 """ |
254 """ |
255 # Extract the file name |
255 # Extract the file name |
256 name = os.path.basename(self.__filename) |
256 name = os.path.basename(self.__filename) |
257 |
257 |
258 # If the name contains a number, then increment it. |
258 # If the name contains a number, then increment it. |
259 numSearch = QRegExp("(^|[^\\d])(\\d+)") |
259 numSearch = QRegExp("(^|[^\\d])(\\d+)") |
260 # We want to match as far left as possible, and when the number is |
260 # We want to match as far left as possible, and when the number is |
261 # at the start of the name. |
261 # at the start of the name. |
262 |
262 |
263 # Does it have a number? |
263 # Does it have a number? |
264 start = numSearch.lastIndexIn(name) |
264 start = numSearch.lastIndexIn(name) |
485 self, |
485 self, |
486 self.trUtf8("eric5 Snapshot"), |
486 self.trUtf8("eric5 Snapshot"), |
487 self.trUtf8( |
487 self.trUtf8( |
488 """The application contains an unsaved snapshot."""), |
488 """The application contains an unsaved snapshot."""), |
489 E5MessageBox.StandardButtons( |
489 E5MessageBox.StandardButtons( |
490 E5MessageBox.Abort | \ |
490 E5MessageBox.Abort | |
491 E5MessageBox.Discard | \ |
491 E5MessageBox.Discard | |
492 E5MessageBox.Save)) |
492 E5MessageBox.Save)) |
493 if res == E5MessageBox.Abort: |
493 if res == E5MessageBox.Abort: |
494 evt.ignore() |
494 evt.ignore() |
495 return |
495 return |
496 elif res == E5MessageBox.Save: |
496 elif res == E5MessageBox.Save: |