App: Add support for <date> metadata element
This commit is contained in:
@@ -149,7 +149,11 @@ std::string Metadata::name() const
|
||||
|
||||
Meta::Version Metadata::version() const
|
||||
{
|
||||
return _version;
|
||||
return _version; }
|
||||
|
||||
std::string App::Metadata::date() const
|
||||
{
|
||||
return _date;
|
||||
}
|
||||
|
||||
std::string Metadata::description() const
|
||||
@@ -257,7 +261,11 @@ void Metadata::setName(const std::string& name)
|
||||
|
||||
void Metadata::setVersion(const Meta::Version& version)
|
||||
{
|
||||
_version = version;
|
||||
_version = version; }
|
||||
|
||||
void App::Metadata::setDate(const std::string &date)
|
||||
{
|
||||
_date = date;
|
||||
}
|
||||
|
||||
void Metadata::setDescription(const std::string& description)
|
||||
@@ -661,6 +669,9 @@ void Metadata::appendToElement(DOMElement* root) const
|
||||
// Only append version if it's not 0.0.0
|
||||
appendSimpleXMLNode(root, "version", _version.str());
|
||||
|
||||
if (!_date.empty())
|
||||
appendSimpleXMLNode(root, "date", _date);
|
||||
|
||||
for (const auto& maintainer : _maintainer) {
|
||||
auto element = appendSimpleXMLNode(root, "maintainer", maintainer.name);
|
||||
if (element)
|
||||
@@ -689,6 +700,7 @@ void Metadata::appendToElement(DOMElement* root) const
|
||||
case Meta::UrlType::bugtracker: typeAsString = "bugtracker"; break;
|
||||
case Meta::UrlType::readme: typeAsString = "readme"; break;
|
||||
case Meta::UrlType::documentation: typeAsString = "documentation"; break;
|
||||
case Meta::UrlType::discussion: typeAsString = "discussion"; break;
|
||||
}
|
||||
addAttribute(element, "type", typeAsString);
|
||||
if (url.type == Meta::UrlType::repository) {
|
||||
@@ -882,6 +894,8 @@ Meta::Url::Url(const XERCES_CPP_NAMESPACE::DOMElement* e)
|
||||
type = UrlType::readme;
|
||||
else if (typeAttribute == "documentation")
|
||||
type = UrlType::documentation;
|
||||
else if (typeAttribute == "discussion")
|
||||
type = UrlType::discussion;
|
||||
else
|
||||
type = UrlType::website;
|
||||
|
||||
|
||||
@@ -74,7 +74,8 @@ namespace App {
|
||||
repository,
|
||||
bugtracker,
|
||||
readme,
|
||||
documentation
|
||||
documentation,
|
||||
discussion
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -203,6 +204,7 @@ namespace App {
|
||||
|
||||
std::string name() const; //< A short name for this package, often used as a menu entry.
|
||||
Meta::Version version() const; //< Version string in symantic triplet format, e.g. "1.2.3".
|
||||
std::string date() const; //< Date string -- currently arbitrary (when C++20 is well-supported we can revisit)
|
||||
std::string description() const; //< Text-only description of the package. No markup.
|
||||
std::vector<Meta::Contact> maintainer() const; //< Must be at least one, and must specify an email address.
|
||||
std::vector<Meta::License> license() const; //< Must be at least one, and most licenses require including a license file.
|
||||
@@ -256,6 +258,7 @@ namespace App {
|
||||
// Setters
|
||||
void setName(const std::string& name);
|
||||
void setVersion(const Meta::Version& version);
|
||||
void setDate(const std::string &date);
|
||||
void setDescription(const std::string& description);
|
||||
void addMaintainer(const Meta::Contact &maintainer);
|
||||
void addLicense(const Meta::License &license);
|
||||
@@ -318,6 +321,7 @@ namespace App {
|
||||
|
||||
std::string _name;
|
||||
Meta::Version _version;
|
||||
std::string _date;
|
||||
std::string _description;
|
||||
std::vector<Meta::Contact> _maintainer;
|
||||
std::vector<Meta::License> _license;
|
||||
|
||||
@@ -44,6 +44,12 @@ file : str\n XML file name.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Version" Type="Object" />
|
||||
</Attribute>
|
||||
<Attribute Name="Date">
|
||||
<Documentation>
|
||||
<UserDocu>String representing the date of this item in YYYY-MM-DD format (format not currently programmatically enforced)</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Date" Type="Object" />
|
||||
</Attribute>
|
||||
<Attribute Name="Description">
|
||||
<Documentation>
|
||||
<UserDocu>String representing the description of this item (text only, no markup allowed).</UserDocu>
|
||||
|
||||
@@ -145,6 +145,21 @@ void MetadataPy::setVersion(Py::Object args)
|
||||
getMetadataPtr()->setVersion(App::Meta::Version());
|
||||
}
|
||||
|
||||
Py::Object MetadataPy::getDate() const
|
||||
{
|
||||
return Py::String(getMetadataPtr()->date());
|
||||
}
|
||||
|
||||
void MetadataPy::setDate(Py::Object args)
|
||||
{
|
||||
const char *date = nullptr;
|
||||
if (!PyArg_Parse(args.ptr(), "z", &date))
|
||||
throw Py::Exception();
|
||||
if (date) getMetadataPtr()->setDate(date);
|
||||
else
|
||||
getMetadataPtr()->setDate("");
|
||||
}
|
||||
|
||||
Py::Object MetadataPy::getDescription() const
|
||||
{
|
||||
return Py::String(getMetadataPtr()->description());
|
||||
|
||||
@@ -166,6 +166,8 @@ class DeveloperMode:
|
||||
result = self.dialog.exec()
|
||||
if result == QDialog.Accepted:
|
||||
self._sync_metadata_to_ui()
|
||||
now = datetime.date.today()
|
||||
self.metadata.Date = str(now)
|
||||
self.metadata.write(os.path.join(self.current_mod, "package.xml"))
|
||||
|
||||
def _populate_dialog(self, path_to_repo):
|
||||
|
||||
Reference in New Issue
Block a user