Commit e804ed9c authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

basic implementation of the addition of extra fields to track metadata

with some limitations but basically usable
parent 74e53afb
......@@ -254,6 +254,20 @@ void EditableTrackMetadataModel::removeData(int index)
validData();
}
void EditableTrackMetadataModel::addData(const QString &name)
{
beginInsertRows({}, rowCount(), rowCount());
addDataByName(name);
endInsertRows();
if (!mIsDirty) {
mIsDirty = true;
Q_EMIT isDirtyChanged();
}
validData();
}
void EditableTrackMetadataModel::fillDataFromTrackData(const TrackMetadataModel::TrackDataType &trackData,
const QList<DataTypes::ColumnsRoles> &fieldsForTrack)
{
......
......@@ -79,6 +79,8 @@ public Q_SLOTS:
void removeData(int index);
void addData(const QString &name);
protected:
void fillDataFromTrackData(const TrackMetadataModel::TrackDataType &trackData,
......
......@@ -495,6 +495,49 @@ void TrackMetadataModel::removeDataByIndex(int index)
mTrackKeys.removeAt(index);
}
void TrackMetadataModel::addDataByName(const QString &name)
{
DataTypes::ColumnsRoles newRole = DataTypes::TitleRole;
if (name == i18nc("Track title for track metadata view", "Title")) {
newRole = DataTypes::TitleRole;
} else if (name == i18nc("Track artist for track metadata view", "Artist")) {
newRole = DataTypes::ArtistRole;
} else if (name == i18nc("Album name for track metadata view", "Album")) {
newRole = DataTypes::AlbumRole;
} else if (name == i18nc("Album artist for track metadata view", "Album Artist")) {
newRole = DataTypes::AlbumArtistRole;
} else if (name == i18nc("Track number for track metadata view", "Track Number")) {
newRole = DataTypes::TrackNumberRole;
} else if (name == i18nc("Disc number for track metadata view", "Disc Number")) {
newRole = DataTypes::DiscNumberRole;
} else if (name == i18nc("Rating label for information panel", "Rating")) {
newRole = DataTypes::RatingRole;
} else if (name == i18nc("Genre label for track metadata view", "Genre")) {
newRole = DataTypes::GenreRole;
} else if (name == i18nc("Lyricist label for track metadata view", "Lyricist")) {
newRole = DataTypes::LyricistRole;
} else if (name == i18nc("Composer name for track metadata view", "Composer")) {
newRole = DataTypes::ComposerRole;
} else if (name == i18nc("Comment label for track metadata view", "Comment")) {
newRole = DataTypes::CommentRole;
} else if (name == i18nc("Year label for track metadata view", "Year")) {
newRole = DataTypes::YearRole;
} else if (name == i18nc("Channels label for track metadata view", "Channels")) {
newRole = DataTypes::ChannelsRole;
} else if (name == i18nc("Bit rate label for track metadata view", "Bit Rate")) {
newRole = DataTypes::BitRateRole;
} else if (name == i18nc("Sample Rate label for track metadata view", "Sample Rate")) {
newRole = DataTypes::SampleRateRole;
} else if (name == i18nc("Lyrics label for track metadata view", "Lyrics")) {
newRole = DataTypes::LyricsRole;
}
mTrackData[newRole] = {};
mFullData[newRole] = {};
mTrackKeys.push_back(newRole);
}
void TrackMetadataModel::fetchLyrics()
{
auto lyricicsValue = QtConcurrent::run(QThreadPool::globalInstance(), [=]() {
......
......@@ -153,6 +153,8 @@ protected:
void removeDataByIndex(int index);
void addDataByName(const QString &name);
private Q_SLOTS:
void lyricsValueIsReady();
......
......@@ -114,7 +114,7 @@ RowLayout {
flat: true
display: AbstractButton.IconOnly
icon.name: 'entry-delete'
icon.name: 'list-remove'
visible: isRemovable
......
......@@ -42,7 +42,7 @@ Window {
modality: Qt.NonModal
flags: Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint
| Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint
| Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint
color: myPalette.window
......@@ -134,6 +134,56 @@ Window {
delegate: ((dialogStates.state === 'readWrite' || dialogStates.state === 'readWriteAndDirty' ||
dialogStates.state === 'create' || dialogStates.state === 'createAndDirty') && !realModel.isReadOnly) ? editableMetaDataDelegate: metaDataDelegate
}
footer: RowLayout {
width: scrollBar.visible ? (!LayoutMirroring.enabled ? trackData.width - scrollBar.width : trackData.width) : trackData.width
spacing: 0
visible: (dialogStates.state === 'readWrite' || dialogStates.state === 'readWriteAndDirty' ||
dialogStates.state === 'create' || dialogStates.state === 'createAndDirty') && !realModel.isReadOnly
ComboBox {
id: selectedField
textRole: "text"
valueRole: "text"
model: [
{ text: i18nc("Track title for track metadata view", "Title" ) },
{ text: i18nc("Track artist for track metadata view", "Artist") },
{ text: i18nc("Album name for track metadata view", "Album") },
{ text: i18nc("Album artist for track metadata view", "Album Artist") },
{ text: i18nc("Track number for track metadata view", "Track Number") },
{ text: i18nc("Disc number for track metadata view", "Disc Number") },
{ text: i18nc("Rating label for information panel", "Rating") },
{ text: i18nc("Genre label for track metadata view", "Genre") },
{ text: i18nc("Lyricist label for track metadata view", "Lyricist") },
{ text: i18nc("Composer name for track metadata view", "Composer") },
{ text: i18nc("Comment label for track metadata view", "Comment") },
{ text: i18nc("Year label for track metadata view", "Year") },
{ text: i18nc("Channels label for track metadata view", "Channels") },
{ text: i18nc("Bit rate label for track metadata view", "Bit Rate") },
{ text: i18nc("Sample Rate label for track metadata view", "Sample Rate") },
{ text: i18nc("Lyrics label for track metadata view", "Lyrics") },
]
}
Item {
Layout.fillWidth: true
}
Button {
Layout.fillHeight: true
Layout.preferredWidth: height
flat: true
display: AbstractButton.IconOnly
icon.name: 'list-add'
onClicked: realModel.addData(selectedField.currentValue)
}
}
}
}
......
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