diff src/metadataview.cpp @ 4:e4748da7140b

Add filter functionalty to metadataview
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 25 Mar 2015 14:23:46 +0100
parents 248d5d1cdb38
children 73efe717b944
line wrap: on
line diff
--- a/src/metadataview.cpp	Mon Mar 23 19:10:01 2015 +0100
+++ b/src/metadataview.cpp	Wed Mar 25 14:23:46 2015 +0100
@@ -1,5 +1,6 @@
 #include "metadataview.h"
 #include "qxtcsvmodel.h"
+#include "filterwidget.h"
 
 #include <QTextCodec>
 #include <QTableView>
@@ -20,11 +21,17 @@
 
     connect(mView->selectionModel(), &QItemSelectionModel::selectionChanged,
             this, &MetaDataView::viewSelectionChanged);
+    connect(mSortModel, &QSortFilterProxyModel::dataChanged,
+            this, &MetaDataView::dataChanged);
     return;
 }
 
 void MetaDataView::setupGUI() {
     QVBoxLayout *baseLayout = new QVBoxLayout;
+
+    FilterWidget *filterWidget = new FilterWidget(mSortModel);
+    baseLayout->addWidget(filterWidget);
+
     mView = new QTableView;
     mView->setModel(mSortModel);
 
@@ -52,8 +59,26 @@
     return QString();
 }
 
+void MetaDataView::dataChanged()
+{
+    QItemSelectionModel *selection = mView->selectionModel();
+    QModelIndexList selected = selection->selectedIndexes();
+
+    qDebug() << "Data Changed.";
+    if (selected.isEmpty()) {
+        /* Nothing selected still we need to emit this signal to update
+         * the viewer otherwise selection changed handles it. */
+        emit selectionChanged(QString(), 0, mSortModel->rowCount() - 1,
+                QDateTime());
+    }
+}
+
 void MetaDataView::viewSelectionChanged(const QItemSelection& selected,
                                         const QItemSelection& deselected) {
+    if (selected.indexes().isEmpty()) {
+        /* Nothing selected */
+        return;
+    }
     /* One row selected */
     Q_ASSERT(selected.indexes().count() == mCSVModel->columnCount());
     const QModelIndex idx = selected.indexes()[0];
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)