#include "entitydata.h" #include using namespace PresentDatas; SpecificEntityData::SpecificEntityData(EntityType type, const QString &uid) : type_store(type), document_id(uid) { visible_bool = true; oritation_store = MemberOri::H_LEFT_TO_RIGHT; } void SpecificEntityData::resetContentLayout(MemberOri oritation, MemberType child_type) { this->oritation_store = oritation; this->layout_type = child_type; this->layout_type = MemberType::BLOCKS; this->anchor_info = std::make_tuple(AnchorTarget::NONE, nullptr, AnchorPos::POINT_LEFT_TOP, 0, 0); this->size_min = QSizeF(20, 20); } void SpecificEntityData::setVisible(bool state){ this->visible_bool = state; } void SpecificEntityData::setAnchorTo(AnchorTarget type, EntityData *tptr) { anchor_info = std::make_tuple(type, tptr, std::get<2>(anchor_info), std::get<3>(anchor_info), std::get<4>(anchor_info)); } void SpecificEntityData::setAnchorPos(AnchorPos point, offset_h hoffset, offset_v v_offset) { anchor_info = std::make_tuple(std::get<0>(anchor_info), std::get<1>(anchor_info), point, hoffset, v_offset); } void SpecificEntityData::insertChild(EntityData *inst, int index) { if (index >= 0 && index < children_store.size()) this->children_store.insert(index, inst); else this->children_store.append(inst); } void SpecificEntityData::removeChild(EntityData *inst) { this->children_store.removeAll(inst); } void SpecificEntityData::setMinSizeHint(const QSizeF &hint) { this->size_min = hint; } void SpecificEntityData::setMaxSizeHint(const QSizeF &hint) { this->size_max = hint; } void SpecificEntityData::setStretchHint(const std::pair &hint) { this->stretch_pair = hint; } QString SpecificEntityData::uID() const { return document_id; } EntityType SpecificEntityData::type() const { return type_store; } MemberOri SpecificEntityData::oritation() const { return oritation_store; } MemberType SpecificEntityData::displayType() const { return layout_type; } std::pair SpecificEntityData::anchorTarget() const { return std::make_pair(std::get<0>(anchor_info), std::get<1>(anchor_info)); } std::tuple SpecificEntityData::anchorPos() const { return std::make_tuple(std::get<2>(anchor_info), std::get<3>(anchor_info), std::get<4>(anchor_info)); } QList SpecificEntityData::children() const { return children_store; } bool SpecificEntityData::isVisible() const { return visible_bool; } QSizeF SpecificEntityData::minSizeHint() const { return this->size_min; } QSizeF SpecificEntityData::maxSizeHint() const { return this->size_max; } std::pair SpecificEntityData::sizeStretchHint() const { return stretch_pair; } Document::Document(const QString &name) : SpecificEntityData(EntityType::DOCUMENT_ENTITY, "Document-Unique") { resetContentLayout(MemberOri::H_LEFT_TO_RIGHT, MemberType::BLOCKS); } QString Document::styledText() const { QString values = "\n"; for(auto &i : children()) values += i->styledText(); values += ""; return values; } QString Document::plainText() const { QString values = ""; for(auto &i : children()) if(i->isVisible()) values += i->plainText(); return values; } void Document::resetContentLayout(MemberOri oritation, MemberType) { SpecificEntityData::resetContentLayout(oritation, MemberType::BLOCKS); }