added import notation readers

This commit is contained in:
Igor Korsukov 2020-06-22 12:16:37 +02:00
parent 7b6b88c504
commit e45781f075
46 changed files with 1170 additions and 135 deletions

View file

@ -42,6 +42,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/iglobalconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/globalconfiguration.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/globalconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/io/filepath.cpp
${CMAKE_CURRENT_LIST_DIR}/io/filepath.h
)
include(${PROJECT_SOURCE_DIR}/build/module.cmake)

View file

@ -19,9 +19,8 @@
#ifndef MU_FRAMEWORK_IINTERACTIVE_H
#define MU_FRAMEWORK_IINTERACTIVE_H
#include <QString>
#include "modularity/imoduleexport.h"
#include "io/filepath.h"
namespace mu {
namespace framework {
@ -32,7 +31,7 @@ class IInteractive : MODULE_EXPORT_INTERFACE
public:
virtual ~IInteractive() = default;
virtual QString selectOpeningFile(const QString& title, const QString& dir, const QString& filter) = 0;
virtual io::path selectOpeningFile(const std::string& title, const std::string& dir, const std::string& filter) = 0;
};
}
}

View file

@ -0,0 +1,43 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "filepath.h"
#include "stringutils.h"
#ifndef NO_QT_SUPPORT
mu::io::path mu::io::pathFromQString(const QString& s)
{
return s.toStdString();
}
QString mu::io::pathToQString(const path& p)
{
return QString::fromStdString(p);
}
#endif
mu::io::path mu::io::syffix(const mu::io::path& path)
{
auto pos = path.find_last_of(".");
if (pos == std::string::npos) {
return std::string();
}
std::string sfx = path.substr(pos + 1);
return strings::toLower(sfx);
}

View file

@ -0,0 +1,38 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_IO_FILEPATH_H
#define MU_IO_FILEPATH_H
#include <string>
#include <QString>
namespace mu {
namespace io {
using path = std::string;
#ifndef NO_QT_SUPPORT
path pathFromQString(const QString& s);
QString pathToQString(const path& p);
#endif
path syffix(const path& path);
}
}
#endif // MU_IO_FILEPATH_H

View file

@ -18,6 +18,9 @@
//=============================================================================
#include "stringutils.h"
#include <cctype>
#include <algorithm>
bool mu::strings::replace(std::string& str, const std::string& from, const std::string& to)
{
size_t start_pos = str.find(from);
@ -27,3 +30,12 @@ bool mu::strings::replace(std::string& str, const std::string& from, const std::
str.replace(start_pos, from.length(), to);
return true;
}
std::string mu::strings::toLower(const std::string& source)
{
std::string str = source;
std::for_each(str.begin(), str.end(), [](char& c) {
c = ::tolower(c);
});
return str;
}

View file

@ -23,9 +23,8 @@
namespace mu {
namespace strings {
bool replace(std::string& source, const std::string& what, const std::string& to);
std::string toLower(const std::string& source);
}
}

View file

@ -19,10 +19,17 @@
#include "uiinteractive.h"
#include <QFileDialog>
#include "io/filepath.h"
using namespace mu::framework;
QString UiInteractive::selectOpeningFile(const QString& title, const QString& dir, const QString& filter)
mu::io::path UiInteractive::selectOpeningFile(const std::string& title,
const std::string& dir,
const std::string& filter)
{
return QFileDialog::getOpenFileName(nullptr /*parent*/, title, dir, filter);
QString path = QFileDialog::getOpenFileName(nullptr, /*parent*/
QString::fromStdString(title),
QString::fromStdString(dir),
QString::fromStdString(filter));
return io::pathFromQString(path);
}

View file

@ -29,7 +29,7 @@ public:
UiInteractive() = default;
QString selectOpeningFile(const QString& title, const QString& dir, const QString& filter) override;
io::path selectOpeningFile(const std::string& title, const std::string& dir, const std::string& filter) override;
};
}
}

View file

@ -32,6 +32,7 @@
#include "mu4/domain/notation/notationdomainmodule.h"
#include "mu4/scenes/notation/notationscenemodule.h"
#include "mu4/scenes/common/commonscenemodule.h"
#include "mu4/domain/importexport/importexportmodule.h"
#ifdef BUILD_TELEMETRY_MODULE
#include "framework/telemetry/telemetrysetup.h"
@ -74,7 +75,7 @@ ModulesSetup::ModulesSetup()
<< new mu::framework::GlobalModule()
<< new mu::framework::UiModule()
<< new mu::framework::UiComponentsModule()
;
<< new mu::domain::importexport::ImportExportModule();
}
//---------------------------------------------------------

View file

@ -32,6 +32,11 @@ class IGlobalContext : MODULE_EXPORT_INTERFACE
public:
~IGlobalContext() = default;
virtual void addNotation(const std::shared_ptr<domain::notation::INotation>& notation) = 0;
virtual void removeNotation(const std::shared_ptr<domain::notation::INotation>& notation) = 0;
virtual const std::vector<std::shared_ptr<domain::notation::INotation> >& notations() const = 0;
virtual bool isContainsNotation(const io::path& path) const = 0;
virtual void setCurrentNotation(const std::shared_ptr<domain::notation::INotation>& notation) = 0;
virtual std::shared_ptr<domain::notation::INotation> currentNotation() const = 0;
virtual async::Notification currentNotationChanged() const = 0;

View file

@ -22,6 +22,31 @@ using namespace mu::context;
using namespace mu::domain::notation;
using namespace mu::shortcuts;
void GlobalContext::addNotation(const std::shared_ptr<domain::notation::INotation>& notation)
{
m_notations.push_back(notation);
}
void GlobalContext::removeNotation(const std::shared_ptr<domain::notation::INotation>& notation)
{
m_notations.erase(std::remove(m_notations.begin(), m_notations.end(), notation), m_notations.end());
}
const std::vector<std::shared_ptr<mu::domain::notation::INotation> >& GlobalContext::notations() const
{
return m_notations;
}
bool GlobalContext::isContainsNotation(const io::path& path) const
{
for (const auto& n : m_notations) {
if (n->path() == path) {
return true;
}
}
return false;
}
void GlobalContext::setCurrentNotation(const std::shared_ptr<domain::notation::INotation>& notation)
{
m_notation = notation;

View file

@ -20,6 +20,7 @@
#define MU_CONTEXT_GLOBALCONTEXT_H
#include <map>
#include <vector>
#include "../iglobalcontext.h"
#include "shortcuts/ishortcutcontextresolver.h"
@ -30,6 +31,11 @@ class GlobalContext : public IGlobalContext, public shortcuts::IShortcutContextR
public:
GlobalContext() = default;
void addNotation(const std::shared_ptr<domain::notation::INotation>& notation) override;
void removeNotation(const std::shared_ptr<domain::notation::INotation>& notation) override;
const std::vector<std::shared_ptr<domain::notation::INotation> >& notations() const override;
bool isContainsNotation(const io::path& path) const override;
void setCurrentNotation(const std::shared_ptr<domain::notation::INotation>& notation) override;
std::shared_ptr<domain::notation::INotation> currentNotation() const override;
async::Notification currentNotationChanged() const override;
@ -42,6 +48,7 @@ public:
private:
std::vector<std::shared_ptr<domain::notation::INotation> > m_notations;
std::shared_ptr<domain::notation::INotation> m_notation;
async::Notification m_notationChanged;

View file

@ -39,6 +39,22 @@ set(MODULE_SRC
${BWW_SRC}
${CMAKE_CURRENT_LIST_DIR}/importexportmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/importexportmodule.h
${CMAKE_CURRENT_LIST_DIR}/internal/musicxmlreader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/musicxmlreader.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationmidireader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationmidireader.h
${CMAKE_CURRENT_LIST_DIR}/internal/musedatareader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/musedatareader.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationbbreader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationbbreader.h
${CMAKE_CURRENT_LIST_DIR}/internal/capellareader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/capellareader.h
${CMAKE_CURRENT_LIST_DIR}/internal/overeader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/overeader.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationbwwreader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationbwwreader.h
${CMAKE_CURRENT_LIST_DIR}/internal/guitarproreader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/guitarproreader.h
)
add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/beatroot beatroot) # for midiimport

View file

@ -1,92 +0,0 @@
#=============================================================================
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2020 MuseScore BVBA and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================
set(MODULE importexport)
include (${PROJECT_SOURCE_DIR}/build/gch.cmake)
include_directories(
${PROJECT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
if (NOT MSVC)
set(_all_h_file "${PROJECT_BINARY_DIR}/all.h")
else (NOT MSVC)
set(_all_h_file "${PROJECT_SOURCE_DIR}/all.h")
endif (NOT MSVC)
include(${CMAKE_CURRENT_LIST_DIR}/musicxml/musicxml.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/midiimport/midiimport.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/ove/ove.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/guitarpro/guitarpro.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/musedata/musedata.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/bb/bb.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/capella/capella.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/bww/bww.cmake)
add_library (
${MODULE} STATIC
${_all_h_file}
${PCH}
${MUSICXML_SRC}
${MIDIIMPORT_SRC}
${OVE_SRC}
${GUITARPRO_SRC}
${MUSEDATA_SRC}
${BB_SRC}
${CAPELLA_SRC}
${BWW_SRC}
)
add_subdirectory(../thirdparty/beatroot beatroot) # for midiimport
add_subdirectory(../thirdparty/rtf2html rtf2html) # for capella
target_link_libraries(${MODULE}
${QT_LIBRARIES}
audio # for midiimport
beatroot # for midiimport
rtf2html # for capella
)
if (NOT MSVC)
set_target_properties (
${MODULE}
PROPERTIES
COMPILE_FLAGS "${PCH_INCLUDE} -g -Wall -Wextra -Winvalid-pch"
)
else (NOT MSVC)
set_target_properties (
${MODULE}
PROPERTIES
COMPILE_FLAGS "${PCH_INCLUDE}"
)
endif (NOT MSVC)
xcode_pch(${MODULE} all)
# Use MSVC pre-compiled headers
vstudio_pch( ${MODULE} )
# MSVC does not depend on mops1 & mops2 for PCH
if (NOT MSVC)
ADD_DEPENDENCIES(${MODULE} mops1)
ADD_DEPENDENCIES(${MODULE} mops2)
endif (NOT MSVC)

View file

@ -18,9 +18,39 @@
//=============================================================================
#include "importexportmodule.h"
using namespace mu::importexport;
#include "log.h"
#include "modularity/ioc.h"
#include "domain/notation/inotationreadersregister.h"
#include "internal/musicxmlreader.h"
#include "internal/notationmidireader.h"
#include "internal/musedatareader.h"
#include "internal/notationbbreader.h"
#include "internal/capellareader.h"
#include "internal/overeader.h"
#include "internal/notationbwwreader.h"
#include "internal/guitarproreader.h"
ImportExportModule::ImportExportModule()
using namespace mu::domain::importexport;
using namespace mu::domain::notation;
std::string ImportExportModule::moduleName() const
{
return "importexport";
}
void ImportExportModule::onInit()
{
auto readers = framework::ioc()->resolve<INotationReadersRegister>(moduleName());
IF_ASSERT_FAILED(readers) {
return;
}
readers->reg({ "xml", "musicxml", "mxl" }, std::make_shared<MusicXmlReader>());
readers->reg({ "mid", "midi", "kar" }, std::make_shared<NotationMidiReader>());
readers->reg({ "md" }, std::make_shared<MuseDataReader>());
readers->reg({ "mgu", "sgu" }, std::make_shared<NotationBBReader>());
readers->reg({ "cap", "capx" }, std::make_shared<CapellaReader>());
readers->reg({ "ove", "scw" }, std::make_shared<OveReader>());
readers->reg({ "bmw", "bww" }, std::make_shared<NotationBwwReader>());
readers->reg({ "gtp", "gp3", "gp4", "gp5", "gpx", "gp", "ptb" }, std::make_shared<GuitarProReader>());
}

View file

@ -16,19 +16,23 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_IMPORTEXPORT_IMPORTEXPORTMODULE_H
#define MU_IMPORTEXPORT_IMPORTEXPORTMODULE_H
#ifndef MU_DOMAIN_IMPORTEXPORTMODULE_H
#define MU_DOMAIN_IMPORTEXPORTMODULE_H
#include "modularity/imodulesetup.h"
namespace mu {
namespace domain {
namespace importexport {
class ImportExportModule
class ImportExportModule : public framework::IModuleSetup
{
public:
ImportExportModule();
std::string moduleName() const override;
void onInit() override;
};
}
}
}
#endif // MU_IMPORTEXPORT_IMPORTEXPORTMODULE_H
#endif // MU_DOMAIN_IMPORTEXPORTMODULE_H

View file

@ -0,0 +1,41 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "capellareader.h"
#include "io/filepath.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importCapella(MasterScore*, const QString& name);
extern Score::FileError importCapXml(MasterScore*, const QString& name);
}
using namespace mu::domain::importexport;
bool CapellaReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::Score::FileError::FILE_UNKNOWN_TYPE;
std::string syffix = io::syffix(path);
if (syffix == "cap") {
err = Ms::importCapella(score, io::pathToQString(path));
} else if (syffix == "capx") {
err = Ms::importCapXml(score, io::pathToQString(path));
}
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_CAPELLAREADER_H
#define MU_DOMAIN_CAPELLAREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class CapellaReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_CAPELLAREADER_H

View file

@ -0,0 +1,33 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "guitarproreader.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importGTP(MasterScore*, const QString& name);
}
using namespace mu::domain::importexport;
bool GuitarProReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::importGTP(score, io::pathToQString(path));
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_GUITARPROREADER_H
#define MU_DOMAIN_GUITARPROREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class GuitarProReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_GUITARPROREADER_H

View file

@ -0,0 +1,33 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "musedatareader.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importMuseData(MasterScore*, const QString& name);
}
using namespace mu::domain::importexport;
bool MuseDataReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::importMuseData(score, io::pathToQString(path));
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_MUSEDATAREADER_H
#define MU_DOMAIN_MUSEDATAREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class MuseDataReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_MUSEDATAREADER_H

View file

@ -0,0 +1,42 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "musicxmlreader.h"
#include "io/filepath.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importMusicXml(MasterScore*, const QString&);
extern Score::FileError importCompressedMusicXml(MasterScore*, const QString&);
}
using namespace mu::domain::importexport;
bool MusicXmlReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::Score::FileError::FILE_UNKNOWN_TYPE;
std::string syffix = io::syffix(path);
if (syffix == "xml" || syffix == "musicxml") {
err = Ms::importMusicXml(score, io::pathToQString(path));
} else if (syffix == "mxl") {
err = Ms::importCompressedMusicXml(score, io::pathToQString(path));
}
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,36 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_MUSICXMLREADER_H
#define MU_DOMAIN_MUSICXMLREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class MusicXmlReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_MUSICXMLREADER_H

View file

@ -0,0 +1,33 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "notationbbreader.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importBB(MasterScore*, const QString& name);
}
using namespace mu::domain::importexport;
bool NotationBBReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::importBB(score, io::pathToQString(path));
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_NOTATIONBBREADER_H
#define MU_DOMAIN_NOTATIONBBREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class NotationBBReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_NOTATIONBBREADER_H

View file

@ -0,0 +1,33 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "notationbwwreader.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importBww(MasterScore*, const QString& name);
}
using namespace mu::domain::importexport;
bool NotationBwwReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::importBww(score, io::pathToQString(path));
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_NOTATIONBWWREADER_H
#define MU_DOMAIN_NOTATIONBWWREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class NotationBwwReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_NOTATIONBWWREADER_H

View file

@ -0,0 +1,33 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "notationmidireader.h"
#include "libmscore/score.h"
namespace Ms {
extern Score::FileError importMidi(MasterScore*, const QString& name);
}
using namespace mu::domain::importexport;
bool NotationMidiReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = Ms::importMidi(score, io::pathToQString(path));
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_NOTATIONMIDIREADER_H
#define MU_DOMAIN_NOTATIONMIDIREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class NotationMidiReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_NOTATIONMIDIREADER_H

View file

@ -0,0 +1,31 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "overeader.h"
#include "libmscore/score.h"
extern Ms::Score::FileError importOve(Ms::MasterScore*, const QString& name);
using namespace mu::domain::importexport;
bool OveReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError err = importOve(score, io::pathToQString(path));
return err == Ms::Score::FileError::FILE_NO_ERROR;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_OVEREADER_H
#define MU_DOMAIN_OVEREADER_H
#include "domain/notation/inotationreader.h"
namespace mu {
namespace domain {
namespace importexport {
class OveReader : public notation::INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_OVEREADER_H

View file

@ -25,6 +25,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/notationdomainmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/notationdomainmodule.h
${CMAKE_CURRENT_LIST_DIR}/inotation.h
${CMAKE_CURRENT_LIST_DIR}/inotationreader.h
${CMAKE_CURRENT_LIST_DIR}/inotationreadersregister.h
${CMAKE_CURRENT_LIST_DIR}/inotationcreator.h
${CMAKE_CURRENT_LIST_DIR}/inotationinputstate.h
${CMAKE_CURRENT_LIST_DIR}/inotationselection.h
@ -50,6 +52,10 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/notationinteraction.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationconfiguration.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/mscznotationreader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/mscznotationreader.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationreadersregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationreadersregister.h
)
set(MODULE_LINK

View file

@ -23,9 +23,11 @@
#include <string>
#include "modularity/imoduleexport.h"
#include "io/filepath.h"
#include "async/notification.h"
#include "inotationinteraction.h"
#include "notationtypes.h"
#include "inotationreader.h"
class QPainter;
namespace mu {
@ -33,12 +35,15 @@ namespace domain {
namespace notation {
class INotation : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(mu::domain::notation::INotation)
INTERFACE_ID(INotation)
public:
~INotation() = default;
virtual bool load(const std::string& path) = 0;
virtual bool load(const io::path& path) = 0;
virtual bool load(const io::path& path, const std::shared_ptr<INotationReader>& reader) = 0;
virtual io::path path() const = 0;
virtual void setViewSize(const QSizeF& vs) = 0;
virtual void paint(QPainter* p, const QRect& r) = 0;

View file

@ -28,7 +28,7 @@ namespace domain {
namespace notation {
class INotationCreator : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(mu::domain::notation::INotationCreator)
INTERFACE_ID(INotationCreator)
public:
~INotationCreator() = default;

View file

@ -0,0 +1,44 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_INOTATIONREADER_H
#define MU_DOMAIN_INOTATIONREADER_H
#include <string>
#include "io/filepath.h"
namespace Ms {
class MasterScore;
}
namespace mu {
namespace domain {
namespace notation {
class INotationReader
{
public:
virtual ~INotationReader() = default;
virtual bool read(Ms::MasterScore* score, const io::path& path) = 0;
};
}
}
}
#endif // MU_DOMAIN_INOTATIONREADER_H

View file

@ -0,0 +1,46 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_INOTATIONREADERSREGISTER_H
#define MU_DOMAIN_INOTATIONREADERSREGISTER_H
#include <string>
#include <vector>
#include "modularity/imoduleexport.h"
#include "inotationreader.h"
namespace mu {
namespace domain {
namespace notation {
class INotationReadersRegister : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(INotationReadersRegister)
public:
virtual ~INotationReadersRegister() = default;
//! NOTE In the future, we need to replace the suffix with an enumerator
//! or a better structure describing the format.
virtual void reg(const std::vector<std::string>& syffixs, std::shared_ptr<INotationReader> reader) = 0;
virtual std::shared_ptr<INotationReader> reader(const std::string& syffix) = 0;
};
}
}
}
#endif // MU_DOMAIN_INOTATIONREADERSREGISTER_H

View file

@ -0,0 +1,32 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "mscznotationreader.h"
#include "libmscore/score.h"
using namespace mu::domain::notation;
bool MsczNotationReader::read(Ms::MasterScore* score, const io::path& path)
{
Ms::Score::FileError rv = score->loadMsc(io::pathToQString(path), true);
if (rv != Ms::Score::FileError::FILE_NO_ERROR) {
return false;
}
return true;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_MSCZNOTATIONREADER_H
#define MU_DOMAIN_MSCZNOTATIONREADER_H
#include "../inotationreader.h"
namespace mu {
namespace domain {
namespace notation {
class MsczNotationReader : public INotationReader
{
public:
bool read(Ms::MasterScore* score, const io::path& path) override;
};
}
}
}
#endif // MU_DOMAIN_MSCZNOTATIONREADER_H

View file

@ -20,10 +20,16 @@
#include <QPointF>
#include <QPainter>
#include <QFileInfo>
#include "log.h"
#include "config.h"
#include "io/filepath.h"
#include "libmscore/score.h"
#include "libmscore/page.h"
#include "libmscore/part.h"
#include "notationinteraction.h"
@ -46,7 +52,6 @@ using namespace Ms;
Notation::Notation()
{
m_scoreGlobal = new MScore(); //! TODO May be static?
m_score = new MasterScore(m_scoreGlobal->baseStyle());
m_interaction = new NotationInteraction(this);
@ -69,19 +74,86 @@ void Notation::init()
MScore::init(); // initialize libmscore
}
bool Notation::load(const std::string& path)
bool Notation::load(const io::path& path)
{
Score::FileError rv = m_score->loadMsc(QString::fromStdString(path), true);
if (rv != Score::FileError::FILE_NO_ERROR) {
std::string syffix = io::syffix(path);
//! NOTE For "mscz", "mscx" see MsczNotationReader
//! for others see readers in importexport module
auto reader = readers()->reader(syffix);
if (!reader) {
LOGE() << "not found reader for file: " << path;
return false;
}
m_score->setUpdateAll();
m_score->doLayout();
return load(path, reader);
}
bool Notation::load(const io::path& path, const std::shared_ptr<INotationReader>& reader)
{
if (m_score) {
delete m_score;
m_score = nullptr;
}
ScoreLoad sl;
MasterScore* score = new MasterScore(m_scoreGlobal->baseStyle());
bool ok = doLoadScore(score, path, reader);
if (ok) {
m_score = score;
}
return ok;
}
bool Notation::doLoadScore(Ms::MasterScore* score,
const io::path& path,
const std::shared_ptr<INotationReader>& reader) const
{
QFileInfo fi(io::pathToQString(path));
score->setName(fi.completeBaseName());
score->setImportedFilePath(fi.filePath());
score->setMetaTag("originalFormat", fi.suffix().toLower());
bool ok = reader->read(score, path);
if (!ok) {
return false;
}
score->connectTies();
for (Part* p : score->parts()) {
p->updateHarmonyChannels(false);
}
score->rebuildMidiMapping();
score->setSoloMute();
for (Score* s : score->scoreList()) {
s->setPlaylistDirty();
s->addLayoutFlags(LayoutFlag::FIX_PITCH_VELO);
s->setLayoutAll();
}
score->updateChannel();
//score->updateExpressive(MuseScore::synthesizer("Fluid"));
score->setSaved(false);
score->update();
if (!score->sanityCheck(QString())) {
return false; //Score::FileError::FILE_CORRUPTED;
}
return true;
}
mu::io::path Notation::path() const
{
if (!m_score) {
return io::path();
}
return io::pathFromQString(m_score->fileInfo()->canonicalFilePath());
}
void Notation::setViewSize(const QSizeF& vs)
{
m_viewSize = vs;

View file

@ -22,6 +22,9 @@
#include "../inotation.h"
#include "async/asyncable.h"
#include "modularity/ioc.h"
#include "../inotationreadersregister.h"
#include "igetscore.h"
namespace Ms {
@ -35,6 +38,8 @@ namespace notation {
class NotationInteraction;
class Notation : public INotation, public IGetScore, public async::Asyncable
{
INJECT(notation, INotationReadersRegister, readers)
public:
Notation();
~Notation();
@ -42,7 +47,10 @@ public:
//! NOTE Needed at the moment to initialize libmscore
static void init();
bool load(const std::string& path) override;
bool load(const io::path& path) override;
bool load(const io::path& path, const std::shared_ptr<INotationReader>& reader) override;
io::path path() const override;
void setViewSize(const QSizeF& vs) override;
void paint(QPainter* p, const QRect& r) override;
@ -60,6 +68,7 @@ private:
friend class NotationInteraction;
bool doLoadScore(Ms::MasterScore* score,const io::path& path,const std::shared_ptr<INotationReader>& reader) const;
void notifyAboutNotationChanged();
QSizeF m_viewSize;

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "notationreadersregister.h"
using namespace mu::domain::notation;
void NotationReadersRegister::reg(const std::vector<std::string>& syffixs, std::shared_ptr<INotationReader> reader)
{
for (const std::string& s : syffixs) {
m_readers.insert({ s, reader });
}
}
std::shared_ptr<INotationReader> NotationReadersRegister::reader(const std::string& syffix)
{
auto it = m_readers.find(syffix);
if (it != m_readers.end()) {
return it->second;
}
return nullptr;
}

View file

@ -0,0 +1,43 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_DOMAIN_NOTATIONREADERSREGISTER_H
#define MU_DOMAIN_NOTATIONREADERSREGISTER_H
#include <map>
#include "../inotationreadersregister.h"
namespace mu {
namespace domain {
namespace notation {
class NotationReadersRegister : public INotationReadersRegister
{
public:
void reg(const std::vector<std::string>& syffixs, std::shared_ptr<INotationReader> reader) override;
std::shared_ptr<INotationReader> reader(const std::string& syffix) override;
private:
std::map<std::string, std::shared_ptr<INotationReader> > m_readers;
};
}
}
}
#endif // MU_DOMAIN_NOTATIONREADERSREGISTER_H

View file

@ -26,6 +26,8 @@
#include "actions/iactionsregister.h"
#include "internal/notationactions.h"
#include "internal/notationreadersregister.h"
#include "internal/mscznotationreader.h"
using namespace mu::domain::notation;
@ -41,6 +43,10 @@ void NotationDomainModule::registerExports()
{
framework::ioc()->registerExport<INotationCreator>(moduleName(), new NotationCreator());
framework::ioc()->registerExport<INotationConfiguration>(moduleName(), m_configuration);
std::shared_ptr<INotationReadersRegister> readers = std::make_shared<NotationReadersRegister>();
readers->reg({ "mscz", "mscx" }, std::make_shared<MsczNotationReader>());
framework::ioc()->registerExport<INotationReadersRegister>(moduleName(), readers);
}
void NotationDomainModule::resolveImports()

View file

@ -18,6 +18,7 @@
//=============================================================================
#include "openscorecontroller.h"
#include <QObject>
#include "log.h"
using namespace mu::scores;
@ -30,8 +31,44 @@ void OpenScoreController::init()
void OpenScoreController::openScore()
{
QString filePath = interactive()->selectOpeningFile("Score", "", "");
if (filePath.isEmpty()) {
QStringList filter;
filter << QObject::tr("MuseScore Files") + " (*.mscz *.mscx)";
doOpenScore(filter);
}
void OpenScoreController::importScore()
{
QString allExt = "*.mscz *.mscx *.mxl *.musicxml *.xml *.mid *.midi *.kar *.md *.mgu *.sgu *.cap *.capx"
"*.ove *.scw *.bmw *.bww *.gtp *.gp3 *.gp4 *.gp5 *.gpx *.gp *.ptb *.mscz, *.mscx,";
QStringList filter;
filter << QObject::tr("All Supported Files") + " (" + allExt + ")"
<< QObject::tr("MuseScore Files") + " (*.mscz *.mscx)"
<< QObject::tr("MusicXML Files") + " (*.mxl *.musicxml *.xml)"
<< QObject::tr("MIDI Files") + " (*.mid *.midi *.kar)"
<< QObject::tr("MuseData Files") + " (*.md)"
<< QObject::tr("Capella Files") + " (*.cap *.capx)"
<< QObject::tr("BB Files (experimental)") + " (*.mgu *.sgu)"
<< QObject::tr("Overture / Score Writer Files (experimental)") + " (*.ove *.scw)"
<< QObject::tr("Bagpipe Music Writer Files (experimental)") + " (*.bmw *.bww)"
<< QObject::tr("Guitar Pro Files") + " (*.gtp *.gp3 *.gp4 *.gp5 *.gpx *.gp)"
<< QObject::tr("Power Tab Editor Files (experimental)") + " (*.ptb)"
<< QObject::tr("MuseScore Backup Files") + " (*.mscz, *.mscx,)";
doOpenScore(filter);
}
void OpenScoreController::doOpenScore(const QStringList& filter)
{
std::string filterStr = filter.join(";;").toStdString();
io::path filePath = interactive()->selectOpeningFile("Score", "", filterStr);
if (filePath.empty()) {
return;
}
if (globalContext()->isContainsNotation(filePath)) {
LOGI() << "already loaded score: " << filePath;
return;
}
@ -40,22 +77,13 @@ void OpenScoreController::openScore()
return;
}
bool ok = notation->load(filePath.toStdString());
bool ok = notation->load(filePath);
if (!ok) {
LOGE() << "failed load: " << filePath;
//! TODO Show dialog about error
return;
}
m_openedNotations.push_back(notation);
globalContext()->addNotation(notation);
globalContext()->setCurrentNotation(notation);
}
void OpenScoreController::importScore()
{
QString filePath = interactive()->selectOpeningFile("Score", "", "");
if (filePath.isEmpty()) {
return;
}
}

View file

@ -48,7 +48,7 @@ public:
private:
std::vector<std::shared_ptr<domain::notation::INotation> > m_openedNotations;
void doOpenScore(const QStringList& filter);
};
}
}