Reduce number of author entries in project to one
This commit is contained in:
@@ -315,12 +315,12 @@ class ProjectBuilder:
|
||||
# Settings
|
||||
projName = data.get("projName", lblNewProject)
|
||||
projTitle = data.get("projTitle", lblNewProject)
|
||||
projAuthors = data.get("projAuthors", "")
|
||||
projAuthor = data.get("projAuthor", "")
|
||||
|
||||
project.data.setUuid(None)
|
||||
project.data.setName(projName)
|
||||
project.data.setTitle(projTitle)
|
||||
project.data.setAuthors(projAuthors)
|
||||
project.data.setAuthor(projAuthor)
|
||||
project.setDefaultStatusImport()
|
||||
project._projOpened = int(time())
|
||||
|
||||
@@ -330,8 +330,8 @@ class ProjectBuilder:
|
||||
novelTitle = project.data.title if project.data.title else project.data.name
|
||||
|
||||
titlePage = f"#! {novelTitle}\n\n"
|
||||
if project.data.authors:
|
||||
titlePage += f">> {lblByAuthors} {project.getFormattedAuthors()} <<\n\n"
|
||||
if project.data.author:
|
||||
titlePage += f">> {lblByAuthors} {project.data.author} <<\n\n"
|
||||
|
||||
aDoc = project.storage.getDocument(hTitlePage)
|
||||
aDoc.writeDocument(titlePage)
|
||||
|
||||
@@ -565,22 +565,6 @@ class NWProject(QObject):
|
||||
return self._lockedBy
|
||||
return None
|
||||
|
||||
def getFormattedAuthors(self):
|
||||
"""Return a formatted string of authors.
|
||||
"""
|
||||
authors = self._data.authors
|
||||
nAuth = len(authors)
|
||||
|
||||
result = ""
|
||||
if nAuth == 1:
|
||||
result = authors[0]
|
||||
elif nAuth > 1:
|
||||
result = "%s %s %s" % (
|
||||
", ".join(authors[0:-1]), self.tr("and"), authors[-1]
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
def getCurrentEditTime(self):
|
||||
"""Get the total project edit time, including the time spent in
|
||||
the current session.
|
||||
|
||||
@@ -46,7 +46,7 @@ class NWProjectData:
|
||||
self._uuid = ""
|
||||
self._name = ""
|
||||
self._title = ""
|
||||
self._authors = []
|
||||
self._author = ""
|
||||
self._saveCount = 0
|
||||
self._autoCount = 0
|
||||
self._editTime = 0
|
||||
@@ -97,8 +97,8 @@ class NWProjectData:
|
||||
return self._title
|
||||
|
||||
@property
|
||||
def authors(self):
|
||||
return self._authors
|
||||
def author(self):
|
||||
return self._author
|
||||
|
||||
@property
|
||||
def saveCount(self):
|
||||
@@ -160,13 +160,6 @@ class NWProjectData:
|
||||
# Methods
|
||||
##
|
||||
|
||||
def addAuthor(self, value):
|
||||
"""Add an author to the authors list.
|
||||
"""
|
||||
self._authors.append(simplified(str(value)))
|
||||
self.theProject.setProjectChanged(True)
|
||||
return
|
||||
|
||||
def incSaveCount(self):
|
||||
"""Increment the save count by one.
|
||||
"""
|
||||
@@ -226,20 +219,12 @@ class NWProjectData:
|
||||
self.theProject.setProjectChanged(True)
|
||||
return
|
||||
|
||||
def setAuthors(self, value):
|
||||
"""Set the list of authors from either a string with one author
|
||||
per line, or a list of authors.
|
||||
def setAuthor(self, value):
|
||||
"""Set the author value.
|
||||
"""
|
||||
self._authors = []
|
||||
self.theProject.setProjectChanged(True)
|
||||
if isinstance(value, str):
|
||||
for author in value.splitlines():
|
||||
author = simplified(author)
|
||||
if author:
|
||||
self._authors.append(author)
|
||||
if value != self._title:
|
||||
self._author = simplified(str(value))
|
||||
self.theProject.setProjectChanged(True)
|
||||
elif isinstance(value, list):
|
||||
self._authors = value
|
||||
return
|
||||
|
||||
def setSaveCount(self, value):
|
||||
|
||||
@@ -245,7 +245,7 @@ class ProjectXMLReader:
|
||||
elif xItem.tag == "title":
|
||||
projData.setTitle(xItem.text)
|
||||
elif xItem.tag == "author":
|
||||
projData.addAuthor(xItem.text)
|
||||
projData.setAuthor(xItem.text)
|
||||
else:
|
||||
logger.warning("Ignored <root/project/%s> in XML", xItem.tag)
|
||||
|
||||
@@ -517,7 +517,7 @@ class ProjectXMLWriter:
|
||||
xProject = etree.SubElement(xRoot, "project", attrib=projAttr)
|
||||
self._packSingleValue(xProject, "name", projData.name)
|
||||
self._packSingleValue(xProject, "title", projData.title)
|
||||
self._packListValue(xProject, "author", projData.authors)
|
||||
self._packSingleValue(xProject, "author", projData.author)
|
||||
|
||||
# Save Project Settings
|
||||
xSettings = etree.SubElement(xRoot, "settings")
|
||||
@@ -590,14 +590,6 @@ class ProjectXMLWriter:
|
||||
xItem.text = str(value) or ""
|
||||
return
|
||||
|
||||
def _packListValue(self, xParent, name, data):
|
||||
"""Pack a list of values into an XML element.
|
||||
"""
|
||||
for value in data:
|
||||
xItem = etree.SubElement(xParent, name)
|
||||
xItem.text = str(value) or ""
|
||||
return
|
||||
|
||||
def _packDictKeyValue(self, xParent, name, data):
|
||||
"""Pack the entries of a dictionary into an XML element.
|
||||
"""
|
||||
|
||||
@@ -262,7 +262,7 @@ class ToOdt(Tokenizer):
|
||||
|
||||
if self._headerText == "":
|
||||
theTitle = self.theProject.data.title
|
||||
theAuth = self.theProject.getFormattedAuthors()
|
||||
theAuth = self.theProject.data.author
|
||||
self._headerText = f"{theTitle} / {theAuth} /"
|
||||
|
||||
# Create Roots
|
||||
|
||||
Reference in New Issue
Block a user