diff options
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/muse/functions.cpp | 21 | ||||
-rw-r--r-- | muse2/muse/functions.h | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 36 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.h | 28 | ||||
-rw-r--r-- | muse2/muse/midieditor.cpp | 10 | ||||
-rw-r--r-- | muse2/muse/midieditor.h | 2 | ||||
-rw-r--r-- | muse2/muse/part.cpp | 4 | ||||
-rw-r--r-- | muse2/muse/part.h | 2 | ||||
-rw-r--r-- | muse2/muse/song.cpp | 8 | ||||
-rw-r--r-- | muse2/muse/song.h | 6 | ||||
-rw-r--r-- | muse2/muse/steprec.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/steprec.h | 2 |
12 files changed, 62 insertions, 61 deletions
diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp index 7d5547cb..380d9718 100644 --- a/muse2/muse/functions.cpp +++ b/muse2/muse/functions.cpp @@ -926,7 +926,7 @@ unsigned get_clipboard_len() return get_groupedevents_len(s); } -bool paste_notes(Part* paste_into_part) +bool paste_notes(const Part* paste_into_part) { unsigned temp_begin = AL::sigmap.raster1(MusEGlobal::song->cpos(),0); unsigned temp_end = AL::sigmap.raster2(temp_begin + get_clipboard_len(), 0); @@ -943,7 +943,7 @@ bool paste_notes(Part* paste_into_part) return true; } -void paste_notes(int max_distance, bool always_new_part, bool never_new_part, Part* paste_into_part, int amount, int raster) +void paste_notes(int max_distance, bool always_new_part, bool never_new_part, const Part* paste_into_part, int amount, int raster) { QString tmp="x-muse-groupedeventlists"; // QClipboard::text() expects a QString&, not a QString :( QString s = QApplication::clipboard()->text(tmp, QClipboard::Clipboard); // TODO CHECK Tim. @@ -1102,11 +1102,11 @@ bool read_eventlist_and_part(Xml& xml, EventList* el, int* part_id) // true on s } } -void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part, bool never_new_part, Part* paste_into_part, int amount, int raster) +void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part, bool never_new_part, const Part* paste_into_part, int amount, int raster) { Undo operations; - map<Part*, unsigned> expand_map; - map<Part*, set<Part*> > new_part_map; + map<const Part*, unsigned> expand_map; + map<const Part*, set<const Part*> > new_part_map; QByteArray pt_= pt.toLatin1(); Xml xml(pt_.constData()); @@ -1128,9 +1128,9 @@ void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part if (read_eventlist_and_part(xml, &el, &part_id)) { - Part* dest_part; + const Part* dest_part; Track* dest_track; - Part* old_dest_part; + const Part* old_dest_part; if (paste_into_part == NULL) dest_part = partFromSerialNumber(part_id); @@ -1157,11 +1157,12 @@ void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part if (create_new_part) { - dest_part = dest_track->newPart(); - dest_part->setTick(AL::sigmap.raster1(first_paste_tick, config.division)); + Part* newpart = dest_track->newPart(); + newpart->setTick(AL::sigmap.raster1(first_paste_tick, config.division)); new_part_map[old_dest_part].insert(dest_part); operations.push_back(UndoOp(UndoOp::AddPart, dest_part)); + dest_part = newpart; } for (iEvent i = el.begin(); i != el.end(); ++i) @@ -1216,7 +1217,7 @@ void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part out_of_paste_at_for: - for (map<Part*, unsigned>::iterator it = expand_map.begin(); it!=expand_map.end(); it++) + for (map<const Part*, unsigned>::iterator it = expand_map.begin(); it!=expand_map.end(); it++) if (it->second != it->first->lenTick()) schedule_resize_all_same_len_clone_parts(it->first, it->second, operations); diff --git a/muse2/muse/functions.h b/muse2/muse/functions.h index b746470c..9493caf7 100644 --- a/muse2/muse/functions.h +++ b/muse2/muse/functions.h @@ -40,7 +40,7 @@ namespace MusECore { class Undo; std::set<const Part*> partlist_to_set(PartList* pl); -std::set<const Part*> part_to_set(Part* p); +std::set<const Part*> part_to_set(const Part* p); std::map<const Event*, const Part*> get_events(const std::set<const Part*>& parts, int range); //these functions simply do their job, non-interactively diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 96fcc5a5..a827e33c 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -520,7 +520,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) selection_changed(); connect(MusEGlobal::song, SIGNAL(songChanged(MusECore::SongChangedFlags_t)), SLOT(song_changed(MusECore::SongChangedFlags_t))); - connect(MusEGlobal::song, SIGNAL(newPartsCreated(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&)), score_canvas, SLOT(add_new_parts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&))); + connect(MusEGlobal::song, SIGNAL(newPartsCreated(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&)), score_canvas, SLOT(add_new_parts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&))); score_canvas->fully_recalculate(); score_canvas->goto_tick(initPos,true); @@ -898,7 +898,7 @@ void staff_t::write_status(int level, MusECore::Xml& xml) const xml.tag(level++, "staff"); xml.intTag(level, "type", type); xml.intTag(level, "clef", clef); - for (set<MusECore::Part*>::iterator part=parts.begin(); part!=parts.end(); part++) + for (set<const MusECore::Part*>::iterator part=parts.begin(); part!=parts.end(); part++) { MusECore::Track* track = (*part)->track(); int trkIdx = MusEGlobal::song->tracks()->index(track); @@ -963,7 +963,7 @@ void ScoreEdit::writeStatus(int level, MusECore::Xml& xml) const xml.intTag(level, "preambleContainsKeysig", preamble_keysig_action->isChecked()); xml.intTag(level, "preambleContainsTimesig", preamble_timesig_action->isChecked()); - MusECore::Part* selected_part=score_canvas->get_selected_part(); + const MusECore::Part* selected_part=score_canvas->get_selected_part(); if (selected_part==NULL) { xml.put(level, "<selectedPart>none</selectedPart>"); @@ -1785,9 +1785,9 @@ void staff_t::create_appropriate_eventlist() // phase one: fill the list ----------------------------------------- //insert note on events - for (set<MusECore::Part*>::const_iterator part_it=parts.begin(); part_it!=parts.end(); part_it++) + for (set<const MusECore::Part*>::const_iterator part_it=parts.begin(); part_it!=parts.end(); part_it++) { - MusECore::Part* part=*part_it; + const MusECore::Part* part=*part_it; for (MusECore::ciEvent it=part->events().begin(); it!=part->events().end(); it++) { @@ -3804,7 +3804,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) if ((mouse_erases_notes) || (event->button()==Qt::MidButton)) //erase? { - MusEGlobal::audio->msgDeleteEvent(dragged_event, dragged_event_part, true, false, false); + MusEGlobal::song->applyOperation(UndoOp(UndoOp::DeleteEvent,dragged_event, dragged_event_part, false, false)); } else if (event->button()==Qt::LeftButton) //edit? { @@ -3818,8 +3818,8 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) { if (mouse_inserts_notes) { - MusECore::Part* curr_part = NULL; - set<MusECore::Part*> possible_dests=staff_it->parts_at_tick(tick); + const MusECore::Part* curr_part = NULL; + set<const MusECore::Part*> possible_dests=staff_it->parts_at_tick(tick); if (!possible_dests.empty()) { @@ -3866,7 +3866,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) newevent.setLenTick(curr_part->lenTick() - newevent.tick()); } - MusEGlobal::audio->msgAddEvent(newevent, curr_part, true, false, false); + MusEGlobal::song->applyOperation(UndoOp(UndoOp::AddEvent, newevent, curr_part,false, false)); set_dragged_event_part(curr_part); dragged_event=newevent; @@ -3913,7 +3913,7 @@ void ScoreCanvas::mouseReleaseEvent (QMouseEvent* event) { if (debugMsg) cout << "new length <= 0, erasing item" << endl; if (undo_started) MusEGlobal::song->undo(); - MusEGlobal::audio->msgDeleteEvent(dragged_event, dragged_event_part, true, false, false); + MusEGlobal::song->applyOperation(UndoOp(UndoOp::DeleteEvent,dragged_event, dragged_event_part, false, false)); } else { @@ -4512,7 +4512,7 @@ bool staff_t::cleanup_parts() { bool did_something=false; - for (set<MusECore::Part*>::iterator it=parts.begin(); it!=parts.end();) + for (set<const MusECore::Part*>::iterator it=parts.begin(); it!=parts.end();) { bool valid=false; @@ -4543,11 +4543,11 @@ bool staff_t::cleanup_parts() return did_something; } -set<MusECore::Part*> staff_t::parts_at_tick(unsigned tick) +set<const MusECore::Part*> staff_t::parts_at_tick(unsigned tick) { - set<MusECore::Part*> result; + set<const MusECore::Part*> result; - for (set<MusECore::Part*>::iterator it=parts.begin(); it!=parts.end(); it++) + for (set<const MusECore::Part*>::iterator it=parts.begin(); it!=parts.end(); it++) if ((tick >= (*it)->tick()) && (tick<=(*it)->endTick())) result.insert(*it); @@ -4611,7 +4611,7 @@ void staff_t::update_part_indices() { part_indices.clear(); - for (set<MusECore::Part*>::iterator it=parts.begin(); it!=parts.end(); it++) + for (set<const MusECore::Part*>::iterator it=parts.begin(); it!=parts.end(); it++) part_indices.insert((*it)->sn()); } @@ -4648,15 +4648,15 @@ void ScoreEdit::keyPressEvent(QKeyEvent* event) } -void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >& param) +void ScoreCanvas::add_new_parts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >& param) { for (list<staff_t>::iterator staff=staves.begin(); staff!=staves.end(); staff++) { - for (std::map< MusECore::Part*, set<MusECore::Part*> >::const_iterator it = param.begin(); it!=param.end(); it++) + for (std::map< const MusECore::Part*, set<const MusECore::Part*> >::const_iterator it = param.begin(); it!=param.end(); it++) if (staff->parts.find(it->first)!=staff->parts.end()) staff->parts.insert(it->second.begin(), it->second.end()); - //staff->cleanup_parts(); // don't cleanup here, because at this point, the parts may only exist + //staff->cleanup_parts(); // don't cleanup here, because at this point, the parts might exist only // in the operation group. cleanup could remove them immediately staff->update_part_indices(); } diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index 2175e1d1..31bc0cff 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -257,7 +257,7 @@ class FloEvent enum typeEnum { NOTE_ON = 30, NOTE_OFF = 10, BAR = 20, KEY_CHANGE=23, TIME_SIG=26 }; //the order matters! typeEnum type; unsigned tick; - MusECore::Part* source_part; + const MusECore::Part* source_part; const MusECore::Event* source_event; int pitch; @@ -270,7 +270,7 @@ class FloEvent MusECore::key_enum key; - FloEvent(unsigned ti, int p,int v,int l,typeEnum t, MusECore::Part* part=NULL, const MusECore::Event* event=NULL) + FloEvent(unsigned ti, int p,int v,int l,typeEnum t, const MusECore::Part* part=NULL, const MusECore::Event* event=NULL) { pitch=p; vel=v; @@ -313,7 +313,7 @@ class FloItem typeEnum type; unsigned begin_tick; const MusECore::Event* source_event; - MusECore::Part* source_part; + const MusECore::Part* source_part; note_pos_t pos; int len; @@ -343,7 +343,7 @@ class FloItem - FloItem(typeEnum t, note_pos_t p, int l=0,int d=0, bool ti=false, unsigned beg=0, MusECore::Part* part=NULL, const MusECore::Event* event=NULL) + FloItem(typeEnum t, note_pos_t p, int l=0,int d=0, bool ti=false, unsigned beg=0, const MusECore::Part* part=NULL, const MusECore::Event* event=NULL) { pos=p; dots=d; @@ -546,7 +546,7 @@ enum staff_mode_t struct staff_t { - set<MusECore::Part*> parts; + set<const MusECore::Part*> parts; set<int> part_indices; ScoreEventList eventlist; ScoreItemList itemlist; @@ -585,7 +585,7 @@ struct staff_t parent=parent_; } - staff_t (ScoreCanvas* parent_, staff_type_t type_, clef_t clef_, set<MusECore::Part*> parts_) + staff_t (ScoreCanvas* parent_, staff_type_t type_, clef_t clef_, set<const MusECore::Part*> parts_) { type=type_; clef=clef_; @@ -596,7 +596,7 @@ struct staff_t bool cleanup_parts(); - set<MusECore::Part*> parts_at_tick(unsigned tick); + set<const MusECore::Part*> parts_at_tick(unsigned tick); void read_status(MusECore::Xml& xml); void write_status(int level, MusECore::Xml& xml) const; @@ -718,7 +718,7 @@ class ScoreCanvas : public MusEGui::View float y_scroll_speed; float y_scroll_pos; - MusECore::Part* selected_part; + const MusECore::Part* selected_part; int selected_part_index; int last_len; @@ -742,7 +742,7 @@ class ScoreCanvas : public MusEGui::View bool inserting; bool dragging; bool drag_cursor_changed; - MusECore::Part* dragged_event_part; + const MusECore::Part* dragged_event_part; int dragged_event_part_index; MusECore::Event dragged_event; MusECore::Event original_dragged_event; @@ -790,7 +790,7 @@ class ScoreCanvas : public MusEGui::View void deselect_all(); void midi_note(int pitch, int velo); - void add_new_parts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&); + void add_new_parts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&); public slots: void x_scroll_event(int); @@ -855,10 +855,10 @@ class ScoreCanvas : public MusEGui::View int get_last_len() {return last_len;} void set_last_len(int l) {last_len=l;} - MusECore::Part* get_selected_part() {return selected_part;} - void set_selected_part(MusECore::Part* p) {selected_part=p; if (selected_part) selected_part_index=selected_part->sn();} - MusECore::Part* get_dragged_event_part() {return dragged_event_part;} - void set_dragged_event_part(MusECore::Part* p) {dragged_event_part=p; if (dragged_event_part) dragged_event_part_index=dragged_event_part->sn();} + const MusECore::Part* get_selected_part() const {return selected_part;} + void set_selected_part(const MusECore::Part* p) {selected_part=p; if (selected_part) selected_part_index=selected_part->sn();} + const MusECore::Part* get_dragged_event_part() const {return dragged_event_part;} + void set_dragged_event_part(const MusECore::Part* p) {dragged_event_part=p; if (dragged_event_part) dragged_event_part_index=dragged_event_part->sn();} set<const MusECore::Part*> get_all_parts(); diff --git a/muse2/muse/midieditor.cpp b/muse2/muse/midieditor.cpp index 13e6edc5..a4052d90 100644 --- a/muse2/muse/midieditor.cpp +++ b/muse2/muse/midieditor.cpp @@ -62,7 +62,7 @@ MidiEditor::MidiEditor(ToplevelType t, int r, MusECore::PartList* pl, mainGrid->setSpacing(0); setCentralWidget(mainw); - connect(MusEGlobal::song, SIGNAL(newPartsCreated(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&)), SLOT(addNewParts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&))); + connect(MusEGlobal::song, SIGNAL(newPartsCreated(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&)), SLOT(addNewParts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&))); } //--------------------------------------------------------- @@ -245,15 +245,15 @@ void MidiEditor::setCurCanvasPart(MusECore::Part* part) canvas->setCurrentPart(part); } -void MidiEditor::addNewParts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >& param) +void MidiEditor::addNewParts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >& param) { using std::map; using std::set; - for (map< MusECore::Part*, set<MusECore::Part*> >::const_iterator it = param.begin(); it!=param.end(); it++) + for (map< const MusECore::Part*, set<const MusECore::Part*> >::const_iterator it = param.begin(); it!=param.end(); it++) if (_pl->index(it->first) != -1) - for (set<MusECore::Part*>::const_iterator it2=it->second.begin(); it2!=it->second.end(); it2++) - addPart(*it2); + for (set<const MusECore::Part*>::const_iterator it2=it->second.begin(); it2!=it->second.end(); it2++) + addPart(const_cast<MusECore::Part*>(*it2)); // FIXME make this const-correct! } } // namespace MusEGui diff --git a/muse2/muse/midieditor.h b/muse2/muse/midieditor.h index 900f06b1..39feeedf 100644 --- a/muse2/muse/midieditor.h +++ b/muse2/muse/midieditor.h @@ -76,7 +76,7 @@ class MidiEditor : public TopWin { void genPartlist(); private slots: - void addNewParts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&); + void addNewParts(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&); public slots: void songChanged(MusECore::SongChangedFlags_t type); diff --git a/muse2/muse/part.cpp b/muse2/muse/part.cpp index e25643c8..b6d1571a 100644 --- a/muse2/muse/part.cpp +++ b/muse2/muse/part.cpp @@ -375,10 +375,10 @@ iEvent Part::addEvent(Event& p) // index //--------------------------------------------------------- -int PartList::index(Part* part) +int PartList::index(const Part* part) const { int index = 0; - for (iPart i = begin(); i != end(); ++i, ++index) + for (ciPart i = begin(); i != end(); ++i, ++index) if (i->second == part) { return index; } diff --git a/muse2/muse/part.h b/muse2/muse/part.h index ea19410d..5523e71d 100644 --- a/muse2/muse/part.h +++ b/muse2/muse/part.h @@ -186,7 +186,7 @@ class PartList : public std::multimap<int, Part*, std::less<unsigned> > { iPart findPart(unsigned tick); iPart add(Part*); void remove(Part* part); - int index(Part*); + int index(const Part*) const; Part* find(int idx); void clearDelete() { for (iPart i = begin(); i != end(); ++i) diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index 6085b1ba..bdd24f8b 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -3520,14 +3520,14 @@ QString Song::getScriptPath(int id, bool isdelivered) return path; } -void Song::informAboutNewParts(const std::map< Part*, std::set<Part*> >& param) +void Song::informAboutNewParts(const std::map< const Part*, std::set<const Part*> >& param) { emit newPartsCreated(param); } -void Song::informAboutNewParts(Part* orig, Part* p1, Part* p2, Part* p3, Part* p4, Part* p5, Part* p6, Part* p7, Part* p8, Part* p9) +void Song::informAboutNewParts(const Part* orig, const Part* p1, const Part* p2, const Part* p3, const Part* p4, const Part* p5, const Part* p6, const Part* p7, const Part* p8, const Part* p9) { - std::map< Part*, std::set<Part*> > temp; + std::map<const Part*, std::set<const Part*> > temp; temp[orig].insert(p1); temp[orig].insert(p2); @@ -3538,7 +3538,7 @@ void Song::informAboutNewParts(Part* orig, Part* p1, Part* p2, Part* p3, Part* p temp[orig].insert(p7); temp[orig].insert(p8); temp[orig].insert(p9); - temp[orig].erase(static_cast<Part*>(NULL)); + temp[orig].erase(static_cast<const Part*>(NULL)); temp[orig].erase(orig); informAboutNewParts(temp); diff --git a/muse2/muse/song.h b/muse2/muse/song.h index 95a383cd..6410084f 100644 --- a/muse2/muse/song.h +++ b/muse2/muse/song.h @@ -179,7 +179,7 @@ class Song : public QObject { * a key in this map, the Editors shall no more edit this part, but instead * all parts in the_map[old_part] (which is a std::set<Part*>) */ - void informAboutNewParts(const std::map< Part*, std::set<Part*> >&); + void informAboutNewParts(const std::map< const Part*, std::set<const Part*> >&); /** this sends emits a signal to each MidiEditor or whoever is interested. * For each part which is 1) opened in this MidiEditor and 2) which is * a key in this map, the Editors shall no more edit this part, but instead @@ -187,7 +187,7 @@ class Song : public QObject { * this is a special case of the general function, which only replaces one part * by up to nine different. */ - void informAboutNewParts(Part* orig, Part* p1, Part* p2=NULL, Part* p3=NULL, Part* p4=NULL, Part* p5=NULL, Part* p6=NULL, Part* p7=NULL, Part* p8=NULL, Part* p9=NULL); + void informAboutNewParts(const Part* orig, const Part* p1, const Part* p2=NULL, const Part* p3=NULL, const Part* p4=NULL, const Part* p5=NULL, const Part* p6=NULL, const Part* p7=NULL, const Part* p8=NULL, const Part* p9=NULL); void putEvent(int pv); void endMsgCmd(); @@ -444,7 +444,7 @@ class Song : public QObject { void midiPortsChanged(); void midiNote(int pitch, int velo); void controllerChanged(MusECore::Track*, int); - void newPartsCreated(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&); + void newPartsCreated(const std::map< const MusECore::Part*, std::set<const MusECore::Part*> >&); void sigDirty(); }; diff --git a/muse2/muse/steprec.cpp b/muse2/muse/steprec.cpp index ab4893d0..44da5a7e 100644 --- a/muse2/muse/steprec.cpp +++ b/muse2/muse/steprec.cpp @@ -55,7 +55,7 @@ void StepRec::timeout() } } -void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ctrl, bool shift, int incoming_pitch) +void StepRec::record(const Part* part, int pitch, int len, int step, int velo, bool ctrl, bool shift, int incoming_pitch) { unsigned tick = MusEGlobal::song->cpos(); unsigned lasttick=0; diff --git a/muse2/muse/steprec.h b/muse2/muse/steprec.h index a82cab20..f99fffc4 100644 --- a/muse2/muse/steprec.h +++ b/muse2/muse/steprec.h @@ -37,7 +37,7 @@ class StepRec : public QObject public: StepRec(bool* note_held_down_array); - void record(Part* part, int recorded_pitch, int len, int step, int velo=80, bool ctrl=false, bool shift=false, int incoming_pitch=1337); + void record(const Part* part, int recorded_pitch, int len, int step, int velo=80, bool ctrl=false, bool shift=false, int incoming_pitch=1337); private slots: void timeout(); |