diff --git a/editwindow.cpp b/editwindow.cpp
index 5321647..75e4153 100644
--- a/editwindow.cpp
+++ b/editwindow.cpp
@@ -38,7 +38,17 @@ EditWindow::EditWindow(int idSocio, QWidget* parent) : QMainWindow(parent), ui(n
query.exec();
query.first();
- showFound(); // TODO
+ /* show everything in the interface */
+ lineID->setText(query.value( query.record().indexOf("id") ).toString());
+ lineNome->setText(query.value( query.record().indexOf("nome") ).toString());
+ lineCognome->setText(query.value( query.record().indexOf("cognome") ).toString());
+ lineComuneResidenza->setText(query.value(query.record().indexOf("comuneResidenza")).toString());
+ lineEmail->setText(query.value(query.record().indexOf("email")).toString());
+ comboProfessione->setCurrentIndex(comboProfessione->findData(query.value(query.record().indexOf("professione")).toInt()));
+ comboFonte->setCurrentIndex(comboFonte->findData(query.value(query.record().indexOf("fonte")).toInt()));
+ dateDataNascita->setDate(QDate(1900, 1, 1)); dateDataNascita->setDate(query.value(query.record().indexOf("dataNascita")).toDate());
+ dateDataCompilazione->setDate(QDate(1900, 1, 1)); dateDataCompilazione->setDate(query.value(query.record().indexOf("dataCompilazione")).toDate());
+ checkAbilitaQuestionario->setChecked( query.value(query.record().indexOf("abilitaQuestionario")).toBool() );
}
/*
@@ -56,42 +66,7 @@ void EditWindow::on_buttonCerca_clicked() {
}
*/
-void EditWindow::showFound() {
- lineID->setText(query.value( query.record().indexOf("id") ).toString());
- lineNome->setText(query.value( query.record().indexOf("nome") ).toString());
- lineCognome->setText(query.value( query.record().indexOf("cognome") ).toString());
- lineComuneResidenza->setText(query.value(query.record().indexOf("comuneResidenza")).toString());
- lineEmail->setText(query.value(query.record().indexOf("email")).toString());
- comboProfessione->setCurrentIndex(comboProfessione->findData(query.value(query.record().indexOf("professione")).toInt()));
- comboFonte->setCurrentIndex(comboFonte->findData(query.value(query.record().indexOf("fonte")).toInt()));
- dateDataNascita->setDate(QDate(1900, 1, 1)); dateDataNascita->setDate(query.value(query.record().indexOf("dataNascita")).toDate());
- dateDataCompilazione->setDate(QDate(1900, 1, 1)); dateDataCompilazione->setDate(query.value(query.record().indexOf("dataCompilazione")).toDate());
- checkAbilitaQuestionario->setChecked( query.value(query.record().indexOf("abilitaQuestionario")).toBool() );
-}
-
-void EditWindow::on_buttonSuccessivo_clicked() {
- if (! query.next()) {
- query.last();
- setStatus(Ui::INFO, "no more results");
- return;
- }
- showFound();
-}
-
-void EditWindow::on_buttonPrecedente_clicked() {
- if (! query.previous()) {
- query.first();
- setStatus(Ui::INFO, "no more results");
- return;
- }
- showFound();
-}
-
-void EditWindow::on_buttonNuovo_clicked() {
- return;
-}
-
-void EditWindow::on_buttonModifica_clicked() {
+void EditWindow::on_buttonSalva_clicked() {
query.prepare("UPDATE socio \
SET nome = NULLIF(:nome, ''), \
@@ -142,6 +117,9 @@ void EditWindow::setStatus(Ui::StatusType type, QString message) {
statusBar->showMessage(message, timeout);
}
+void EditWindow::on_buttonAnnulla_clicked() {
+ this->close();
+}
EditWindow::~EditWindow()
{
diff --git a/editwindow.h b/editwindow.h
index de61b0d..5bf9fed 100644
--- a/editwindow.h
+++ b/editwindow.h
@@ -33,10 +33,8 @@ public:
void setStatus(Ui::StatusType type, QString message);
private slots:
- void on_buttonNuovo_clicked();
- void on_buttonModifica_clicked();
- void on_buttonSuccessivo_clicked();
- void on_buttonPrecedente_clicked();
+ void on_buttonSalva_clicked();
+ void on_buttonAnnulla_clicked();
private:
QLineEdit* lineID = nullptr;
@@ -53,8 +51,6 @@ private:
QSqlQuery query;
Ui::EditWindow *ui;
- bool populateUi(void);
- void showFound(void);
};
#endif
diff --git a/editwindow.ui b/editwindow.ui
index 66d3c40..472ec78 100644
--- a/editwindow.ui
+++ b/editwindow.ui
@@ -241,56 +241,17 @@
Qt::Horizontal
-
+
- 10
+ 550
230
91
34
- Cerca
-
-
-
-
-
- 310
- 230
- 91
- 34
-
-
-
- Modifica
-
-
-
-
-
- 110
- 230
- 91
- 34
-
-
-
- Precedente
-
-
-
-
-
- 210
- 230
- 91
- 34
-
-
-
- Successivo
+ Salva
@@ -344,17 +305,17 @@
true
-
+
- 410
+ 450
230
91
34
- Nuovo
+ Annulla
@@ -372,10 +333,7 @@
comboFonte
dateDataCompilazione
checkAbilitaQuestionario
- buttonCerca
- buttonPrecedente
- buttonSuccessivo
- buttonModifica
+ buttonSalva