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);
//update data
updateList();
if(presel>-1){
- for(int i=0;i<m_listmodel->rowCount();i++){
- QModelIndex idx=m_listmodel->index(0,i);
- if(m_listmodel->data(idx,Qt::UserRole).toInt()==presel)
+ for(int i=0;i<m_proxymodel->rowCount();i++){
+ QModelIndex idx=m_proxymodel->index(0,i);
+ if(m_proxymodel->data(idx,Qt::UserRole).toInt()==presel)
m_listview->setCurrentIndex(idx);
}
}
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];
}
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);
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:")));