-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
106 lines (83 loc) · 3.29 KB
/
Copy pathmainwindow.cpp
File metadata and controls
106 lines (83 loc) · 3.29 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
load_config();
this->ui->resultats->setFixedWidth(150*2+34);
QObject::connect(this->ui->actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
//Afficher affiche;
connect(this->ui->actionAfficher, SIGNAL(triggered()), this, SLOT(get_started_info()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::get_started_info()
{
one = new Afficher(this);
one->setModal(true); // if you need it.
one->show();
//get_started one(this); //create a object directly
//one.exec(); //modal dialog
}
void MainWindow::on_calculer_clicked()
{
QString val = this->ui->lineEdit->text();
this->ui->lineEdit->setReadOnly(true);
this->ui->calculer->setDisabled(true);
long long somme = convertion( val.toStdString().c_str());
long numByPiece[num_piece()];
if(somme < 0){
alert("NOMBRE INVALIDE LA SOMME DOIS ETRE UN ENTIER");
}else{
if(somme != 0){
this->ui->somme->setText(QString((::to_str(somme)+ std::string(" ") + get_type()).c_str()));
size_t i = num_piece();
long piece ;
this->ui->etatpes->clear();
while (true ) {
--i;
piece = get_piece(i);
numByPiece[i] = num_piece_of(somme,piece);
if(numByPiece[i]!=0){
std::string msg("Choix glouton\t");
msg += to_str<long>(piece) + std::string(",\nnombre de piece\t") + to_str<long>(numByPiece[i]) + std::string (",\nsomme restante\t") + to_str<long long>(somme) + std::string(".\n");
new QListWidgetItem(tr(msg.c_str()),this->ui->etatpes);
}
if(i == 0 ){
break;
}
}
i = num_piece();
size_t j = 0;
this->ui->reste->setText(QString((::to_str(somme)+std::string(" ") + get_type()).c_str()));
this->ui->resultats->setRowCount(i);
this->ui->resultats->setColumnCount(2);
this->ui->resultats->setHorizontalHeaderItem(0,new QTableWidgetItem(tr("PIECE").arg(QString((0+1)*(0+1)))));
this->ui->resultats->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("NOMBRE").arg(QString((0+1)*(1+1)))));
this->ui->resultats->setColumnWidth(1,150);
this->ui->resultats->setColumnWidth(0,150);
while (j <i) {
this->ui->resultats->setRowHeight(j,50);
QTableWidgetItem *newItem = new QTableWidgetItem(tr(to_str<long>( get_piece(j)).c_str()).arg( (j+1)*(0+1)));
newItem->setTextAlignment(Qt::AlignCenter);
this->ui->resultats->setItem(j, 0, newItem);
QTableWidgetItem *newItem2 = new QTableWidgetItem(tr(to_str<long>(numByPiece[j]).c_str()).arg((j+1)*(1+1)));
this->ui->resultats->setItem(j, 1, newItem2);
newItem2->setTextAlignment(Qt::AlignCenter);
j ++;
}
}
}
this->ui->lineEdit->setReadOnly(false);
this->ui->calculer->setDisabled(false);
}
void MainWindow::on_lineEdit_editingFinished()
{
}
void MainWindow::alert(const char * msg){
QMessageBox::warning(this, "Alerte",msg );
}