Proper retriveal of id socio from QTableView and case insensitive search
This commit is contained in:
parent
5cb738dce4
commit
7ffeed0495
|
@ -38,7 +38,8 @@ MainWindow::~MainWindow() {
|
||||||
void MainWindow::on_buttonCerca_clicked() {
|
void MainWindow::on_buttonCerca_clicked() {
|
||||||
if (!db.open()) connectDatabase();
|
if (!db.open()) connectDatabase();
|
||||||
|
|
||||||
query.prepare("SELECT id, nome, cognome FROM socio WHERE cognome LIKE :cognome");
|
query.prepare("SELECT id, nome, cognome FROM socio WHERE LOWER(nome) LIKE LOWER(:nome) AND LOWER(cognome) LIKE LOWER(:cognome)");
|
||||||
|
query.bindValue( ":nome", QString("%%1%").arg(lineNome->text()) );
|
||||||
query.bindValue( ":cognome", QString("%%1%").arg(lineCognome->text()) );
|
query.bindValue( ":cognome", QString("%%1%").arg(lineCognome->text()) );
|
||||||
|
|
||||||
if ( ! query.exec() ) { qDebug() << query.lastQuery(); return; }
|
if ( ! query.exec() ) { qDebug() << query.lastQuery(); return; }
|
||||||
|
@ -59,7 +60,8 @@ void MainWindow::on_buttonNuovo_clicked() { /* TODO -- please implement me thank
|
||||||
|
|
||||||
void MainWindow::on_tableSoci_clicked(const QModelIndex& index) {
|
void MainWindow::on_tableSoci_clicked(const QModelIndex& index) {
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
int id = index.data().toInt(); /* retrieve id socio */
|
/* extracts id socio from first column of table view */
|
||||||
|
int id = index.model()->data(index.siblingAtColumn(0)).toInt();
|
||||||
if (id != 0) { /* if click is not on other fields than id... */
|
if (id != 0) { /* if click is not on other fields than id... */
|
||||||
EditWindow* w = new EditWindow(id, this);
|
EditWindow* w = new EditWindow(id, this);
|
||||||
w->show();
|
w->show();
|
||||||
|
|
Loading…
Reference in New Issue