/* * Alabastra Project - C++ Editor writed with QT Library V.4 * Copyright (C) Igor Maculan - geocronos@gmail.com Marco Buoncristiano - marco.buoncristiano@gmail.com * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "AlProject.h" #include #include #include #include #include AlProject::AlProject() : QObject() {}; bool AlProject::open(QString a_filename){ if (!a_filename.isEmpty()){ QFile f(a_filename); if (f.open(QIODevice::ReadOnly)){ this->filename=a_filename; QDomDocument *doc = new QDomDocument(); if (doc->setContent(&f)){ //Ok file associato iniziano le danze QDomElement el = doc->documentElement(); QDomNode nBase=el.firstChild(); QDomNode n=nBase; //recupero i dati del progetto el=n.toElement(); if (el.tagName()=="Project"){ this->name=el.attribute("name"); this->path=el.attribute("path"); } //RECUPERO l'header el=nBase.firstChildElement("Header"); if ( ! el.isNull() ){ this->header=el.text(); } //RECUPERO gli autori el=nBase.firstChildElement("Authors"); if ( ! el.isNull() ){ n=el.firstChild(); author a; while ( ! n.isNull() ){ el=n.toElement(); a.name=el.attribute("name"); a.email=el.attribute("email"); authors << a; n=n.nextSibling(); } } el=nBase.firstChildElement("Documents"); if (!el.isNull()){ //DOCUMENTI n=el.firstChild(); prjfile fl; while (!n.isNull()){ //ciclo x i documenti el=n.toElement(); fl.filename = this->path + el.attribute("filename"); prjFiles<< fl; n=n.nextSibling(); } } f.close(); makeHeader(); return true; } else { //il file non va bene f.close(); return false; } } else return false; } else return false; }; QList AlProject::getFiles(){ return prjFiles; }; void AlProject::makeHeader(){ QString strAuthors; for (int i=0;i