src/linetypes/errorline.cpp

Sat, 05 Mar 2022 13:19:59 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 05 Mar 2022 13:19:59 +0200
changeset 162
3ebe1a0ca818
parent 158
5bd755eaa5a8
child 177
f69d53c053df
permissions
-rw-r--r--

only render svg to png if the png does not exist

#include <QBrush>
#include "errorline.h"

ldraw::ErrorLine::ErrorLine(QStringView text, QStringView message) :
	text{text.toString()},
	message{message.toString()}
{
}

QVariant ldraw::ErrorLine::getProperty(Property property) const
{
	switch (property)
	{
	case Property::Text:
		return this->text;
	case Property::ErrorMessage:
		return this->message;
	default:
		return Object::getProperty(property);
	}
}

void ldraw::ErrorLine::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
{
	LDRAW_OBJECT_HANDLE_SET_PROPERTY(Text, {this->text = value;});
	LDRAW_OBJECT_HANDLE_SET_PROPERTY(ErrorMessage, {this->message = value;});
	BaseClass::setProperty(result, pair);
}

QString ldraw::ErrorLine::textRepresentation() const
{
	return this->text;
}

QBrush ldraw::ErrorLine::textRepresentationForeground() const
{
	return QBrush{Qt::yellow};
}

QBrush ldraw::ErrorLine::textRepresentationBackground() const
{
	return QBrush{Qt::red};
}

ldraw::Object::Type ldraw::ErrorLine::typeIdentifier() const
{
	return Type::ErrorLine;
}

QDataStream &ldraw::ErrorLine::serialize(QDataStream &stream) const
{
	return ldraw::Object::serialize(stream) << this->text;
}

QDataStream &ldraw::ErrorLine::deserialize(QDataStream &stream)
{
	return ldraw::Object::deserialize(stream) >> this->text;
}

QString ldraw::ErrorLine::toLDrawCode() const
{
	return this->text;
}

QString ldraw::ErrorLine::iconName() const
{
	return ":/icons/linetype-errorline.png";
}

mercurial