LCOV - code coverage report
Current view: top level - src/project/internal - exportprojectscenario.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 3 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) 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 "modularity/ioc.h"
      26              : 
      27              : #include "iexportprojectscenario.h"
      28              : #include "iprojectconfiguration.h"
      29              : #include "interactive/iinteractive.h"
      30              : #include "interactive/iplatforminteractive.h"
      31              : #include "inotationwritersregister.h"
      32              : #include "importexport/imagesexport/iimagesexportconfiguration.h"
      33              : #include "project/iprojectsession.h"
      34              : #include "io/ifilesystem.h"
      35              : #include "async/asyncable.h"
      36              : #include "notation/types/viewmode.h"
      37              : 
      38              : namespace mu::project {
      39              : class ExportProjectScenario : public IExportProjectScenario, public muse::async::Asyncable, public muse::Contextable
      40              : {
      41              :     muse::GlobalInject<muse::io::IFileSystem> fileSystem;
      42              :     muse::GlobalInject<IProjectConfiguration> configuration;
      43              :     muse::GlobalInject<iex::imagesexport::IImagesExportConfiguration> imagesExportConfiguration;
      44              :     muse::GlobalInject<INotationWritersRegister> writers;
      45              :     muse::GlobalInject<muse::IPlatformInteractive> platformInteractive;
      46              :     muse::ContextInject<muse::IInteractive> interactive = { this };
      47              :     muse::ContextInject<project::IProjectSession> context = { this };
      48              : 
      49              : public:
      50              : 
      51            0 :     ExportProjectScenario(const muse::modularity::ContextPtr& iocCtx)
      52            0 :         : muse::Contextable(iocCtx)
      53              :     {
      54            0 :     }
      55              : 
      56              :     std::vector<INotationWriter::UnitType> supportedUnitTypes(const ExportType& exportType) const override;
      57              : 
      58              :     muse::RetVal<muse::io::path_t> askExportPath(const notation::INotationPtrList& notations, const ExportType& exportType,
      59              :                                                  INotationWriter::UnitType unitType = INotationWriter::UnitType::PER_PART,
      60              :                                                  muse::io::path_t defaultDirPath = "") const override;
      61              : 
      62              :     bool exportScores(notation::INotationPtrList notations, const muse::io::path_t destinationPath,
      63              :                       INotationWriter::UnitType unitType = INotationWriter::UnitType::PER_PART,
      64              :                       bool openDestinationFolderOnExport = false) const override;
      65              : 
      66              :     const ExportInfo& exportInfo() const override;
      67              :     void setExportInfo(const ExportInfo& exportInfo) override;
      68              : 
      69              : private:
      70              :     enum class FileConflictPolicy {
      71              :         Undefined,
      72              :         SkipAll,
      73              :         ReplaceAll
      74              :     };
      75              : 
      76              :     /// When the user is trying to export a part that is a "potential excerpt", the corresponding score
      77              :     /// is not initialized yet, so we can't be certain about the page count. We should not initialize
      78              :     /// these scores either, until the user really starts the export, because initializing these scores
      79              :     /// means making changes to the file, which can't be done without the user's consent.
      80              :     bool guessIsCreatingOnlyOneFile(const notation::INotationPtrList& notations, INotationWriter::UnitType unitType) const;
      81              :     size_t exportFileCount(const notation::INotationPtrList& notations, INotationWriter::UnitType unitType) const;
      82              : 
      83              :     bool isMainNotation(notation::INotationPtr notation) const;
      84              :     notation::IMasterNotationPtr masterNotation() const;
      85              : 
      86              :     muse::io::path_t completeExportPath(const muse::io::path_t& basePath, notation::INotationPtr notation, bool isMain,
      87              :                                         bool isExportingOnlyOneScore, int pageIndex = -1) const;
      88              : 
      89              :     bool shouldReplaceFile(const QString& filename) const;
      90              :     bool askForRetry(const QString& filename) const;
      91              : 
      92              :     muse::Ret doExportLoop(const muse::io::path_t& path, std::function<muse::Ret(muse::io::IODevice&)> exportFunction) const;
      93              : 
      94              :     void showExportProgress(bool isAudioExport) const;
      95              : 
      96              :     void openFolder(const muse::io::path_t& path) const;
      97              : 
      98              :     std::vector<notation::ViewMode> viewModes(const notation::INotationPtrList& notations) const;
      99              :     void setViewModes(const notation::INotationPtrList& notations, const std::vector<notation::ViewMode>& viewModes) const;
     100              :     void setViewModes(const notation::INotationPtrList& notations, notation::ViewMode viewMode) const;
     101              : 
     102              :     mutable FileConflictPolicy m_fileConflictPolicy = FileConflictPolicy::Undefined;
     103              :     mutable muse::Progress m_exportProgress;
     104              :     ExportInfo m_exportInfo;
     105              : };
     106              : }
        

Generated by: LCOV version 2.0-1