Skip to content

Commit

Permalink
Les vols qui n'ont pas de recette associées dans l'onglet "Ajoute rec…
Browse files Browse the repository at this point in the history
…ette" apparaissent désormais en rouge
  • Loading branch information
cvermot committed Mar 4, 2024
1 parent 163f588 commit be28269
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
13 changes: 10 additions & 3 deletions src/AeroDms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ void AeroDms::enregistrerUneRecette()
montantRecette->clear();

peuplerTableRecettes();
peuplerListeBaladesEtSorties();
}

float AeroDms::calculerCoutHoraire()
Expand Down Expand Up @@ -1456,12 +1457,18 @@ void AeroDms::peuplerListeBaladesEtSorties()
{
listeBaladesEtSorties->clear();

QStringList itemLabels = db->recupererBaladesEtSorties(typeDeRecette->currentText());
QStringListIterator it(itemLabels);
//QStringList itemLabels = db->recupererBaladesEtSorties(typeDeRecette->currentText());
AeroDmsTypes::ListeVolSortieOuBalade itemLabels = db->recupererBaladesEtSorties(typeDeRecette->currentText());
QListIterator it(itemLabels);
while (it.hasNext())
{
QListWidgetItem* itemBaladesEtSorties = new QListWidgetItem(it.next(), listeBaladesEtSorties);
const AeroDmsTypes::VolSortieOuBalade & vol = it.next();
QListWidgetItem* itemBaladesEtSorties = new QListWidgetItem(vol.nomVol, listeBaladesEtSorties);
itemBaladesEtSorties->setCheckState(Qt::Unchecked);
if (!vol.volAAuMoinsUnPaiement)
{
itemBaladesEtSorties->setForeground(Qt::red);
}
listeBaladesEtSorties->addItem(itemBaladesEtSorties);
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/AeroDmsTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class AeroDmsTypes
QString heuresDeVol;
int tempsDeVolEnMinutes;
};
static const HeureDeVolRemboursement K_INIT_HEURE_DE_VOL_REMBOURSEMENT;

struct SubventionsParPilote {
QString idPilote;
int annee;
Expand All @@ -170,6 +172,7 @@ class AeroDmsTypes
HeureDeVolRemboursement sortie;
HeureDeVolRemboursement totaux;
};
static const SubventionsParPilote K_INIT_SUBVENTION_PAR_PILOTE;
typedef QList<SubventionsParPilote> ListeSubventionsParPilotes;

struct Vol {
Expand Down Expand Up @@ -254,6 +257,12 @@ class AeroDmsTypes
};
typedef QList< StatsHeuresDeVol> ListeStatsHeuresDeVol;

struct VolSortieOuBalade {
QString nomVol;
bool volAAuMoinsUnPaiement;
};
typedef QList<VolSortieOuBalade> ListeVolSortieOuBalade;

struct StatsHeuresDeVolParActivite {
QString piloteId;
QString nomPrenomPilote;
Expand Down
21 changes: 17 additions & 4 deletions src/ManageDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,15 +1093,28 @@ QStringList ManageDb::recupererTypesDesVol(const bool recupererUniquementLesType
return liste;
}

QStringList ManageDb::recupererBaladesEtSorties(const QString p_typeDeVol)
AeroDmsTypes::ListeVolSortieOuBalade ManageDb::recupererBaladesEtSorties(const QString p_typeDeVol)
{
QStringList liste;
AeroDmsTypes::ListeVolSortieOuBalade liste;
QSqlQuery query;
query.prepare("SELECT * FROM 'volsBaladesEtSorties' WHERE typeDeVol = :typeDeVol");
query.bindValue(":typeDeVol", p_typeDeVol);
query.exec();
while (query.next()) {
liste.append(query.value(2).toString());
while (query.next())
{
AeroDmsTypes::VolSortieOuBalade vol;
vol.nomVol = query.value("NomVol").toString();

QSqlQuery paiementAssocie;
paiementAssocie.prepare("SELECT COUNT(*) AS nombreVol FROM 'xAssociationRecette-Vol' WHERE volId = :volId");
paiementAssocie.bindValue(":volId", query.value("volId").toInt());
paiementAssocie.exec();
paiementAssocie.next();

vol.volAAuMoinsUnPaiement = (paiementAssocie.value("nombreVol").toInt() != 0 );

liste.append(vol);

}

return liste;
Expand Down
2 changes: 1 addition & 1 deletion src/ManageDb.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ManageDb : public QWidget {

QStringList recupererTypesDesVol(bool recupererUniquementLesTypesDeVolAvecRecette = false);

QStringList recupererBaladesEtSorties(const QString p_typeDeVol);
AeroDmsTypes::ListeVolSortieOuBalade recupererBaladesEtSorties(const QString p_typeDeVol);
QList<int> recupererAnnees();
QList<int> recupererAnneesAvecVolNonSoumis();
AeroDmsTypes::ListeSortie recupererListeSorties();
Expand Down

0 comments on commit be28269

Please sign in to comment.