1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A MIDI and audio sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7 
8     Other copyrights also apply to some parts of this work.  Please
9     see the AUTHORS file and individual file headers for details.
10 
11     This program is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License as
13     published by the Free Software Foundation; either version 2 of the
14     License, or (at your option) any later version.  See the file
15     COPYING included with this distribution for more information.
16 */
17 
18 
19 #include "AddSlashesCommand.h"
20 
21 #include "base/Selection.h"
22 #include "document/BasicSelectionCommand.h"
23 #include "document/CommandRegistry.h"
24 #include "gui/editors/notation/NotationProperties.h"
25 
26 
27 namespace Rosegarden
28 {
29 
30 void
31 AddSlashesCommand::registerCommand(CommandRegistry *r)
32 {
33     static QString slashTitles[] = {
34         tr("&None"), "&1", "&2", "&3", "&4", "&5"
getGlobalName(Mark markType)35     };
36 
37     for (int i = 0; i <= 5; ++i) {
38         r->registerCommand
39             (QString("slashes_%1").arg(i),
40              new ArgumentAndSelectionCommandBuilder<AddSlashesCommand>());
41     }
42 }
43 
44 int
45 AddSlashesCommand::getArgument(QString actionName, CommandArgumentQuerier &)
46 {
47     QString pfx("slashes_");
48     if (actionName.startsWith(pfx)) {
49         return actionName.right(actionName.length() - pfx.length()).toInt();
50     }
51     return 0;
52 }
53 
54 void
55 AddSlashesCommand::modifySegment()
56 {
57     EventSelection::eventcontainer::iterator i;
58 
59     for (i = m_selection->getSegmentEvents().begin();
60             i != m_selection->getSegmentEvents().end(); ++i) {
61 
62         if (m_number < 1) {
63             (*i)->unset(NotationProperties::SLASHES);
64         } else {
65             (*i)->set<Int>(NotationProperties::SLASHES, m_number);
66         }
67     }
68 }
69 
70 }
71