Auto-reload

This is an auto-reload feature. I used it successfully in conjunction with Simpletask Cloudless and BTsync.
But it may have quirks on race conditions.

could solve #92 
i think i will add some debbugging-statements and maybe some tests into it within the next days to really understand what's going on.


Am 06.09.2014 um 18:57 schrieb mNantern:
> In qtodotxt/lib/file.py:
>
> > +
> > +
> > +class FileObserver(QtCore.QFileSystemWatcher):
> > +   def __init__(self, parent, file):
> > +       super().__init__(parent)
> > +       self._file = file
> > +       self.fileChanged.connect(self.fileChangedHandler)
> > +
> > +   @QtCore.Slot(str)
> > +   def fileChangedHandler(self, path):
> > +       self.removePath(path)
> > +       if path == self._file.filename:
> > +           try:
> > +               self.parent().openFileByName(self._file.filename)
> > +           except ErrorLoadingFile:
> > +               pass    # let auto-reload errors pass silently
>
> @funkyfuture <https://github.com/funkyfuture> : I just try the
> auto-reload with QTodoTxt on MacOs and Windows and I always have an
> exception here on Windows:
>
> [Errno 13] Permission denied: 'path to my Dropbox file'
>
> Looks like we try to openFileByName before the file is completely
> written. It happens only when I close or delete a task on Mac. Creating
> or modifying a task is correctly replicated.
> Adding a (ugly) sleep(1) before loading the file works
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/mNantern/QTodoTxt/pull/99/files#r17209393>.
>