1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| ModeleDevis::ModeleDevis(QList<Materiel> const & mat):m_materiels{mat}{
}
QVariant ModeleComplet::data(QIndexModel index, int role){
int row = index.row();
int column = index.column();
auto const & four = m_fournitures.at(row);
int matIndex = four.mat;
switch(role){
case Qt::DisplayRole:
auto const & mat = m_materiels.at(matIndex);
switch(row){
case 1:
return mat.nom;
case 2:
/* faudra chipoter ici pour avoir une chaine de caractères */
return mat.categorie;
case 3:
return mat.prixVente;
case 4 : // la quantite
return four.quantite;
case 5: // le total au vu de la quantite
return four.quantite * mat.prixVente;
}
return QVariant;
}
void ModelDevis::ajouterFourniture(int index, int quantite){
/* je te laisse faire le plus gros, mais il faudra terminer par
* quelque chose comme
*/
Fourniture four;
four.index = index;
four.quantite= quantité;
m_fournitures << temp;
}
bool ModelDevis::setData(onst QModelIndex &index, const QVariant &value, int role = Qt::EditRole){
int row = index.row();
int column=index.column();
auto & four = m_fournitures.at(row);
if(role == Qt::EditRole){
/* parce que l'on n'accepte la modification que de la quantite */
if(colum == 4){
four.quantite = value.toInt();
return true;
}
}
return false;
} |