LCOV - code coverage report
Current view: top level - src/project/internal - notationproject.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 2 0
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 "../inotationproject.h"
      26              : 
      27              : #include "async/asyncable.h"
      28              : 
      29              : #include "modularity/ioc.h"
      30              : #include "io/ifilesystem.h"
      31              : #include "../iprojectconfiguration.h"
      32              : #include "inotationreadersregister.h"
      33              : #include "inotationwritersregister.h"
      34              : 
      35              : #include "engraving/engravingproject.h"
      36              : #include "engraving/rendering/iscorerenderer.h"
      37              : 
      38              : #include "notation/inotationconfiguration.h"
      39              : #include "projectaudiosettings.h"
      40              : #include "iprojectmigrator.h"
      41              : 
      42              : #include "global/iglobalconfiguration.h"
      43              : #include "project/iprojectsession.h"
      44              : 
      45              : namespace mu::engraving {
      46              : class MscReader;
      47              : class MscWriter;
      48              : 
      49              : namespace write {
      50              : class WriteContext;
      51              : }
      52              : }
      53              : 
      54              : namespace mu::project {
      55              : class NotationProject : public INotationProject, public muse::Contextable, public muse::async::Asyncable
      56              : {
      57              :     muse::GlobalInject<muse::io::IFileSystem> fileSystem;
      58              :     muse::GlobalInject<IProjectConfiguration> configuration;
      59              :     muse::GlobalInject<muse::IGlobalConfiguration> globalConfiguration;
      60              :     muse::GlobalInject<notation::INotationConfiguration> notationConfiguration;
      61              :     muse::GlobalInject<INotationReadersRegister> readers;
      62              :     muse::GlobalInject<INotationWritersRegister> writers;
      63              :     muse::GlobalInject<engraving::rendering::IScoreRenderer> renderer;
      64              :     muse::ContextInject<project::IProjectSession> projectSession = { this };
      65              :     muse::ContextInject<IProjectMigrator> migrator = { this };
      66              : 
      67              : public:
      68            0 :     NotationProject(const muse::modularity::ContextPtr& iocCtx)
      69            0 :         : muse::Contextable(iocCtx) {}
      70              :     ~NotationProject() override;
      71              : 
      72              :     static QString scoreDefaultTitle();
      73              : 
      74              :     muse::Ret load(const muse::io::path_t& path, const OpenParams& params = {}, const std::string& format = "") override;
      75              :     muse::Ret createNew(const ProjectCreateOptions& projectInfo) override;
      76              : 
      77              :     muse::io::path_t path() const override;
      78              :     void setPath(const muse::io::path_t& path) override;
      79              :     muse::async::Notification pathChanged() const override;
      80              : 
      81              :     QString displayName() const override;
      82              :     muse::async::Notification displayNameChanged() const override;
      83              : 
      84              :     bool isCloudProject() const override;
      85              :     const CloudProjectInfo& cloudInfo() const override;
      86              :     void setCloudInfo(const CloudProjectInfo& info) override;
      87              : 
      88              :     const CloudAudioInfo& cloudAudioInfo() const override;
      89              :     void setCloudAudioInfo(const CloudAudioInfo& audioInfo) override;
      90              : 
      91              :     bool isNewlyCreated() const override;
      92              :     void markAsNewlyCreated() override;
      93              : 
      94              :     bool isImported() const override;
      95              : 
      96              :     void markAsUnsaved() override;
      97              : 
      98              :     bool isNeedSave() const override;
      99              :     muse::async::Notification needSaveChanged() const override;
     100              :     muse::Ret canSave() const override;
     101              : 
     102              :     bool needAutoSave() const override;
     103              :     void setNeedAutoSave(bool val) override;
     104              : 
     105              :     muse::Ret save(
     106              :         const muse::io::path_t& path = muse::io::path_t(), SaveMode saveMode = SaveMode::Save, bool createBackup = true) override;
     107              :     muse::Ret savePage(const muse::io::path_t& path, const size_t pageNum) override;
     108              :     muse::async::Channel<muse::io::path_t, SaveMode> saveComplited() const override;
     109              : 
     110              :     muse::Ret writeToDevice(QIODevice* device) override;
     111              : 
     112              :     ProjectMeta metaInfo() const override;
     113              :     void setMetaInfo(const ProjectMeta& meta, bool undoable = false) override;
     114              : 
     115              :     notation::IMasterNotationPtr masterNotation() const override;
     116              :     IProjectAudioSettingsPtr audioSettings() const override;
     117              : 
     118              : private:
     119              :     void setupProject();
     120              : 
     121              :     muse::Ret loadTemplate(const ProjectCreateOptions& projectOptions);
     122              : 
     123              :     muse::Ret doLoad(const muse::io::path_t& path, const OpenParams& params, const std::string& format);
     124              :     muse::Ret doImport(const muse::io::path_t& path, const OpenParams& params);
     125              : 
     126              :     muse::Ret saveScore(const muse::io::path_t& path, const std::string& fileSuffix, bool generateBackup = true,
     127              :                         bool createThumbnail = true, bool isAutosave = false, const engraving::write::WriteContext* ctx = nullptr);
     128              :     muse::Ret saveSelectionOnScore(const muse::io::path_t& path = muse::io::path_t());
     129              :     muse::Ret exportProject(const muse::io::path_t& path, const std::string& suffix);
     130              :     muse::Ret doSave(const muse::io::path_t& path, engraving::MscIoMode ioMode, bool generateBackup = true, bool createThumbnail = true,
     131              :                      bool isAutosave = false, const engraving::write::WriteContext* ctx = nullptr);
     132              :     muse::Ret makeBackup(muse::io::path_t filePath);
     133              :     muse::Ret writeProject(const muse::io::path_t& path, const engraving::write::WriteContext* ctx = nullptr);
     134              :     muse::Ret writeProject(engraving::MscWriter& msczWriter, bool createThumbnail = true,
     135              :                            const engraving::write::WriteContext* ctx = nullptr);
     136              :     muse::Ret checkSavedFileForCorruption(engraving::MscIoMode ioMode, const muse::io::path_t& path, const muse::io::path_t& scoreFileName);
     137              : 
     138              :     void listenIfNeedSaveChanges();
     139              :     void markAsSaved(const muse::io::path_t& path);
     140              :     void setNeedSave(bool needSave);
     141              : 
     142              :     mu::engraving::EngravingProjectPtr m_engravingProject = nullptr;
     143              :     notation::IMasterNotationPtr m_masterNotation = nullptr;
     144              :     ProjectAudioSettingsPtr m_projectAudioSettings = nullptr;
     145              :     mutable CloudProjectInfo m_cloudInfo;
     146              :     mutable CloudAudioInfo m_cloudAudioInfo;
     147              : 
     148              :     muse::io::path_t m_path;
     149              :     muse::async::Notification m_pathChanged;
     150              :     muse::async::Notification m_displayNameChanged;
     151              : 
     152              :     muse::async::Notification m_needSaveChanged;
     153              : 
     154              :     muse::async::Channel<muse::io::path_t, SaveMode> m_saved;
     155              : 
     156              :     bool m_isNewlyCreated = false; /// true if the file has never been saved yet
     157              :     bool m_isImported = false;
     158              :     bool m_isNeedSave = false;
     159              :     bool m_needAutoSave = false;
     160              :     bool m_hasNonUndoStackChanges = false;
     161              : };
     162              : }
        

Generated by: LCOV version 2.0-1