~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/designer/src/lib/shared/qdesigner_command_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the designer application of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
//
 
30
//  W A R N I N G
 
31
//  -------------
 
32
//
 
33
// This file is not part of the Qt API.  It exists for the convenience
 
34
// of Qt Designer.  This header
 
35
// file may change from version to version without notice, or even be removed.
 
36
//
 
37
// We mean it.
 
38
//
 
39
 
 
40
#ifndef QDESIGNER_COMMAND_H
 
41
#define QDESIGNER_COMMAND_H
 
42
 
 
43
#include "shared_global_p.h"
 
44
#include "qtundo_p.h"
 
45
#include "layoutinfo_p.h"
 
46
 
 
47
#include <QtDesigner/layoutdecoration.h>
 
48
 
 
49
#include <QtCore/QPointer>
 
50
#include <QtCore/QPair>
 
51
 
 
52
#include <QtCore/QVariant>
 
53
 
 
54
class QDesignerFormEditorInterface;
 
55
class QDesignerFormWindowManagerInterface;
 
56
class QDesignerFormWindowInterface;
 
57
class QDesignerWidgetDataBaseItemInterface;
 
58
class Layout;
 
59
 
 
60
class QDesignerPropertySheetExtension;
 
61
class QDesignerMetaDataBaseItemInterface;
 
62
class QDesignerPromotedWidget;
 
63
 
 
64
class QToolBox;
 
65
class QTabWidget;
 
66
class QStackedWidget;
 
67
class QDockWidget;
 
68
class QMainWindow;
 
69
 
 
70
class QT_SHARED_EXPORT QDesignerFormEditorCommand: public QtCommand
 
71
{
 
72
    Q_OBJECT
 
73
public:
 
74
    QDesignerFormEditorCommand(const QString &description, QDesignerFormEditorInterface *core);
 
75
 
 
76
    QDesignerFormEditorInterface *core() const;
 
77
 
 
78
private:
 
79
    QPointer<QDesignerFormEditorInterface> m_core;
 
80
};
 
81
 
 
82
class QT_SHARED_EXPORT QDesignerFormWindowManagerCommand: public QtCommand
 
83
{
 
84
    Q_OBJECT
 
85
public:
 
86
    QDesignerFormWindowManagerCommand(const QString &description, QDesignerFormWindowManagerInterface *formWindowManager);
 
87
 
 
88
    QDesignerFormWindowManagerInterface *formWindowManager() const;
 
89
 
 
90
private:
 
91
    QPointer<QDesignerFormWindowManagerInterface> m_formWindowManager;
 
92
};
 
93
 
 
94
class QT_SHARED_EXPORT QDesignerFormWindowCommand: public QtCommand
 
95
{
 
96
    Q_OBJECT
 
97
public:
 
98
    QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow);
 
99
 
 
100
    QDesignerFormWindowInterface *formWindow() const;
 
101
 
 
102
protected:
 
103
    void checkObjectName(QWidget *widget);
 
104
    void updateBuddies(const QString &old_name, const QString &new_name);
 
105
    void checkSelection(QWidget *widget);
 
106
    void checkParent(QWidget *widget, QWidget *parentWidget);
 
107
    bool hasLayout(QWidget *widget) const;
 
108
 
 
109
private:
 
110
    QPointer<QDesignerFormWindowInterface> m_formWindow;
 
111
};
 
112
 
 
113
class QT_SHARED_EXPORT SetPropertyCommand: public QDesignerFormWindowCommand
 
114
{
 
115
    Q_OBJECT
 
116
public:
 
117
    SetPropertyCommand(QDesignerFormWindowInterface *formWindow);
 
118
 
 
119
    void init(QWidget *widget, const QString &propertyName, const QVariant &newValue);
 
120
 
 
121
    QWidget *widget() const;
 
122
    QWidget *parentWidget() const;
 
123
 
 
124
    inline QString propertyName() const
 
125
    { return m_propertyName; }
 
126
 
 
127
    inline QVariant oldValue() const
 
128
    { return m_oldValue; }
 
129
 
 
130
    inline void setOldValue(const QVariant &oldValue)
 
131
    { m_oldValue = oldValue; }
 
132
 
 
133
    inline QVariant newValue() const
 
134
    { return m_newValue; }
 
135
 
 
136
    inline void setNewValue(const QVariant &newValue)
 
137
    { m_newValue = newValue; }
 
138
 
 
139
    virtual void redo();
 
140
    virtual void undo();
 
141
 
 
142
protected:
 
143
    virtual bool mergeMeWith(QtCommand *other);
 
144
 
 
145
private:
 
146
    QString m_propertyName;
 
147
    int m_index;
 
148
    QPointer<QWidget> m_widget;
 
149
    QPointer<QWidget> m_parentWidget;
 
150
    QDesignerPropertySheetExtension *m_propertySheet;
 
151
    QVariant m_oldValue;
 
152
    QVariant m_newValue;
 
153
    bool m_changed;
 
154
};
 
155
 
 
156
class QT_SHARED_EXPORT ResetPropertyCommand: public QDesignerFormWindowCommand
 
157
{
 
158
    Q_OBJECT
 
159
public:
 
160
    ResetPropertyCommand(QDesignerFormWindowInterface *formWindow);
 
161
 
 
162
    void init(QWidget *widget, const QString &propertyName);
 
163
 
 
164
    QWidget *widget() const;
 
165
    QWidget *parentWidget() const;
 
166
 
 
167
    inline QString propertyName() const
 
168
    { return m_propertyName; }
 
169
 
 
170
    inline QVariant oldValue() const
 
171
    { return m_oldValue; }
 
172
 
 
173
    inline void setOldValue(const QVariant &oldValue)
 
174
    { m_oldValue = oldValue; }
 
175
 
 
176
    virtual void redo();
 
177
    virtual void undo();
 
178
 
 
179
protected:
 
180
    virtual bool mergeMeWith(QtCommand *other) { Q_UNUSED(other); return false; }
 
181
 
 
182
private:
 
183
    QString m_propertyName;
 
184
    int m_index;
 
185
    QPointer<QWidget> m_widget;
 
186
    QPointer<QWidget> m_parentWidget;
 
187
    QDesignerPropertySheetExtension *m_propertySheet;
 
188
    QVariant m_oldValue;
 
189
    bool m_changed;
 
190
};
 
191
 
 
192
class QT_SHARED_EXPORT InsertWidgetCommand: public QDesignerFormWindowCommand
 
193
{
 
194
    Q_OBJECT
 
195
public:
 
196
    InsertWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
197
 
 
198
    void init(QWidget *widget);
 
199
 
 
200
    virtual void redo();
 
201
    virtual void undo();
 
202
 
 
203
private:
 
204
    QPointer<QWidget> m_widget;
 
205
    QDesignerLayoutDecorationExtension::InsertMode m_insertMode;
 
206
    QPair<int, int> m_cell;
 
207
};
 
208
 
 
209
class QT_SHARED_EXPORT RaiseWidgetCommand: public QDesignerFormWindowCommand
 
210
{
 
211
    Q_OBJECT
 
212
public:
 
213
    RaiseWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
214
 
 
215
    void init(QWidget *widget);
 
216
 
 
217
    virtual void redo();
 
218
    virtual void undo();
 
219
 
 
220
private:
 
221
    QPointer<QWidget> m_widget;
 
222
};
 
223
 
 
224
class QT_SHARED_EXPORT LowerWidgetCommand: public QDesignerFormWindowCommand
 
225
{
 
226
    Q_OBJECT
 
227
public:
 
228
    LowerWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
229
 
 
230
    void init(QWidget *widget);
 
231
 
 
232
    virtual void redo();
 
233
    virtual void undo();
 
234
 
 
235
private:
 
236
    QPointer<QWidget> m_widget;
 
237
};
 
238
 
 
239
class QT_SHARED_EXPORT AdjustWidgetSizeCommand: public QDesignerFormWindowCommand
 
240
{
 
241
    Q_OBJECT
 
242
public:
 
243
    AdjustWidgetSizeCommand(QDesignerFormWindowInterface *formWindow);
 
244
 
 
245
    void init(QWidget *widget);
 
246
 
 
247
    virtual void redo();
 
248
    virtual void undo();
 
249
 
 
250
private:
 
251
    QPointer<QWidget> m_widget;
 
252
};
 
253
 
 
254
class QT_SHARED_EXPORT DeleteWidgetCommand: public QDesignerFormWindowCommand
 
255
{
 
256
    Q_OBJECT
 
257
public:
 
258
    DeleteWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
259
 
 
260
    void init(QWidget *widget);
 
261
 
 
262
    virtual void redo();
 
263
    virtual void undo();
 
264
 
 
265
private:
 
266
    QPointer<QWidget> m_widget;
 
267
    QPointer<QWidget> m_parentWidget;
 
268
    QRect m_geometry;
 
269
    LayoutInfo::Type m_layoutType;
 
270
    int m_index;
 
271
    int m_row, m_col;
 
272
    int m_rowspan, m_colspan;
 
273
    QDesignerMetaDataBaseItemInterface *m_formItem;
 
274
    int m_tabOrderIndex;
 
275
};
 
276
 
 
277
class QT_SHARED_EXPORT ReparentWidgetCommand: public QDesignerFormWindowCommand
 
278
{
 
279
    Q_OBJECT
 
280
public:
 
281
    ReparentWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
282
 
 
283
    void init(QWidget *widget, QWidget *parentWidget);
 
284
 
 
285
    virtual void redo();
 
286
    virtual void undo();
 
287
 
 
288
private:
 
289
    QPointer<QWidget> m_widget;
 
290
    QPoint m_oldPos;
 
291
    QPoint m_newPos;
 
292
    QPointer<QWidget> m_oldParentWidget;
 
293
    QPointer<QWidget> m_newParentWidget;
 
294
};
 
295
 
 
296
class QT_SHARED_EXPORT ChangeLayoutItemGeometry: public QDesignerFormWindowCommand
 
297
{
 
298
    Q_OBJECT
 
299
public:
 
300
    ChangeLayoutItemGeometry(QDesignerFormWindowInterface *formWindow);
 
301
 
 
302
    void init(QWidget *widget, int row, int column, int rowspan, int colspan);
 
303
 
 
304
    virtual void redo();
 
305
    virtual void undo();
 
306
 
 
307
protected:
 
308
    void changeItemPosition(const QRect &g);
 
309
 
 
310
private:
 
311
    QPointer<QWidget> m_widget;
 
312
    QRect m_oldInfo;
 
313
    QRect m_newInfo;
 
314
};
 
315
 
 
316
class QT_SHARED_EXPORT InsertRowCommand: public QDesignerFormWindowCommand
 
317
{
 
318
    Q_OBJECT
 
319
public:
 
320
    InsertRowCommand(QDesignerFormWindowInterface *formWindow);
 
321
 
 
322
    void init(QWidget *widget, int row);
 
323
 
 
324
    virtual void redo();
 
325
    virtual void undo();
 
326
 
 
327
private:
 
328
    QPointer<QWidget> m_widget;
 
329
    int m_row;
 
330
};
 
331
 
 
332
 
 
333
class QT_SHARED_EXPORT TabOrderCommand: public QDesignerFormWindowCommand
 
334
{
 
335
    Q_OBJECT
 
336
public:
 
337
    TabOrderCommand(QDesignerFormWindowInterface *formWindow);
 
338
 
 
339
    void init(const QList<QWidget*> &newTabOrder);
 
340
 
 
341
    inline QList<QWidget*> oldTabOrder() const
 
342
    { return m_oldTabOrder; }
 
343
 
 
344
    inline QList<QWidget*> newTabOrder() const
 
345
    { return m_newTabOrder; }
 
346
 
 
347
    virtual void redo();
 
348
    virtual void undo();
 
349
 
 
350
private:
 
351
    QDesignerMetaDataBaseItemInterface *m_widgetItem;
 
352
    QList<QWidget*> m_oldTabOrder;
 
353
    QList<QWidget*> m_newTabOrder;
 
354
};
 
355
 
 
356
class QT_SHARED_EXPORT PromoteToCustomWidgetCommand : public QDesignerFormWindowCommand
 
357
{
 
358
public:
 
359
    PromoteToCustomWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
360
    void init(QDesignerWidgetDataBaseItemInterface *item, QWidget *widget);
 
361
    virtual void redo();
 
362
    virtual void undo();
 
363
private:
 
364
    QWidget *m_widget;
 
365
    QDesignerPromotedWidget *m_promoted;
 
366
    friend class DemoteFromCustomWidgetCommand;
 
367
};
 
368
 
 
369
class QT_SHARED_EXPORT DemoteFromCustomWidgetCommand : public QDesignerFormWindowCommand
 
370
{
 
371
public:
 
372
    DemoteFromCustomWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
373
    void init(QDesignerPromotedWidget *promoted);
 
374
    virtual void redo();
 
375
    virtual void undo();
 
376
private:
 
377
    PromoteToCustomWidgetCommand *m_promote_cmd;
 
378
};
 
379
 
 
380
class QT_SHARED_EXPORT LayoutCommand: public QDesignerFormWindowCommand
 
381
{
 
382
    Q_OBJECT
 
383
public:
 
384
    LayoutCommand(QDesignerFormWindowInterface *formWindow);
 
385
    virtual ~LayoutCommand();
 
386
 
 
387
    inline QList<QWidget*> widgets() const
 
388
    { return m_widgets; }
 
389
 
 
390
    void init(QWidget *parentWidget, const QList<QWidget*> &widgets, LayoutInfo::Type layoutType,
 
391
        QWidget *layoutBase = 0, bool splitter = false);
 
392
 
 
393
    virtual void redo();
 
394
    virtual void undo();
 
395
 
 
396
private:
 
397
    QPointer<QWidget> m_parentWidget;
 
398
    QList<QWidget*> m_widgets;
 
399
    QPointer<QWidget> m_layoutBase;
 
400
    QPointer<Layout> m_layout;
 
401
};
 
402
 
 
403
class QT_SHARED_EXPORT BreakLayoutCommand: public QDesignerFormWindowCommand
 
404
{
 
405
    Q_OBJECT
 
406
public:
 
407
    BreakLayoutCommand(QDesignerFormWindowInterface *formWindow);
 
408
    virtual ~BreakLayoutCommand();
 
409
 
 
410
    inline QList<QWidget*> widgets() const
 
411
    { return m_widgets; }
 
412
 
 
413
    void init(const QList<QWidget*> &widgets, QWidget *layoutBase);
 
414
 
 
415
    virtual void redo();
 
416
    virtual void undo();
 
417
 
 
418
private:
 
419
    QList<QWidget*> m_widgets;
 
420
    QPointer<QWidget> m_layoutBase;
 
421
    QPointer<Layout> m_layout;
 
422
    int m_margin;
 
423
    int m_spacing;
 
424
};
 
425
 
 
426
class QT_SHARED_EXPORT ToolBoxCommand: public QDesignerFormWindowCommand
 
427
{
 
428
    Q_OBJECT
 
429
public:
 
430
    ToolBoxCommand(QDesignerFormWindowInterface *formWindow);
 
431
    virtual ~ToolBoxCommand();
 
432
 
 
433
    void init(QToolBox *toolBox);
 
434
 
 
435
    virtual void removePage();
 
436
    virtual void addPage();
 
437
 
 
438
protected:
 
439
    QPointer<QToolBox> m_toolBox;
 
440
    QPointer<QWidget> m_widget;
 
441
    int m_index;
 
442
    QString m_itemText;
 
443
    QIcon m_itemIcon;
 
444
};
 
445
 
 
446
class QT_SHARED_EXPORT DeleteToolBoxPageCommand: public ToolBoxCommand
 
447
{
 
448
    Q_OBJECT
 
449
public:
 
450
    DeleteToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);
 
451
    virtual ~DeleteToolBoxPageCommand();
 
452
 
 
453
    void init(QToolBox *toolBox);
 
454
 
 
455
    virtual void redo();
 
456
    virtual void undo();
 
457
};
 
458
 
 
459
class QT_SHARED_EXPORT AddToolBoxPageCommand: public ToolBoxCommand
 
460
{
 
461
    Q_OBJECT
 
462
public:
 
463
    AddToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);
 
464
    virtual ~AddToolBoxPageCommand();
 
465
 
 
466
    void init(QToolBox *toolBox);
 
467
 
 
468
    virtual void redo();
 
469
    virtual void undo();
 
470
};
 
471
 
 
472
class QT_SHARED_EXPORT TabWidgetCommand: public QDesignerFormWindowCommand
 
473
{
 
474
    Q_OBJECT
 
475
public:
 
476
    TabWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
477
    virtual ~TabWidgetCommand();
 
478
 
 
479
    void init(QTabWidget *tabWidget);
 
480
 
 
481
    virtual void removePage();
 
482
    virtual void addPage();
 
483
 
 
484
protected:
 
485
    QPointer<QTabWidget> m_tabWidget;
 
486
    QPointer<QWidget> m_widget;
 
487
    int m_index;
 
488
    QString m_itemText;
 
489
    QIcon m_itemIcon;
 
490
};
 
491
 
 
492
class QT_SHARED_EXPORT DeleteTabPageCommand: public TabWidgetCommand
 
493
{
 
494
    Q_OBJECT
 
495
public:
 
496
    DeleteTabPageCommand(QDesignerFormWindowInterface *formWindow);
 
497
    virtual ~DeleteTabPageCommand();
 
498
 
 
499
    void init(QTabWidget *tabWidget);
 
500
 
 
501
    virtual void redo();
 
502
    virtual void undo();
 
503
};
 
504
 
 
505
class QT_SHARED_EXPORT AddTabPageCommand: public TabWidgetCommand
 
506
{
 
507
    Q_OBJECT
 
508
public:
 
509
    AddTabPageCommand(QDesignerFormWindowInterface *formWindow);
 
510
    virtual ~AddTabPageCommand();
 
511
 
 
512
    void init(QTabWidget *tabWidget);
 
513
 
 
514
    virtual void redo();
 
515
    virtual void undo();
 
516
};
 
517
 
 
518
class QT_SHARED_EXPORT MoveTabPageCommand: public TabWidgetCommand
 
519
{
 
520
    Q_OBJECT
 
521
public:
 
522
    MoveTabPageCommand(QDesignerFormWindowInterface *formWindow);
 
523
    virtual ~MoveTabPageCommand();
 
524
 
 
525
    void init(QTabWidget *tabWidget, QWidget *page,
 
526
                      const QIcon &icon, const QString &label,
 
527
                      int index, int newIndex);
 
528
 
 
529
    virtual void redo();
 
530
    virtual void undo();
 
531
 
 
532
private:
 
533
    int m_newIndex;
 
534
    int m_oldIndex;
 
535
    QPointer<QWidget> m_page;
 
536
    QString m_label;
 
537
    QIcon m_icon;
 
538
};
 
539
 
 
540
class QT_SHARED_EXPORT StackedWidgetCommand: public QDesignerFormWindowCommand
 
541
{
 
542
    Q_OBJECT
 
543
public:
 
544
    StackedWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
545
    virtual ~StackedWidgetCommand();
 
546
 
 
547
    void init(QStackedWidget *stackedWidget);
 
548
 
 
549
    virtual void removePage();
 
550
    virtual void addPage();
 
551
 
 
552
protected:
 
553
    QPointer<QStackedWidget> m_stackedWidget;
 
554
    QPointer<QWidget> m_widget;
 
555
    int m_index;
 
556
};
 
557
 
 
558
class QT_SHARED_EXPORT DeleteStackedWidgetPageCommand: public StackedWidgetCommand
 
559
{
 
560
    Q_OBJECT
 
561
public:
 
562
    DeleteStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow);
 
563
    virtual ~DeleteStackedWidgetPageCommand();
 
564
 
 
565
    void init(QStackedWidget *stackedWidget);
 
566
 
 
567
    virtual void redo();
 
568
    virtual void undo();
 
569
};
 
570
 
 
571
class QT_SHARED_EXPORT AddStackedWidgetPageCommand: public StackedWidgetCommand
 
572
{
 
573
    Q_OBJECT
 
574
public:
 
575
    AddStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow);
 
576
    virtual ~AddStackedWidgetPageCommand();
 
577
 
 
578
    void init(QStackedWidget *stackedWidget);
 
579
 
 
580
    virtual void redo();
 
581
    virtual void undo();
 
582
};
 
583
 
 
584
class QT_SHARED_EXPORT DockWidgetCommand: public QDesignerFormWindowCommand
 
585
{
 
586
    Q_OBJECT
 
587
public:
 
588
    DockWidgetCommand(const QString &description, QDesignerFormWindowInterface *formWindow);
 
589
    virtual ~DockWidgetCommand();
 
590
 
 
591
    void init(QDockWidget *dockWidget);
 
592
 
 
593
protected:
 
594
    QPointer<QDockWidget> m_dockWidget;
 
595
};
 
596
 
 
597
class QT_SHARED_EXPORT SetDockWidgetCommand: public DockWidgetCommand
 
598
{
 
599
    Q_OBJECT
 
600
public:
 
601
    SetDockWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
602
 
 
603
    void init(QDockWidget *dockWidget, QWidget *widget);
 
604
 
 
605
    virtual void undo();
 
606
    virtual void redo();
 
607
 
 
608
private:
 
609
    QPointer<QWidget> m_widget;
 
610
    QPointer<QWidget> m_oldWidget;
 
611
};
 
612
 
 
613
class QT_SHARED_EXPORT AddDockWidgetCommand: public QDesignerFormWindowCommand
 
614
{
 
615
    Q_OBJECT
 
616
public:
 
617
    AddDockWidgetCommand(QDesignerFormWindowInterface *formWindow);
 
618
 
 
619
    void init(QMainWindow *mainWindow, QDockWidget *dockWidget);
 
620
 
 
621
    virtual void undo();
 
622
    virtual void redo();
 
623
 
 
624
private:
 
625
    QPointer<QMainWindow> m_mainWindow;
 
626
    QPointer<QDockWidget> m_dockWidget;
 
627
};
 
628
 
 
629
#endif // QDESIGNER_COMMAND_H