comparison src/filterwidget.cpp @ 89:b8c7644a9d49

Add config settings to hide specific columns
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 19 Jun 2015 14:27:15 +0200
parents 3916cb3c9105
children 07e1e47954f6
comparison
equal deleted inserted replaced
88:3916cb3c9105 89:b8c7644a9d49
4 * This file is Free Software under the GNU GPL (v>=2) 4 * This file is Free Software under the GNU GPL (v>=2)
5 * and comes with ABSOLUTELY NO WARRANTY! 5 * and comes with ABSOLUTELY NO WARRANTY!
6 * See LICENSE.txt for details. 6 * See LICENSE.txt for details.
7 */ 7 */
8 #include "filterwidget.h" 8 #include "filterwidget.h"
9 #include "constants.h"
9 10
11 #include <QSettings>
10 #include <QComboBox> 12 #include <QComboBox>
11 #include <QHBoxLayout> 13 #include <QHBoxLayout>
12 #include <QGroupBox> 14 #include <QGroupBox>
13 #include <QSortFilterProxyModel> 15 #include <QSortFilterProxyModel>
14 #include <QAbstractItemModel> 16 #include <QAbstractItemModel>
15 #include <QLineEdit> 17 #include <QLineEdit>
16 #include <QDebug> 18 #include <QDebug>
19 #include <QCheckBox>
17 20
18 FilterWidget::FilterWidget(QSortFilterProxyModel *model, bool addWithEmptyChk, 21 FilterWidget::FilterWidget(QSortFilterProxyModel *model, bool addWithEmptyChk,
19 QWidget *parent, Qt::WindowFlags f) : 22 QWidget *parent, Qt::WindowFlags f) :
20 QWidget(parent, f), 23 QWidget(parent, f),
21 mModel(model), 24 mModel(model),
36 QAbstractItemModel *newSource = mModel->sourceModel(); 39 QAbstractItemModel *newSource = mModel->sourceModel();
37 Q_ASSERT(newSource); 40 Q_ASSERT(newSource);
38 mCombo->clear(); 41 mCombo->clear();
39 mColFilterMap.clear(); 42 mColFilterMap.clear();
40 int addedItems = 0; 43 int addedItems = 0;
44 QSettings settings;
45 settings.beginGroup(HIDE_CONFIG_GROUP);
41 for (int i=0; i < newSource->columnCount(); i++) { 46 for (int i=0; i < newSource->columnCount(); i++) {
42 QString entry = newSource->headerData(i, Qt::Horizontal).toString(); 47 QString entry = newSource->headerData(i, Qt::Horizontal).toString();
48 if (settings.value(entry, false).toBool()) {
49 continue;
50 }
43 if (!entry.startsWith("#")) { 51 if (!entry.startsWith("#")) {
44 mCombo->addItem(entry); 52 mCombo->addItem(entry);
45 mColFilterMap.insert(addedItems++, i); 53 mColFilterMap.insert(addedItems++, i);
46 } else { 54 } else {
47 if (!newSource->setHeaderData(i, Qt::Horizontal, entry.remove(0,1), Qt::DisplayRole)) { 55 if (!newSource->setHeaderData(i, Qt::Horizontal, entry.remove(0,1), Qt::DisplayRole)) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)