make customer dialog filtering
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 7 Dec 2008 15:57:22 +0000 (15:57 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 7 Dec 2008 15:57:22 +0000 (15:57 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@209 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/customer.cpp
src/customer.h

index 496eaf1..b10db78 100644 (file)
@@ -24,6 +24,7 @@
 #include <QListView>
 #include <QMessageBox>
 #include <QPushButton>
+#include <QSortFilterProxyModel>
 #include <QStandardItemModel>
 #include <QTextEdit>
 
@@ -204,8 +205,15 @@ MCustomerListDialog::MCustomerListDialog(MWebRequest*r,QWidget*par,bool isselect
        QHBoxLayout*hl;
        setLayout(vl=new QVBoxLayout);
        vl->addLayout(hl=new QHBoxLayout,10);
-       hl->addWidget(m_listview=new QListView,10);
-       m_listview->setModel(m_listmodel=new QStandardItemModel(this));
+       hl->addLayout(vl2=new QVBoxLayout,10);
+       vl2->addWidget(m_filter=new QLineEdit,0);
+       vl2->addWidget(m_listview=new QListView,10);
+       m_listmodel=new QStandardItemModel(this);
+       m_proxymodel=new QSortFilterProxyModel(this);
+       m_proxymodel->setSourceModel(m_listmodel);
+       connect(m_filter,SIGNAL(textChanged(const QString&)),m_proxymodel,SLOT(setFilterFixedString(const QString&)));
+       m_proxymodel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+       m_listview->setModel(m_proxymodel);
        m_listview->setEditTriggers(QAbstractItemView::NoEditTriggers);
        hl->addLayout(vl2=new QVBoxLayout,0);
        QPushButton*p;
index 275f25e..a63b1f5 100644 (file)
@@ -89,6 +89,8 @@ class MCustomer
 
 class QListView;
 class QStandardItemModel;
+class QSortFilterProxyModel;
+class QLineEdit;
 
 /**shows a list of customers, lets the user select and offers to alter/create customers*/
 class MCustomerListDialog:public QDialog
@@ -113,6 +115,8 @@ class MCustomerListDialog:public QDialog
                QList<MCustomer> m_list;
                QListView*m_listview;
                QStandardItemModel*m_listmodel;
+               QSortFilterProxyModel*m_proxymodel;
+               QLineEdit*m_filter;
                MWebRequest*m_req;
                
                /**updates internal list*/