From: konrad Date: Mon, 8 Dec 2008 14:02:05 +0000 (+0000) Subject: fix:use proxy model in customer dialog X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=31e6644284aff33759a99906e088d0096c8c6844;p=web%2Fkonrad%2Fsmoke.git fix:use proxy model in customer dialog git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@212 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/customer.cpp b/src/customer.cpp index b10db78..09290b1 100644 --- a/src/customer.cpp +++ b/src/customer.cpp @@ -211,6 +211,8 @@ MCustomerListDialog::MCustomerListDialog(MWebRequest*r,QWidget*par,bool isselect m_listmodel=new QStandardItemModel(this); m_proxymodel=new QSortFilterProxyModel(this); m_proxymodel->setSourceModel(m_listmodel); + m_proxymodel->setDynamicSortFilter(true); + m_proxymodel->setSortCaseSensitivity(Qt::CaseInsensitive); connect(m_filter,SIGNAL(textChanged(const QString&)),m_proxymodel,SLOT(setFilterFixedString(const QString&))); m_proxymodel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_listview->setModel(m_proxymodel); @@ -243,9 +245,9 @@ MCustomerListDialog::MCustomerListDialog(MWebRequest*r,QWidget*par,bool isselect //update data updateList(); if(presel>-1){ - for(int i=0;irowCount();i++){ - QModelIndex idx=m_listmodel->index(0,i); - if(m_listmodel->data(idx,Qt::UserRole).toInt()==presel) + for(int i=0;irowCount();i++){ + QModelIndex idx=m_proxymodel->index(0,i); + if(m_proxymodel->data(idx,Qt::UserRole).toInt()==presel) m_listview->setCurrentIndex(idx); } } @@ -273,7 +275,7 @@ MCustomer MCustomerListDialog::getCustomer() QModelIndex idx=m_listview->currentIndex(); if(!idx.isValid())return MCustomer(); //return object - int i=m_listmodel->data(idx,Qt::UserRole).toInt(); + int i=m_proxymodel->data(idx,Qt::UserRole).toInt(); if(i<0||i>=m_list.size())return MCustomer(); return m_list[i]; } @@ -290,7 +292,7 @@ void MCustomerListDialog::editCustomer() QModelIndex idx=m_listview->currentIndex(); if(!idx.isValid())return; //return object - int i=m_listmodel->data(idx,Qt::UserRole).toInt(); + int i=m_proxymodel->data(idx,Qt::UserRole).toInt(); if(i<0||i>=m_list.size())return; //open dialog MCustomerDialog cd(m_list[i],this); @@ -303,14 +305,14 @@ void MCustomerListDialog::deleteCustomer() QModelIndex idx=m_listview->currentIndex(); if(!idx.isValid())return; //get pointer to customer - int dusr=m_listmodel->data(idx,Qt::UserRole).toInt(); + int dusr=m_proxymodel->data(idx,Qt::UserRole).toInt(); if(dusr<0||dusr>=m_list.size())return; //show delete dialog QDialog d; d.setWindowTitle(tr("Delete Customer")); QVBoxLayout*vl; d.setLayout(vl=new QVBoxLayout); - vl->addWidget(new QLabel(tr("Really delete this customer (%1)?").arg(m_listmodel->data(idx).toString()))); + vl->addWidget(new QLabel(tr("Really delete this customer (%1)?").arg(m_proxymodel->data(idx).toString()))); vl->addSpacing(20); QCheckBox*cb; vl->addWidget(cb=new QCheckBox(tr("merge with other entry:")));