mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Import: preview after chosing file, and add seting to Mind Map importer #208
This commit is contained in:
parent
c41f77548a
commit
d3e724ccb0
|
@ -19,8 +19,7 @@ class mindMapImporter(abstractImporter):
|
|||
def isValid(cls):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def startImport(cls, filePath, parentItem, settingsWidget, fromString=None):
|
||||
def startImport(self, filePath, parentItem, settingsWidget, fromString=None):
|
||||
"""
|
||||
Import/export outline cards in mind map free plane.
|
||||
"""
|
||||
|
@ -48,7 +47,7 @@ class mindMapImporter(abstractImporter):
|
|||
items = []
|
||||
|
||||
if node is not None:
|
||||
items.extend(cls.parseItems(node, parentItem))
|
||||
items.extend(self.parseItems(node, parentItem))
|
||||
ret = True
|
||||
|
||||
if not ret:
|
||||
|
@ -61,8 +60,26 @@ class mindMapImporter(abstractImporter):
|
|||
|
||||
return items
|
||||
|
||||
@classmethod
|
||||
def parseItems(cls, underElement, parentItem=None):
|
||||
def settingsWidget(self, widget):
|
||||
"""
|
||||
Takes a QWidget that can be modified and must be returned.
|
||||
"""
|
||||
|
||||
# Add group
|
||||
group = self.addGroup(widget.toolBox.widget(0),
|
||||
qApp.translate("Import", "Mind Map import"))
|
||||
|
||||
self.addSetting("importTipAs", "combo",
|
||||
qApp.translate("Import", "Import tip as:"),
|
||||
vals="Folder|Text",
|
||||
)
|
||||
|
||||
for s in self.settings:
|
||||
self.settings[s].widget(group)
|
||||
|
||||
return widget
|
||||
|
||||
def parseItems(self, underElement, parentItem=None):
|
||||
items = []
|
||||
title = underElement.get('TEXT')
|
||||
if title is not None:
|
||||
|
@ -73,8 +90,8 @@ class mindMapImporter(abstractImporter):
|
|||
children = underElement.findall('node')
|
||||
if children is not None and len(children) > 0:
|
||||
for c in children:
|
||||
items.extend(cls.parseItems(c, item))
|
||||
else:
|
||||
items.extend(self.parseItems(c, item))
|
||||
elif self.getSetting("importTipAs").value() == "Text":
|
||||
item.setData(Outline.type.value, 'md')
|
||||
|
||||
return items
|
||||
|
|
|
@ -130,6 +130,7 @@ class importerDialog(QWidget, Ui_importer):
|
|||
fileName, _ = QFileDialog.getOpenFileName(self, "Import from file", "",
|
||||
F.fileFormat, options=options)
|
||||
self.setFileName(fileName)
|
||||
self.preview()
|
||||
|
||||
def setFileName(self, fileName):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue