simplify iterating with Cursor

This adds to Cursor:
property 'inSelection' is true if the current cursor position is inside the selection
property 'hasSelection' is true if there is a selection

    while(cursor.inSelection) { ... cursor.next(); }

will iterate over all segments of current track in the selection

function 'iterate(type)' resets the cursor to start of score (type==false) or selection (type==true)
function 'iterating()' remains true while there are still tracks/staves to be iterated
functions 'nextTrack()' and 'nextStaff()' setting the iterator to the beginning of the next track or staff. (according to type set when calling iterate).

     for (cursor.iterate(true); cursor.iterating(); cursor.nextTrack()) { ... }

will iterate over the selection track by track.

Below is a sample that iterates over all notes and grace notes of the selection or - if none - the whole score:

    import QtQuick 2.0
    import MuseScore 1.0
   
    MuseScore {
      menuPath: "Plugins.newCursorTest"

      function fn(note) {
            note.color = "#ff0000";
     }

      onRun: {
            var cursor = curScore.newCursor();
            // This iterates through the selection if there is one
            // or through the whole score if there's no selection

            // iterate tracks
            for (cursor.iterate(cursor.hasSelection); cursor.iterating(); cursor.nextTrack()) {
                  // iterate segments
                  while (cursor.segment && (cursor.inSelection || (!cursor.hasSelection))) {
                        // if there's a chord, iterate all grace notes and notes
                        if (cursor.element && cursor.element.type == Element.CHORD) {
                              var chord = cursor.element;
                              // grace notes
                              var graceChords = chord.graceNotes;
                              for (var i = 0; i < graceChords.length; i++) {
                                    var notes = graceChords[i].notes;
                                    for (var j = 0; j < notes.length; j++) {
                                          fn(notes[j]);
                                    }
                              }
                              // notes of chord
                              var notes = chord.notes;
                              for (var i = 0; i < notes.length; i++) {
                                    fn(notes[i]);
                              }
                        }
                        cursor.next();
                  }
            }

            Qt.quit()
            }
      }