Move project name to project data class

This commit is contained in:
Veronica Berglyd Olsen
2022-10-30 23:18:18 +01:00
parent ea80fd3c71
commit e887ec6991
13 changed files with 174 additions and 73 deletions
+112
View File
@@ -0,0 +1,112 @@
"""
novelWriter Project Data Class
================================
Class for holding the project settings
File History:
Created: 2022-10-30 [2.0rc1]
This file is a part of novelWriter
Copyright 20182022, Veronica Berglyd Olsen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
from novelwriter.common import checkInt, simplified
logger = logging.getLogger(__name__)
class NWProjectData:
def __init__(self):
# Project Meta
self._name = ""
self._title = ""
self._authors = []
self._saveCount = 0
self._autoCount = 0
self._editTime = 0
# Internal
self._changed = False
return
##
# Properties
##
@property
def name(self):
return self._name
@property
def title(self):
return self._title
@property
def autors(self):
return self._authors
@property
def saveCount(self):
return self._saveCount
@property
def autoCount(self):
return self._autoCount
@property
def editTime(self):
return self._editTime
##
# Setters
##
def setName(self, value):
self._name = simplified(str(value))
self._changed = True
return
def setTitle(self, value):
self._title = simplified(str(value))
self._changed = True
return
def addAuthor(self, value):
self._authors.append(simplified(str(value)))
self._changed = True
return
def setSaveCount(self, value):
self._saveCount = checkInt(value, 0)
self._changed = True
return
def setAutoCount(self, value):
self._autoCount = checkInt(value, 0)
self._changed = True
return
def setEditTime(self, value):
self._editTime = checkInt(value, 0)
self._changed = True
return
# END Class NWProjectData