コード例 #1
0
ファイル: document.py プロジェクト: EdwardBetts/frescobaldi
 def load(self, url=None, encoding=None, keepUndo=False):
     """Load the specified or current url (if None was specified).
     
     Currently only local files are supported. An IOError is raised
     when trying to load a nonlocal URL.
     
     If loading succeeds and an url was specified, the url is make the
     current url (by calling setUrl() internally).
     
     If keepUndo is True, the loading can be undone (with Ctrl-Z).
     
     """
     if url is None:
         url = QUrl()
     u = url if not url.isEmpty() else self.url()
     text = self.load_data(u, encoding or self._encoding)
     if keepUndo:
         c = QTextCursor(self)
         c.select(QTextCursor.Document)
         c.insertText(text)
     else:
         self.setPlainText(text)
     self.setModified(False)
     if not url.isEmpty():
         self.setUrl(url)
     self.loaded()
     app.documentLoaded(self)
コード例 #2
0
ファイル: document.py プロジェクト: mamoch/frescobaldi
 def load(self, url=None, encoding=None, keepUndo=False):
     """Load the specified or current url (if None was specified).
     
     Currently only local files are supported. An IOError is raised
     when trying to load a nonlocal URL.
     
     If loading succeeds and an url was specified, the url is make the
     current url (by calling setUrl() internally).
     
     If keepUndo is True, the loading can be undone (with Ctrl-Z).
     
     """
     if url is None:
         url = QUrl()
     u = url if not url.isEmpty() else self.url()
     text = self.load_data(u, encoding or self._encoding)
     if keepUndo:
         c = QTextCursor(self)
         c.select(QTextCursor.Document)
         c.insertText(text)
     else:
         self.setPlainText(text)
     self.setModified(False)
     if not url.isEmpty():
         self.setUrl(url)
     self.loaded()
     app.documentLoaded(self)
コード例 #3
0
ファイル: document.py プロジェクト: WedgeLeft/frescobaldi
 def load(self, keepUndo=False):
     """Loads the current url.
     
     Returns True if loading succeeded, False if an error occurred,
     and None when the current url is empty or non-local.
     Currently only local files are supported.
     
     If keepUndo is True, the loading can be undone (with Ctrl-Z).
     
     """
     fileName = self.url().toLocalFile()
     if fileName:
         try:
             with open(fileName) as f:
                 data = f.read()
         except (IOError, OSError):
             return False # errors are caught in MainWindow.openUrl()
         text = util.decode(data)
         if keepUndo:
             c = QTextCursor(self)
             c.select(QTextCursor.Document)
             c.insertText(text)
         else:
             self.setPlainText(text)
         self.setModified(False)
         self.loaded()
         app.documentLoaded(self)
         return True
コード例 #4
0
 def load(self, keepUndo=False):
     """Loads the current url.
     
     Returns True if loading succeeded, False if an error occurred,
     and None when the current url is empty or non-local.
     Currently only local files are supported.
     
     If keepUndo is True, the loading can be undone (with Ctrl-Z).
     
     """
     fileName = self.url().toLocalFile()
     if fileName:
         try:
             with open(fileName) as f:
                 data = f.read()
         except (IOError, OSError):
             return False # errors are caught in MainWindow.openUrl()
         text = util.decode(data)
         if keepUndo:
             c = QTextCursor(self)
             c.select(QTextCursor.Document)
             c.insertText(text)
         else:
             self.setPlainText(text)
         self.setModified(False)
         self.loaded()
         app.documentLoaded(self)
         return True
コード例 #5
0
ファイル: document.py プロジェクト: cognot/frescobaldi
 def new_from_url(cls, url, encoding=None):
     """Create and return a new document, loaded from url.
     
     This is intended to open a new Document without instantiating one
     if loading the contents fails.
     
     """
     text = cls.load_data(url, encoding)
     d = cls(url, encoding)
     d.setPlainText(text)
     d.setModified(False)
     d.loaded()
     app.documentLoaded(d)
     return d
コード例 #6
0
ファイル: document.py プロジェクト: EdwardBetts/frescobaldi
 def new_from_url(cls, url, encoding=None):
     """Create and return a new document, loaded from url.
     
     This is intended to open a new Document without instantiating one
     if loading the contents fails.
     
     """
     if not url.isEmpty():
         text = cls.load_data(url, encoding)
     d = cls(url, encoding)
     if not url.isEmpty():
         d.setPlainText(text)
         d.setModified(False)
         d.loaded()
         app.documentLoaded(d)
     return d
コード例 #7
0
ファイル: document.py プロジェクト: aspiers/frescobaldi
 def load(self):
     """Loads the current url.
     
     Returns True if loading succeeded, False if an error occurred,
     and None when the current url is empty or non-local.
     Currently only local files are supported.
     
     """
     fileName = self.url().toLocalFile()
     if fileName:
         try:
             with open(fileName) as f:
                 data = f.read()
         except (IOError, OSError):
             return False # errors are caught in MainWindow.openUrl()
         
         self.setPlainText(util.decode(data))
         self.setModified(False)
         self.loaded()
         app.documentLoaded(self)
         return True
コード例 #8
0
 def load(self, url=None, encoding=None, keepUndo=False):
     super(EditorDocument, self).load(url, encoding, keepUndo)
     self.loaded()
     app.documentLoaded(self)
コード例 #9
0
 def new_from_url(cls, url, encoding=None):
     d = super(EditorDocument, cls).new_from_url(url, encoding)
     if not url.isEmpty():
         d.loaded()
         app.documentLoaded(d)
     return d
コード例 #10
0
ファイル: document.py プロジェクト: 19joho66/frescobaldi
 def load(self, url=None, encoding=None, keepUndo=False):
     super(EditorDocument, self).load(url, encoding, keepUndo)
     self.loaded()
     app.documentLoaded(self)
コード例 #11
0
ファイル: document.py プロジェクト: 19joho66/frescobaldi
 def new_from_url(cls, url, encoding=None):
     d = super(EditorDocument, cls).new_from_url(url, encoding)
     if not url.isEmpty():
         d.loaded()
         app.documentLoaded(d)
     return d