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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include <QtGui>
#include "DomComptes.h"
#include "VueComptes.h"
CVueComptes::CVueComptes(CDomComptes *ptComptes)
{
QTreeWidgetItem *ptItem;
if (ptComptes != 0) {
connect(this, SIGNAL(currentItemChanged(*ptCurrent, *ptPrevious)),this, SLOT(updateSelectedCompte(*ptCurrent, *ptPrevious)));
m_ptComptes = ptComptes;
setColumnCount(1);
header()->hide();
ptItem = new QTreeWidgetItem(this);
ptItem->setText(0, tr("Livre des Comptes"));
installComptes(ptItem);
}
}
void CVueComptes::installComptes(QTreeWidgetItem *ptParent)
{
QTreeWidgetItem *ptItemCompte;
QTreeWidgetItem *ptItemInfo;
CInfoCompte infoCompte;
m_ptComptes->firstCompte(infoCompte);
while (!infoCompte.isEmpty()) {
qDebug() << "## Fonction installComptes ## : " << infoCompte.nomCompte() << " " << infoCompte.nombreOperations() << " " << infoCompte.soldeCourant();
ptItemCompte = new QTreeWidgetItem(ptParent);
ptItemCompte->setText(0, tr("%1").arg(infoCompte.nomCompte()));
ptItemInfo = new QTreeWidgetItem(ptItemCompte);
ptItemInfo->setText(0, tr("Nombre d'opérations = %1").arg(infoCompte.nombreOperations()));
ptItemInfo = new QTreeWidgetItem(ptItemCompte);
ptItemInfo->setText(0, tr("Solde courant = %1").arg(infoCompte.soldeCourant(), 0, 'f', 2));
m_ptComptes->nextCompte(infoCompte);
}
ptItemCompte = ptParent->child(0);
qDebug() << "## Fonction installComptes ## : " << ptItemCompte->text(0);
setCurrentItem (ptItemCompte);
emit currentItemChanged(ptItemCompte, ptItemCompte);
qDebug() << "## Fonction installComptes ## : Current Item = " << currentItem()->text(0);
}
void CVueComptes::updateSelectedCompte(QTreeWidgetItem *ptCurrent, QTreeWidgetItem *ptPrevious)
{
CInfoCompte infoCompte;
qDebug() << "## Fonction updateSelectedCompte ## : ";
if (ptCurrent != 0) {
infoCompte.setNomCompte(ptCurrent->text(0));
emit selectedCompteChanged(infoCompte);
}
} |
Partager