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_EDITVIEWBASE_H
19 #define RG_EDITVIEWBASE_H
geqo_set_seed(PlannerInfo * root,double seed)20 
21 #include <set>
22 #include <string>
23 #include <vector>
24 #include "base/Event.h"
25 #include "ActionFileClient.h"
26 
27 #include <QMainWindow>
28 #include <QString>
29 
30 class QShortcut;
31 class QCloseEvent;
32 
33 namespace Rosegarden
34 {
geqo_rand(PlannerInfo * root)35 class Clipboard;
36 class Command;
37 class Segment;
38 class RosegardenDocument;
39 class Event;
40 
41 
42 class EditViewBase : public QMainWindow, public ActionFileClient
43 {
44     Q_OBJECT
45 
46 public:
47     EditViewBase(RosegardenDocument *doc,
48                  std::vector<Segment *> segments,
49                  QWidget *parent);
50 
51     ~EditViewBase() override;
52 
53     const RosegardenDocument *getDocument() const { return m_doc; }
54     RosegardenDocument *getDocument() { return m_doc; }
55 
56     Clipboard *getClipboard();
57 
58     /**
59      * Return our local shortcut object
60      */
61     QShortcut* getShortcuts() { return m_shortcuts; }
62 
63     /**
64      * Let tools know if their current element has gone
65      */
66     virtual void handleEventRemoved(Event *event);
67 
68 signals:
69     /**
70      * Tell the app to save the file.
71      */
72     void saveFile();
73 
74     /**
75      * Reopen the given segments in another sort of editor.
76      */
77     void openInNotation(std::vector<Segment *>);
78     void openInMatrix(std::vector<Segment *>);
79     void openInPercussionMatrix(std::vector<Segment *>);
80     void openInEventList(std::vector<Segment *>);
81     void slotOpenInPitchTracker(std::vector<Segment *>);
82 
83     /**
84      * Tell the main view that the track being edited is the
85      * current selected track
86      * This is used by #slotToggleSolo
87      */
88     void selectTrack(int);
89 
90     /**
91      * Tell the main view that the solo status has changed (the user clicked on the 'solo' toggle)
92      */
93     void toggleSolo(bool);
94 
95 public slots:
96     /**
97      * close window
98      */
99     virtual void slotCloseWindow();
100 
101     /**
102      * put the indicationed text/object into the clipboard and remove * it
103      * from the document
104      */
105     virtual void slotEditCut() = 0;
106 
107     /**
108      * put the indicationed text/object into the clipboard
109      */
110     virtual void slotEditCopy() = 0;
111 
112     /**
113      * paste the clipboard into the document
114      */
115     virtual void slotEditPaste() = 0;
116 
117     /**
118      * toggles the main toolbar
119      */
120 //    virtual void slotToggleToolBar();
121 
122     /**
123      * toggles the statusbar
124      */
125     virtual void slotToggleStatusBar();
126 
127     /**
128      * Changes the statusbar contents for the standard label permanently,
129      * used to indicate current actions.
130      *
131      * @param text the text that is displayed in the statusbar
132      */
133     virtual void slotStatusMsg(const QString &text);
134 
135     /**
136      * Changes the status message of the whole statusbar for two
137      * seconds, then restores the last status. This is used to display
138      * statusbar messages that give information about actions for
139      * toolbar icons and menuentries.
140      *
141      * @param text the text that is displayed in the statusbar
142      */
143     virtual void slotStatusHelpMsg(const QString &text);
144 
145     /**
146      * A command has happened; check the clipboard in case we
147      * need to change state
148      */
149     virtual void slotTestClipboard();
150 
151     /**
152      * Connected to this view's toolbar 'solo' button
153      */
154     virtual void slotToggleSolo();
155 
156     virtual void slotOpenInMatrix();
157     virtual void slotOpenInPercussionMatrix();
158     virtual void slotOpenInNotation();
159     virtual void slotOpenInEventList();
160     virtual void slotOpenInPitchTracker();
161 
162     virtual void slotSegmentDeleted(Segment *);
163 
164     /**
165      * Set the start time of the current segment
166      */
167     void slotSetSegmentStartTime();
168 
169     /**
170      * Set the duration of the current segment
171      */
172     void slotSetSegmentDuration();
173 
174     /**
175      * Global composition updates from the main view (track selection, solo, etc...)
176      */
177     virtual void slotCompositionStateUpdate();
178 
179 protected:
180 
181     /**
182      * @see #setInCtor
183      */
184     void closeEvent(QCloseEvent* e) override;
185 
186     /**
187      * read general Options again and initialize all variables like the recent file list
188      */
189     virtual void readOptions();
190 
191     /**
192      * Helper to set checkboxes for visibility of toolbars
193      */
194     void setCheckBoxState(QString actionName, QString toolbarName);
195 
196     /**
197      * create menus and toolbars
198      */
199     virtual void setupBaseActions(bool haveClipboard);
200 
201     /**
202      * setup status bar
203      */
204     virtual void initStatusBar() = 0;
205 
206     /**
207      * Abstract method to get current segment
208      */
209     virtual Segment *getCurrentSegment() = 0;
210 
211     /**
212      * Set the caption of the view's window
213      */
214     virtual void updateViewCaption() = 0;
215 
216 protected slots:
217     /**
218      * save general Options like all bar positions and status as well
219      * as the geometry and the recent file list to the configuration
220      * file
221      */
222     virtual void slotSaveOptions();
223     virtual void slotConfigure();
224 
225 protected:
226     /**
227      * Set the page index of the config dialog which corresponds to
228      * this editview
229      */
230     void setConfigDialogPageIndex(int p) { m_configDialogPageIndex = p; }
231     int getConfigDialogPageIndex()       { return m_configDialogPageIndex; }
232 
233     /// form a suitable title string for the window
234     QString getTitle(const QString& view);
235 
236     RosegardenDocument* m_doc;
237 
238     /// The Segment(s) that are being edited.
239     std::vector<Segment *> m_segments;
240 
241     int m_configDialogPageIndex;
242 
243     QShortcut *m_shortcuts;
244 };
245 
246 
247 }
248 
249 #endif
250