changeset 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 92bb9687d716
children 26e1521b9afd
files CMakeLists.txt src/constants.h src/libqxt/qxtcsvmodel.cpp src/metadataview.cpp src/metadataview.h src/pngplayer.cpp src/pngplayer.h
diffstat 7 files changed, 32 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Wed May 06 16:10:01 2015 +0200
+++ b/CMakeLists.txt	Wed May 06 17:17:13 2015 +0200
@@ -6,7 +6,7 @@
 # See LICENSE.txt for details.
 
 cmake_minimum_required(VERSION 2.8.8)
-project(relayit)
+project(retraceit)
 
 
 ### Generic Setup
--- a/src/constants.h	Wed May 06 16:10:01 2015 +0200
+++ b/src/constants.h	Wed May 06 17:17:13 2015 +0200
@@ -77,4 +77,10 @@
 /**@def The default sort order value. */
 #define SORT_ORDER_VALUE true
 
+/**@def The column to use (counted from 0 and including index nr) for the filename */
+#define FILENAME_COLUMN 1
+
+/**@def The column to use as the date */
+#define DATE_COLUMN 2
+
 #endif // CONSTANTS_H
--- a/src/libqxt/qxtcsvmodel.cpp	Wed May 06 16:10:01 2015 +0200
+++ b/src/libqxt/qxtcsvmodel.cpp	Wed May 06 17:17:13 2015 +0200
@@ -179,6 +179,7 @@
     QChar quote;
     QChar ch, buffer(0);
     bool readCR = false;
+    int idx_nr = 1; // XXX added for retraceit
     QTextStream stream(file);
     if(codec) {
         stream.setCodec(codec);
@@ -202,6 +203,7 @@
             row << field;
             field.clear();
             if(!row.isEmpty()) {
+                row.insert(0, headerSet ? QString::number(idx_nr++) : QString::fromLatin1("Index Nr.")); // XXX added for retraceit
                 if(!headerSet) {
                     d_ptr->header = row;
                     headerSet = true;
@@ -242,6 +244,7 @@
     if(!field.isEmpty()) 
         row << field;
     if(!row.isEmpty()) {
+        row.insert(0, headerSet ? QString::number(idx_nr++) : QString::fromLatin1("#Index Nr.")); // XXX added for relayit
         if(!headerSet)
             d_ptr->header = row;
         else
--- 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;
         }
     }
--- a/src/metadataview.h	Wed May 06 16:10:01 2015 +0200
+++ b/src/metadataview.h	Wed May 06 17:17:13 2015 +0200
@@ -32,12 +32,9 @@
     QString parseMetaData(const QString& fileName);
 
 Q_SIGNALS:
-    /**@brief emited when the selection changed.
-     *
-     * @param pictureFile: The file that is now selected.
-     * @param info: Additional info to show with the file.*/
+    /**@brief emited when the selection changed. */
     void selectionChanged(const QString& pictureFile, int current, int max,
-        const QDateTime& timestamp);
+        const QDateTime& timestamp, int number);
 
 protected slots:
     /** @brief internal slot to handle table view selection changes */
--- a/src/pngplayer.cpp	Wed May 06 16:10:01 2015 +0200
+++ b/src/pngplayer.cpp	Wed May 06 17:17:13 2015 +0200
@@ -107,27 +107,31 @@
 }
 
 void PNGPlayer::showPicture(const QString& fileName, int current, int max,
-        const QDateTime& timestamp) {
+        const QDateTime& timestamp, int number) {
     QPixmap pic(mBaseDir.filePath(fileName));
     /* If this is too slow we could use a pixmap cache here and do
      * some intelligent preloading */
     if (pic.isNull()) {
         qWarning() << "Failed to load picture: " << fileName;
 //        emit error(tr("Failed to load picture: '%1'").arg(fileName));
-        return;
+        QIcon errIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
+        mPNGLabel->setPixmap(errIcon.pixmap(QSize(128, 128)));
+    } else {
+        mPNGLabel->setPixmap(pic);
     }
-    mPNGLabel->setPixmap(pic);
-    updatePositions(current, max, timestamp);
+    updatePositions(current, max, timestamp, number);
 }
 
-void PNGPlayer::updatePositions(int current, int max, const QDateTime& timestamp) {
+void PNGPlayer::updatePositions(int current, int max, const QDateTime& timestamp,
+        int number) {
     mMax = max;
     mSlider->blockSignals(true); /* We only want user generated changes */
     mSlider->setValue(current);
     mSlider->blockSignals(false);
     mSlider->setMaximum(max);
     mPositionLabel->setText("<b>" + tr("Screenshot Nr.:") + " </b>" +
-            QString("%1 (%2)").arg(current + 1).arg(max + 1) + " / <b>" +
+            QString("%1 (%2)").arg(current + 1).arg(max + 1) +
+            "<b> " + tr("Index Nr.:") + " </b>" + QString::number(number) + " / <b>" +
         tr("Timestamp:") + " </b>" + (timestamp.isValid() ?
             timestamp.toString(LONG_DATE_FORMAT) : tr("Unknown")));
 
--- a/src/pngplayer.h	Wed May 06 16:10:01 2015 +0200
+++ b/src/pngplayer.h	Wed May 06 17:17:13 2015 +0200
@@ -48,15 +48,16 @@
      * @param current: The row index of the currently shown image.
      * @param max: The row count.
      * @param timestamp: The timestamp of the image.
+     * @param number: The index number of the picture to show.
      */
     void showPicture(const QString& fileName, int current, int max,
-        const QDateTime& timestamp);
+        const QDateTime& timestamp, int number);
 
     /**@brief set the base dir to which filenames will be relative. */
     void setBaseDir(const QString& dirName) { mBaseDir.setPath(dirName); }
 
     /**@brief update positional information / slider current / max info. */
-    void updatePositions(int current, int max, const QDateTime& timestamp);
+    void updatePositions(int current, int max, const QDateTime& timestamp, int number);
 
     /**@brief set the replay speed */
     void setSpeed(int mSecsPerPicture);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)