comparison src/filterwidget.cpp @ 14:315e6988952a

Only add entries that do not start with # to filter
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 14 Apr 2015 17:25:15 +0200
parents e4748da7140b
children 73efe717b944
comparison
equal deleted inserted replaced
13:06c9b37d1e1b 14:315e6988952a
26 26
27 void FilterWidget::headersChanged() { 27 void FilterWidget::headersChanged() {
28 QAbstractItemModel *newSource = mModel->sourceModel(); 28 QAbstractItemModel *newSource = mModel->sourceModel();
29 Q_ASSERT(newSource); 29 Q_ASSERT(newSource);
30 mCombo->clear(); 30 mCombo->clear();
31 mColFilterMap.clear();
32 int addedItems = 0;
31 for (int i=0; i < newSource->columnCount(); i++) { 33 for (int i=0; i < newSource->columnCount(); i++) {
32 mCombo->addItem(newSource->headerData(i, Qt::Horizontal).toString()); 34 QString entry = newSource->headerData(i, Qt::Horizontal).toString();
35 if (!entry.startsWith("#")) {
36 mCombo->addItem(entry);
37 mColFilterMap.insert(addedItems++, i);
38 } else {
39 QString shortended = entry.remove(0,1);
40 // TODO this does not work as expected
41 newSource->setHeaderData(i, Qt::Horizontal, shortended);
42 }
33 } 43 }
34 } 44 }
35 45
36 void FilterWidget::filterChanged() { 46 void FilterWidget::filterChanged() {
37 QString filterText = mEditLine->text(); 47 QString filterText = mEditLine->text();
38 if (filterText.size() < 1) { 48 if (filterText.size() < 1) {
39 return; 49 return;
40 } 50 }
41 mModel->setFilterKeyColumn(mCombo->currentIndex()); 51 qDebug() << "Filter on Column: " << mColFilterMap.value(mCombo->currentIndex());
52 qDebug() << "Instead of: " << mCombo->currentIndex();
53 mModel->setFilterKeyColumn(mColFilterMap.value(mCombo->currentIndex()));
42 mModel->setFilterWildcard(filterText); 54 mModel->setFilterWildcard(filterText);
43 } 55 }
44 56
45 void FilterWidget::setupGUI() { 57 void FilterWidget::setupGUI() {
46 QHBoxLayout *root = new QHBoxLayout; 58 QHBoxLayout *root = new QHBoxLayout;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)