82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
#include "metadata.h"
|
|
|
|
Section::Section()
|
|
{
|
|
|
|
}
|
|
|
|
Section::~Section()
|
|
{
|
|
|
|
}
|
|
|
|
// Warning! this method won't copy anything from the given argument!
|
|
// we actually doesn't care about this, but since QList and QMap are not movable
|
|
// so there won't be a (not ill-formed) default ctor to use and we won't get a
|
|
// proper copy ctor, thus the operator= will be deleted.
|
|
// When accessing QMap value if not exist, we just use this to create a new Section.
|
|
Section & Section::operator=(const Section &)
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
int Section::count() const
|
|
{
|
|
return m_propertiesValueMap.count();
|
|
}
|
|
|
|
void Section::setSectionName(const QString &displayName)
|
|
{
|
|
m_displayName = displayName;
|
|
}
|
|
|
|
void Section::setValue(PropertyType type, const QString &value)
|
|
{
|
|
if (!m_propertiesValueMap.contains(type)) {
|
|
m_propertyIndexes.append(type);
|
|
}
|
|
|
|
m_propertiesValueMap[type] = value;
|
|
}
|
|
|
|
QString Section::valueAt(int index) const
|
|
{
|
|
Q_ASSERT(index >= 0 && index < m_propertyIndexes.count());
|
|
|
|
return m_propertiesValueMap[m_propertyIndexes[index]];
|
|
}
|
|
|
|
QString Section::value(Section::PropertyType type) const
|
|
{
|
|
return m_propertiesValueMap.value(type, tr("Unknown"));
|
|
}
|
|
|
|
QString Section::propertyName(PropertyType type) const
|
|
{
|
|
return m_propertiesOverrideDisplayNameMap.value(
|
|
type,
|
|
m_builtinPropDisplayNameMap.value(type, tr("Unknown"))
|
|
);
|
|
}
|
|
|
|
Metadata::Metadata()
|
|
{
|
|
|
|
}
|
|
|
|
Metadata::~Metadata()
|
|
{
|
|
|
|
}
|
|
|
|
void Metadata::setSectionName(SectionType type, const QString &displayName)
|
|
{
|
|
m_sections[type].setSectionName(displayName);
|
|
}
|
|
|
|
void Metadata::setPropertyValue(Metadata::SectionType type, Section::PropertyType propType, QString value)
|
|
{
|
|
m_sections[type].setValue(propType, value);
|
|
}
|
|
|