QML api: "Select an element" needed so plugins can search

• Aug 5, 2019 - 19:34
Reported version
S5 - Suggestion
PR created

The desirability of having plugins to look for a specific thing, e.g., a certain harmonic or contrapuntal feature, or, most significantly, a word or string of lyric or text, seems self-evident.

All that is needed (as far as I can tell) is the ability to select an extant element (as does clicking single on it) exposed to QML.


"Well, ain't that special!??!" Fantastic. Do you have a merged branch with the previous stuff I can clone? Thanks so much; what an elegant solution!

The ability to select elements from plugins could certainly be useful but I believe it should be added with some caution. While preparing 3.0 release (and perhaps some time after it) we had a lot of issues related to wrong elements being somehow added to a selection, for example, some elements that may get deleted during a re-layout (Brackets for example). Such elements are better not to be added to a selection. Other elements (like Measure, Segment) cannot normally be directly added to a selection, and it is not clear what can happen if we put such an element to the selected elements list.

Unfortunately libmscore does not currently have any mechanism to determine which elements can be added to a selection and which cannot. Some information on which elements are probably safe to be selected programmatically can be found in UndoStack implementation as we try to make selection undoable in the cases when it is most necessary and safe to implement. Maybe for the time being the same set of restrictions (maybe with some exceptions like Chord type) could be applied for plugins too.

What should be probably safer to implement is allowing a range selection: it is enough just to define its boundaries and all the relevant elements will be found automatically.

So, to sum up, for now it seems to be better to an ability to select only a limited subset of elements and/or an ability to select a range of a score. Does this make sense for this feature request?

By the way, concerning the "so plugins can search" part, it should be also needed to allow plugins to adjust score view position (either by specifying a position directly or by going to a specific element), otherwise it may happen to be not easy to figure out what exactly a plugin has found.

These are reasonable reservations; the rest of "search" (e.g., position the score) is needed. The largest "search" thing I currently find missing is find text, extremely important to me because I write (to the joy of many) pamphlet/book texts in many of my scores and cannot find text I have entered. But a lot is missing for that, including QML visibility of frames, words within text, and more. Finding a particular chord or stack of notes (in a part or the score) would be great, too. I had hoped that this would be the start for experimentation, but so much more is needed (and I am studying the source). This should not be on a 3.3 timeframe, obviously.