10 #include "model/Project.h"
12 #include <QReadWriteLock>
23 entities[this->getUniqueId()] =
this;
25 lockEntities =
new QMutex();
33 entities[this->getUniqueId()] =
this;
35 lockEntities =
new QMutex();
40 Entity(uniqueId,
"document", atts, parent)
43 entities[this->getUniqueId()] =
this;
45 lockEntities =
new QMutex();
58 return this->projectType;
63 this->projectType = type;
68 QMutexLocker locker(lockEntities);
69 return entities.contains(_id) ? entities[_id] : NULL;
74 QMutexLocker locker(lockEntities);
75 QMapIterator<QString, Entity*> it(entities);
76 QList<Entity*> listRet;
77 qDebug() <<
"Project::getEntitiesbyType " << type;
82 if (ent->getType() == _type)
91 return this->projectLocation;
97 this->projectLocation = location;
103 QMutexLocker locker(lockEntities);
104 if (!entities.contains(parentId))
106 throw ParentNotFound(entity->getType(), entity->getType(), parentId);
109 if (entities.contains(entity->getUniqueId()))
115 Entity *parent = entities[parentId];
116 parent->addChild(entity);
117 entities[entity->getUniqueId()] = entity;
126 QMutexLocker locker(lockEntities);
127 QString _id = entity->getUniqueId();
129 if (entities.contains(entity->getUniqueId()))
131 Entity *parent = entity->getParent();
137 QStack <Entity*> stack;
142 Entity *currentEntity = stack.top();
144 entities.remove(currentEntity->getUniqueId());
146 QVector <Entity *> children = currentEntity->getChildren();
147 for(
int i = 0; i < children.size(); i++)
148 stack.push(children.at(i));
175 result +=
"#COMPOSER_PROJECT name=\"" + this->projectName
176 +
"\" version=\"0.1\"#\n";
178 result +=
"#COMPOSER_MODEL#\n";
180 result +=
"#END_COMPOSER_MODEL#\n";
183 foreach(key, pluginData.keys())
185 result +=
"#COMPOSER_PLUGIN_DATA "+ key +
"#\n";
186 result += pluginData[key];
187 result +=
"\n#END_COMPOSER_PLUGIN_DATA#\n";
194 this->pluginData[pluginId] = data;
202 if(pluginData.contains(pluginId))
204 return this->pluginData[pluginId];
209 bool Project::isDirty()
218 emit dirtyProject(isDirty);
225 QList <QString> currentElementsNCLID;
226 for(
int i = 0; i < elements.size(); i++)
228 if(elements.at(i)->hasAttribute(
"id"))
229 currentElementsNCLID.push_back(elements.at(i)->getAttribute(
"id"));
232 for(
int i = 1; ; i++)
234 QString retNCLID = tagname + QString::number(i);
235 if(!currentElementsNCLID.contains(retNCLID))
240 QList<Entity*> Project::getEntityByAttrId(
const QString &
id)
242 QMutexLocker locker(lockEntities);
243 QMapIterator<QString, Entity*> it(entities);
244 QList<Entity*> listRet;
245 qDebug() <<
"Project::getEntitiesbyType " << type;