src/objecttypes/modelobject.h

Sun, 03 Nov 2019 12:56:42 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 03 Nov 2019 12:56:42 +0200
changeset 9
8b9780700b5e
parent 8
44679e468ba9
child 13
6e838748867b
permissions
-rw-r--r--

added saving of splitter state and recent files

#pragma once
#include <QPointF>
#include <QString>
#include <QStringView>
#include "main.h"
#include "colors.h"
#include "vertex.h"

namespace modelobjects
{
	enum class Property;
	class BaseObject;
	class ColoredBaseObject;
	class Empty;
}

enum class modelobjects::Property
{
	Color,
	Text,
	Point1,
	Point2,
	Point3,
	Point4,
	ControlPoint1,
	ControlPoint2,
	Position,
	Transformation,
	ReferenceName,
	IsInverted,
	ErrorMessage
};

class modelobjects::BaseObject
{
public:
	enum class SetPropertyResult
	{
		Success = 0,
		PropertyNotHandled,
		InvalidValue
	};
	BaseObject();
	BaseObject(const BaseObject&) = delete;
	virtual ~BaseObject();
	const unsigned int id;
	//virtual void toString(QTextStream &out) = 0;
	virtual bool hasColor() const;
	virtual QVariant getProperty(Property id) const;
	virtual SetPropertyResult setProperty(Property id, const QVariant& value);
	virtual QString textRepresentation() const = 0;
	virtual QBrush textRepresentationForeground() const;
	virtual QBrush textRepresentationBackground() const;
	virtual QFont textRepresentationFont() const;
};

class modelobjects::ColoredBaseObject : public BaseObject
{
public:
	ColoredBaseObject(const Color color_index = colors::main);
	bool hasColor() const override final;
	QVariant getProperty(Property id) const override;
	SetPropertyResult setProperty(Property id, const QVariant& value) override;
private:
	Color color_index = colors::main;
};

class modelobjects::Empty : public BaseObject
{
	QString textRepresentation() const override;
};

namespace modelobjects
{
	using Id = std::remove_const_t<decltype(BaseObject::id)>;
}

mercurial