comparison src/metadataview.cpp @ 88:3916cb3c9105

Add new FilterSort model that allows to include empty values
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 19 Jun 2015 14:26:16 +0200
parents 9a03703622b8
children b8c7644a9d49
comparison
equal deleted inserted replaced
87:3b3a1384eb5f 88:3916cb3c9105
6 * See LICENSE.txt for details. 6 * See LICENSE.txt for details.
7 */ 7 */
8 #include "metadataview.h" 8 #include "metadataview.h"
9 #include "qxtcsvmodel.h" 9 #include "qxtcsvmodel.h"
10 #include "filterwidget.h" 10 #include "filterwidget.h"
11 #include "includeemptysortmodel.h"
11 #include "constants.h" 12 #include "constants.h"
12 13
13 #include <QTextCodec> 14 #include <QTextCodec>
14 #include <QTableView> 15 #include <QTableView>
15 #include <QSortFilterProxyModel> 16 #include <QSortFilterProxyModel>
45 46
46 MetaDataView::MetaDataView(QWidget *parent, Qt::WindowFlags f) : 47 MetaDataView::MetaDataView(QWidget *parent, Qt::WindowFlags f) :
47 QWidget(parent, f), 48 QWidget(parent, f),
48 mDateColIdx(-1) { 49 mDateColIdx(-1) {
49 /* Create models */ 50 /* Create models */
50 mSortModel = new QSortFilterProxyModel; 51 mSortModel = new IncludeEmptySortModel;
51 mCSVModel = new numericSortCSVModel; 52 mCSVModel = new numericSortCSVModel;
52 setupGUI(); 53 setupGUI();
53 54
54 connect(mView->selectionModel(), &QItemSelectionModel::selectionChanged, 55 connect(mView->selectionModel(), &QItemSelectionModel::selectionChanged,
55 this, &MetaDataView::viewSelectionChanged); 56 this, &MetaDataView::viewSelectionChanged);
59 } 60 }
60 61
61 void MetaDataView::setupGUI() { 62 void MetaDataView::setupGUI() {
62 QVBoxLayout *baseLayout = new QVBoxLayout; 63 QVBoxLayout *baseLayout = new QVBoxLayout;
63 64
64 FilterWidget *filterWidget = new FilterWidget(mSortModel); 65 mFilterWidget = new FilterWidget(mSortModel, true);
65 connect(filterWidget, &FilterWidget::filterHasChanged, 66 connect(mFilterWidget, &FilterWidget::filterHasChanged,
66 this, &MetaDataView::applyDefaultSort); 67 this, &MetaDataView::applyDefaultSort);
67 connect(filterWidget, &FilterWidget::filterHasChanged, 68 connect(mFilterWidget, &FilterWidget::includeEmptyChanged,
69 mSortModel, &IncludeEmptySortModel::setIncludeEmpty);
70 connect(mFilterWidget, &FilterWidget::filterHasChanged,
68 this, &MetaDataView::selectFirstRow); 71 this, &MetaDataView::selectFirstRow);
69 baseLayout->addWidget(filterWidget); 72 baseLayout->addWidget(mFilterWidget);
70 73
71 mView = new QTableView; 74 mView = new QTableView;
72 mView->setModel(mSortModel); 75 mView->setModel(mSortModel);
73 76
74 mView->horizontalHeader()->setStretchLastSection(true); 77 mView->horizontalHeader()->setStretchLastSection(true);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)