# HG changeset patch # User Andre Heinecke # Date 1430925433 -7200 # Node ID 0c05958d254c95be152e0d4f42c07a1328f4cef3 # Parent 92bb9687d716fd8c544d10e9e2b327c1324dd46f (issue 13, 6) Add constant index number column to data and view diff -r 92bb9687d716 -r 0c05958d254c CMakeLists.txt --- 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 diff -r 92bb9687d716 -r 0c05958d254c src/constants.h --- 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 diff -r 92bb9687d716 -r 0c05958d254c src/libqxt/qxtcsvmodel.cpp --- 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 diff -r 92bb9687d716 -r 0c05958d254c src/metadataview.cpp --- 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; } } diff -r 92bb9687d716 -r 0c05958d254c src/metadataview.h --- 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 */ diff -r 92bb9687d716 -r 0c05958d254c src/pngplayer.cpp --- 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("" + tr("Screenshot Nr.:") + " " + - QString("%1 (%2)").arg(current + 1).arg(max + 1) + " / " + + QString("%1 (%2)").arg(current + 1).arg(max + 1) + + " " + tr("Index Nr.:") + " " + QString::number(number) + " / " + tr("Timestamp:") + " " + (timestamp.isValid() ? timestamp.toString(LONG_DATE_FORMAT) : tr("Unknown"))); diff -r 92bb9687d716 -r 0c05958d254c src/pngplayer.h --- 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);