summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/scoreedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/muse/midiedit/scoreedit.cpp')
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 543e86aa..954cd08a 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -73,6 +73,8 @@ using namespace std;
using MusEGlobal::debugMsg;
using MusEGlobal::heavyDebugMsg;
+using MusECore::UndoOp;
+using MusECore::Undo;
namespace MusEGui {
@@ -519,7 +521,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);
@@ -653,7 +655,7 @@ void ScoreEdit::song_changed(MusECore::SongChangedFlags_t flags)
if (flags & (SC_SELECTION | SC_EVENT_MODIFIED | SC_EVENT_REMOVED))
{
- map<MusECore::Event*, MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1);
+ map<const MusECore::Event*, const MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1);
if (selection.empty())
{
apply_velo_to_label->setText(tr("Apply to new notes:"));
@@ -664,7 +666,7 @@ void ScoreEdit::song_changed(MusECore::SongChangedFlags_t flags)
int velo=-1;
int velo_off=-1;
- for (map<MusECore::Event*, MusECore::Part*>::iterator it=selection.begin(); it!=selection.end(); it++)
+ for (map<const MusECore::Event*, const MusECore::Part*>::iterator it=selection.begin(); it!=selection.end(); it++)
if (it->first->type()==MusECore::Note)
{
if (velo==-1) velo=it->first->velo();
@@ -897,7 +899,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);
@@ -962,7 +964,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>");
@@ -1520,9 +1522,9 @@ void ScoreCanvas::move_staff_below(list<staff_t>::iterator dest, list<staff_t>::
move_staff_above(dest, src);
}
-set<MusECore::Part*> ScoreCanvas::get_all_parts()
+set<const MusECore::Part*> ScoreCanvas::get_all_parts()
{
- set<MusECore::Part*> result;
+ set<const MusECore::Part*> result;
for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++)
result.insert(it->parts.begin(), it->parts.end());
@@ -1784,14 +1786,13 @@ 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;
- MusECore::EventList* el=part->events();
+ const MusECore::Part* part=*part_it;
- for (MusECore::iEvent it=el->begin(); it!=el->end(); it++)
+ for (MusECore::ciEvent it=part->events().begin(); it!=part->events().end(); it++)
{
- MusECore::Event& event=it->second;
+ const MusECore::Event& event=it->second;
if ( ( event.isNote() && !event.isNoteOff() &&
// (event.endTick() <= part->lenTick()) ) &&
@@ -3804,7 +3805,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 +3819,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 +3867,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 +3914,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
{
@@ -3928,9 +3929,7 @@ void ScoreCanvas::mouseReleaseEvent (QMouseEvent* event)
if (!ctrl)
deselect_all();
- clicked_event_ptr->setSelected(!clicked_event_ptr->selected());
-
- MusEGlobal::song->update(SC_SELECTION);
+ MusEGlobal::song->applyOperation(UndoOp(UndoOp::SelectEvent, *clicked_event_ptr, !clicked_event_ptr->selected(), clicked_event_ptr->selected()));
}
setMouseTracking(false);
@@ -3971,7 +3970,7 @@ void ScoreCanvas::mouseReleaseEvent (QMouseEvent* event)
if (!ctrl)
deselect_all();
- set<MusECore::Event*> already_processed;
+ set<const MusECore::Event*> already_processed;
for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++)
it->apply_lasso(lasso.translated(x_pos-x_left, y_pos - it->y_draw), already_processed);
@@ -4029,9 +4028,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event)
if (!ctrl)
deselect_all();
- clicked_event_ptr->setSelected(true);
-
- MusEGlobal::song->update(SC_SELECTION);
+ MusEGlobal::song->applyOperation(UndoOp(UndoOp::SelectEvent, *clicked_event_ptr, true, clicked_event_ptr->selected()));
}
old_pitch=-1;
@@ -4505,20 +4502,23 @@ void ScoreCanvas::set_velo_off(int velo)
void ScoreCanvas::deselect_all()
{
- set<MusECore::Part*> all_parts=get_all_parts();
+ set<const MusECore::Part*> all_parts=get_all_parts();
+
+ Undo operations;
+ operations.combobreaker=true;
- for (set<MusECore::Part*>::iterator part=all_parts.begin(); part!=all_parts.end(); part++)
- for (MusECore::iEvent event=(*part)->events()->begin(); event!=(*part)->events()->end(); event++)
- event->second.setSelected(false);
+ for (set<const MusECore::Part*>::iterator part=all_parts.begin(); part!=all_parts.end(); part++)
+ for (MusECore::ciEvent event=(*part)->events().begin(); event!=(*part)->events().end(); event++)
+ operations.push_back(UndoOp(UndoOp::SelectEvent, event->second, false, event->second.selected()));
- MusEGlobal::song->update(SC_SELECTION);
+ MusEGlobal::song->applyOperationGroup(operations);
}
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;
@@ -4549,18 +4549,18 @@ 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);
return result;
}
-void staff_t::apply_lasso(QRect rect, set<MusECore::Event*>& already_processed)
+void staff_t::apply_lasso(QRect rect, set<const MusECore::Event*>& already_processed)
{
for (ScoreItemList::iterator it=itemlist.begin(); it!=itemlist.end(); it++)
for (set<FloItem>::iterator it2=it->second.begin(); it2!=it->second.end(); it2++)
@@ -4569,7 +4569,7 @@ void staff_t::apply_lasso(QRect rect, set<MusECore::Event*>& already_processed)
if (rect.contains(it2->x, it2->y))
if (already_processed.find(it2->source_event)==already_processed.end())
{
- it2->source_event->setSelected(!it2->source_event->selected());
+ MusEGlobal::song->applyOperation(UndoOp(UndoOp::SelectEvent,*it2->source_event,!it2->source_event->selected(),it2->source_event->selected()));
already_processed.insert(it2->source_event);
}
}
@@ -4617,7 +4617,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());
}
@@ -4654,15 +4654,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();
}