1 2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 3 4 /* 5 Rosegarden 6 A MIDI and audio sequencer and musical notation editor. 7 Copyright 2000-2021 the Rosegarden development team. 8 9 Other copyrights also apply to some parts of this work. Please 10 see the AUTHORS file and individual file headers for details. 11 12 This program is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 2 of the 15 License, or (at your option) any later version. See the file 16 COPYING included with this distribution for more information. 17 */ 18 19 #ifndef RG_EVENTVIEW_H 20 #define RG_EVENTVIEW_H 21 22 #include "base/MidiTypes.h" 23 #include "base/NotationTypes.h" 24 #include "base/Segment.h" 25 #include "gui/general/ListEditView.h" 26 #include "base/Event.h" 27 28 #include <set> 29 #include <vector> 30 31 #include <QSize> 32 #include <QString> 33 34 35 class QWidget; 36 class QMenu; 37 class QPoint; 38 class QTreeWidget; 39 class QTreeWidgetItem; 40 class QLabel; 41 class QCheckBox; 42 class QGroupBox; 43 class QTreeWidget; 44 45 46 namespace Rosegarden 47 { 48 49 class Segment; 50 class RosegardenDocument; 51 class Event; 52 53 54 class EventView : public ListEditView, public SegmentObserver 55 { 56 Q_OBJECT 57 58 public: 59 EventView(RosegardenDocument *doc, 60 std::vector<Segment *> segments, 61 QWidget *parent); 62 63 ~EventView() override; 64 65 void refreshSegment(Segment *segment, 66 timeT startTime = 0, 67 timeT endTime = 0) override; 68 69 void updateView() override; 70 71 void setupActions(); 72 void initStatusBar() override; 73 virtual QSize getViewSize(); 74 virtual void setViewSize(QSize); 75 76 // Set the button states to the current filter positions 77 // 78 void setButtonsToFilter(); 79 80 // Menu creation and show 81 // 82 void createMenu(); 83 84 // SegmentObserver overrides. eventAdded(const Segment *,Event *)85 void eventAdded(const Segment *, Event *) override { } 86 void eventRemoved(const Segment *, Event *) override; endMarkerTimeChanged(const Segment *,bool)87 void endMarkerTimeChanged(const Segment *, bool) override { } 88 void segmentDeleted(const Segment *) override; 89 90 public slots: 91 92 // standard slots 93 void slotEditCut() override; 94 void slotEditCopy() override; 95 void slotEditPaste() override; 96 97 // other edit slots 98 void slotEditDelete(); 99 void slotEditInsert(); 100 101 void slotSelectAll(); 102 void slotClearSelection(); 103 104 void slotMusicalTime(); 105 void slotRealTime(); 106 void slotRawTime(); 107 108 // Change filter parameters 109 // 110 void slotModifyFilter(); 111 112 void slotHelpRequested(); 113 void slotHelpAbout(); 114 115 signals: 116 void editTriggerSegment(int); 117 118 protected: 119 // QWidget overrides. 120 void closeEvent(QCloseEvent *event) override; 121 122 private slots: 123 void slotSaveOptions() override; 124 125 // Menu Handlers 126 127 /// Edit > Edit Event 128 void slotEditEvent(); 129 /// Edit > Advanced Event Editor 130 void slotEditEventAdvanced(); 131 132 /// Handle double-click on an event in the event list. 133 void slotPopupEventEditor(QTreeWidgetItem *item, int column); 134 135 /// Right-click context menu. 136 void slotPopupMenu(const QPoint&); 137 /// Right-click context menu handler. 138 void slotOpenInEventEditor(bool checked); 139 /// Right-click context menu handler. 140 void slotOpenInExpertEventEditor(bool checked); 141 142 void slotEditTriggerName(); 143 void slotEditTriggerPitch(); 144 void slotEditTriggerVelocity(); 145 void slotTriggerTimeAdjustChanged(int); 146 void slotTriggerRetuneChanged(); 147 148 /// slot connected to signal RosegardenDocument::setModified(bool) 149 void updateWindowTitle(bool m = false); 150 151 private: 152 153 bool applyLayout(); 154 155 /// virtual function inherited from the base class, this implementation just 156 /// calls updateWindowTitle() and avoids a refactoring job, even though 157 /// updateViewCaption is superfluous 158 void updateViewCaption() override; 159 160 void readOptions() override; 161 QString makeTimeString(timeT time, int timeMode); 162 QString makeDurationString(timeT time, 163 timeT duration, int timeMode); 164 Segment *getCurrentSegment() override; 165 166 QGroupBox *m_filterGroup; // Event filters 167 QCheckBox *m_noteCheckBox; 168 QCheckBox *m_programCheckBox; 169 QCheckBox *m_controllerCheckBox; 170 QCheckBox *m_pitchBendCheckBox; 171 QCheckBox *m_sysExCheckBox; 172 QCheckBox *m_keyPressureCheckBox; 173 QCheckBox *m_channelPressureCheckBox; 174 QCheckBox *m_restCheckBox; 175 QCheckBox *m_indicationCheckBox; 176 QCheckBox *m_textCheckBox; 177 QCheckBox *m_generatedRegionCheckBox; 178 QCheckBox *m_segmentIDCheckBox; 179 QCheckBox *m_otherCheckBox; 180 181 enum EventFilter 182 { 183 None = 0x0000, 184 Note = 0x0001, 185 Rest = 0x0002, 186 Text = 0x0004, 187 SystemExclusive = 0x0008, 188 Controller = 0x0010, 189 ProgramChange = 0x0020, 190 PitchBend = 0x0040, 191 ChannelPressure = 0x0080, 192 KeyPressure = 0x0100, 193 Indication = 0x0200, 194 Other = 0x0400, 195 GeneratedRegion = 0x0800, 196 SegmentID = 0x1000, 197 }; 198 int m_eventFilter; 199 200 // ??? Why is this a tree widget? When are there ever sub-nodes? 201 QTreeWidget *m_eventList; 202 203 std::vector<int> m_listSelection; 204 void makeInitialSelection(timeT); 205 206 std::set<Event *> m_deletedEvents; // deleted since last refresh 207 208 // Pop-up menu for the event list. 209 QMenu *m_menu; 210 211 bool m_isTriggerSegment; 212 QLabel *m_triggerName; 213 QLabel *m_triggerPitch; 214 QLabel *m_triggerVelocity; 215 216 }; 217 218 219 } 220 221 #endif 222