feat(sorting): proposta di modifica per il sorting dei soci nella tab Rinnovi secondo i campi id, nome o cognome.
- RenewalTab.ui: aggiunta combobox a fianco dell'anno per selezionare il campo con cui ordinare i soci. - RenewalTab.cpp: modificata la query per la refresh per sceglere ORDER BY da combobox. Per adesso, aggiunti i campi nella combobox hardcoded. Risoluzione della issue #3
This commit is contained in:
parent
004a53300e
commit
a97f34bc95
|
@ -28,13 +28,18 @@ RenewalTab::RenewalTab(QWidget *parent) :
|
|||
|
||||
}
|
||||
|
||||
|
||||
ui->orderBy->addItem("id");
|
||||
ui->orderBy->addItem("nome");
|
||||
ui->orderBy->addItem("cognome");
|
||||
}
|
||||
|
||||
void RenewalTab::refresh() {
|
||||
const int anno = ui->renewalYear->currentData().toInt();
|
||||
const QString order_by = ui->orderBy->currentText();
|
||||
QString query_str = "SELECT YEAR(i.anno) AS anno, s.id, s.cognome, s.nome FROM iscrizione AS i INNER JOIN socio AS s ON s.id = i.socio WHERE YEAR(i.anno) = :anno";
|
||||
query_str += " ORDER BY s." + order_by;
|
||||
|
||||
query.prepare("SELECT YEAR(i.anno) AS anno, s.cognome, s.nome FROM iscrizione AS i INNER JOIN socio AS s ON s.id = i.socio WHERE YEAR(i.anno) = :anno ORDER BY s.cognome");
|
||||
query.prepare(query_str);
|
||||
query.bindValue(":anno", anno);
|
||||
|
||||
if (! query.exec()) {
|
||||
|
@ -49,4 +54,4 @@ void RenewalTab::refresh() {
|
|||
|
||||
void RenewalTab::on_buttonRefresh_clicked() {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,7 @@
|
|||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="table">
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -40,6 +33,9 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="orderBy"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="renewalYear"/>
|
||||
</item>
|
||||
|
@ -52,6 +48,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="table">
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
Loading…
Reference in New Issue