LCOV - code coverage report
Current view: top level - src/notation/internal - excerptnotation.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 55 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "excerptnotation.h"
      24              : 
      25              : #include "engraving/dom/excerpt.h"
      26              : #include "engraving/editing/editexcerpt.h"
      27              : #include "engraving/editing/transaction/transaction.h"
      28              : 
      29              : #include "inotationundostack.h"
      30              : 
      31              : using namespace mu::notation;
      32              : 
      33            0 : ExcerptNotation::ExcerptNotation(MasterNotation* master, engraving::Excerpt* excerpt, const muse::modularity::ContextPtr& iocCtx)
      34            0 :     : Notation(master, iocCtx), m_excerpt(excerpt)
      35              : {
      36            0 : }
      37              : 
      38            0 : ExcerptNotation::~ExcerptNotation()
      39              : {
      40              :     //! NOTE: do not destroy the score here, because it may be stored in UndoStack
      41              :     //! (after opening an excerpt via the Parts dialog and pressing ctrl + z)
      42            0 :     setScore(nullptr);
      43            0 : }
      44              : 
      45            0 : void ExcerptNotation::init()
      46              : {
      47            0 :     if (m_inited) {
      48            0 :         return;
      49              :     }
      50              : 
      51            0 :     setScore(m_excerpt->excerptScore());
      52              : 
      53            0 :     m_inited = true;
      54              : }
      55              : 
      56            0 : void ExcerptNotation::reinit(engraving::Excerpt* newExcerpt)
      57              : {
      58            0 :     m_inited = false;
      59            0 :     m_excerpt = newExcerpt;
      60              : 
      61            0 :     init();
      62              : 
      63            0 :     notifyAboutNotationChanged();
      64            0 : }
      65              : 
      66            0 : bool ExcerptNotation::isInited() const
      67              : {
      68            0 :     return m_inited;
      69              : }
      70              : 
      71            0 : bool ExcerptNotation::isCustom() const
      72              : {
      73            0 :     return m_excerpt->custom();
      74              : }
      75              : 
      76            0 : bool ExcerptNotation::isEmpty() const
      77              : {
      78            0 :     return m_excerpt->parts().empty();
      79              : }
      80              : 
      81            0 : mu::engraving::Excerpt* ExcerptNotation::excerpt() const
      82              : {
      83            0 :     return m_excerpt;
      84              : }
      85              : 
      86            0 : QString ExcerptNotation::name() const
      87              : {
      88            0 :     return m_excerpt->name().toQString();
      89              : }
      90              : 
      91            0 : void ExcerptNotation::setName(const QString& name)
      92              : {
      93            0 :     bool changed = name != this->name();
      94            0 :     m_excerpt->setName(name);
      95              : 
      96            0 :     if (changed) {
      97            0 :         notifyAboutNotationChanged();
      98              :     }
      99            0 : }
     100              : 
     101            0 : void ExcerptNotation::undoSetName(const QString& name)
     102              : {
     103            0 :     if (name == this->name()) {
     104            0 :         return;
     105              :     }
     106              : 
     107            0 :     if (!score()) {
     108            0 :         setName(name);
     109            0 :         return;
     110              :     }
     111              : 
     112              :     //: Means: "edit the name of a part score"
     113            0 :     undoStack()->transaction(muse::TranslatableString("undoableAction", "Rename part"), [&](engraving::Transaction& tx) {
     114            0 :         tx.push(new engraving::ChangeExcerptTitle(m_excerpt, name));
     115            0 :     });
     116              : 
     117            0 :     notifyAboutNotationChanged();
     118              : }
     119              : 
     120            0 : muse::async::Notification ExcerptNotation::nameChanged() const
     121              : {
     122            0 :     return m_excerpt->nameChanged();
     123              : }
     124              : 
     125            0 : bool ExcerptNotation::hasFileName() const
     126              : {
     127            0 :     return m_excerpt->hasFileName();
     128              : }
     129              : 
     130            0 : const muse::String& ExcerptNotation::fileName() const
     131              : {
     132            0 :     return m_excerpt->fileName();
     133              : }
     134              : 
     135            0 : INotationPtr ExcerptNotation::notation()
     136              : {
     137            0 :     return shared_from_this();
     138              : }
     139              : 
     140            0 : IExcerptNotationPtr ExcerptNotation::clone() const
     141              : {
     142            0 :     mu::engraving::Excerpt* copy = new mu::engraving::Excerpt(*m_excerpt);
     143            0 :     copy->markAsCustom();
     144              : 
     145            0 :     return std::make_shared<ExcerptNotation>(m_masterNotation, copy, iocContext());
     146              : }
        

Generated by: LCOV version 2.0-1