Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions framework/learn/qml/Muse/Learn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ qt_add_qml_module(muse_learn_qml
SOURCES
learnpagemodel.cpp
learnpagemodel.h
internal/playlistmodel.cpp
internal/playlistmodel.h
QML_FILES
LearnPage.qml
internal/ClassesPage.qml
Expand Down
24 changes: 19 additions & 5 deletions framework/learn/qml/Muse/Learn/LearnPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ FocusScope {
navigation.order: 1

visible: tabBar.currentIndex !== 1 // Not visible for Classes tab

onSearchTextChanged: {
pageModel.setSearchText(searchText)
}
}
}

Expand Down Expand Up @@ -205,7 +201,25 @@ FocusScope {
Playlist {
id: getStartedComp

playlist: pageModel.startedPlaylist
playlist: SortFilterProxyModel {
sourceModel: pageModel.startedPlaylist
filters: [
FuzzyFilter {
id: fuzzyFilter
enabled: Boolean(fuzzyPattern)
fuzzyPattern: searchField.searchText
roleName: "searchKey"
caseSensitivity: Qt.CaseInsensitive
}
]

sorters: [
FuzzyScoreSorter {
enabled: fuzzyFilter.enabled
fuzzyFilter: fuzzyFilter
}
]
}
Comment thread
juli27 marked this conversation as resolved.

navigation.section: navSec
navigation.order: 3
Expand Down
25 changes: 16 additions & 9 deletions framework/learn/qml/Muse/Learn/internal/Playlist.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls

import Muse.Ui
Expand Down Expand Up @@ -87,6 +89,11 @@ FocusScope {
}

delegate: Item {
id: cellWrap

required property var model
required property int index

height: view.cellHeight
width: view.cellWidth

Expand All @@ -98,21 +105,21 @@ FocusScope {
anchors.horizontalCenter: parent.horizontalCenter

navigation.panel: navPanel
navigation.row: view.columns === 0 ? 0 : Math.floor(model.index / view.columns)
navigation.column: model.index - (navigation.row * view.columns)
navigation.row: view.columns === 0 ? 0 : Math.floor(cellWrap.index / view.columns)
navigation.column: cellWrap.index - (navigation.row * view.columns)
navigation.onActiveChanged: {
if (navigation.active) {
view.positionViewAtIndex(index, ListView.Contain)
view.positionViewAtIndex(cellWrap.index, ListView.Contain)
}
}

title: modelData.title
author: modelData.author
duration: modelData.duration
thumbnail: modelData.thumbnailUrl
title: cellWrap.model.title
author: cellWrap.model.author
duration: cellWrap.model.duration
thumbnail: cellWrap.model.thumbnailUrl

onClicked: {
api.launcher.openUrl(modelData.url)
api.launcher.openUrl(cellWrap.model.url)
}
}
}
Expand Down
117 changes: 117 additions & 0 deletions framework/learn/qml/Muse/Learn/internal/playlistmodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "playlistmodel.h"

#include <QString>
#include <QStringList>

#include "global/log.h"

namespace muse::learn {
PlaylistModel::PlaylistModel(QObject* parent)
: QAbstractListModel(parent)
{
}

const Playlist& PlaylistModel::playlist()
{
return m_playlist;
}

void PlaylistModel::setPlaylist(const Playlist& playlist)
{
beginResetModel();
m_playlist = playlist;
endResetModel();
}

int PlaylistModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid()) {
return 0;
}

return m_playlist.size();
}

QVariant PlaylistModel::data(const QModelIndex& index, int roleId) const
{
IF_ASSERT_FAILED(index.isValid() && index.row() < m_playlist.size()) {
return QVariant();
}

const PlaylistItem& item = m_playlist[index.row()];

switch (roleId) {
case RoleTitle:
return item.title;
case RoleAuthor:
return item.author;
case RoleDuration: {
// h:mm:ss for anything over an hour
// m:ss for anything under an hour
// 0:ss for anything under a minute
int seconds = item.durationSecs;
int minutes = seconds / 60;
seconds -= minutes * 60;
int hours = minutes / 60;
minutes -= hours * 60;

return ((hours > 0)
? (QString::number(hours) + ":" + QString::number(minutes).rightJustified(2, '0'))
: QString::number(minutes)
) + ":"
+ QString::number(seconds).rightJustified(2, '0');
}
case RoleUrl:
return item.url;
case RoleThumbnailUrl:
return item.thumbnailUrl;
case RoleSearchKey: {
QStringList searchKeyItems;
searchKeyItems << item.title
<< item.author;

return searchKeyItems.join(u' ');
}

default:
UNREACHABLE;
break;
}

return QVariant();
}

QHash<int, QByteArray> PlaylistModel::roleNames() const
{
return QHash<int, QByteArray> {
{ RoleTitle, "title" },
{ RoleAuthor, "author" },
{ RoleDuration, "duration" },
{ RoleUrl, "url" },
{ RoleThumbnailUrl, "thumbnailUrl" },
{ RoleSearchKey, "searchKey" },
};
}
}
56 changes: 56 additions & 0 deletions framework/learn/qml/Muse/Learn/internal/playlistmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <QAbstractListModel>

#include "learn/learntypes.h"

namespace muse::learn {
class PlaylistModel final : public QAbstractListModel
{
Q_OBJECT

public:
explicit PlaylistModel(QObject* parent = nullptr);

const Playlist& playlist();
void setPlaylist(const Playlist&);

int rowCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int roleId) const override;
QHash<int, QByteArray> roleNames() const override;

private:
enum Roles {
RoleTitle = Qt::UserRole,
RoleAuthor,
RoleDuration,
RoleUrl,
RoleThumbnailUrl,
RoleSearchKey,
};

Playlist m_playlist;
};
}
Loading