changeset 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 c3000fa6ca56
files src/constants.h src/filterwidget.cpp src/metadataview.cpp src/metadataview.h
diffstat 4 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/constants.h	Fri Jun 19 14:26:16 2015 +0200
+++ b/src/constants.h	Fri Jun 19 14:27:15 2015 +0200
@@ -131,4 +131,8 @@
 * @brief The configuration group for the tooltips. */
 #define TOOLTIP_CONFIG_GROUP "Tooltips"
 
+/**
+* @brief The configuration group for hide settings */
+#define HIDE_CONFIG_GROUP "Hidden"
+
 #endif // CONSTANTS_H
--- a/src/filterwidget.cpp	Fri Jun 19 14:26:16 2015 +0200
+++ b/src/filterwidget.cpp	Fri Jun 19 14:27:15 2015 +0200
@@ -6,7 +6,9 @@
  * See LICENSE.txt for details.
  */
 #include "filterwidget.h"
+#include "constants.h"
 
+#include <QSettings>
 #include <QComboBox>
 #include <QHBoxLayout>
 #include <QGroupBox>
@@ -14,6 +16,7 @@
 #include <QAbstractItemModel>
 #include <QLineEdit>
 #include <QDebug>
+#include <QCheckBox>
 
 FilterWidget::FilterWidget(QSortFilterProxyModel *model, bool addWithEmptyChk, 
                            QWidget *parent, Qt::WindowFlags f) :
@@ -38,8 +41,13 @@
     mCombo->clear();
     mColFilterMap.clear();
     int addedItems = 0;
+    QSettings settings;
+    settings.beginGroup(HIDE_CONFIG_GROUP);
     for (int i=0; i < newSource->columnCount(); i++) {
         QString entry = newSource->headerData(i, Qt::Horizontal).toString();
+        if (settings.value(entry, false).toBool()) {
+            continue;
+        }
         if (!entry.startsWith("#")) {
             mCombo->addItem(entry);
             mColFilterMap.insert(addedItems++, i);
--- a/src/metadataview.cpp	Fri Jun 19 14:26:16 2015 +0200
+++ b/src/metadataview.cpp	Fri Jun 19 14:27:15 2015 +0200
@@ -95,6 +95,8 @@
 
     mSortModel->setSourceModel(mCSVModel);
     qDebug() << "Parsed: " << mCSVModel->rowCount() << " rows.";
+    mFilterWidget->headersChanged();
+    hideCols();
     applyDefaultSort();
     resizeColsToHeaders();
 
@@ -269,3 +271,14 @@
         }
     }
 }
+
+void MetaDataView::hideCols() {
+    QSettings settings;
+    settings.beginGroup(HIDE_CONFIG_GROUP);
+    for (int i=0; i < mSortModel->columnCount(); i++) {
+        QString entry = mSortModel->headerData(i, Qt::Horizontal).toString();
+        bool hidden = settings.value(entry, false).toBool();
+        settings.setValue(entry, hidden);
+        mView->setColumnHidden(i, hidden);
+    }
+}
--- a/src/metadataview.h	Fri Jun 19 14:26:16 2015 +0200
+++ b/src/metadataview.h	Fri Jun 19 14:27:15 2015 +0200
@@ -60,6 +60,9 @@
     /** @brief load the configured header tooltips */
     void setupHeaderTooltips();
 
+    /** @brief hides the columns that are set in the config hide section */
+    void hideCols();
+
 public slots:
     /** @brief selects the next row and emits a selection changed signal */
     void selectNextRow();
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)