LCOV - code coverage report
Current view: top level - src/engraving/editing - editstaff.h Coverage Total Hit
Test: filtered_coverage.info Lines: 53.7 % 54 29
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              : #pragma once
      24              : 
      25              : #include "transaction/undoablecommand.h"
      26              : 
      27              : #include "../dom/measure.h"
      28              : #include "../dom/score.h"
      29              : #include "../dom/staff.h"
      30              : 
      31              : namespace mu::engraving {
      32              : class InsertStaff : public UndoableCommand
      33              : {
      34          108 :     OBJECT_ALLOCATOR(engraving, InsertStaff)
      35              : 
      36              :     Staff* staff = nullptr;
      37              :     staff_idx_t ridx = muse::nidx;
      38              : 
      39              : public:
      40              :     InsertStaff(Staff*, staff_idx_t idx);
      41              :     void undo() override;
      42              :     void redo() override;
      43              :     void cleanup(bool) override;
      44              : 
      45           58 :     UNDO_TYPE(CommandType::InsertStaff)
      46            0 :     UNDO_NAME("InsertStaff")
      47          174 :     UNDO_CHANGED_OBJECTS({ staff })
      48              : };
      49              : 
      50              : class RemoveStaff : public UndoableCommand
      51              : {
      52           40 :     OBJECT_ALLOCATOR(engraving, RemoveStaff)
      53              : 
      54              :     Staff* staff = nullptr;
      55              :     staff_idx_t ridx = muse::nidx;
      56              :     bool wasSystemObjectStaff = false;
      57              : 
      58              : public:
      59              :     RemoveStaff(Staff*);
      60              :     void undo() override;
      61              :     void redo() override;
      62              :     void cleanup(bool) override;
      63              : 
      64           21 :     UNDO_TYPE(CommandType::RemoveStaff)
      65            0 :     UNDO_NAME("RemoveStaff")
      66           63 :     UNDO_CHANGED_OBJECTS({ staff })
      67              : };
      68              : 
      69              : class AddSystemObjectStaff : public UndoableCommand
      70              : {
      71            0 :     OBJECT_ALLOCATOR(engraving, AddSystemObjectStaff)
      72              : 
      73              :     Staff* staff = nullptr;
      74              : 
      75              : public:
      76              :     AddSystemObjectStaff(Staff*);
      77              :     void undo() override;
      78              :     void redo() override;
      79              : 
      80            0 :     UNDO_TYPE(CommandType::AddSystemObjectStaff)
      81            0 :     UNDO_NAME("AddSystemObjectStaff")
      82            0 :     UNDO_CHANGED_OBJECTS({ staff })
      83              : };
      84              : 
      85              : class RemoveSystemObjectStaff : public UndoableCommand
      86              : {
      87            0 :     OBJECT_ALLOCATOR(engraving, RemoveSystemObjectStaff)
      88              : 
      89              :     Staff* staff = nullptr;
      90              : 
      91              : public:
      92              :     RemoveSystemObjectStaff(Staff*);
      93              :     void undo() override;
      94              :     void redo() override;
      95              : 
      96            0 :     UNDO_TYPE(CommandType::RemoveSystemObjectStaff)
      97            0 :     UNDO_NAME("RemoveSystemObjectStaff")
      98            0 :     UNDO_CHANGED_OBJECTS({ staff })
      99              : };
     100              : 
     101              : class InsertMStaff : public UndoableCommand
     102              : {
     103          684 :     OBJECT_ALLOCATOR(engraving, InsertMStaff)
     104              : 
     105              :     Measure* measure = nullptr;
     106              :     MStaff* mstaff = nullptr;
     107              :     staff_idx_t idx = muse::nidx;
     108              : 
     109              : public:
     110              :     InsertMStaff(Measure*, MStaff*, staff_idx_t);
     111              :     void undo() override;
     112              :     void redo() override;
     113              : 
     114          453 :     UNDO_TYPE(CommandType::InsertMStaff)
     115            0 :     UNDO_NAME("InsertMStaff")
     116         1359 :     UNDO_CHANGED_OBJECTS({ measure })
     117              : };
     118              : 
     119              : class RemoveMStaff : public UndoableCommand
     120              : {
     121          373 :     OBJECT_ALLOCATOR(engraving, RemoveMStaff)
     122              : 
     123              :     Measure* measure = nullptr;
     124              :     MStaff* mstaff = nullptr;
     125              :     int idx = 0;
     126              : 
     127              : public:
     128              :     RemoveMStaff(Measure*, MStaff*, int);
     129              :     void undo() override;
     130              :     void redo() override;
     131              : 
     132          270 :     UNDO_TYPE(CommandType::RemoveMStaff)
     133            0 :     UNDO_NAME("RemoveMStaff")
     134          810 :     UNDO_CHANGED_OBJECTS({ measure })
     135              : };
     136              : 
     137              : class InsertStaves : public UndoableCommand
     138              : {
     139          684 :     OBJECT_ALLOCATOR(engraving, InsertStaves)
     140              : 
     141              :     Measure* measure = nullptr;
     142              :     staff_idx_t a = muse::nidx;
     143              :     staff_idx_t b = muse::nidx;
     144              : 
     145              : public:
     146              :     InsertStaves(Measure*, staff_idx_t, staff_idx_t);
     147              :     void undo() override;
     148              :     void redo() override;
     149              : 
     150          453 :     UNDO_TYPE(CommandType::InsertStaves)
     151            0 :     UNDO_NAME("InsertStaves")
     152         1359 :     UNDO_CHANGED_OBJECTS({ measure })
     153              : };
     154              : 
     155              : class RemoveStaves : public UndoableCommand
     156              : {
     157          373 :     OBJECT_ALLOCATOR(engraving, RemoveStaves)
     158              : 
     159              :     Measure* measure = nullptr;
     160              :     staff_idx_t a = muse::nidx;
     161              :     staff_idx_t b = muse::nidx;
     162              : 
     163              : public:
     164              :     RemoveStaves(Measure*, staff_idx_t, staff_idx_t);
     165              :     void undo() override;
     166              :     void redo() override;
     167              : 
     168          270 :     UNDO_TYPE(CommandType::RemoveStaves)
     169            0 :     UNDO_NAME("RemoveStaves")
     170          810 :     UNDO_CHANGED_OBJECTS({ measure })
     171              : };
     172              : 
     173              : class SortStaves : public UndoableCommand
     174              : {
     175            6 :     OBJECT_ALLOCATOR(engraving, SortStaves)
     176              : 
     177              :     Score* score = nullptr;
     178              :     std::vector<staff_idx_t> list;
     179              :     std::vector<staff_idx_t> rlist;
     180              : 
     181              : public:
     182              :     SortStaves(Score*, const std::vector<staff_idx_t>&);
     183              :     void undo() override;
     184              :     void redo() override;
     185              : 
     186            4 :     UNDO_TYPE(CommandType::SortStaves)
     187            0 :     UNDO_NAME("SortStaves")
     188           12 :     UNDO_CHANGED_OBJECTS({ score })
     189              : };
     190              : 
     191              : //---------------------------------------------------------
     192              : //   ChangeStaff
     193              : //---------------------------------------------------------
     194              : 
     195              : class ChangeStaff : public UndoableCommand
     196              : {
     197            2 :     OBJECT_ALLOCATOR(engraving, ChangeStaff)
     198              : 
     199              :     Staff* staff = nullptr;
     200              : 
     201              :     bool visible = false;
     202              :     ClefTypeList clefType;
     203              :     Spatium userDist = 0.0_sp;
     204              :     bool cutaway = false;
     205              :     bool hideSystemBarLine = false;
     206              :     AutoOnOff mergeMatchingRests = AutoOnOff::AUTO;
     207              :     bool reflectTranspositionInLinkedTab = false;
     208              : 
     209              :     void flip() override;
     210              : 
     211              : public:
     212              :     ChangeStaff(Staff*);
     213              : 
     214              :     ChangeStaff(Staff*, bool _visible, ClefTypeList _clefType, Spatium userDist, bool _cutaway, bool _hideSystemBarLine,
     215              :                 AutoOnOff _mergeRests, bool _reflectTranspositionInLinkedTab);
     216              : 
     217            2 :     UNDO_TYPE(CommandType::ChangeStaff)
     218            0 :     UNDO_NAME("ChangeStaff")
     219            6 :     UNDO_CHANGED_OBJECTS({ staff })
     220              : };
     221              : 
     222              : //---------------------------------------------------------
     223              : //   ChangeStaffType
     224              : //---------------------------------------------------------
     225              : 
     226              : class ChangeStaffType : public UndoableCommand
     227              : {
     228            4 :     OBJECT_ALLOCATOR(engraving, ChangeStaffType)
     229              : 
     230              :     Staff* staff = nullptr;
     231              :     StaffType staffType;
     232              :     Fraction tick;
     233              : 
     234              :     void flip() override;
     235              : 
     236              : public:
     237            2 :     ChangeStaffType(Staff* s, const StaffType& t, Fraction tick = Fraction(0, 1))
     238            2 :         : staff(s), staffType(t), tick(tick) {}
     239              : 
     240            2 :     UNDO_TYPE(CommandType::ChangeStaffType)
     241            0 :     UNDO_NAME("ChangeStaffType")
     242            6 :     UNDO_CHANGED_OBJECTS({ staff })
     243              : };
     244              : 
     245              : class ChangeMStaffProperties : public UndoableCommand
     246              : {
     247            0 :     OBJECT_ALLOCATOR(engraving, ChangeMStaffProperties)
     248              : 
     249              :     Measure* measure = nullptr;
     250              :     staff_idx_t staffIdx = 0;
     251              :     bool visible = false;
     252              :     bool stemless = false;
     253              : 
     254              :     void flip() override;
     255              : 
     256              : public:
     257              :     ChangeMStaffProperties(Measure*, staff_idx_t staffIdx, bool visible, bool stemless);
     258              : 
     259            0 :     UNDO_TYPE(CommandType::ChangeMStaffProperties)
     260            0 :     UNDO_NAME("ChangeMStaffProperties")
     261            0 :     UNDO_CHANGED_OBJECTS({ measure })
     262              : };
     263              : 
     264              : class ChangeMStaffHideIfEmpty : public UndoableCommand
     265              : {
     266            0 :     OBJECT_ALLOCATOR(engraving, ChangeMStaffHideIfEmpty)
     267              : 
     268              :     Measure* measure = nullptr;
     269              :     staff_idx_t staffIdx = 0;
     270              :     AutoOnOff hideIfEmpty = AutoOnOff::AUTO;
     271              : 
     272              :     void flip() override;
     273              : 
     274              : public:
     275              :     ChangeMStaffHideIfEmpty(Measure*, staff_idx_t staffIdx, AutoOnOff hideIfEmpty);
     276              : 
     277            0 :     UNDO_TYPE(CommandType::ChangeMStaffHideIfEmpty)
     278            0 :     UNDO_NAME("ChangeMStaffHideIfEmpty")
     279            0 :     UNDO_CHANGED_OBJECTS({ measure })
     280              : };
     281              : }
        

Generated by: LCOV version 2.0-1