summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2012-07-04 14:57:46 +0000
committerRobert Jonsson <spamatica@gmail.com>2012-07-04 14:57:46 +0000
commita540a4b8b05225762b9d4f5f8e37580620bf61d4 (patch)
treeaa855eb7e45172ba781841d2365082fa6f2b14be /muse2/muse
parenta01e888685ab8990a6d534c39c86ab258b7dc501 (diff)
inc/dec tick for events
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/liste/listedit.cpp128
-rw-r--r--muse2/muse/liste/listedit.h2
2 files changed, 81 insertions, 49 deletions
diff --git a/muse2/muse/liste/listedit.cpp b/muse2/muse/liste/listedit.cpp
index cdc34b45..0f6fd137 100644
--- a/muse2/muse/liste/listedit.cpp
+++ b/muse2/muse/liste/listedit.cpp
@@ -517,6 +517,12 @@ ListEdit::ListEdit(MusECore::PartList* pl)
editSignalMapper->setMapping(deleteAction, CMD_DELETE);
deleteAction->setShortcut(Qt::Key_Delete);
menuEdit->addSeparator();
+ QAction *incAction = menuEdit->addAction(tr("Increase Tick"));
+ connect(incAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(incAction, CMD_INC);
+ QAction *decAction = menuEdit->addAction(tr("Decrease Tick"));
+ connect(decAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(decAction, CMD_DEC);
menuEdit->addActions(insertItems->actions());
@@ -918,61 +924,87 @@ void ListEdit::doubleClicked(QTreeWidgetItem* item)
//---------------------------------------------------------
void ListEdit::cmd(int cmd)
+{
+ bool found = false;
+ for (int row = 0; row < liste->topLevelItemCount(); ++row)
+ {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+ if (i->isSelected() || item->event.selected())
{
- switch(cmd) {
- case CMD_DELETE:
- bool found = false;
- for (int row = 0; row < liste->topLevelItemCount(); ++row)
- {
+ found = true;
+ break;
+ }
+ }
+
+ switch(cmd) {
+ case CMD_DELETE:
+ {
+ if(!found)
+ break;
+
+ MusECore::Undo operations;
+
+ EventListItem *deletedEvent=NULL;
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
QTreeWidgetItem* i = liste->topLevelItem(row);
EventListItem *item = (EventListItem *) i;
- if (i->isSelected() || item->event.selected())
- {
- found = true;
+ if (i->isSelected() || item->event.selected()) {
+ deletedEvent=item;
+ // Port controller values and clone parts.
+ operations.push_back(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent,item->event, item->part, true, true));
+ }
+ }
+
+ unsigned int nextTick=0;
+ // find biggest tick
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+ if (item->event.tick() > nextTick && item != deletedEvent)
+ nextTick=item->event.tick();
+ }
+ // check if there's a tick that is "just" bigger than the deleted
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+ if (item->event.tick() >= deletedEvent->event.tick() &&
+ item->event.tick() < nextTick &&
+ item != deletedEvent ) {
+ nextTick=item->event.tick();
+ }
+ }
+ selectedTick=nextTick;
+
+ MusEGlobal::song->applyOperationGroup(operations);
+ }
+ break;
+ case CMD_INC:
+ case CMD_DEC:
+ {
+ if(!found)
+ break;
+
+ MusECore::Undo operations;
+
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+
+ if (i->isSelected() || item->event.selected()) {
+ MusECore::Event new_event=item->event.clone();
+ new_event.setTick( new_event.tick() + ( cmd==CMD_INC?1:-1) );
+ operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent,new_event, item->event, item->part, false, false));
+ selectedTick=new_event.tick();
break;
+ }
}
- }
- if(!found)
- break;
-
- MusECore::Undo operations;
-
- EventListItem *deletedEvent=NULL;
- for (int row = 0; row < liste->topLevelItemCount(); ++row) {
- QTreeWidgetItem* i = liste->topLevelItem(row);
- EventListItem *item = (EventListItem *) i;
- if (i->isSelected() || item->event.selected()) {
- deletedEvent=item;
- // Port controller values and clone parts.
- operations.push_back(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent,item->event, item->part, true, true));
- }
- }
-
- unsigned int nextTick=0;
- // find biggest tick
- for (int row = 0; row < liste->topLevelItemCount(); ++row) {
- QTreeWidgetItem* i = liste->topLevelItem(row);
- EventListItem *item = (EventListItem *) i;
- if (item->event.tick() > nextTick && item != deletedEvent)
- nextTick=item->event.tick();
- }
- // check if there's a tick that is "just" bigger than the deleted
- for (int row = 0; row < liste->topLevelItemCount(); ++row) {
- QTreeWidgetItem* i = liste->topLevelItem(row);
- EventListItem *item = (EventListItem *) i;
- if (item->event.tick() >= deletedEvent->event.tick() &&
- item->event.tick() < nextTick &&
- item != deletedEvent ) {
- nextTick=item->event.tick();
- }
- }
- selectedTick=nextTick;
+ MusEGlobal::song->applyOperationGroup(operations);
- MusEGlobal::song->applyOperationGroup(operations);
- break;
- }
- }
+ }
+ }
+}
//---------------------------------------------------------
// configChanged
diff --git a/muse2/muse/liste/listedit.h b/muse2/muse/liste/listedit.h
index 1dddb9a6..d9cdac96 100644
--- a/muse2/muse/liste/listedit.h
+++ b/muse2/muse/liste/listedit.h
@@ -61,7 +61,7 @@ class ListEdit : public MidiEditor {
int selectedTick;
int curPartId;
- enum { CMD_DELETE };
+ enum { CMD_DELETE, CMD_INC, CMD_DEC };
virtual void closeEvent(QCloseEvent*);