removed the "delete" and "rename" operations for non-custom parts
This commit is contained in:
parent
aac13473d0
commit
ad1571629f
12 changed files with 70 additions and 58 deletions
|
@ -88,6 +88,11 @@ bool Excerpt::inited() const
|
|||
return m_inited;
|
||||
}
|
||||
|
||||
String Excerpt::initialInstrumentId() const
|
||||
{
|
||||
return m_initialInstrumentId;
|
||||
}
|
||||
|
||||
void Excerpt::setInited(bool inited)
|
||||
{
|
||||
m_inited = inited;
|
||||
|
@ -1507,6 +1512,8 @@ std::vector<Excerpt*> Excerpt::createExcerptsFromParts(const std::vector<Part*>&
|
|||
|
||||
String name = formatName(part->partName(), result);
|
||||
excerpt->setName(name);
|
||||
excerpt->m_initialInstrumentId = part->instrumentId();
|
||||
|
||||
result.push_back(excerpt);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
~Excerpt();
|
||||
|
||||
bool inited() const;
|
||||
String initialInstrumentId() const;
|
||||
|
||||
MasterScore* masterScore() const { return m_masterScore; }
|
||||
Score* excerptScore() const { return m_excerptScore; }
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
std::vector<Part*> m_parts;
|
||||
TracksMap m_tracksMapping;
|
||||
bool m_inited = false;
|
||||
String m_initialInstrumentId;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ class IExcerptNotation
|
|||
public:
|
||||
virtual ~IExcerptNotation() = default;
|
||||
|
||||
virtual bool isCreated() const = 0;
|
||||
virtual bool isCustom() const = 0;
|
||||
virtual bool isEmpty() const = 0;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual void setName(const QString& name) = 0;
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
|
||||
virtual ValNt<bool> needSave() const = 0;
|
||||
|
||||
virtual IExcerptNotationPtr newExcerptBlankNotation() const = 0;
|
||||
virtual IExcerptNotationPtr createEmptyExcerpt() const = 0;
|
||||
|
||||
virtual ValCh<ExcerptNotationList> excerpts() const = 0;
|
||||
virtual const ExcerptNotationList& potentialExcerpts() const = 0;
|
||||
|
||||
|
|
|
@ -39,30 +39,30 @@ ExcerptNotation::~ExcerptNotation()
|
|||
setScore(nullptr);
|
||||
}
|
||||
|
||||
bool ExcerptNotation::isCreated() const
|
||||
void ExcerptNotation::init()
|
||||
{
|
||||
return m_isCreated;
|
||||
}
|
||||
|
||||
void ExcerptNotation::setIsCreated(bool created)
|
||||
{
|
||||
m_isCreated = created;
|
||||
|
||||
if (!created) {
|
||||
if (m_inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
void ExcerptNotation::init()
|
||||
{
|
||||
setScore(m_excerpt->excerptScore());
|
||||
setName(m_name);
|
||||
|
||||
if (isEmpty()) {
|
||||
fillWithDefaultInfo();
|
||||
}
|
||||
|
||||
m_inited = true;
|
||||
}
|
||||
|
||||
bool ExcerptNotation::isCustom() const
|
||||
{
|
||||
return m_excerpt && m_excerpt->initialInstrumentId().empty();
|
||||
}
|
||||
|
||||
bool ExcerptNotation::isEmpty() const
|
||||
{
|
||||
return m_excerpt ? m_excerpt->parts().empty() : true;
|
||||
}
|
||||
|
||||
void ExcerptNotation::fillWithDefaultInfo()
|
||||
|
@ -106,11 +106,6 @@ mu::engraving::Excerpt* ExcerptNotation::excerpt() const
|
|||
return m_excerpt;
|
||||
}
|
||||
|
||||
bool ExcerptNotation::isEmpty() const
|
||||
{
|
||||
return m_excerpt ? m_excerpt->parts().empty() : true;
|
||||
}
|
||||
|
||||
QString ExcerptNotation::name() const
|
||||
{
|
||||
return m_excerpt ? m_excerpt->name().toQString() : m_name;
|
||||
|
|
|
@ -35,10 +35,11 @@ public:
|
|||
|
||||
~ExcerptNotation() override;
|
||||
|
||||
bool isCreated() const override;
|
||||
void setIsCreated(bool created);
|
||||
void init();
|
||||
|
||||
bool isCustom() const override;
|
||||
bool isEmpty() const override;
|
||||
|
||||
mu::engraving::Excerpt* excerpt() const;
|
||||
|
||||
QString name() const override;
|
||||
|
@ -48,12 +49,11 @@ public:
|
|||
IExcerptNotationPtr clone() const override;
|
||||
|
||||
private:
|
||||
bool isEmpty() const;
|
||||
void fillWithDefaultInfo();
|
||||
|
||||
mu::engraving::Excerpt* m_excerpt = nullptr;
|
||||
bool m_isCreated = false;
|
||||
QString m_name;
|
||||
bool m_inited = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,10 @@ static ExcerptNotation* get_impl(const IExcerptNotationPtr& excerpt)
|
|||
return static_cast<ExcerptNotation*>(excerpt.get());
|
||||
}
|
||||
|
||||
static IExcerptNotationPtr createExcerptNotation(mu::engraving::Excerpt* excerpt)
|
||||
static IExcerptNotationPtr createAndInitExcerptNotation(mu::engraving::Excerpt* excerpt)
|
||||
{
|
||||
auto excerptNotation = std::make_shared<ExcerptNotation>(excerpt);
|
||||
excerptNotation->setIsCreated(true);
|
||||
excerptNotation->init();
|
||||
|
||||
return excerptNotation;
|
||||
}
|
||||
|
@ -430,11 +430,8 @@ void MasterNotation::addExcerpts(const ExcerptNotationList& excerpts)
|
|||
}
|
||||
|
||||
ExcerptNotation* excerptNotationImpl = get_impl(excerptNotation);
|
||||
|
||||
if (!excerptNotationImpl->isCreated()) {
|
||||
masterScore()->initAndAddExcerpt(excerptNotationImpl->excerpt(), false);
|
||||
excerptNotationImpl->init();
|
||||
}
|
||||
masterScore()->initAndAddExcerpt(excerptNotationImpl->excerpt(), false);
|
||||
excerptNotationImpl->init();
|
||||
|
||||
result.push_back(excerptNotation);
|
||||
}
|
||||
|
@ -519,7 +516,6 @@ void MasterNotation::updateExcerpts()
|
|||
continue;
|
||||
}
|
||||
|
||||
impl->setIsCreated(false);
|
||||
impl->setIsOpen(false);
|
||||
}
|
||||
|
||||
|
@ -529,7 +525,7 @@ void MasterNotation::updateExcerpts()
|
|||
continue;
|
||||
}
|
||||
|
||||
IExcerptNotationPtr excerptNotation = createExcerptNotation(excerpt);
|
||||
IExcerptNotationPtr excerptNotation = createAndInitExcerptNotation(excerpt);
|
||||
excerptNotation->notation()->setIsOpen(true);
|
||||
|
||||
updatedExcerpts.push_back(excerptNotation);
|
||||
|
@ -579,11 +575,10 @@ void MasterNotation::markScoreAsNeedToSave()
|
|||
m_needSaveNotification.notify();
|
||||
}
|
||||
|
||||
IExcerptNotationPtr MasterNotation::newExcerptBlankNotation() const
|
||||
IExcerptNotationPtr MasterNotation::createEmptyExcerpt() const
|
||||
{
|
||||
auto excerptNotation = std::make_shared<ExcerptNotation>(new mu::engraving::Excerpt(masterScore()));
|
||||
excerptNotation->setName(qtrc("notation", "Part"));
|
||||
excerptNotation->setIsCreated(false);
|
||||
|
||||
return excerptNotation;
|
||||
}
|
||||
|
@ -638,7 +633,6 @@ void MasterNotation::updatePotentialExcerpts() const
|
|||
|
||||
for (mu::engraving::Excerpt* excerpt : excerpts) {
|
||||
auto excerptNotation = std::make_shared<ExcerptNotation>(excerpt);
|
||||
excerptNotation->setIsCreated(false);
|
||||
m_potentialExcerpts.push_back(excerptNotation);
|
||||
}
|
||||
|
||||
|
@ -656,7 +650,7 @@ void MasterNotation::initExcerptNotations(const std::vector<mu::engraving::Excer
|
|||
masterScore()->initEmptyExcerpt(excerpt);
|
||||
}
|
||||
|
||||
IExcerptNotationPtr excerptNotation = createExcerptNotation(excerpt);
|
||||
IExcerptNotationPtr excerptNotation = createAndInitExcerptNotation(excerpt);
|
||||
notationExcerpts.push_back(excerptNotation);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ public:
|
|||
|
||||
mu::ValNt<bool> needSave() const override;
|
||||
|
||||
IExcerptNotationPtr newExcerptBlankNotation() const override;
|
||||
IExcerptNotationPtr createEmptyExcerpt() const override;
|
||||
|
||||
ValCh<ExcerptNotationList> excerpts() const override;
|
||||
const ExcerptNotationList& potentialExcerpts() const override;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ ListItemBlank {
|
|||
property string title: ""
|
||||
property int currentPartIndex: -1
|
||||
|
||||
property bool isCreated: false
|
||||
property bool isCustom: false
|
||||
|
||||
property int sideMargin: 0
|
||||
|
||||
|
@ -71,7 +71,9 @@ ListItemBlank {
|
|||
}
|
||||
|
||||
onDoubleClicked: {
|
||||
root.startEditTitle()
|
||||
if (root.isCustom) {
|
||||
root.startEditTitle()
|
||||
}
|
||||
}
|
||||
|
||||
onIsSelectedChanged: {
|
||||
|
@ -138,11 +140,16 @@ ListItemBlank {
|
|||
}
|
||||
|
||||
MenuButton {
|
||||
menuModel: [
|
||||
{ "id": "duplicate", "title": qsTrc("notation", "Duplicate"), "enabled": root.isCreated },
|
||||
{ "id": "rename", "title": qsTrc("notation", "Rename") },
|
||||
{ "id": "delete", "title": qsTrc("notation", "Delete"), "enabled": root.isCreated }
|
||||
]
|
||||
Component.onCompleted: {
|
||||
var operations = [ { "id": "duplicate", "title": qsTrc("notation", "Duplicate") }]
|
||||
|
||||
if (root.isCustom) {
|
||||
operations.push({ "id": "rename", "title": qsTrc("notation", "Rename") })
|
||||
operations.push({ "id": "delete", "title": qsTrc("notation", "Delete") })
|
||||
}
|
||||
|
||||
menuModel = operations
|
||||
}
|
||||
|
||||
navigation.name: title
|
||||
navigation.panel: root.navigation.panel
|
||||
|
|
|
@ -110,7 +110,7 @@ Item {
|
|||
title: model.title
|
||||
currentPartIndex: view.currentIndex
|
||||
isSelected: model.isSelected
|
||||
isCreated: model.isCreated
|
||||
isCustom: model.isCustom
|
||||
|
||||
navigation.name: model.title + model.index
|
||||
navigation.panel: view.navigationPanel
|
||||
|
|
|
@ -76,8 +76,8 @@ QVariant PartListModel::data(const QModelIndex& index, int role) const
|
|||
return excerpt->name();
|
||||
case RoleIsSelected:
|
||||
return m_selectionModel->isSelected(index);
|
||||
case RoleIsCreated:
|
||||
return excerpt->isCreated();
|
||||
case RoleIsCustom:
|
||||
return excerpt->isCustom();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
@ -93,7 +93,7 @@ QHash<int, QByteArray> PartListModel::roleNames() const
|
|||
static const QHash<int, QByteArray> roles {
|
||||
{ RoleTitle, "title" },
|
||||
{ RoleIsSelected, "isSelected" },
|
||||
{ RoleIsCreated, "isCreated" }
|
||||
{ RoleIsCustom, "isCustom" }
|
||||
};
|
||||
|
||||
return roles;
|
||||
|
@ -106,7 +106,7 @@ bool PartListModel::hasSelection() const
|
|||
|
||||
void PartListModel::createNewPart()
|
||||
{
|
||||
IExcerptNotationPtr excerpt = masterNotation()->newExcerptBlankNotation();
|
||||
IExcerptNotationPtr excerpt = masterNotation()->createEmptyExcerpt();
|
||||
|
||||
int index = m_excerpts.size();
|
||||
insertExcerpt(index, excerpt);
|
||||
|
@ -130,15 +130,19 @@ void PartListModel::removePart(int partIndex)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string question = mu::trc("notation", "Are you sure you want to delete this part?");
|
||||
if (!m_excerpts[partIndex]->isEmpty()) {
|
||||
std::string question = mu::trc("notation", "Are you sure you want to delete this part?");
|
||||
|
||||
IInteractive::Button btn = interactive()->question("", question, {
|
||||
IInteractive::Button::Yes, IInteractive::Button::No
|
||||
}).standardButton();
|
||||
IInteractive::Button btn = interactive()->question("", question, {
|
||||
IInteractive::Button::Yes, IInteractive::Button::No
|
||||
}).standardButton();
|
||||
|
||||
if (btn == IInteractive::Button::Yes) {
|
||||
doRemovePart(partIndex);
|
||||
if (btn != IInteractive::Button::Yes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
doRemovePart(partIndex);
|
||||
}
|
||||
|
||||
void PartListModel::doRemovePart(int partIndex)
|
||||
|
|
|
@ -82,7 +82,7 @@ private:
|
|||
enum Roles {
|
||||
RoleTitle = Qt::UserRole + 1,
|
||||
RoleIsSelected,
|
||||
RoleIsCreated
|
||||
RoleIsCustom
|
||||
};
|
||||
|
||||
uicomponents::ItemMultiSelectionModel* m_selectionModel = nullptr;
|
||||
|
|
Loading…
Reference in a new issue