Commit f64bed95 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

add missing metadata fields in metadata dialog

durationa and a few other roles where mssing. Add them back.
parent e804ed9c
......@@ -112,7 +112,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
QCOMPARE(beginRemovedRowsSpy.count(), 0);
QCOMPARE(endRemovedRowsSpy.count(), 0);
QCOMPARE(myModel.rowCount(), 12);
QCOMPARE(myModel.rowCount(), 13);
musicDb.trackHasStartedPlaying(QUrl::fromLocalFile(QStringLiteral("/$2")), QDateTime::currentDateTime());
......@@ -123,7 +123,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
QCOMPARE(beginRemovedRowsSpy.count(), 0);
QCOMPARE(endRemovedRowsSpy.count(), 0);
QCOMPARE(myModel.rowCount(), 12);
QCOMPARE(myModel.rowCount(), 13);
musicDb.trackHasStartedPlaying(QUrl::fromLocalFile(QStringLiteral("/$1")), QDateTime::currentDateTime());
......@@ -134,7 +134,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
QCOMPARE(beginRemovedRowsSpy.count(), 0);
QCOMPARE(endRemovedRowsSpy.count(), 0);
QCOMPARE(myModel.rowCount(), 13);
QCOMPARE(myModel.rowCount(), 14);
}
};
......
......@@ -96,9 +96,23 @@ QVariant EditableTrackMetadataModel::data(const QModelIndex &index, int role) co
result = false;
break;
case DataTypes::DurationRole:
result = true;
break;
case DataTypes::SampleRateRole:
result = false;
break;
case DataTypes::BitRateRole:
result = false;
break;
case DataTypes::ChannelsRole:
result = false;
break;
case DataTypes::FirstPlayDate:
result = true;
break;
case DataTypes::PlayFrequency:
result = true;
break;
case DataTypes::SecondaryTextRole:
case DataTypes::ShadowForImageRole:
case DataTypes::ChildModelRole:
......@@ -115,8 +129,6 @@ QVariant EditableTrackMetadataModel::data(const QModelIndex &index, int role) co
case DataTypes::AlbumIdRole:
case DataTypes::HasEmbeddedCover:
case DataTypes::FileModificationTime:
case DataTypes::FirstPlayDate:
case DataTypes::PlayFrequency:
case DataTypes::ElementTypeRole:
case DataTypes::FullDataRole:
case DataTypes::IsDirectoryRole:
......@@ -142,14 +154,14 @@ QVariant EditableTrackMetadataModel::data(const QModelIndex &index, int role) co
case DataTypes::ComposerRole:
case DataTypes::CommentRole:
case DataTypes::YearRole:
case DataTypes::LastPlayDate:
case DataTypes::PlayCounter:
case DataTypes::LyricsRole:
case DataTypes::SampleRateRole:
result = true;
break;
case DataTypes::LastPlayDate:
case DataTypes::PlayCounter:
case DataTypes::ImageUrlRole:
case DataTypes::DurationRole:
case DataTypes::SampleRateRole:
case DataTypes::SecondaryTextRole:
case DataTypes::ShadowForImageRole:
case DataTypes::ChildModelRole:
......
......@@ -86,6 +86,16 @@ QVariant TrackMetadataModel::data(const QModelIndex &index, int role) const
}
break;
}
case DataTypes::DurationRole:
{
auto trackDuration = mTrackData.duration();
if (trackDuration.hour() == 0) {
result = trackDuration.toString(QStringLiteral("mm:ss"));
} else {
result = trackDuration.toString();
}
break;
}
default:
result = mTrackData[currentKey];
break;
......@@ -235,10 +245,21 @@ QVariant TrackMetadataModel::data(const QModelIndex &index, int role) const
case DataTypes::LyricsRole:
result = LongTextEntry;
break;
case DataTypes::DurationRole:
case DataTypes::SampleRateRole:
result = IntegerEntry;
break;
case DataTypes::BitRateRole:
result = IntegerEntry;
break;
case DataTypes::ChannelsRole:
result = IntegerEntry;
break;
case DataTypes::FirstPlayDate:
result = DateEntry;
break;
case DataTypes::DurationRole:
result = DurationEntry;
break;
case DataTypes::SecondaryTextRole:
case DataTypes::ShadowForImageRole:
case DataTypes::ChildModelRole:
......@@ -255,7 +276,6 @@ QVariant TrackMetadataModel::data(const QModelIndex &index, int role) const
case DataTypes::AlbumIdRole:
case DataTypes::HasEmbeddedCover:
case DataTypes::FileModificationTime:
case DataTypes::FirstPlayDate:
case DataTypes::PlayFrequency:
case DataTypes::ElementTypeRole:
case DataTypes::FullDataRole:
......@@ -336,12 +356,15 @@ void TrackMetadataModel::trackData(const TrackMetadataModel::TrackDataType &trac
}
const QList<DataTypes::ColumnsRoles> fieldsForTrack({DataTypes::TitleRole, DataTypes::ArtistRole,
DataTypes::AlbumRole, DataTypes::AlbumArtistRole,
DataTypes::TrackNumberRole, DataTypes::DiscNumberRole,
DataTypes::RatingRole, DataTypes::GenreRole,
DataTypes::LyricistRole, DataTypes::ComposerRole,
DataTypes::CommentRole, DataTypes::YearRole,
DataTypes::LastPlayDate, DataTypes::PlayCounter});
DataTypes::AlbumRole, DataTypes::AlbumArtistRole,
DataTypes::TrackNumberRole, DataTypes::DiscNumberRole,
DataTypes::RatingRole, DataTypes::GenreRole,
DataTypes::LyricistRole, DataTypes::ComposerRole,
DataTypes::CommentRole, DataTypes::YearRole,
DataTypes::ChannelsRole, DataTypes::BitRateRole,
DataTypes::SampleRateRole, DataTypes::LyricsRole,
DataTypes::LastPlayDate, DataTypes::PlayCounter,
DataTypes::DurationRole});
fillDataFromTrackData(trackData, fieldsForTrack);
}
......@@ -531,6 +554,8 @@ void TrackMetadataModel::addDataByName(const QString &name)
newRole = DataTypes::SampleRateRole;
} else if (name == i18nc("Lyrics label for track metadata view", "Lyrics")) {
newRole = DataTypes::LyricsRole;
} else if (name == i18nc("Duration label for track metadata view", "Duration")) {
newRole = DataTypes::DurationRole;
}
mTrackData[newRole] = {};
......
......@@ -63,6 +63,7 @@ public:
IntegerEntry,
RatingEntry,
DateEntry,
DurationEntry,
LongTextEntry,
};
......
......@@ -40,8 +40,10 @@ RowLayout {
Loader {
id: textDisplayLoader
active: type === EditableTrackMetadataModel.TextEntry || type === EditableTrackMetadataModel.IntegerEntry || type === EditableTrackMetadataModel.UrlEntry
visible: type === EditableTrackMetadataModel.TextEntry || type === EditableTrackMetadataModel.IntegerEntry || type === EditableTrackMetadataModel.UrlEntry
active: type === EditableTrackMetadataModel.TextEntry || type === EditableTrackMetadataModel.IntegerEntry
|| type === EditableTrackMetadataModel.UrlEntry || type === EditableTrackMetadataModel.DurationEntry
visible: type === EditableTrackMetadataModel.TextEntry || type === EditableTrackMetadataModel.IntegerEntry
|| type === EditableTrackMetadataModel.UrlEntry || type === EditableTrackMetadataModel.DurationEntry
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment