Krita Source Code Documentation
Loading...
Searching...
No Matches
scripter.documentcontroller.DocumentController Class Reference
+ Inheritance diagram for scripter.documentcontroller.DocumentController:

Public Member Functions

 __init__ (self)
 
 activeDocument (self)
 
 clearActiveDocument (self)
 
 openDocument (self, filePath)
 
 saveDocument (self, data, filePath, save_as=False)
 

Protected Attributes

 _activeDocument
 

Detailed Description

Definition at line 9 of file documentcontroller.py.

Constructor & Destructor Documentation

◆ __init__()

scripter.documentcontroller.DocumentController.__init__ ( self)

Definition at line 11 of file documentcontroller.py.

11 def __init__(self):
12 self._activeDocument = None
13

Member Function Documentation

◆ activeDocument()

scripter.documentcontroller.DocumentController.activeDocument ( self)

Definition at line 15 of file documentcontroller.py.

15 def activeDocument(self):
16 return self._activeDocument
17

References scripter.documentcontroller.DocumentController._activeDocument.

◆ clearActiveDocument()

scripter.documentcontroller.DocumentController.clearActiveDocument ( self)

Definition at line 44 of file documentcontroller.py.

44 def clearActiveDocument(self):
45 self._activeDocument = None

References scripter.documentcontroller.DocumentController._activeDocument.

◆ openDocument()

scripter.documentcontroller.DocumentController.openDocument ( self,
filePath )

Definition at line 18 of file documentcontroller.py.

18 def openDocument(self, filePath):
19 if filePath:
20 newDocument = document.Document(filePath)
21 newDocument.open()
22 self._activeDocument = newDocument
23 return newDocument
24

References scripter.documentcontroller.DocumentController._activeDocument.

◆ saveDocument()

scripter.documentcontroller.DocumentController.saveDocument ( self,
data,
filePath,
save_as = False )
data - data to be written
filePath - file path to write data to
save_as = boolean, is this call made from save_as functionality. If so, do not compare data
against existing document before save.

Definition at line 25 of file documentcontroller.py.

25 def saveDocument(self, data, filePath, save_as=False):
26 """
27 data - data to be written
28 filePath - file path to write data to
29 save_as = boolean, is this call made from save_as functionality. If so, do not compare data
30 against existing document before save.
31 """
32
33 if save_as or not self._activeDocument:
34 self._activeDocument = document.Document(filePath)
35
36 text = str(data)
37 if save_as or not self._activeDocument.compare(text):
38 # compare is not evaluated if save_as is True
39 self._activeDocument.data = text
40 self._activeDocument.save()
41
42 return self._activeDocument
43

References scripter.documentcontroller.DocumentController._activeDocument.

Member Data Documentation

◆ _activeDocument

scripter.documentcontroller.DocumentController._activeDocument
protected

Definition at line 12 of file documentcontroller.py.


The documentation for this class was generated from the following file: