Commit 35b6a6a8 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵 Committed by Nate Graham

in grid view, do not try to open music files but enqueue them

in the file browser, it was possible to try to open music files leading
to an invalid state. ensure they will be queued to the playlist instead
of open as if they had children

BUG: 429460
parent 0c82e169
Pipeline #42890 passed with stage
in 23 seconds
......@@ -71,6 +71,7 @@ public:
IsDirectoryRole,
IsPlayListRole,
FilePathRole,
HasChildrenRole,
};
Q_ENUM(ColumnsRoles)
......
......@@ -94,6 +94,7 @@ QHash<int, QByteArray> DataModel::roleNames() const
roles[static_cast<int>(DataTypes::ColumnsRoles::YearRole)] = "year";
roles[static_cast<int>(DataTypes::ColumnsRoles::IsSingleDiscAlbumRole)] = "isSingleDiscAlbum";
roles[static_cast<int>(DataTypes::ColumnsRoles::FullDataRole)] = "fullData";
roles[static_cast<int>(DataTypes::ColumnsRoles::HasChildrenRole)] = "hasChildren";
return roles;
}
......@@ -290,6 +291,27 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
}
break;
}
case DataTypes::ColumnsRoles::HasChildrenRole:
{
switch (d->mModelType)
{
case ElisaUtils::Track:
case ElisaUtils::FileName:
case ElisaUtils::Radio:
case ElisaUtils::Unknown:
result = false;
break;
case ElisaUtils::Album:
case ElisaUtils::Artist:
case ElisaUtils::Genre:
case ElisaUtils::Lyricist:
case ElisaUtils::Composer:
case ElisaUtils::Container:
result = true;
break;
}
break;
}
default:
switch(d->mModelType)
{
......
......@@ -73,6 +73,7 @@ QHash<int, QByteArray> FileBrowserModel::roleNames() const
roles[static_cast<int>(DataTypes::ColumnsRoles::RatingRole)] = "rating";
roles[static_cast<int>(DataTypes::ColumnsRoles::IsSingleDiscAlbumRole)] = "isSingleDiscAlbum";
roles[static_cast<int>(DataTypes::ColumnsRoles::FullDataRole)] = "fullData";
roles[static_cast<int>(DataTypes::ColumnsRoles::HasChildrenRole)] = "hasChildren";
roles[static_cast<int>(DataTypes::ColumnsRoles::IsDirectoryRole)] = "isDirectory";
roles[static_cast<int>(DataTypes::ColumnsRoles::IsPlayListRole)] = "isPlaylist";
......@@ -103,6 +104,7 @@ QVariant FileBrowserModel::data(const QModelIndex &index, int role) const
break;
}
case DataTypes::ColumnsRoles::IsDirectoryRole:
case DataTypes::ColumnsRoles::HasChildrenRole:
{
KFileItem item = itemForIndex(index);
result = item.isDir();
......
......@@ -29,6 +29,7 @@ FocusScope {
property bool showDetailsButton: false
property bool showPlayButton: true
property bool showEnqueueButton: true
property bool hasChildren: true
signal enqueue()
signal replaceAndPlay()
......@@ -80,12 +81,12 @@ FocusScope {
hoverEnabled: true
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
cursorShape: hasChildren ? Qt.PointingHandCursor : Qt.ArrowCursor
Layout.preferredHeight: gridEntry.height
Layout.fillWidth: true
onClicked: open()
onClicked: hasChildren ? open() : enqueue()
TextMetrics {
id: mainLabelSize
......
......@@ -140,6 +140,7 @@ FocusScope {
databaseId: model.databaseId
delegateDisplaySecondaryText: gridView.delegateDisplaySecondaryText
entryType: model.dataType
hasChildren: model.hasChildren
onEnqueue: gridView.enqueue(model.fullData, model.display)
onReplaceAndPlay: gridView.replaceAndPlay(model.fullData, model.display)
......
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