/[qspeakers]/branches/qtcharts/undocommands.h
ViewVC logotype

Contents of /branches/qtcharts/undocommands.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 270 - (show annotations)
Sun Oct 25 20:46:15 2020 UTC (7 months, 2 weeks ago) by ben
File MIME type: text/plain
File size: 8036 byte(s)
Implement dual VC display
1 #ifndef UNDOCOMMANDS_H
2 #define UNDOCOMMANDS_H
3
4 #include <QUndoCommand>
5 #include "mainwindow.h"
6
7 class GenericCommand: public QUndoCommand
8 {
9 public:
10 GenericCommand(QObject *parent)
11 : manual(true), mainwindow(static_cast<MainWindow*>(parent)) {}
12 void undo() override {
13 this->manual = false;
14 }
15 void redo() override {
16 this->manual = false;
17 }
18 protected:
19 bool manual;
20 MainWindow* mainwindow;
21 };
22
23 class NumberCommand: public GenericCommand
24 {
25 public:
26 NumberCommand(int older, int newer, QObject *parent)
27 : GenericCommand(parent) {
28 this->older = older;
29 this->newer = newer;
30 };
31 void undo() override {
32 this->mainwindow->changeSpeakerNumber(older);
33 GenericCommand::undo();
34 };
35 void redo() override {
36 this->mainwindow->changeSpeakerNumber(newer);
37 GenericCommand::redo();
38 };
39
40 private:
41 int older;
42 int newer;
43 };
44
45 class VendorCommand: public GenericCommand
46 {
47 public:
48 VendorCommand(const QString& older, const QString& newer, const Speaker& oldspeaker, QObject *parent)
49 : GenericCommand(parent) {
50 this->oldspeaker = oldspeaker;
51 this->older = older;
52 this->newer = newer;
53 };
54 void undo() override {
55 this->mainwindow->changeVendor(older, oldspeaker);
56 GenericCommand::undo();
57 };
58 void redo() override {
59 this->mainwindow->changeVendor(newer, Speaker());
60 GenericCommand::redo();
61 };
62
63 private:
64 Speaker oldspeaker;
65 QString older;
66 QString newer;
67 };
68
69 class ModelCommand: public GenericCommand
70 {
71 public:
72 ModelCommand(const QString& older, const QString& newer, QObject *parent)
73 : GenericCommand(parent) {
74 this->older = older;
75 this->newer = newer;
76 };
77 void undo() override {
78 this->mainwindow->changeModel(older);
79 GenericCommand::undo();
80 };
81 void redo() override {
82 this->mainwindow->changeModel(newer);
83 GenericCommand::redo();
84 };
85
86 private:
87 QString older;
88 QString newer;
89 };
90
91 class SealedVolumeCommand: public GenericCommand
92 {
93 public:
94 SealedVolumeCommand(double older, double newer, QObject *parent)
95 : GenericCommand(parent) {
96 this->older = older;
97 this->newer = newer;
98 };
99 void undo() override {
100 this->mainwindow->changeSealedVolume(older);
101 GenericCommand::undo();
102 };
103 void redo() override {
104 this->mainwindow->changeSealedVolume(newer);
105 GenericCommand::redo();
106 };
107
108 protected:
109 double older;
110 double newer;
111 };
112
113 class PortedVolumeCommand: public GenericCommand
114 {
115 public:
116 PortedVolumeCommand(double older, double newer, QObject *parent)
117 : GenericCommand(parent) {
118 this->older = older;
119 this->newer = newer;
120 };
121 void undo() override {
122 this->mainwindow->changePortedVolume(older);
123 GenericCommand::undo();
124 };
125 void redo() override {
126 this->mainwindow->changePortedVolume(newer);
127 GenericCommand::redo();
128 };
129
130 protected:
131 double older;
132 double newer;
133 };
134
135 class PortedResFreqCommand: public GenericCommand
136 {
137 public:
138 PortedResFreqCommand(double older, double newer, QObject *parent)
139 : GenericCommand(parent) {
140 this->older = older;
141 this->newer = newer;
142 };
143 void undo() override {
144 this->mainwindow->changePortedResFreq(older);
145 GenericCommand::undo();
146 };
147 void redo() override {
148 this->mainwindow->changePortedResFreq(newer);
149 GenericCommand::redo();
150 };
151
152 protected:
153 double older;
154 double newer;
155 };
156
157 class PortedPortNumberCommand: public GenericCommand
158 {
159 public:
160 PortedPortNumberCommand(unsigned int older, unsigned int newer, QObject *parent)
161 : GenericCommand(parent) {
162 this->older = older;
163 this->newer = newer;
164 };
165 void undo() override {
166 this->mainwindow->changePortedPortNumber(older);
167 GenericCommand::undo();
168 };
169 void redo() override {
170 this->mainwindow->changePortedPortNumber(newer);
171 GenericCommand::redo();
172 };
173
174 protected:
175 unsigned int older;
176 unsigned int newer;
177 };
178
179 class PortedPortDiamCommand: public GenericCommand
180 {
181 public:
182 PortedPortDiamCommand(double older, double newer, QObject *parent)
183 : GenericCommand(parent) {
184 this->older = older;
185 this->newer = newer;
186 };
187 void undo() override {
188 this->mainwindow->changePortedPortDiam(older);
189 GenericCommand::undo();
190 };
191 void redo() override {
192 this->mainwindow->changePortedPortDiam(newer);
193 GenericCommand::redo();
194 };
195
196 protected:
197 double older;
198 double newer;
199 };
200
201 class PortedSlotPortCommand: public GenericCommand
202 {
203 public:
204 PortedSlotPortCommand(bool older, bool newer, QObject *parent)
205 : GenericCommand(parent) {
206 this->older = older;
207 this->newer = newer;
208 };
209 void undo() override {
210 this->mainwindow->changePortedSlotPortActivation(older);
211 GenericCommand::undo();
212 };
213 void redo() override {
214 this->mainwindow->changePortedSlotPortActivation(newer);
215 GenericCommand::redo();
216 };
217
218 private:
219 bool older;
220 bool newer;
221 };
222
223 class PortedSlotWidthCommand: public GenericCommand
224 {
225 public:
226 PortedSlotWidthCommand(double older, double newer, QObject *parent)
227 : GenericCommand(parent) {
228 this->older = older;
229 this->newer = newer;
230 };
231 void undo() override {
232 this->mainwindow->changePortedSlotWidth(older);
233 GenericCommand::undo();
234 };
235 void redo() override {
236 this->mainwindow->changePortedSlotWidth(newer);
237 GenericCommand::redo();
238 };
239
240 private:
241 double older;
242 double newer;
243 };
244
245 class BPSealedVolumeCommand: public SealedVolumeCommand
246 {
247 public:
248 BPSealedVolumeCommand(double older, double newer, QObject *parent)
249 : SealedVolumeCommand(older, newer, parent)
250 {};
251
252 void undo() override {
253 this->mainwindow->changeBPSealedVolume(this->older);
254 GenericCommand::undo();
255 };
256 void redo() override {
257 this->mainwindow->changeBPSealedVolume(this->newer);
258 GenericCommand::redo();
259 };
260 };
261
262 class BPPortedVolumeCommand: public PortedVolumeCommand
263 {
264 public:
265 BPPortedVolumeCommand(double older, double newer, QObject *parent)
266 :PortedVolumeCommand(older, newer, parent)
267 {};
268 void undo() override {
269 this->mainwindow->changeBPPortedVolume(older);
270 GenericCommand::undo();
271 };
272 void redo() override {
273 this->mainwindow->changeBPPortedVolume(newer);
274 GenericCommand::redo();
275 };
276 };
277
278 class BPPortedResFreqCommand: public PortedResFreqCommand
279 {
280 public:
281 BPPortedResFreqCommand(double older, double newer, QObject *parent)
282 : PortedResFreqCommand(older, newer, parent)
283 {};
284
285 void undo() override {
286 this->mainwindow->changeBPPortedResFreq(older);
287 GenericCommand::undo();
288 };
289 void redo() override {
290 this->mainwindow->changeBPPortedResFreq(newer);
291 GenericCommand::redo();
292 };
293 };
294
295 class BPPortedPortNumberCommand: public PortedPortNumberCommand
296 {
297 public:
298 BPPortedPortNumberCommand(unsigned int older, unsigned int newer, QObject *parent)
299 : PortedPortNumberCommand(older, newer, parent)
300 {};
301 void undo() override {
302 this->mainwindow->changeBPPortedPortNumber(older);
303 GenericCommand::undo();
304 };
305 void redo() override {
306 this->mainwindow->changeBPPortedPortNumber(newer);
307 GenericCommand::redo();
308 };
309 };
310
311 class BPPortedPortDiamCommand: public PortedPortDiamCommand
312 {
313 public:
314 BPPortedPortDiamCommand(double older, double newer, QObject *parent)
315 : PortedPortDiamCommand(older, newer, parent)
316 {};
317 void undo() override {
318 this->mainwindow->changeBPPortedPortDiam(older);
319 GenericCommand::undo();
320 };
321 void redo() override {
322 this->mainwindow->changeBPPortedPortDiam(newer);
323 GenericCommand::redo();
324 };
325 };
326
327 #endif // UNDOCOMMANDS_H

  ViewVC Help
Powered by ViewVC 1.1.26