10 #include "modules/ProjectControl.h"
11 #include "modules/ProjectReader.h"
22 ProjectControl::~ProjectControl()
24 QMap<QString,Project*>::iterator it;
26 for (it = openProjects.begin(); it != openProjects.end(); it++)
34 qDebug() <<
"Error: Failed to releasePlugins ";
41 if (!openProjects.contains(location))
return false;
43 Project *project = openProjects[location];
44 if (PluginControl::getInstance()->releasePlugins(project))
48 openProjects.remove(location);
52 qDebug() <<
"Error: Failed to close the project :" << location;
60 if (openProjects.contains(location))
66 QString ext = location;
67 ext = ext.remove(0, ext.lastIndexOf(
".") + 1);
68 LanguageType type = Utilities::getLanguageTypeByExtension( ext );
86 getProfileFromType(type);
90 emit
notifyError(tr(
"No Language Profile Extension "
97 QMap<QString,QString> atts;
98 QString documentId = location;
101 documentId = documentId.remove(0, location.lastIndexOf(
"/") + 1);
102 atts[
"id"] = documentId;
105 Project *project = pr.readFile(location);
114 PluginControl::getInstance()->launchProject(project);
115 openProjects[location] = project;
117 this, SLOT(projectIsDirty(
bool)));
120 qDebug() << tr(
"Project could not be open!");
130 QString projLocation)
132 if (openProjects.contains(projLocation))
138 QString ext = docLocation;
139 ext = ext.remove(0, ext.lastIndexOf(
".") + 1);
140 LanguageType type = Utilities::getLanguageTypeByExtension( ext );
144 qDebug() <<
"File format not recognized.";
150 getProfileFromType(type);
154 emit
notifyError(tr(
"No Language Profile Extension "
162 QMap<QString,QString> atts;
163 QString projectId = projLocation;
164 projectId.remove(0, projLocation.lastIndexOf(
"/")+1);
165 atts[
"id"] = projectId;
168 Project *project = pr.readFile(projLocation);
177 PluginControl::getInstance()->launchProject(project);
180 openProjects[projLocation] = project;
183 parser = profile->createParser(project);
184 PluginControl::getInstance()->
185 connectParser(parser, PluginControl::getInstance()->
186 getMessageControl(project));
188 QFile input(docLocation);
189 if(input.open(QIODevice::ReadOnly))
192 qDebug() << tr(
"File could not be open!");
197 qDebug() << tr(
"Project could not be open!");
209 Project *project = openProjects.value(location);
210 QFile fout(location);
215 qDebug() <<
"The file (" << location <<
") doesn't exists. It will be\
219 if( !fout.open( QIODevice::WriteOnly ) )
222 qDebug() <<
"Failed to open file (" << location <<
") for writing.";
226 QString content = project->
toString();
227 fout.write(qCompress(content.toAscii(), content.size()));
234 QFileInfo fileInfo(dest);
235 if(fileInfo.absoluteDir().exists())
237 Project *project = openProjects.value(location);
239 openProjects.insert(dest, project);
240 openProjects.remove(location);
245 QMap<QString,QString> atts;
246 QString documentId = dest;
247 documentId = documentId.remove(0, location.lastIndexOf(
"/") + 1);
248 atts[
"id"] = documentId;
252 qWarning() <<
"Could not copy the current project from " << location
258 Project *project = openProjects.value(location);
259 QFile fout(location+
"~");
261 qDebug() <<
"Trying to autosave: " << location;
264 qDebug() <<
"The file (" << location <<
") doesn't exists. It will be\
268 if( !fout.open( QIODevice::WriteOnly ) )
271 qDebug() <<
"Failed to open file (" << location <<
") for writing.";
275 QString content = project->
toString();
276 fout.write(qCompress(content.toAscii(), content.size()));
283 if(openProjects.contains(location))
284 return openProjects.value(location);
289 void ProjectControl::projectIsDirty(
bool isDirty)
296 else qDebug() <<
"Received a dirtyProject message for a NULL project";