Exemplo n.º 1
0
void MainWindow::exportXML(Projet* p) {
    vector<Evenement*> events;
    if (p) {
        qDebug()<<"Export depuis un projet";
        events = em->getFromProjet(p);
    }
    else
        events = em->getFromPeriod(this->current_debut,this->current_fin);

    QString filename = QFileDialog::getSaveFileName(this,"Exporter la semaine en XML",QDir::homePath(), "XML files (*.xml)");
    if (filename != "") {
        QFile newfile(filename);
        if (!newfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
            showError("Project Calendar", "Impossible d'ouvrir le fichier de destination");
            return;
        }
        QXmlStreamWriter stream(&newfile);
        stream.setAutoFormatting(true);
        stream.writeStartDocument();
        stream.writeStartElement("evenements");

        for (vector<Evenement*>::const_iterator it = events.begin(); it != events.end(); ++it){
            Evenement* ev = *it;
            stream.writeStartElement("evenement");
            stream.writeAttribute("id", (QString::number(ev->getId())));
            stream.writeTextElement("titre",ev->getTitre());
            stream.writeTextElement("description",ev->getDescription());
            stream.writeTextElement("lieu",ev->getLieu());
                stream.writeStartElement("debut");
                    stream.writeTextElement("jour",ev->getDateDebut().toString("yyyy-MM-dd"));
                    stream.writeTextElement("heure",ev->getHeureDebut().toString("hh:mm"));
                stream.writeEndElement();
                stream.writeStartElement("fin");
                    stream.writeTextElement("jour",ev->getDateFin().toString("yyyy-MM-dd"));
                    stream.writeTextElement("heure",ev->getHeureFin().toString("hh:mm"));
                stream.writeEndElement();
            stream.writeEndElement();
        }
        stream.writeEndElement();
        stream.writeEndDocument();
        newfile.close();
        QMessageBox::information(this, "Project Calendar", "Exporté !");
    }
    else
        showError("Project Calendar", "Opération annulée");
}
Exemplo n.º 2
0
bool operator ==(const Evenement& e1, const Evenement& e2){
    return(e1.getDate()==e2.getDate() && e1.getEcheance()==e2.getEcheance() && e1.getId()==e2.getId() && e1.getTitre()==e2.getTitre());
}