File: score.h

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 218,192 kB
  • sloc: cpp: 291,369; xml: 200,226; sh: 3,779; ansic: 1,447; python: 393; makefile: 249; perl: 82; pascal: 79
file content (179 lines) | stat: -rw-r--r-- 9,156 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//=============================================================================
//  MuseScore
//  Music Composition & Notation
//
//  Copyright (C) 2019 Werner Schweer 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
//  as published by the Free Software Foundation and appearing in
//  the file LICENCE.GPL
//=============================================================================

#ifndef __PLUGIN_API_SCORE_H__
#define __PLUGIN_API_SCORE_H__

#include "scoreelement.h"
#include "part.h"
#include "excerpt.h"
#include "libmscore/score.h"

namespace Ms {
namespace PluginAPI {

class Cursor;
class Segment;
class Measure;
class Selection;
class Score;

extern Selection* selectionWrap(Ms::Selection* select);

//---------------------------------------------------------
//   Score
//---------------------------------------------------------

class Score : public Ms::PluginAPI::ScoreElement {
      Q_OBJECT
      /** Composer of the score, as taken from the score properties (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(QString                        composer          READ composer)
      /** Duration of score in seconds (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(int                            duration          READ duration)
      /** List of the excerpts (linked parts) (read only) */
      Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Excerpt>  excerpts   READ excerpts)
      /** First measure of the score (read only) */
      Q_PROPERTY(Ms::PluginAPI::Measure*        firstMeasure      READ firstMeasure)
      /** First multimeasure rest measure of the score (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(Ms::PluginAPI::Measure*        firstMeasureMM    READ firstMeasureMM)
      /** Number of harmony items (chord symbols) in the score (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(int                            harmonyCount      READ harmonyCount)
      /** Whether score has harmonies (chord symbols) (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(bool                           hasHarmonies      READ hasHarmonies)
      /** Whether score has lyrics (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(bool                           hasLyrics         READ hasLyrics)
      /// Key signature at the start of the score, in number of accidentals,
      /// negative for flats, postitive for sharps (read only).\n \since MuseScore 3.2
      Q_PROPERTY(int                            keysig            READ keysig)
      /** Last measure of the score (read only) */
      Q_PROPERTY(Ms::PluginAPI::Measure*        lastMeasure       READ lastMeasure)
      /** Last multimeasure rest measure of the score (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(Ms::PluginAPI::Measure*        lastMeasureMM     READ lastMeasureMM)
      /** Last score segment (read only) */
      Q_PROPERTY(Ms::PluginAPI::Segment*        lastSegment       READ lastSegment) // TODO: make it function? Was property in 2.X, but firstSegment is a function...
      /** Number of lyrics items (syllables) in the score (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(int                            lyricCount        READ lyricCount)
      /** Name of the score, without path leading to it and extension.\n \since MuseScore 3.2 */
      Q_PROPERTY(QString                        scoreName         READ name           WRITE setName)
      /** Number of measures (read only) */
      Q_PROPERTY(int                            nmeasures         READ nmeasures)
      /** Number of pages (read only) */
      Q_PROPERTY(int                            npages            READ npages)
      /** Number of staves (read only) */
      Q_PROPERTY(int                            nstaves           READ nstaves)
      /** Number of tracks (#nstaves * 4) (read only) */
      Q_PROPERTY(int                            ntracks           READ ntracks)
//      Q_PROPERTY(Ms::PageFormat*                pageFormat        READ pageFormat     WRITE undoChangePageFormat)
      /** The list of parts */
      Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Part>     parts      READ parts)
      /** Lyricist of score, as taken from the score properties.\n \since MuseScore 3.2 */
      Q_PROPERTY(QString                        lyricist              READ lyricist)
//      Q_PROPERTY(QString                        subtitle          READ subtitle)
      /** Title of score, as taken from the score properties' workTitle (read only).\n \since MuseScore 3.2 */
      Q_PROPERTY(QString                        title             READ title)
      /** MuseScore version the score has been last saved with (includes autosave) (read only) */
      Q_PROPERTY(QString                        mscoreVersion     READ mscoreVersion)
      /** MuseScore revision the score has been last saved with (includes autosave) (read only) */
      Q_PROPERTY(QString                        mscoreRevision    READ mscoreRevision)
      /** Current selections for the score. \since MuseScore 3.3 */
      Q_PROPERTY(Ms::PluginAPI::Selection*      selection         READ selection)

   public:
      /// \cond MS_INTERNAL
      Score(Ms::Score* s = nullptr, Ownership o = Ownership::SCORE)
         : ScoreElement(s, o) {}

      Ms::Score* score() { return toScore(e); }
      const Ms::Score* score() const { return toScore(e); }

      QString composer() { return score()->metaTag("composer"); }
      int duration() { return score()->duration(); }
      int harmonyCount() { return score()->harmonyCount(); }
      bool hasHarmonies() { return score()->hasHarmonies(); }
      bool hasLyrics() { return score()->hasLyrics(); }
      int keysig() { return score()->keysig(); }
      int lyricCount() { return score()->lyricCount(); }
      QString lyricist() { return score()->metaTag("lyricist"); } // not the meanwhile obsolete "poet"
      QString title() { return score()->metaTag("workTitle"); }
      Ms::PluginAPI::Selection* selection() { return selectionWrap(&score()->selection()); }

      /// \endcond

      /// Returns as a string the metatag named \p tag
      Q_INVOKABLE QString metaTag(const QString& tag) const { return score()->metaTag(tag); }
      /// Sets the metatag named \p tag to \p val
      Q_INVOKABLE void setMetaTag(const QString& tag, const QString& val) { score()->setMetaTag(tag, val); }

//      //@ appends to the score a named part as last part
//      Q_INVOKABLE void appendPart(const QString&);
      /// Appends a number of measures to this score.
      Q_INVOKABLE void appendMeasures(int n) { score()->appendMeasures(n); }
      Q_INVOKABLE void addText(const QString& type, const QString& text);
      /// Creates and returns a cursor to be used to navigate in the score
      Q_INVOKABLE Ms::PluginAPI::Cursor* newCursor();

      Q_INVOKABLE Ms::PluginAPI::Segment* firstSegment(); // TODO: segment type
      /// \cond MS_INTERNAL
      Segment* lastSegment();

      Measure* firstMeasure();
      Measure* firstMeasureMM();
      Measure* lastMeasure();
      Measure* lastMeasureMM();

      QString name() const { return score()->masterScore()->title(); }
      void setName(const QString& name) { score()->masterScore()->setName(name); }
      /// \endcond

      Q_INVOKABLE QString extractLyrics() { return score()->extractLyrics(); }

//      //@ ??
//      Q_INVOKABLE void updateRepeatList(bool expandRepeats) { score()->updateRepeatList(); } // TODO: needed?

      /// \cond MS_INTERNAL
      int nmeasures() const { return score()->nmeasures(); }
      int npages() const { return score()->npages(); }
      int nstaves() const { return score()->nstaves(); }
      int ntracks() const { return score()->ntracks(); }
      /// \endcond

      /**
       * For "dock" type plugins: to be used before score
       * modifications to make them undoable.
       * Starts an undoable command. Must be accompanied by
       * a corresponding endCmd() call. Should be used at
       * least once by "dock" type plugins in case they
       * modify the score.
       */
      Q_INVOKABLE void startCmd() { score()->startCmd(); }
      /**
       * For "dock" type plugins: to be used after score
       * modifications to make them undoable.
       * Ends an undoable command. Should be used at least
       * once by "dock" type plugins in case they modify
       * the score.
       * \param rollback If true, reverts all the changes
       * made since the last startCmd() invocation.
       */
      Q_INVOKABLE void endCmd(bool rollback = false) { score()->endCmd(rollback); }

      /// \cond MS_INTERNAL
      QString mscoreVersion() { return score()->mscoreVersion(); }
      QString mscoreRevision() { return QString::number(score()->mscoreRevision(), /* base */ 16); }

      QQmlListProperty<Part> parts() { return wrapContainerProperty<Part>(this, score()->parts());   }
      QQmlListProperty<Excerpt> excerpts() { return wrapExcerptsContainerProperty<Excerpt>(this, score()->excerpts());   }
      /// \endcond
      };
} // namespace PluginAPI
} // namespace Ms
#endif