E5XML/SessionReader.py

changeset 6052
8b49d3e0b4c8
parent 6048
82ad8ec9548c
child 6352
4bdc6503df81
equal deleted inserted replaced
6051:6e09a9a73cb7 6052:8b49d3e0b4c8
17 17
18 class SessionReader(XMLStreamReaderBase): 18 class SessionReader(XMLStreamReaderBase):
19 """ 19 """
20 Class for reading an XML session file. 20 Class for reading an XML session file.
21 """ 21 """
22 supportedVersions = ["4.3", "4.4", "5.0", "6.0"] 22 supportedVersions = ["4.3", "4.4", "5.0", "6.0", "6.1"]
23 23
24 def __init__(self, device, isGlobal): 24 def __init__(self, device, isGlobal):
25 """ 25 """
26 Constructor 26 Constructor
27 27
28 @param device reference to the I/O device to read from (QIODevice) 28 @param device reference to the I/O device to read from
29 @param isGlobal flag indicating to read the global session (boolean). 29 @type QIODevice
30 @param isGlobal flag indicating to read the global session
31 @type bool
30 """ 32 """
31 XMLStreamReaderBase.__init__(self, device) 33 XMLStreamReaderBase.__init__(self, device)
32 34
33 self.version = "" 35 self.version = ""
34 self.isGlobal = isGlobal 36 self.isGlobal = isGlobal
54 def readXML(self, quiet=False): 56 def readXML(self, quiet=False):
55 """ 57 """
56 Public method to read and parse the XML document. 58 Public method to read and parse the XML document.
57 59
58 @param quiet flag indicating quiet operations. 60 @param quiet flag indicating quiet operations.
59 If this flag is true, no errors are reported. 61 If this flag is true, no errors are reported.
62 @type bool
60 """ 63 """
61 while not self.atEnd(): 64 while not self.atEnd():
62 self.readNext() 65 self.readNext()
63 if self.isStartElement(): 66 if self.isStartElement():
64 if self.name() == "Session": 67 if self.name() == "Session":
90 self.__readDebugInfo() 93 self.__readDebugInfo()
91 elif self.name() == "Bookmarks": 94 elif self.name() == "Bookmarks":
92 self.__readBookmarks() 95 self.__readBookmarks()
93 elif self.name() == "ProjectBrowserStates": 96 elif self.name() == "ProjectBrowserStates":
94 self.__readProjectBrowserStates() 97 self.__readProjectBrowserStates()
98 elif self.name() == "ViewManagerSplits":
99 splitCount = int(self.attribute("count", "0"))
100 orientation = int(self.attribute("orientation", "1"))
101 self.vm.setSplitOrientation(orientation)
102 self.vm.setSplitCount(splitCount)
95 else: 103 else:
96 self.raiseUnexpectedStartTag(self.name()) 104 self.raiseUnexpectedStartTag(self.name())
97 105
98 if not quiet: 106 if not quiet:
99 self.showErrorMessage() 107 self.showErrorMessage()
100 108
101 def __readFilenames(self): 109 def __readFilenames(self):
102 """ 110 """
103 Private method to read the file name infos. 111 Private method to read the file name infos.
104 """ 112 """
113 editorDict = {}
105 while not self.atEnd(): 114 while not self.atEnd():
106 self.readNext() 115 self.readNext()
107 if self.isEndElement() and self.name() == "Filenames": 116 if self.isEndElement() and self.name() == "Filenames":
108 break 117 break
109 118
115 if folds: 124 if folds:
116 folds = [int(f) - 1 for f in folds.split(',')] 125 folds = [int(f) - 1 for f in folds.split(',')]
117 else: 126 else:
118 folds = [] 127 folds = []
119 zoom = int(self.attribute("zoom", "-9999")) 128 zoom = int(self.attribute("zoom", "-9999"))
129 cloned = bool(int(self.attribute("cloned", "0")))
130 splitIndex = int(self.attribute("splitindex", "0"))
131 editorIndex = int(self.attribute("editorindex", "-1"))
120 filename = self.readElementText() 132 filename = self.readElementText()
121 133
122 self.vm.openFiles(filename) 134 if cloned and filename in editorDict:
123 ed = self.vm.getOpenEditor(filename) 135 editor = editorDict[filename]
136 ed = self.vm.newEditorView(
137 filename, editor, editor.getFileType(),
138 indexes=(splitIndex, editorIndex))
139 else:
140 ed = self.vm.openSourceFile(
141 filename, indexes=(splitIndex, editorIndex))
142 editorDict[filename] = ed
124 if ed is not None: 143 if ed is not None:
125 if zoom > -9999: 144 if zoom > -9999:
126 ed.zoomTo(zoom) 145 ed.zoomTo(zoom)
127 if folds: 146 if folds:
128 ed.recolor() 147 ed.recolor()
364 383
365 def __readProjectBrowserState(self, browserName): 384 def __readProjectBrowserState(self, browserName):
366 """ 385 """
367 Private method to read the project browser state info. 386 Private method to read the project browser state info.
368 387
369 @param browserName name of the project browser (string) 388 @param browserName name of the project browser
389 @type str
370 """ 390 """
371 expandedNames = [] 391 expandedNames = []
372 392
373 while not self.atEnd(): 393 while not self.atEnd():
374 self.readNext() 394 self.readNext()

eric ide

mercurial