LCOV - code coverage report
Current view: top level - src/engraving/editing - editharppedaldiagram.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 84.2 % 38 32
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) 2025 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 "editharppedaldiagram.h"
      24              : 
      25              : #include <vector>
      26              : 
      27              : #include "navigation.h"
      28              : 
      29              : #include "../dom/harppedaldiagram.h"
      30              : #include "../dom/part.h"
      31              : #include "../dom/score.h"
      32              : 
      33              : using namespace mu::engraving;
      34              : 
      35              : //---------------------------------------------------------
      36              : //   ChangeHarpPedalState
      37              : //---------------------------------------------------------
      38              : 
      39            3 : void ChangeHarpPedalState::flip()
      40              : {
      41            3 :     std::array<PedalPosition, HARP_STRING_NO> f_state = diagram->getPedalState();
      42            3 :     if (f_state == pedalState) {
      43            1 :         return;
      44              :     }
      45              : 
      46            2 :     diagram->setPedalState(pedalState);
      47            2 :     pedalState = f_state;
      48              : 
      49            2 :     diagram->triggerLayout();
      50              : }
      51              : 
      52            3 : std::vector<EngravingObject*> ChangeHarpPedalState::objectItems() const
      53              : {
      54            3 :     Part* part = diagram->originPart();
      55            6 :     std::vector<EngravingObject*> objs{ diagram };
      56            3 :     if (!part) {
      57            0 :         return objs;
      58              :     }
      59              : 
      60            3 :     HarpPedalDiagram* nextDiagram = part->nextHarpDiagram(diagram->tick());
      61            3 :     if (nextDiagram) {
      62            2 :         objs.push_back(nextDiagram);
      63              :     } else {
      64            1 :         objs.push_back(Navigation::lastElement(diagram->score()));
      65              :     }
      66            3 :     return objs;
      67            0 : }
      68              : 
      69              : //---------------------------------------------------------
      70              : //   ChangeSingleHarpPedal
      71              : //---------------------------------------------------------
      72              : 
      73            3 : void ChangeSingleHarpPedal::flip()
      74              : {
      75            3 :     HarpStringType f_type = type;
      76            3 :     PedalPosition f_pos = diagram->getPedalState()[type];
      77            3 :     if (f_pos == pos) {
      78            0 :         return;
      79              :     }
      80              : 
      81            3 :     diagram->setPedal(type, pos);
      82            3 :     type = f_type;
      83            3 :     pos = f_pos;
      84              : 
      85            3 :     diagram->triggerLayout();
      86              : }
      87              : 
      88            3 : std::vector<EngravingObject*> ChangeSingleHarpPedal::objectItems() const
      89              : {
      90            3 :     Part* part = diagram->originPart();
      91            6 :     std::vector<EngravingObject*> objs{ diagram };
      92            3 :     if (!part) {
      93            0 :         return objs;
      94              :     }
      95              : 
      96            3 :     HarpPedalDiagram* nextDiagram = part->nextHarpDiagram(diagram->tick());
      97            3 :     if (nextDiagram) {
      98            0 :         objs.push_back(nextDiagram);
      99              :     } else {
     100            3 :         objs.push_back(Navigation::lastElement(diagram->score()));
     101              :     }
     102            3 :     return objs;
     103            0 : }
        

Generated by: LCOV version 2.0-1