コード例 #1
0
ファイル: tachemanager.cpp プロジェクト: fabBu/brabrabra
void TacheManager::setDatesDisponibiliteEcheance(Tache& t, const QDate& disp, const QDate& e)
{
    if (e<disp)
        throw CalendarException("erreur Tâche : date echéance < date disponibilité");

    const list<Tache*> l = this->getTaches();
    list<Tache*>::const_iterator it;
    for( it = l.begin() ; it != l.end() ; ++it )
    {
        if( (*it)->estPredecesseur(t) )
        {
            if( (*it)->getDateDisponibilite() > disp )
                throw CalendarException( "Le successeur "+(*it)->getTitre()+" possede une date de dispo supérieure" );

            if( (*it)->getDateEcheance() < e )
                throw CalendarException( "Le successeur "+(*it)->getTitre()+" possede une date d'échéance inférieure" );
        }

        TacheComposite* tc = dynamic_cast<TacheComposite*>(*it);
        if( tc && tc->estSousTache(t) )
        {
            if( (*it)->getDateDisponibilite() > disp )
                throw CalendarException( "La sur-tache "+tc->getTitre()+" possede une date de dispo supérieure" );

            if( (*it)->getDateEcheance() < e )
                throw CalendarException( "Le successeur "+tc->getTitre()+" possede une date d'échéance inférieure" );
        }
    }

    t.setDatesDisponibiliteEcheance(disp, e);
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: Pauchpock/UTC-GI
void MainWindow::nouvelleTacheUnitairePreemptable()
{
    QList<QTreeWidgetItem*> selected = projets->selectedItems();
    if (selected.size() != 0 && (selected.at(0)->text(0) == "Projet" || dynamic_cast<TacheComposite*>(tm->trouverTache(selected.at(0)->text(1))))) {
        Tache& tach = tm->ajouterTache("preemptable");
        if (selected.at(0)->text(0) == "Projet") {
            QString id = selected.at(0)->text(1);
            Projet* proj = pm->trouverProjet(id);
            try{proj->ajouterTache(&tach);}catch(ProjetException e){qDebug()<<e.get_info();}
            tach.setProjet_conteneur(proj);
        }
        else {
            TacheComposite* task = dynamic_cast<TacheComposite*>(tm->trouverTache(selected.at(0)->text(1)));
            task->ajouterTache(&tach);
            tach.setTache_conteneur(task);
        }

        try {
            tm->saveToDB();
        } catch (TacheManagerException e) {
            showError("Project Calendar", e.getInfo());
            tm->clearAll();
            pm->clearAll();
            pm->loadProjets();
            tm->loadTaches();
            em->clearAll();
            em->loadEvents();
            displayEvents(this->current_debut,this->current_fin);
        }
        displayProjetsAndTasks();
    }

}
コード例 #3
0
void ProjetManager::ajouterTacheUnitaire(const QString& titre, QDate debTot, QDate finTard, const QString& nomMere, TIME::Duree duree, bool preemptable)
{

	if (this->existeNom(titre))
		throw ProjectException("Impossible de créer la tache : le nom est déjà pris !");
	
	TacheComposite* mere = dynamic_cast<TacheComposite*>(this->get(nomMere));
	if (mere == 0)
		throw ProjectException("Impossible de créer la tache : parent introuvable ou n'est pas une tache composite !");

	if (debTot < mere->getDebTot() || mere->getFinTard() < finTard)
		throw ProjectException("Impossible de créer la tache : Les dates doivent concorder avec les dates du parent !");

	Tache* t;

	if (!preemptable)
	{
		if (duree.getDureeEnHeures() > 12)
			throw ProjectException("Impossible de créer la tache : Les taches non préemptables ne doivent pas dépasser 12h !");
        t = new TacheUnitaire(titre, debTot, finTard, mere, duree);
	}
	else
        t = new TachePreemptable(titre, debTot, finTard, mere, duree);

    this->addItem(t);
    mere->addTache(t);
}
コード例 #4
0
void SupprimerSousTache::remplirComboSousTache(const QString& t){
    ui->comboBoxSousTache->clear();
    ui->comboBoxSousTache->addItem(" ");
    if(t!=" "){
        TacheComposite* mere = static_cast<TacheComposite*>(ProjetManager::getInstance().trouverTache(t));
        if (mere!=0) {
            for(QMap<QString, Tache*>::const_iterator it=mere->getSousTaches().begin(); it!=mere->getSousTaches().end(); ++it){
                ui->comboBoxSousTache->addItem((*it)->getId());
            }
        }
    }
}
コード例 #5
0
void ProjetManager::ajouterTacheComposite(const QString& titre, QDate debTot, const QString& nomMere, QDate finTard)
{
	if (this->existeNom(titre))
		throw ProjectException("Impossible de créer la tache : le nom est déjà pris !");

	TacheComposite* mere = dynamic_cast<TacheComposite*>(this->get(nomMere));
	if (mere == 0)
		throw ProjectException("Impossible de créer la tache : parent introuvable ou n'est pas une tache composite !");

	if (debTot < mere->getDebTot() || mere->getFinTard() < finTard)
		throw ProjectException("Impossible de créer la tache : Les dates doivent concorder avec les dates du parent !");

    Tache * t = new TacheComposite(titre, debTot, finTard, mere);
	this->addItem(t);
    mere->addTache(t);
}
コード例 #6
0
ファイル: projet.cpp プロジェクト: zinsmatt/ProjectCalendar
std::map<QString, Tache*>* Projet::getTacheMap(const QString &id)
{
    if(taches.find(id) != taches.end())
        return &taches;
    else
    {
        for(Projet::iterator it = begin() ; it != end() ; ++it)
        {
            if((*it).isComposite())
            {
                TacheComposite* tc = dynamic_cast<TacheComposite*>(&(*it));
                std::map<QString, Tache*>* result = tc->getTacheMap(id);
                if(result)
                    return result;
            }
        }
        return 0;
    }
}
コード例 #7
0
void SupprimerSousTache::suppressionSousTache(){
    try{
        if (ui->comboBoxSousTache->currentText()!=QString(" ") && ui->comboBoxTacheMere->currentText()!=QString(" ")) {
            TacheComposite* mere =static_cast<TacheComposite*>(ProjetManager::getInstance().trouverTache(ui->comboBoxTacheMere->currentText()));
            Tache* soustache = ProjetManager::getInstance().trouverTache(ui->comboBoxSousTache->currentText());
            mere->removeSousTache(soustache);
            MessageValidation mv(QString("Succès"), QString("La sous-tâche "+ui->comboBoxSousTache->currentText()+" a été enlevée à "+ui->comboBoxTacheMere->currentText()+"."));
            int rep = mv.exec();
            if (rep == QMessageBox::No)
                close();
            else { remplirComboTacheMere(ui->comboBoxProjet->currentText()); }
        }
        else
            throw CalendarException("Veuillez séléctionner des tâches");
    }
    catch(CalendarException e){
        QMessageBox::warning(this, "Erreur Suppression", e.getInfo());
    }
}
コード例 #8
0
void FenetreGraphique::recursiveTreeView(QStandardItem& itemPere, TacheComposite& t)
{
    for ( QVector<Tache*>::iterator it = t.IteratorSousTachesBegin(); it != t.IteratorSousTachesEnd(); ++it)
    {
        if((typeid(**it)==typeid(TacheUnitaire))||(typeid(**it)==typeid(TacheUnitairePreemptive)))
        {
            QStandardItem* itemTmp = new QStandardItem((*it)->getId());
            itemPere.appendRow(itemTmp);
        }
        else if(typeid(**it)==typeid(TacheComposite))
        {
            QStandardItem* itemTmp = new QStandardItem((*it)->getId());
            itemPere.appendRow(itemTmp);
            recursiveTreeView(*itemTmp,dynamic_cast<TacheComposite&>(**it));
        }
        else
        {
        QMessageBox::warning(this, "erreur", "la tache est du type");
        }
    }
}
コード例 #9
0
ファイル: tachemanager.cpp プロジェクト: fabBu/brabrabra
void TacheManager::retirerTache(const QString& id)
{

    Tache* t=trouverTache(id);
    if( !t ) throw CalendarException("TM : Retrait d'une tache inexistante");

    TacheUnaire* tu = dynamic_cast<TacheUnaire*>(t);
    ProgrammationManager::getInstance().removeProgrammation(tu);

    const list<Tache*> l = t->getSucc();
    list<Tache*>::const_iterator it;
    for( it = l.begin() ; it != l.end() ; ++it )
    {
            (*it)->retirerPredecesseur(*t);
    }

    TacheComposite* tc;
    // Retirer la tâche de la sur-tache (composite) si elle existe
    Tache* st = t->getSurtache();
    if( st != 0 ) // La tache est une sous-tache d'une tacheComposite
    {
        tc = dynamic_cast<TacheComposite*>(st);
        tc->retirerSousTache(*t);
    }

    // Retirer toutes les sous-taches si la tache courante est composite
    if( tc = dynamic_cast<TacheComposite*>(t) )
    {
        const list<Tache*> l2 = tc->getSousTaches();
        for( it = l2.begin() ; it != l2.end() ; ++it )
        {
            tc->retirerSousTache((**it));
        }
    }

    taches.remove(t);
    delete t;
}
コード例 #10
0
void window_addtacheunaire::click_bok()
{
    if (ui->t_titre->text().isEmpty())
    {
        QMessageBox::critical(this, "Erreur", "Veuillez entrer un titre");
        return;
    }
    if (ui->dt_dispo->dateTime()>ui->dt_ech->dateTime())
    {
        QMessageBox::critical(this, "Erreur", "La date de disponibilité est supérieure à la date d'échéance");
        return;
    }

    if (ui->rb_preemp->isChecked())
    {
        TacheUnitaire * newTache;
        try
        {
            newTache = new TacheUnitaire (ui->t_titre->text(), ui->dt_dispo->dateTime(), ui->dt_ech->dateTime(), ui->t_duree->time(), true);
        }
        catch (CalendarException& e)
        {
            QMessageBox::critical(this, "Erreur", e.getInfo());
            return;
        }
        ajouter_prerequis(newTache);
        Model::ajouterTache(newTache);
        ajouterDansProjet(newTache);
    }
    else if (ui->rb_unaire->isChecked())
    {
        TacheUnitaire * newTache;
        try
        {
            newTache = new TacheUnitaire (ui->t_titre->text(), ui->dt_dispo->dateTime(), ui->dt_ech->dateTime(), ui->t_duree->time(), false);
        }
        catch (CalendarException& e)
        {
            QMessageBox::critical(this, "Erreur", e.getInfo());
            return;
        }
        ajouter_prerequis(newTache);
        Model::ajouterTache(newTache);
        ajouterDansProjet(newTache);
    }
    else
    {
        TacheComposite * newTache;
        try
        {
            newTache = new TacheComposite (ui->t_titre->text(), ui->dt_dispo->dateTime(), ui->dt_ech->dateTime());
        }
        catch (CalendarException& e)
        {
            QMessageBox::critical(this, "Erreur", e.getInfo());
            return;

        }

        ajouter_prerequis(newTache);

        QItemSelectionModel *selectionComp = ui->list_comp->selectionModel();
        QModelIndexList listeSelectionsComp = selectionComp->selectedIndexes();

        for (int i = 0 ; i < listeSelectionsComp.size() ; i++)
        {
            QVariant elem = modele->data(listeSelectionsComp[i], Qt::DisplayRole);
            QString titreTache = elem.toString();

            std::list<Tache*> taches = Model::getTaches();
            std::list<Tache*>::iterator it = taches.begin();
            for (unsigned int i = 0 ; i < taches.size() ; i++)
            {
                QString titre = (*it)->getTitre();
                if (titre == titreTache)
                {
                    try
                    {
                        newTache->addElement((*it));
                        supprimerDeProjet((*it));
                    }
                    catch (CalendarException& e)
                    {
                        QMessageBox::critical(this, "Erreur", e.getInfo());
                        return;
                    }
                }
                it++;
            }
        }
        Model::ajouterTache(newTache);
        ajouterDansProjet(newTache);
    }

    this->close();
}
コード例 #11
0
void AjoutTacheDialog::accept()
{
    QString id = ui->lineEdit_id->text();
    QString titre = ui->lineEdit_titre->text();
    QString desc = ui->textEdit_desc->toPlainText();
    QDate dispo = ui->dateEdit_dispo->date();
    QDate ech = ui->dateEdit_ech->date();

    //verification titre et id non vides
    if(id!="" && titre!="")
    {
        bool fin = true;
        Tache* t;
        try{
            //creation de la tache
            if(ui->checkBox_composite->isChecked())
            {
                t = new TacheComposite(id,titre,dispo,ech,desc);
            }else if(ui->checkBox_unitaire_non_preemptive->isChecked())
            {
                QTime time = ui->timeEdit_duree->time();
                Duree duree(time.hour(),time.minute());
                t = new TacheUnitaire(id,titre,dispo,ech,desc,duree,false);
            }else
            {
                QTime time = ui->timeEdit_duree->time();
                Duree duree(time.hour(),time.minute());
                t = new TacheUnitaire(id,titre,dispo,ech,desc,duree,true);
            }
        }catch(CalendarException e)
        {
            QMessageBox::warning(this,"Avertissement",e.getInfo());
            fin = false;
        }
        if(fin){
            if(nomTacheComposite == "")
            {
                //on ajoute dans un projet
                ProjetManager& pm = ProjetManager::getInstance();
                Projet& proj = pm.getProjet(nomProjet);
                try{
                    proj.ajouterTache(t);
                }catch(CalendarException e)
                {
                    QMessageBox::warning(this,"Avertissement",e.getInfo());
                    fin = false;
                }
            }else
            {
                //on ajoute dans une tache composite
                ProjetManager& pm = ProjetManager::getInstance();
                Projet& proj = pm.getProjet(nomProjet);
                TacheComposite* tc = dynamic_cast<TacheComposite*>(proj.getTache(nomTacheComposite));
                try{
                    tc->ajouterSousTache(t);
                }catch(CalendarException e)
                {
                    QMessageBox::warning(this,"Avertissement",e.getInfo());
                    fin = false;
                }
            }
        }
        if(fin){ //on notifie l'ajout a l'observateur pour qu'il se mette a jour
            ProjetManager::getInstance().notifier();
            this->done(1);
        }
    }

}