mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
go on with the work
This commit is contained in:
@@ -26,12 +26,18 @@ namespace {
|
||||
const QString boolS = "bool";
|
||||
const QString stringS = "string";
|
||||
const QString uuidS = "uuid";
|
||||
const QString colorS = "color";
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertiesInterface()
|
||||
{
|
||||
}
|
||||
|
||||
bool PropertiesInterface::valideXml(QDomElement& element) {
|
||||
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const QString value) const {
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
@@ -44,7 +50,7 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", integerS);
|
||||
p.setAttribute("value", value);
|
||||
p.setAttribute("value", QString::number(value));
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -52,7 +58,7 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", doubleS);
|
||||
p.setAttribute("value", value);
|
||||
p.setAttribute("value", QString::number(value));
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -60,7 +66,7 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", boolS);
|
||||
p.setAttribute("value", value);
|
||||
p.setAttribute("value", QString::number(value));
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -72,6 +78,14 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QColor value) const {
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", colorS);
|
||||
p.setAttribute("value", value.name());
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::property(const QDomElement& e, const QString& name) {
|
||||
for (int i=0; i < e.childNodes().count(); i++) {
|
||||
QDomElement child = e.childNodes().at(i).toElement();
|
||||
@@ -86,7 +100,7 @@ QDomElement PropertiesInterface::property(const QDomElement& e, const QString& n
|
||||
|
||||
/*!
|
||||
* \brief PropertiesInterface::attribute
|
||||
* Returns the property with the name \p attribute_name
|
||||
* Returns the property with the name \p attribute_name and type \p type
|
||||
* \param e Xml element which contains the property
|
||||
* \param attribute_name
|
||||
* \param type Type of the property
|
||||
@@ -185,6 +199,26 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color, QColor defaultValue) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||
*color = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
// verifie la validite de l'attribut
|
||||
QColor tmp = QColor(attr);
|
||||
if (!tmp.isValid())
|
||||
return PropertyFlags::NoValidConversion;
|
||||
|
||||
if (color != nullptr)
|
||||
*color = tmp;
|
||||
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, QUuid defaultValue) {
|
||||
QString attr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user