18 #include "qnlycomposerplugin.h"
24 QnlyComposerPlugin::QnlyComposerPlugin(QObject* parent)
33 QnlyComposerPlugin::~QnlyComposerPlugin()
38 void QnlyComposerPlugin::createView()
43 void QnlyComposerPlugin::createDocument()
48 void QnlyComposerPlugin::createConnections()
50 connect(view, SIGNAL(itemChanged(QString,QString,QMap<QString,QString>)), SLOT(changeRegion(QString,QString,QMap<QString,QString>)));
68 void QnlyComposerPlugin::errorMessage(QString error)
73 void QnlyComposerPlugin::onEntityAdded(QString pluginID, Entity *entity)
76 if (entity->getType() ==
"region")
78 qDebug() <<
"QnlyComposerPlugin::onEntityAdded (" << entity->getType();
82 else if (entity->getType() ==
"regionBase")
84 addRegionBase(entity);
89 void QnlyComposerPlugin::onEntityRemoved(QString pluginID, QString entityID)
94 void QnlyComposerPlugin::onEntityChanged(QString pluginID, Entity *entity)
97 if (entity->getType() ==
"region"){
100 }
else if (entity->getType() ==
"regionBase"){
101 changeRegionBase(entity);
106 void QnlyComposerPlugin::changeSelectedEntity (
void*)
111 void QnlyComposerPlugin::addRegion(Entity* entity)
115 if (entity->getType() ==
"region")
119 if (!entity->getUniqueId().isEmpty())
121 entityUID = entity->getUniqueId();
125 qFatal(
"QnlyComposerPlugin::addRegion 1");
130 regionUID = entityUID;
132 QString parentregionUID;
134 if (regions.contains(entity->getParentUniqueId()))
136 parentregionUID = entity->getParentUniqueId();
140 parentregionUID =
"";
143 QString regionbaseUID;
144 if (regions.contains(parentregionUID))
146 regionbaseUID = relations[parentregionUID];
149 else if (regionbases.contains(entity->getParentUniqueId()))
151 regionbaseUID = entity->getParentUniqueId();
156 qFatal(
"QnlyComposerPlugin::addRegion 2");
160 QMap<QString, QString> attributes;
162 if (!entity->getAttribute(
"id").isEmpty())
163 attributes[
"id"] = entity->getAttribute(
"id");
165 if (!entity->getAttribute(
"title").isEmpty())
166 attributes[
"title"] = entity->getAttribute(
"title");
168 if (!entity->getAttribute(
"zIndex").isEmpty())
169 attributes[
"zIndex"] = entity->getAttribute(
"zIndex");
171 if (!entity->getAttribute(
"top").isEmpty())
172 attributes[
"top"] = entity->getAttribute(
"top");
174 if (!entity->getAttribute(
"left").isEmpty())
175 attributes[
"left"] = entity->getAttribute(
"left");
177 if (!entity->getAttribute(
"bottom").isEmpty())
178 attributes[
"bottom"] = entity->getAttribute(
"bottom");
180 if (!entity->getAttribute(
"right").isEmpty())
181 attributes[
"right"] = entity->getAttribute(
"right");
183 if (!entity->getAttribute(
"width").isEmpty())
184 attributes[
"width"] = entity->getAttribute(
"width");
186 if (!entity->getAttribute(
"height").isEmpty())
187 attributes[
"height"] = entity->getAttribute(
"height");
190 regions[regionUID] = entity;
192 relations[regionUID] = regionbaseUID;
194 qDebug() <<
"Calling view->addRegion";
195 view->addRegion(regionUID, parentregionUID, regionbaseUID,
201 void QnlyComposerPlugin::removeRegion(Entity* entity)
204 if (entity->getType() ==
"region"){
208 if (!entity->getUniqueId().isEmpty()){
209 entityUID = entity->getUniqueId();
217 if (entities.contains(entityUID)){
218 regionUID = entities[entityUID];
224 QString regionbaseUID;
226 if (relations.contains(regionUID)){
227 regionbaseUID = relations[regionUID];
233 view->removeRegion(regionUID, regionbaseUID);
238 void QnlyComposerPlugin::selectRegion(Entity *entity)
243 void QnlyComposerPlugin::changeRegion(Entity *entity)
246 if (entity->getType() ==
"region"){
250 if (!entity->getUniqueId().isEmpty()){
251 entityUID = entity->getUniqueId();
259 if (regions.contains(entityUID)){
260 regionUID = entityUID;
266 QString regionbaseUID;
268 if (regionbases.contains(relations[regionUID])){
269 regionbaseUID = relations[regionUID];
275 QMap<QString, QString> attributes;
277 if (!entity->getAttribute(
"id").isEmpty()){
278 attributes[
"id"] = entity->getAttribute(
"id");
284 if (!entity->getAttribute(
"title").isEmpty()){
285 attributes[
"title"] = entity->getAttribute(
"title");
291 if (!entity->getAttribute(
"zIndex").isEmpty()){
292 attributes[
"zIndex"] = entity->getAttribute(
"zIndex");
298 if (!entity->getAttribute(
"top").isEmpty()){
299 attributes[
"top"] = entity->getAttribute(
"top");
305 if (!entity->getAttribute(
"left").isEmpty()){
306 attributes[
"left"] = entity->getAttribute(
"left");
312 if (!entity->getAttribute(
"bottom").isEmpty()){
313 attributes[
"bottom"] = entity->getAttribute(
"bottom");
319 if (!entity->getAttribute(
"right").isEmpty()){
320 attributes[
"right"] = entity->getAttribute(
"right");
326 if (!entity->getAttribute(
"width").isEmpty()){
327 attributes[
"width"] = entity->getAttribute(
"width");
333 if (!entity->getAttribute(
"height").isEmpty()){
334 attributes[
"height"] = entity->getAttribute(
"height");
341 view->changeRegion(regionUID, regionbaseUID, attributes);
346 void QnlyComposerPlugin::addRegion(
const QString regionUID,
const QString parentregionUID,
const QString regionbaseUID,
const QMap<QString, QString> &attributes)
348 if (!regions.contains(regionUID) && regionbases.contains(regionbaseUID)){
350 QMap<QString, QString> standard;
352 if (attributes.contains(
"id")){
353 standard[
"id"] = attributes[
"id"];
359 if (attributes.contains(
"title")){
360 standard[
"title"] = attributes[
"title"];
366 if (attributes.contains(
"top")){
367 standard[
"top"] = attributes[
"top"];
373 if (attributes.contains(
"left")){
374 standard[
"left"] = attributes[
"left"];
380 if (attributes.contains(
"bottom")){
381 standard[
"bottom"] = attributes[
"bottom"];
387 if (attributes.contains(
"right")){
388 standard[
"right"] = attributes[
"right"];
394 if (attributes.contains(
"width")){
395 standard[
"width"] = attributes[
"width"];
401 if (attributes.contains(
"height")){
402 standard[
"height"] = attributes[
"height"];
408 if (attributes.contains(
"zIndex")){
409 standard[
"zIndex"] = attributes[
"zIndex"];
416 if (!parentregionUID.isEmpty()){
417 emit
addEntity(
"region", parentregionUID, standard,
false);
420 emit
addEntity(
"region", regionbaseUID, standard,
false);
425 void QnlyComposerPlugin::removeRegion(
const QString regionUID,
const QString regionbaseUID)
462 void QnlyComposerPlugin::selectRegion(
const QString regionUID,
const QString regionbaseUID)
467 void QnlyComposerPlugin::changeRegion(
const QString regionUID,
const QString regionbaseUID,
const QMap<QString, QString> &attributes)
480 QMap<QString, QString> standard;
482 if (attributes.contains(
"id")){
483 standard[
"id"] = attributes[
"id"];
489 if (attributes.contains(
"title")){
490 standard[
"title"] = attributes[
"title"];
496 if (attributes.contains(
"top")){
497 standard[
"top"] = attributes[
"top"];
503 if (attributes.contains(
"left")){
504 standard[
"left"] = attributes[
"left"];
510 if (attributes.contains(
"bottom")){
511 standard[
"bottom"] = attributes[
"bottom"];
517 if (attributes.contains(
"right")){
518 standard[
"right"] = attributes[
"right"];
524 if (attributes.contains(
"width")){
525 standard[
"width"] = attributes[
"width"];
531 if (attributes.contains(
"height")){
532 standard[
"height"] = attributes[
"height"];
538 if (attributes.contains(
"zIndex")){
539 standard[
"zIndex"] = attributes[
"zIndex"];
551 void QnlyComposerPlugin::addRegionBase(Entity *entity)
555 if (entity->getType() ==
"regionBase"){
559 if (!entity->getUniqueId().isEmpty()){
560 entityUID = entity->getUniqueId();
566 QString regionbaseUID;
568 regionbaseUID = entityUID;
570 QMap<QString, QString> attributes;
572 if (!entity->getAttribute(
"id").isEmpty()){
573 attributes[
"id"] = entity->getAttribute(
"id");
579 if (!entity->getAttribute(
"region").isEmpty()){
580 attributes[
"region"] = entity->getAttribute(
"region");
586 if (!entity->getAttribute(
"device").isEmpty()){
587 attributes[
"device"] = entity->getAttribute(
"device");
594 regionbases[regionbaseUID] = entity;
596 view->addRegionbase(regionbaseUID, attributes);
602 void QnlyComposerPlugin::removeRegionBase(Entity *entity)
607 void QnlyComposerPlugin::selectRegionBase(Entity *entity)
612 void QnlyComposerPlugin::changeRegionBase(Entity *entity)
617 void QnlyComposerPlugin::addRegionBase(
const QString regionbaseUID,
const QMap<QString, QString> &attributes)
622 void QnlyComposerPlugin::removeRegionBase(
const QString regionbaseUID)
627 void QnlyComposerPlugin::selectRegionBase(
const QString regionbaseUID)
632 void QnlyComposerPlugin::changeRegionBase(
const QString regionbaseUID,
const QMap<QString, QString> &attributes)