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 #ifndef RG_SEGMENTCHANGEQUANTIZATIONCOMMAND_H 19 #define RG_SEGMENTCHANGEQUANTIZATIONCOMMAND_H 20 21 #include "document/Command.h" 22 #include <QString> 23 #include <QCoreApplication> 24 #include <vector> 25 #include "base/Event.h" 26 #include "gui/editors/notation/NotationStrings.h" 27 28 namespace Rosegarden 29 { 30 31 class Segment; 32 33 34 class SegmentChangeQuantizationCommand : public NamedCommand 35 { 36 Q_DECLARE_TR_FUNCTIONS (Rosegarden::SegmentChangeQuantizationCommand) 37 public: 38 /// Set quantization on segments. If unit is zero, switch quantization off 39 SegmentChangeQuantizationCommand(timeT); 40 ~SegmentChangeQuantizationCommand() override; 41 42 void addSegment(Segment *s); 43 44 void execute() override; 45 void unexecute() override; 46 getGlobalName(timeT unit)47 static QString getGlobalName(timeT unit) { 48 if (!unit) { 49 return tr("Unquantize"); 50 } else { 51 timeT error = 0; 52 QString label = NotationStrings::makeNoteMenuLabel(unit, true, error); 53 return tr("Quantize to %1").arg(label); 54 } 55 } 56 57 58 private: 59 struct SegmentRec { 60 Segment *segment; 61 timeT oldUnit; 62 bool wasQuantized; 63 }; 64 typedef std::vector<SegmentRec> SegmentRecSet; 65 SegmentRecSet m_records; 66 67 timeT m_unit; 68 }; 69 70 71 72 } 73 74 #endif 75