LCOV - code coverage report
Current view: top level - src/engraving/dom - instrchange.h Coverage Total Hit
Test: filtered_coverage.info Lines: 90.0 % 10 9
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              : #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          123 :     OBJECT_ALLOCATOR(engraving, InstrumentChange)
      40         1625 :     DECLARE_CLASSOF(ElementType::INSTRUMENT_CHANGE)
      41              : 
      42              : public:
      43              :     InstrumentChange(EngravingObject* parent);
      44              :     InstrumentChange(const Instrument&, EngravingObject* parent);
      45              :     InstrumentChange(const InstrumentChange&);
      46              :     ~InstrumentChange();
      47              : 
      48            6 :     InstrumentChange* clone() const override { return new InstrumentChange(*this); }
      49              : 
      50          107 :     Instrument* instrument() const { return m_instrument; }
      51            3 :     void setInstrument(Instrument* i) { m_instrument = i; }
      52              :     void setInstrument(Instrument&& i) { *m_instrument = i; }
      53              :     void setInstrument(const Instrument& i);
      54              :     void setupInstrument(const Instrument* instrument, bool updateText = true);
      55              : 
      56              :     std::vector<KeySig*> keySigs(bool all=false) const;
      57              :     std::vector<Clef*> clefs() const;
      58              : 
      59           25 :     bool init() const { return m_init; }
      60            7 :     void setInit(bool init) { m_init = init; }
      61              : 
      62           18 :     Segment* segment() const { return toSegment(ownershipParent()); }
      63              : 
      64              :     PropertyValue propertyDefault(Pid) const override;
      65              : 
      66          103 :     bool positionRelativeToNoteheadRest() const override { return true; }
      67              : 
      68            0 :     bool placeMultiple() const override { return false; }
      69              : 
      70              : private:
      71              : 
      72              :     Instrument* m_instrument = nullptr;     // Staff holds ownership if part of score
      73              :     bool m_init = false;                    // Set if the instrument has been set by the user, as there is no other way to tell.
      74              : };
      75              : } // namespace mu::engraving
      76              : #endif
        

Generated by: LCOV version 2.0-1