EditWindow purged, now it only does editing

This commit is contained in:
giomba 2019-08-06 11:11:20 +02:00
parent 61059d12c8
commit 6851637b7d
3 changed files with 24 additions and 92 deletions

View File

@ -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()
{

View File

@ -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

View File

@ -241,56 +241,17 @@
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QPushButton" name="buttonCerca">
<widget class="QPushButton" name="buttonSalva">
<property name="geometry">
<rect>
<x>10</x>
<x>550</x>
<y>230</y>
<width>91</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string>Cerca</string>
</property>
</widget>
<widget class="QPushButton" name="buttonModifica">
<property name="geometry">
<rect>
<x>310</x>
<y>230</y>
<width>91</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string>Modifica</string>
</property>
</widget>
<widget class="QPushButton" name="buttonPrecedente">
<property name="geometry">
<rect>
<x>110</x>
<y>230</y>
<width>91</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string>Precedente</string>
</property>
</widget>
<widget class="QPushButton" name="buttonSuccessivo">
<property name="geometry">
<rect>
<x>210</x>
<y>230</y>
<width>91</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string>Successivo</string>
<string>Salva</string>
</property>
</widget>
<widget class="QCheckBox" name="checkAbilitaQuestionario">
@ -344,17 +305,17 @@
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="buttonNuovo">
<widget class="QPushButton" name="buttonAnnulla">
<property name="geometry">
<rect>
<x>410</x>
<x>450</x>
<y>230</y>
<width>91</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string>Nuovo</string>
<string>Annulla</string>
</property>
</widget>
</widget>
@ -372,10 +333,7 @@
<tabstop>comboFonte</tabstop>
<tabstop>dateDataCompilazione</tabstop>
<tabstop>checkAbilitaQuestionario</tabstop>
<tabstop>buttonCerca</tabstop>
<tabstop>buttonPrecedente</tabstop>
<tabstop>buttonSuccessivo</tabstop>
<tabstop>buttonModifica</tabstop>
<tabstop>buttonSalva</tabstop>
</tabstops>
<resources/>
<connections/>