Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xmind/core/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
TAG_TITLE = "title"
TAG_POSITION = "position"
TAG_CHILDREN = "children"
TAG_LABELS = "labels"
TAG_NOTES = "notes"
TAG_RELATIONSHIP = "relationship"
TAG_RELATIONSHIPS = "relationships"
Expand Down Expand Up @@ -75,3 +76,4 @@

HTML_FORMAT_NOTE = "html"
PLAIN_FORMAT_NOTE = "plain"
LABEL = "label"
71 changes: 71 additions & 0 deletions xmind/core/labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

"""
xmind.core.notes
~~~~~~~~~~~~~~~~

:copyright:
:license:

"""

__author__ = "aiqi@xmind.net <Woody Ai>"

from . import const

from .mixin import TopicMixinElement


class LabelsElement(TopicMixinElement):
TAG_NAME = const.TAG_LABELS

def __init__(self, node=None, ownerTopic=None):
super(LabelsElement, self).__init__(node, ownerTopic)

def getContent(self):
""" Get notes content

"""

content = self.getFirstChildNodeByTagName(const.TAG_LABEL)

if not content:
return

return content.getTextContent()


class _LabelContentElement(TopicMixinElement):
def __init__(self, node=None, ownerTopic=None):
super(_LabelContentElement, self).__init__(node, ownerTopic)

def getFormat(self):
return self.getImplementation().tagName


class Labels(_LabelContentElement):
""" text notes

:param content: utf8 plain text.
:param node: `xml.dom.Element` object`
:param ownerTopic: `xmind.core.topic.TopicElement` object

"""

TAG_NAME = const.LABEL

def __init__(self, content=None, node=None, ownerTopic=None):
super(Labels, self).__init__(node, ownerTopic)
if content is not None:
self.setTextContent(content)

def setContent(self, content):
self.setTextContent(content)


def main():
pass

if __name__ == '__main__':
main()
32 changes: 32 additions & 0 deletions xmind/core/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .title import TitleElement
from .position import PositionElement
from .notes import NotesElement, PlainNotes
from .labels import Labels, LabelsElement
from .markerref import MarkerRefElement
from .markerref import MarkerRefsElement
from .markerref import MarkerId
Expand Down Expand Up @@ -331,6 +332,26 @@ def getNotes(self):
if notes is not None:
return NotesElement(notes, self)

def getLabels(self):
"""
Return `NotesElement` object` and invoke
`NotesElement.getContent()` to get notes content.
"""

labels = self.getFirstChildNodeByTagName(const.TAG_LABELS)

if labels is not None:
return LabelsElement(labels, self)

def _set_labels(self):
labels = self.getLabels()

if labels is None:
labels = LabelsElement(ownerTopic=self)
self.appendChild(labels)

return labels

def _set_notes(self):
notes = self.getNotes()

Expand All @@ -355,6 +376,17 @@ def setPlainNotes(self, content):

notes.appendChild(new)

def setLabels(self, content):
""" Set plain text notes to topic

:param content: utf8 plain text

"""
labels = self._set_labels()
new = Labels(content, None)

labels.appendChild(new)


class ChildrenElement(WorkbookMixinElement):
TAG_NAME = const.TAG_CHILDREN
Expand Down