diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index b44dc821f60..6f2996dbc65 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -553,6 +553,9 @@ QVariant BaseTrackTableModel::roleValue( return composeCoverArtToolTipHtml(index); case ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW: return QVariant(); + case ColumnCache::COLUMN_LIBRARYTABLE_RATING: + case ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED: + return std::move(rawValue); default: // Same value as for Qt::DisplayRole (see below) break; @@ -646,20 +649,6 @@ QVariant BaseTrackTableModel::roleValue( return QChar('-'); } } - case ColumnCache::COLUMN_LIBRARYTABLE_YEAR: { - if (rawValue.isNull()) { - return QVariant(); - } - VERIFY_OR_DEBUG_ASSERT(rawValue.canConvert()) { - return QVariant(); - } - bool ok; - const auto year = mixxx::TrackMetadata::formatCalendarYear(rawValue.toString(), &ok); - if (!ok) { - return QVariant(); - } - return year; - } case ColumnCache::COLUMN_LIBRARYTABLE_BITRATE: { if (rawValue.isNull()) { return QVariant(); diff --git a/src/library/parsercsv.cpp b/src/library/parsercsv.cpp index 41f411d6f14..3a3f4fde4e9 100644 --- a/src/library/parsercsv.cpp +++ b/src/library/parsercsv.cpp @@ -1,17 +1,3 @@ -// -// C++ Implementation: parsercsv -// -// Description: module to parse Comma-Separated Values (CSV) formatted playlists (rfc4180) -// -// -// Author: Ingo Kossyk , (C) 2004 -// Author: Tobias Rafreider trafreider@mixxx.org, (C) 2011 -// Author: Daniel Schürmann daschuer@gmx.de, (C) 2011 -// -// Copyright: See COPYING file that comes with this distribution -// -// - #include "library/parsercsv.h" #include @@ -21,12 +7,24 @@ #include "moc_parsercsv.cpp" -ParserCsv::ParserCsv() : Parser() { -} +namespace { -ParserCsv::~ParserCsv() { +bool isColumnExported(BaseSqlTableModel* pPlaylistTableModel, int column) { + if (pPlaylistTableModel->isColumnInternal(column)) { + return false; + } + if (pPlaylistTableModel->fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW) == column) { + return false; + } + if (pPlaylistTableModel->fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART) == column) { + // This is the bas64 encoded image which may hit the maximum line length of spreadsheet applications + return false; + } + return true; } +} // namespace + QList ParserCsv::parse(const QString& sFilename) { QFile file(sFilename); QString basepath = sFilename.section('/', 0, -2); @@ -148,8 +146,7 @@ bool ParserCsv::writeCSVFile(const QString &file_str, BaseSqlTableModel* pPlayli bool first = true; int columns = pPlaylistTableModel->columnCount(); for (int i = 0; i < columns; ++i) { - if (pPlaylistTableModel->isColumnInternal(i) || - (pPlaylistTableModel->fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW) == i)) { + if (!isColumnExported(pPlaylistTableModel, i)) { continue; } if (!first) { @@ -170,8 +167,7 @@ bool ParserCsv::writeCSVFile(const QString &file_str, BaseSqlTableModel* pPlayli // writing fields section first = true; for (int i = 0; i < columns; ++i) { - if (pPlaylistTableModel->isColumnInternal(i) || - (pPlaylistTableModel->fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW) == i)) { + if (!isColumnExported(pPlaylistTableModel, i)) { continue; } if (!first) { diff --git a/src/library/parsercsv.h b/src/library/parsercsv.h index ecf1e1167ed..4b7b168d444 100644 --- a/src/library/parsercsv.h +++ b/src/library/parsercsv.h @@ -1,16 +1,3 @@ -// -// C++ Interface: parserm3u -// -// Description: Interface header parse Comma-Separated Values (CSV) formatted playlists (rfc4180) -// -// -// Author: Ingo Kossyk , (C) 2004 -// Author: Tobias Rafreider trafreider@mixxx.org, (C) 2011 -// Author: Daniel Schürmann daschuer@gmx.de, (C) 2011 -// -// Copyright: See COPYING file that comes with this distribution -// -// #pragma once #include @@ -20,21 +7,22 @@ #include "library/parser.h" #include "library/basesqltablemodel.h" -class ParserCsv : public Parser -{ +class ParserCsv : public Parser { Q_OBJECT -public: - ParserCsv(); - virtual ~ParserCsv(); - /**Overwriting function parse in class Parser**/ - QList parse(const QString&); - // Playlist Export - static bool writeCSVFile(const QString &file, BaseSqlTableModel* pPlaylistTableModel, bool useRelativePath); - // Readable Text export - static bool writeReadableTextFile(const QString &file, BaseSqlTableModel* pPlaylistTableModel, bool writeTimestamp); -private: - /**Reads a line from the file and returns filepath if a valid file**/ - QList > tokenize(const QByteArray& str, char delimiter); + public: + ~ParserCsv() override = default; + QList parse(const QString&) override; + static bool writeCSVFile( + const QString& file, + BaseSqlTableModel* pPlaylistTableModel, + bool useRelativePath); + static bool writeReadableTextFile( + const QString& file, + BaseSqlTableModel* pPlaylistTableModel, + bool writeTimestamp); + private: + /// Reads a line from the file and returns filepath if a valid file + QList> tokenize(const QByteArray& str, char delimiter); };