From 2cab37c3bfffc6a17fbae61a2b4599fa533d2775 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 19 Mar 2009 12:46:24 +0000 Subject: Optmized number of queries in dbwidget. --- client/widgets/dbwidget.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'client/widgets/dbwidget.cc') diff --git a/client/widgets/dbwidget.cc b/client/widgets/dbwidget.cc index 9ec0c0d..31a6a42 100644 --- a/client/widgets/dbwidget.cc +++ b/client/widgets/dbwidget.cc @@ -78,7 +78,7 @@ DBWidget::DBWidget(QDomNode &node, MacroWindow *macrowindow) setEditable(true); // Make empty default selection. - addItem("Skriv noget i søgefeltet."); + addItem(tr("Write something in the searchfield")); setCurrentIndex(-1); QStringListModel *strlst = new QStringListModel(); @@ -123,9 +123,15 @@ void DBWidget::setValue(QString value, QString source) bool DBWidget::isValid() { + + return currentText() != tr("Write something in the searchfield") + && findText(currentText()) != -1; + + /* QSqlQuery query = db.exec("SELECT " + select + " FROM " + from + " WHERE LOWER(" + where + ") = '" + currentText().toLower() + "';"); return query.size() != 0; + */ } void DBWidget::changed() @@ -147,14 +153,13 @@ void DBWidget::changed() void DBWidget::update_list(QString prefix) { - /* if(prefix == "") { clear(); - addItem("Skriv noget i søgefeltet."); + addItem(tr("Write something in the searchfield")); setCurrentIndex(-1); return; } - */ + QSqlQuery query = db.exec("SELECT " + select + " FROM " + from + " WHERE LOWER(" + where + ") LIKE '" + prefix.toLower() + "%';"); QStringList lst; -- cgit v1.2.3