8397 Public slot to check, if the file needs to be re-read, and refresh it if |
8397 Public slot to check, if the file needs to be re-read, and refresh it if |
8398 needed. |
8398 needed. |
8399 """ |
8399 """ |
8400 if self.__checkExternalModification and self.checkModificationTime(): |
8400 if self.__checkExternalModification and self.checkModificationTime(): |
8401 if Preferences.getEditor("AutoReopen") and not self.isModified(): |
8401 if Preferences.getEditor("AutoReopen") and not self.isModified(): |
8402 self.__refresh() |
8402 self.refresh() |
8403 else: |
8403 else: |
8404 msg = self.tr( |
8404 msg = self.tr( |
8405 """<p>The file <b>{0}</b> has been changed while it""" |
8405 """<p>The file <b>{0}</b> has been changed while it""" |
8406 """ was opened in eric. Reread it?</p>""" |
8406 """ was opened in eric. Reread it?</p>""" |
8407 ).format(self.fileName) |
8407 ).format(self.fileName) |
8418 msg, |
8418 msg, |
8419 icon=EricMessageBox.Warning, |
8419 icon=EricMessageBox.Warning, |
8420 yesDefault=yesDefault, |
8420 yesDefault=yesDefault, |
8421 ) |
8421 ) |
8422 if res: |
8422 if res: |
8423 self.__refresh() |
8423 self.refresh() |
8424 else: |
8424 else: |
8425 # do not prompt for this change again... |
8425 # do not prompt for this change again... |
8426 self.recordModificationTime() |
8426 self.recordModificationTime() |
8427 |
8427 |
8428 def getModificationTime(self): |
8428 def getModificationTime(self): |
8497 return pathlib.Path(filename).stat().st_mtime != self.lastModified |
8497 return pathlib.Path(filename).stat().st_mtime != self.lastModified |
8498 |
8498 |
8499 return False |
8499 return False |
8500 |
8500 |
8501 @pyqtSlot() |
8501 @pyqtSlot() |
8502 def __refresh(self): |
8502 def refresh(self): |
8503 """ |
8503 """ |
8504 Private slot to refresh the editor contents. |
8504 Public slot to refresh the editor contents. |
8505 """ |
8505 """ |
8506 # save cursor position |
8506 # save cursor position |
8507 cline, cindex = self.getCursorPosition() |
8507 cline, cindex = self.getCursorPosition() |
8508 |
8508 |
8509 # save bookmarks and breakpoints and clear them |
8509 # save bookmarks and breakpoints and clear them |