MuseScore  3.4
Music composition and notation
score.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2019 Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __PLUGIN_API_SCORE_H__
14 #define __PLUGIN_API_SCORE_H__
15 
16 #include "scoreelement.h"
17 #include "part.h"
18 #include "excerpt.h"
19 #include "libmscore/score.h"
20 
21 namespace Ms {
22 namespace PluginAPI {
23 
24 class Cursor;
25 class Segment;
26 class Measure;
27 class Selection;
28 class Score;
29 
30 extern Selection* selectionWrap(Ms::Selection* select);
31 
32 //---------------------------------------------------------
33 // Score
34 //---------------------------------------------------------
35 
37  Q_OBJECT
39  Q_PROPERTY(QString composer READ composer)
41  Q_PROPERTY(int duration READ duration)
43  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Excerpt> excerpts READ excerpts)
49  Q_PROPERTY(int harmonyCount READ harmonyCount)
51  Q_PROPERTY(bool hasHarmonies READ hasHarmonies)
53  Q_PROPERTY(bool hasLyrics READ hasLyrics)
56  Q_PROPERTY(int keysig READ keysig)
62  Q_PROPERTY(Ms::PluginAPI::Segment* lastSegment READ lastSegment) // TODO: make it function? Was property in 2.X, but firstSegment is a function...
64  Q_PROPERTY(int lyricCount READ lyricCount)
66  Q_PROPERTY(QString scoreName READ name WRITE setName)
68  Q_PROPERTY(int nmeasures READ nmeasures)
70  Q_PROPERTY(int npages READ npages)
72  Q_PROPERTY(int nstaves READ nstaves)
74  Q_PROPERTY(int ntracks READ ntracks)
75 // Q_PROPERTY(Ms::PageFormat* pageFormat READ pageFormat WRITE undoChangePageFormat)
77  Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Part> parts READ parts)
79  Q_PROPERTY(QString lyricist READ lyricist)
80 // Q_PROPERTY(QString subtitle READ subtitle)
82  Q_PROPERTY(QString title READ title)
84  Q_PROPERTY(QString mscoreVersion READ mscoreVersion)
86  Q_PROPERTY(QString mscoreRevision READ mscoreRevision)
89 
90  public:
92  Score(Ms::Score* s = nullptr, Ownership o = Ownership::SCORE)
93  : ScoreElement(s, o) {}
94 
95  Ms::Score* score() { return toScore(e); }
96  const Ms::Score* score() const { return toScore(e); }
97 
98  QString composer() { return score()->metaTag("composer"); }
99  int duration() { return score()->duration(); }
100  int harmonyCount() { return score()->harmonyCount(); }
101  bool hasHarmonies() { return score()->hasHarmonies(); }
102  bool hasLyrics() { return score()->hasLyrics(); }
103  int keysig() { return score()->keysig(); }
104  int lyricCount() { return score()->lyricCount(); }
105  QString lyricist() { return score()->metaTag("lyricist"); } // not the meanwhile obsolete "poet"
106  QString title() { return score()->metaTag("workTitle"); }
108 
110 
112  Q_INVOKABLE QString metaTag(const QString& tag) const { return score()->metaTag(tag); }
114  Q_INVOKABLE void setMetaTag(const QString& tag, const QString& val) { score()->setMetaTag(tag, val); }
115 
116 // //@ appends to the score a named part as last part
117 // Q_INVOKABLE void appendPart(const QString&);
119  Q_INVOKABLE void appendMeasures(int n) { score()->appendMeasures(n); }
120  Q_INVOKABLE void addText(const QString& type, const QString& text);
122  Q_INVOKABLE Ms::PluginAPI::Cursor* newCursor();
123 
124  Q_INVOKABLE Ms::PluginAPI::Segment* firstSegment(); // TODO: segment type
126  Segment* lastSegment();
127 
130  Measure* lastMeasure();
132 
133  QString name() const { return score()->masterScore()->title(); }
134  void setName(const QString& name) { score()->masterScore()->setName(name); }
136 
137  Q_INVOKABLE QString extractLyrics() { return score()->extractLyrics(); }
138 
139 // //@ ??
140 // Q_INVOKABLE void updateRepeatList(bool expandRepeats) { score()->updateRepeatList(); } // TODO: needed?
141 
143  int nmeasures() const { return score()->nmeasures(); }
144  int npages() const { return score()->npages(); }
145  int nstaves() const { return score()->nstaves(); }
146  int ntracks() const { return score()->ntracks(); }
148 
157  Q_INVOKABLE void startCmd();
167  Q_INVOKABLE void endCmd(bool rollback = false) { score()->endCmd(rollback); }
168 
176  Q_INVOKABLE void createPlayEvents() { score()->createPlayEvents(); }
177 
179  QString mscoreVersion() { return score()->mscoreVersion(); }
180  QString mscoreRevision() { return QString::number(score()->mscoreRevision(), /* base */ 16); }
181 
182  QQmlListProperty<Part> parts() { return wrapContainerProperty<Part>(this, score()->parts()); }
183  QQmlListProperty<Excerpt> excerpts() { return wrapExcerptsContainerProperty<Excerpt>(this, score()->excerpts()); }
185  };
186 } // namespace PluginAPI
187 } // namespace Ms
188 #endif
virtual int npages() const
Definition: score.h:976
bool hasLyrics()
Definition: score.h:102
Q_INVOKABLE QString metaTag(const QString &tag) const
Returns as a string the metatag named tag.
Definition: score.h:112
Definition: elements.h:631
Measure * lastMeasureMM()
int npages() const
Definition: score.h:144
Definition: select.h:136
Base class for most of object wrappers exposed to QML.
Definition: scoreelement.h:42
QQmlListProperty< Excerpt > excerpts()
Definition: score.h:183
void appendMeasures(int)
Definition: score.cpp:3723
Definition: selection.h:28
Definition: elements.h:565
Definition of Score class.
int nmeasures() const
Definition: score.cpp:3945
int lyricCount()
Definition: score.h:104
QString extractLyrics()
Definition: score.cpp:4025
Selection * selectionWrap(Ms::Selection *select)
Definition: selection.cpp:23
QString mscoreVersion()
Definition: score.h:179
int harmonyCount()
Definition: score.h:100
Definition: part.h:26
void setMetaTag(const QString &tag, const QString &val)
Definition: score.cpp:1967
const Ms::Score * score() const
Definition: score.h:96
int ntracks() const
Definition: score.h:146
QQmlListProperty< Part > parts()
Definition: score.h:182
int nmeasures() const
Definition: score.h:143
Ms::ScoreElement *const e
Definition: scoreelement.h:60
Definition: excerpt.h:35
void endCmd(bool rollback=false)
End a GUI command by (if undo) ending a user-visble undo and (always) updating the redraw area...
Definition: cmd.cpp:247
void setName(const QString &)
Definition: score.cpp:4583
int keysig()
Definition: score.cpp:4104
Q_INVOKABLE void startCmd()
For "dock" type plugins: to be used before score modifications to make them undoable.
Definition: score.cpp:128
Definition: score.h:391
bool hasHarmonies()
Definition: score.cpp:3974
Q_INVOKABLE void createPlayEvents()
Create PlayEvents for all notes based on ornamentation.
Definition: score.h:176
int ntracks() const
Definition: score.h:638
Cursor can be used by plugins to manipulate the score.
Definition: cursor.h:43
MasterScore * masterScore() const
Definition: score.h:1039
Ownership
Definition: scoreelement.h:32
Ms::PluginAPI::Selection * selection()
Definition: score.h:107
Definition: score.h:36
Q_INVOKABLE void addText(const QString &type, const QString &text)
Adds a header text to the score.
Definition: score.cpp:48
Q_INVOKABLE void endCmd(bool rollback=false)
For "dock" type plugins: to be used after score modifications to make them undoable.
Definition: score.h:167
virtual QString title() const override
Definition: score.cpp:4596
Definition: aeolus.cpp:26
Segment * lastSegment()
QString scoreName
Name of the score, without path leading to it and extension.
Definition: score.h:66
virtual QList< Excerpt * > & excerpts()
Definition: score.h:1412
Q_INVOKABLE void setMetaTag(const QString &tag, const QString &val)
Sets the metatag named tag to val.
Definition: score.h:114
QString title()
Definition: score.h:106
int lyricCount()
Definition: score.cpp:3990
int nstaves() const
Definition: score.h:637
int harmonyCount()
Definition: score.cpp:4008
Measure * firstMeasure()
int duration()
Definition: score.h:99
QString mscoreRevision()
Definition: score.h:180
Main class of the plugins framework. Named as MuseScore in QML.
Definition: qmlpluginapi.h:54
Q_INVOKABLE QString extractLyrics()
Definition: score.h:137
Ms::Score * score()
Definition: score.h:95
bool hasHarmonies()
Definition: score.h:101
int nstaves() const
Definition: score.h:145
int duration()
Definition: score.cpp:4126
QString lyricist()
Definition: score.h:105
QString mscoreVersion() const
Definition: score.h:1059
QList< Part * > & parts()
Definition: score.h:768
QString composer()
Definition: score.h:98
int keysig()
Definition: score.h:103
void setName(const QString &name)
Definition: score.h:134
Measure * lastMeasure()
Q_INVOKABLE Ms::PluginAPI::Cursor * newCursor()
Creates and returns a cursor to be used to navigate in the score.
Definition: score.cpp:31
QString name() const
Definition: score.h:133
Q_INVOKABLE void appendMeasures(int n)
Appends a number of measures to this score.
Definition: score.h:119
Q_INVOKABLE Ms::PluginAPI::Segment * firstSegment()
Definition: score.cpp:75
QString metaTag(const QString &tag) const
Definition: score.cpp:1956
void createPlayEvents(Chord *)
Definition: rendermidi.cpp:2351
Measure * firstMeasureMM()
bool hasLyrics()
Definition: score.cpp:3957