self.pb_reset.setEnabled(True)
self.pb_save.setEnabled(True)
self.pb_saveclose.setEnabled(True)
- def updateTable(self):
+ def updateTable(self, text):
+ if text.isEmpty():
+ self.model.setFilter("")
+ self.model.select()
+ return
+ t = str(text)
+ strs = t.split()
+ patterns = [] # can't use list comprehensions for this one because setValue returns void
+ for i in strs:
+ f = QSqlField("input",QVariant.String)
+ f.setValue(QVariant(QString("%" + i + "%")))
+ patterns.append(f)
+ escapedpatterns = [ self.model.database().driver().formatValue(wc, False) for wc in patterns]
+ filters = [ str(QString("(surname LIKE %1 OR forename LIKE %2)").arg(wc).arg(wc)) for wc in escapedpatterns]
+ filterString = " AND ".join(filters)
+ self.model.setFilter(QString(filterString))
self.model.select()
- print "Text changed"
+ if self.model.rowCount() == 1:
+ self.tableview.selectRow(0)
def resetPressed(self):
self.fillForm([])
self.pb_reset.setEnabled(False)