Skip to content

Commit 0e27188

Browse files
author
Tarek Yassine
committed
Petit push avant ma réunion, je continue sans souci ce soir (mate la chouette allitération!)
1 parent eb1a93a commit 0e27188

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

mainwindow.cpp

+21-4
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ void MainWindow::on_nbPile(int n){
302302

303303
void MainWindow::on_commit(){
304304
if (ui->Afficheur->text().isEmpty())
305+
{
305306
on_dup();
307+
instancePile->getGardien()->addMemento(instancePile);
308+
}
306309
else{
307310
parser();
308311
ui->Afficheur->clear();
@@ -381,29 +384,42 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
381384
void MainWindow::on_swap(){
382385
ui->Afficheur->insert("SWAP");
383386
instancePile->swap(1,2);
387+
instancePile->getGardien()->addMemento(instancePile);
384388
refresh();
385389
}
386390
void MainWindow::on_sum(){
387391
ui->Afficheur->insert("SUM");
388392
//instancePile->sum(10);
393+
instancePile->getGardien()->addMemento(instancePile);
389394
refresh();
390395
}
391396
void MainWindow::on_dup(){
392-
instancePile->dup();
393-
refresh();
397+
if (!(instancePile->pileVide()))
398+
{
399+
instancePile->dup();
400+
instancePile->getGardien()->addMemento(instancePile);
401+
// Régler le problème gardien <-> dup
402+
refresh();
403+
}
394404
}
395405
void MainWindow::on_mean(){
396406
ui->Afficheur->insert("MEAN");
397407
//instancePile->mean(10);
408+
instancePile->getGardien()->addMemento(instancePile);
398409
refresh();
399410
}
400411
void MainWindow::on_clear(){
401412
instancePile->clear();
413+
instancePile->getGardien()->addMemento(instancePile);
402414
refresh();
403415
}
404416
void MainWindow::on_drop(){
405-
instancePile->drop();
406-
refresh();
417+
if (!(instancePile->pileVide()))
418+
{
419+
instancePile->drop();
420+
instancePile->getGardien()->addMemento(instancePile);
421+
refresh();
422+
}
407423
}
408424

409425
MainWindow::~MainWindow(){
@@ -480,6 +496,7 @@ void refresh_complexe(Ui::MainWindow *ui){
480496
}
481497

482498
// fonctions de récupération ou suppression d'historique
499+
// quelque part parmi elles, s'occuper de récupérer le gardien? Ou au moins en faire un nouveau
483500

484501
void MainWindow::InitParam(){
485502
std::ifstream fichier("sauvegarde_CooCoo.txt", std::ios::in); // Ouverture en lecture du fichier de sauvegarde

memento.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ Pile* Gardien::undo()
2727

2828
Pile* Gardien::redo()
2929
{
30-
if (current < tabPile.size()-1)
30+
if (tabPile[current+1] != NULL)
3131
{
32-
// Probleme, il rentre quand-meme... size doit pas etre adapté, à revoir!
3332
current++;
3433
return tabPile[current]->cloner();
3534
}

pile.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,11 @@ void Pile::mean(const unsigned int x){
124124
*/
125125

126126
void Pile::dup(){
127-
if (!pileVide()) empiler(tab[sommet]);
127+
if (!pileVide()) empiler(tab[sommet]);
128128
}
129129

130130
void Pile::drop(){
131-
if(!pileVide()){
132-
depiler();
133-
}
131+
if(!pileVide()) depiler();
132+
134133
}
135134

0 commit comments

Comments
 (0)