diff src/metadataview.cpp @ 37:0c05958d254c

(issue 13, 6) Add constant index number column to data and view
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 May 2015 17:17:13 +0200
parents f10d4e035eec
children 73e6b6b12412
line wrap: on
line diff
--- a/src/metadataview.cpp	Wed May 06 16:10:01 2015 +0200
+++ b/src/metadataview.cpp	Wed May 06 17:17:13 2015 +0200
@@ -56,6 +56,7 @@
     mView->setEditTriggers(QAbstractItemView::NoEditTriggers);
 
     baseLayout->addWidget(mView);
+    mView->verticalHeader()->setVisible(false);
 
     setLayout(baseLayout);
 }
@@ -83,7 +84,7 @@
         /* 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());
+                QDateTime(), 0);
     }
 }
 
@@ -95,8 +96,8 @@
     }
     /* One row selected */
     Q_ASSERT(selected.indexes().count() == mCSVModel->columnCount());
-    const QModelIndex idx = selected.indexes()[0];
-    const QString dateString = selected.indexes()[1].data().toString();
+    const QModelIndex idx = selected.indexes()[FILENAME_COLUMN];
+    const QString dateString = selected.indexes()[DATE_COLUMN].data().toString();
     bool ok;
     qint64 secondsSinceEpoch = dateString.toLongLong(&ok);
     if (!ok) {
@@ -105,7 +106,7 @@
     }
     QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(secondsSinceEpoch * 1000);
     emit selectionChanged(idx.data().toString(), idx.row(), mSortModel->rowCount() - 1,
-            timestamp);
+            timestamp, selected.indexes()[0].data().toInt());
     qDebug() << "Selection changed: " << idx.data();
 }
 
@@ -175,8 +176,9 @@
     int idx = -1;
     for (int i=0; i < mSortModel->columnCount(); i++) {
         QString entry = mSortModel->headerData(i, Qt::Horizontal).toString();
+        qDebug() << "Looking at entry: " << entry;
         if (entry.toLower() == sortField.toLower()) {
-            idx = 1;
+            idx = i;
             break;
         }
     }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)