changeset 53:28d5a77db9fb 0.9.1

Ensure that the first row is properly set after filtering
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 18 May 2015 12:06:01 +0200
parents f38e4cd95d52
children db2a9d9c15fc
files src/l10n/main_de_DE.ts src/metadataview.cpp src/metadataview.h
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/l10n/main_de_DE.ts	Thu May 07 10:38:07 2015 +0200
+++ b/src/l10n/main_de_DE.ts	Mon May 18 12:06:01 2015 +0200
@@ -103,7 +103,7 @@
 <context>
     <name>MetaDataView</name>
     <message>
-        <location filename="../metadataview.cpp" line="68"/>
+        <location filename="../metadataview.cpp" line="70"/>
         <source>Failed to parse file: &apos;%1&apos;</source>
         <translation>Die Datei &apos;%1&apos; konnte nicht eingelesen werden.</translation>
     </message>
--- a/src/metadataview.cpp	Thu May 07 10:38:07 2015 +0200
+++ b/src/metadataview.cpp	Mon May 18 12:06:01 2015 +0200
@@ -44,6 +44,8 @@
     FilterWidget *filterWidget = new FilterWidget(mSortModel);
     connect(filterWidget, &FilterWidget::filterHasChanged,
             this, &MetaDataView::applyDefaultSort);
+    connect(filterWidget, &FilterWidget::filterHasChanged,
+            this, &MetaDataView::selectFirstRow);
     baseLayout->addWidget(filterWidget);
 
     mView = new QTableView;
@@ -128,6 +130,11 @@
     qDebug() << "Selection changed: " << idx.data();
 }
 
+void MetaDataView::selectFirstRow() {
+    qDebug() << "Selecting first row";
+    selectRow(0);
+}
+
 void MetaDataView::selectRow(int row) {
     QItemSelectionModel *selection = mView->selectionModel();
     if (!mSortModel->hasIndex(row, 0)) {
@@ -135,7 +142,7 @@
         return;
     }
     QModelIndex newIdx = mSortModel->index(row, 0);
-    selection->select(newIdx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+    selection->select(newIdx, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
 }
 
 void MetaDataView::selectPrevRow() {
--- a/src/metadataview.h	Thu May 07 10:38:07 2015 +0200
+++ b/src/metadataview.h	Mon May 18 12:06:01 2015 +0200
@@ -53,6 +53,9 @@
     /**@brief select a specific row. */
     void selectRow(int row);
 
+    /**@brief select the first row. */
+    void selectFirstRow();
+
     /**@brief applies the default sort order from configuration */
     void applyDefaultSort();
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)