2023-09-01 22:34:06 +00:00
|
|
|
#include "entitydata.h"
|
2023-09-04 14:35:14 +00:00
|
|
|
#include <QList>
|
2023-09-01 22:34:06 +00:00
|
|
|
using namespace PresentDatas;
|
|
|
|
|
2023-09-04 14:35:14 +00:00
|
|
|
SpecificEntityData::SpecificEntityData(EntityType type, const QString &uid) : type_store(type), document_id(uid) {
|
|
|
|
visible_bool = true;
|
|
|
|
oritation_store = MemberOri::H_LEFT_TO_RIGHT;
|
|
|
|
}
|
2023-09-01 22:34:06 +00:00
|
|
|
|
|
|
|
void SpecificEntityData::resetContentLayout(MemberOri oritation, MemberType child_type) {
|
|
|
|
this->oritation_store = oritation;
|
|
|
|
this->layout_type = child_type;
|
2023-09-04 14:35:14 +00:00
|
|
|
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;
|
2023-09-01 22:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2023-09-04 14:35:14 +00:00
|
|
|
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<float, float> &hint) { this->stretch_pair = hint; }
|
|
|
|
|
2023-09-01 22:34:06 +00:00
|
|
|
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<AnchorTarget, EntityData *> SpecificEntityData::anchorTarget() const {
|
|
|
|
return std::make_pair(std::get<0>(anchor_info), std::get<1>(anchor_info));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::tuple<AnchorPos, EntityData::offset_h, EntityData::offset_v> SpecificEntityData::anchorPos() const {
|
|
|
|
return std::make_tuple(std::get<2>(anchor_info), std::get<3>(anchor_info), std::get<4>(anchor_info));
|
|
|
|
}
|
|
|
|
|
2023-09-04 14:35:14 +00:00
|
|
|
QList<EntityData *> 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<float, float> SpecificEntityData::sizeStretchHint() const { return stretch_pair; }
|
|
|
|
|
|
|
|
Document::Document(const QString &name) : SpecificEntityData(EntityType::DOCUMENT_ENTITY, "Document-Unique") {
|
2023-09-01 22:34:06 +00:00
|
|
|
resetContentLayout(MemberOri::H_LEFT_TO_RIGHT, MemberType::BLOCKS);
|
|
|
|
}
|
|
|
|
|
2023-09-04 14:35:14 +00:00
|
|
|
QString Document::styledText() const
|
|
|
|
{
|
|
|
|
QString values = "<docment type = '7' visible='true' >\n";
|
|
|
|
for(auto &i : children())
|
|
|
|
values += i->styledText();
|
|
|
|
values += "</document>";
|
|
|
|
|
|
|
|
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); }
|