LCOV - code coverage report
Current view: top level - src/engraving/dom - instrchange.h Coverage Total Hit
Test: filtered_coverage.info Lines: 90.9 % 11 10
Test Date: 2026-11-19 04:14:36

            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              : #ifndef MU_ENGRAVING_INSTRCHANGE_H
      24              : #define MU_ENGRAVING_INSTRCHANGE_H
      25              : 
      26              : #include "textbase.h"
      27              : 
      28              : #include "instrument.h"
      29              : 
      30              : namespace mu::engraving {
      31              : class Clef;
      32              : 
      33              : //---------------------------------------------------------
      34              : //   @@ InstrumentChange
      35              : //---------------------------------------------------------
      36              : 
      37              : class InstrumentChange final : public TextBase
      38              : {
      39          127 :     OBJECT_ALLOCATOR(engraving, InstrumentChange)
      40         1625 :     DECLARE_CLASSOF(ElementType::INSTRUMENT_CHANGE)
      41              : 
      42              : public:
      43              :     InstrumentChange(DummyParentOr<Segment> parent);
      44              :     InstrumentChange(const Instrument&, DummyParentOr<Segment> parent);
      45              :     InstrumentChange(const InstrumentChange&);
      46              :     ~InstrumentChange();
      47              : 
      48            7 :     InstrumentChange* clone() const override { return new InstrumentChange(*this); }
      49            8 :     void setOwnershipParent(DummyParentOr<Segment> parent) { EngravingItem::setOwnershipParent(parent); }
      50              : 
      51          123 :     Instrument* instrument() const { return m_instrument; }
      52           11 :     void setInstrument(Instrument* i) { m_instrument = i; }
      53              :     void setInstrument(Instrument&& i) { *m_instrument = i; }
      54              :     void setInstrument(const Instrument& i);
      55              :     void setupInstrument(const Instrument* instrument, bool updateText = true);
      56              : 
      57              :     std::vector<KeySig*> keySigs(bool all=false) const;
      58              :     std::vector<Clef*> clefs() const;
      59              : 
      60           25 :     bool init() const { return m_init; }
      61            9 :     void setInit(bool init) { m_init = init; }
      62              : 
      63           32 :     Segment* segment() const { return toSegment(ownershipParent()); }
      64              : 
      65              :     PropertyValue propertyDefault(Pid) const override;
      66              : 
      67          106 :     bool positionRelativeToNoteheadRest() const override { return true; }
      68              : 
      69            0 :     bool placeMultiple() const override { return false; }
      70              : 
      71              : private:
      72              : 
      73              :     Instrument* m_instrument = nullptr;     // Staff holds ownership if part of score
      74              :     bool m_init = false;                    // Set if the instrument has been set by the user, as there is no other way to tell.
      75              : };
      76              : } // namespace mu::engraving
      77              : #endif
        

Generated by: LCOV version 2.0-1