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
13 changes: 13 additions & 0 deletions framework/uicomponents/qml/Muse/UiComponents/abstractmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,19 @@ MenuItem* AbstractMenuModel::makeSeparator()
return item;
}

MenuItemList AbstractMenuModel::makeItems(const MenuCommandList& commands)
{
MenuItemList list;
for (const auto& command : commands) {
if (command.has_value()) {
list.append(makeMenuItem(command.value()));
} else {
list.append(makeSeparator());
}
}
return list;
}

void AbstractMenuModel::subscribeOnChanges()
{
if (m_subscribedOnChanges) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
#pragma once

#include <optional>
#include <vector>

#include <qqmlintegration.h>

#include <QAbstractListModel>
Expand All @@ -46,6 +49,9 @@
#endif

namespace muse::uicomponents {
using MenuCommandList = std::vector<std::optional<rcommand::Command> >;
inline constexpr std::optional<rcommand::Command> MENU_SEPARATOR = std::nullopt;

class AbstractMenuModel : public QAbstractListModel, public muse::Contextable, public async::Asyncable
{
Q_OBJECT
Expand Down Expand Up @@ -131,6 +137,7 @@ class AbstractMenuModel : public QAbstractListModel, public muse::Contextable, p
#endif

MenuItem* makeSeparator();
MenuItemList makeItems(const MenuCommandList& commands);

bool isIndexValid(int index) const;

Expand Down