void Projet::load(const QString &f) { //qDebug()<<"debut load\n"; //this->~TacheManager(); QFile fin(f); // If we can't open it, let's show an error message. if (!fin.open(QIODevice::ReadOnly | QIODevice::Text)) { throw CalendarException("Erreur ouverture fichier tâches"); } // QXmlStreamReader takes any QIODevice. QXmlStreamReader xml(&fin); //qDebug()<<"debut fichier\n"; // We'll parse the XML until we reach end of it. while(!xml.atEnd() && !xml.hasError()) { // Read next element. QXmlStreamReader::TokenType token = xml.readNext(); // If token is just StartDocument, we'll go to next. if(token == QXmlStreamReader::StartDocument) continue; // If token is StartElement, we'll see if we can read it. if(token == QXmlStreamReader::StartElement) { // If it's named taches, we'll go to the next. if(xml.name() == "taches") continue; // If it's named tache, we'll dig the information from there. if(xml.name() == "tacheunitaire") { ajouterTache(TacheUnitaire::getFromXml(xml)); }else if(xml.name() == "tachecomposite") { ajouterTache(TacheComposite::getFromXml(xml)); } } } // Error handling. if(xml.hasError()) { throw CalendarException("Erreur lecteur fichier taches, parser xml"); } // Removes any device() or data from the reader * and resets its internal state to the initial state. xml.clear(); //qDebug()<<"fin load\n"; }
TacheUnitaire* TacheManager::ajouterTacheUnitaire(const QString& titre, QDate debut, QDate fin, Duree duree, bool preemp){ TacheUnitaire* tu= new TacheUnitaire(titre, debut, fin, duree, preemp); ajouterTache(tu); return tu; }
TacheComposite* TacheManager::ajouterTacheComposite(const QString &titre, QDate debut, QDate fin){ TacheComposite* tc= new TacheComposite(titre, debut, fin); ajouterTache(tc); return tc; }