LCOV - code coverage report
Current view: top level - src/engraving/dom - keysig.h Coverage Total Hit
Test: filtered_coverage.info Lines: 91.7 % 24 22
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              : #pragma once
      24              : 
      25              : #include "key.h"
      26              : #include "engravingitem.h"
      27              : 
      28              : namespace mu::engraving {
      29              : class Factory;
      30              : class Segment;
      31              : class Transaction;
      32              : 
      33              : class KeySig final : public EngravingItem
      34              : {
      35        13689 :     OBJECT_ALLOCATOR(engraving, KeySig)
      36         1525 :     DECLARE_CLASSOF(ElementType::KEYSIG)
      37              : 
      38         3036 :     M_PROPERTY2(bool, isCourtesy, setIsCourtesy, false)
      39              : 
      40              : public:
      41              : 
      42          165 :     KeySig* clone() const override { return new KeySig(*this); }
      43              : 
      44              :     bool acceptDrop(EditData&) const override;
      45              :     EngravingItem* drop(Transaction& tx, EditData&) override;
      46              : 
      47              :     double mag() const override;
      48              : 
      49              :     void setKey(Key concertKey, Key transposedKey);
      50              :     void setKey(Key concertKey);
      51              : 
      52        92310 :     Segment* segment() const { return (Segment*)ownershipParent(); }
      53        46069 :     Measure* measure() const { return ownershipParent() ? (Measure*)ownershipParent()->ownershipParent() : nullptr; }
      54              : 
      55        25230 :     Key key() const { return m_sig.key(); }
      56         2467 :     Key concertKey() const { return m_sig.concertKey(); }
      57           50 :     const std::vector<CustDef>& customKeyDefs() const { return m_sig.customKeyDefs(); }
      58           98 :     int degInKey(int degree) const { return m_sig.degInKey(degree); }
      59           98 :     SymId symInKey(SymId sym, int degree) const { return m_sig.symInKey(sym, degree); }
      60        24822 :     bool isCustom() const { return m_sig.custom(); }
      61         1352 :     bool isAtonal() const { return m_sig.isAtonal(); }
      62              :     bool isChange() const;
      63         3053 :     const KeySigEvent& keySigEvent() const { return m_sig; }
      64              :     bool operator==(const KeySig&) const;
      65              :     void changeKeySigEvent(const KeySigEvent&);
      66        19026 :     void setKeySigEvent(const KeySigEvent& e) { m_sig = e; }
      67              : 
      68        48122 :     bool showCourtesy() const { return m_showCourtesy; }
      69           82 :     void setShowCourtesy(bool v) { m_showCourtesy = v; }
      70              : 
      71         1990 :     KeyMode mode() const { return m_sig.mode(); }
      72          303 :     void setMode(KeyMode v) { m_sig.setMode(v); }
      73              : 
      74              :     PointF staffOffset() const override;
      75              : 
      76        23029 :     bool hideNaturals() const { return m_hideNaturals; }
      77            0 :     void setHideNaturals(bool hide) { m_hideNaturals = hide; }
      78              : 
      79              :     void setForInstrumentChange(bool forInstrumentChange) { m_sig.setForInstrumentChange(forInstrumentChange); }
      80         1253 :     bool forInstrumentChange() const { return m_sig.forInstrumentChange(); }
      81              : 
      82              :     PropertyValue getProperty(Pid propertyId) const override;
      83              :     bool setProperty(Pid propertyId, const PropertyValue&) override;
      84              :     using EngravingItem::undoChangeProperty;
      85              :     void undoChangeProperty(Pid id, const PropertyValue& v, PropertyFlags ps) override;
      86              :     PropertyValue propertyDefault(Pid id) const override;
      87              :     EngravingObject* propertyDelegate(Pid) const override;
      88              : 
      89              :     EngravingItem* nextSegmentElement() override;
      90              :     EngravingItem* prevSegmentElement() override;
      91              :     String accessibleInfo() const override;
      92              : 
      93            0 :     int subtype() const override { return int(key()) + 7; }
      94              :     muse::TranslatableString subtypeUserName() const override;
      95              : 
      96              :     struct LayoutData : public EngravingItem::LayoutData {
      97              :         std::vector<KeySym> keySymbols;
      98              :     };
      99        47037 :     DECLARE_LAYOUTDATA_METHODS(KeySig)
     100              : 
     101              : private:
     102              :     friend class Factory;
     103              : 
     104              :     KeySig(DummyParentOr<Segment>);
     105              :     KeySig(const KeySig&);
     106              : 
     107              :     void addLayout(SymId sym, int line);
     108              : 
     109              :     bool m_showCourtesy;
     110              :     bool m_hideNaturals;       // used in layout to override score style (needed for the Continuous panel)
     111              :     KeySigEvent m_sig;
     112              : };
     113              : }
        

Generated by: LCOV version 2.0-1