tools/designer/src/lib/shared/qdesigner_command_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the Qt Designer of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 //
00025 //  W A R N I N G
00026 //  -------------
00027 //
00028 // This file is not part of the Qt API.  It exists for the convenience
00029 // of Qt Designer.  This header
00030 // file may change from version to version without notice, or even be removed.
00031 //
00032 // We mean it.
00033 //
00034 
00035 #ifndef QDESIGNER_COMMAND_H
00036 #define QDESIGNER_COMMAND_H
00037 
00038 #include "shared_global_p.h"
00039 #include "layoutinfo_p.h"
00040 
00041 #include <QtDesigner/layoutdecoration.h>
00042 
00043 #include <QtGui/QUndoCommand>
00044 #include <QtGui/QIcon>
00045 
00046 #include <QtCore/QObject>
00047 #include <QtCore/QPointer>
00048 #include <QtCore/QPair>
00049 #include <QtCore/QVariant>
00050 
00051 class QDesignerFormEditorInterface;
00052 class QDesignerFormWindowManagerInterface;
00053 class QDesignerFormWindowInterface;
00054 class QDesignerWidgetDataBaseItemInterface;
00055 
00056 class QDesignerContainerExtension;
00057 class QDesignerPropertySheetExtension;
00058 class QDesignerMetaDataBaseItemInterface;
00059 
00060 class QDesignerMenu;
00061 
00062 class QMenuBar;
00063 class QStatusBar;
00064 class QToolBar;
00065 class QToolBox;
00066 class QTabWidget;
00067 class QTableWidget;
00068 class QTreeWidget;
00069 class QTreeWidgetItem;
00070 class QListWidget;
00071 class QComboBox;
00072 class QStackedWidget;
00073 class QDockWidget;
00074 class QMainWindow;
00075 
00076 namespace qdesigner_internal {
00077 
00078 class QDesignerPromotedWidget;
00079 class Layout;
00080 
00081 class QDESIGNER_SHARED_EXPORT QDesignerFormEditorCommand: public QUndoCommand
00082 {
00083 
00084 public:
00085     QDesignerFormEditorCommand(const QString &description, QDesignerFormEditorInterface *core);
00086 
00087     QDesignerFormEditorInterface *core() const;
00088 
00089 private:
00090     QPointer<QDesignerFormEditorInterface> m_core;
00091 };
00092 
00093 class QDESIGNER_SHARED_EXPORT QDesignerFormWindowManagerCommand: public QUndoCommand
00094 {
00095 
00096 public:
00097     QDesignerFormWindowManagerCommand(const QString &description, QDesignerFormWindowManagerInterface *formWindowManager);
00098 
00099     QDesignerFormWindowManagerInterface *formWindowManager() const;
00100 
00101 private:
00102     QPointer<QDesignerFormWindowManagerInterface> m_formWindowManager;
00103 };
00104 
00105 class QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand: public QUndoCommand
00106 {
00107 
00108 public:
00109     QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow);
00110 
00111     QDesignerFormWindowInterface *formWindow() const;
00112     QDesignerFormEditorInterface *core() const;
00113 
00114     virtual void undo();
00115     virtual void redo();
00116 
00117 protected:
00118     void checkObjectName(QObject *object);
00119     void updateBuddies(const QString &old_name, const QString &new_name);
00120     void checkSelection(QWidget *widget);
00121     void checkParent(QWidget *widget, QWidget *parentWidget);
00122     bool hasLayout(QWidget *widget) const;
00123 
00124     void cheapUpdate();
00125 
00126 private:
00127     QPointer<QDesignerFormWindowInterface> m_formWindow;
00128 };
00129 
00130 class QDESIGNER_SHARED_EXPORT SetPropertyCommand: public QDesignerFormWindowCommand
00131 {
00132 
00133 public:
00134     SetPropertyCommand(QDesignerFormWindowInterface *formWindow);
00135 
00136     void init(QObject *object, const QString &propertyName, const QVariant &newValue);
00137 
00138     QObject *object() const;
00139 
00140     QWidget *widget() const;
00141     QWidget *parentWidget() const;
00142 
00143     inline QString propertyName() const
00144     { return m_propertyName; }
00145 
00146     inline QVariant oldValue() const
00147     { return m_oldValue; }
00148 
00149     inline void setOldValue(const QVariant &oldValue)
00150     { m_oldValue = oldValue; }
00151 
00152     inline QVariant newValue() const
00153     { return m_newValue; }
00154 
00155     inline void setNewValue(const QVariant &newValue)
00156     { m_newValue = newValue; }
00157 
00158     virtual void redo();
00159     virtual void undo();
00160 
00161     virtual int id() const;
00162     virtual bool mergeWith(const QUndoCommand *other);
00163 
00164 private:
00165     QString m_propertyName;
00166     int m_index;
00167     QPointer<QObject> m_object;
00168     QPointer<QWidget> m_parentWidget;
00169     QDesignerPropertySheetExtension *m_propertySheet;
00170     QVariant m_oldValue;
00171     QVariant m_newValue;
00172     bool m_changed;
00173 };
00174 
00175 class QDESIGNER_SHARED_EXPORT SetFormPropertyCommand: public QDesignerFormWindowCommand
00176 {
00177 
00178 public:
00179     SetFormPropertyCommand(QDesignerFormWindowInterface *formWindow);
00180 
00181     void init(QObject *object, const QString &propertyName, const QVariant &newValue);
00182 
00183     inline QString propertyName() const
00184     { return m_propertyName; }
00185 
00186     inline QVariant oldValue() const
00187     { return m_oldValue; }
00188 
00189     inline void setOldValue(const QVariant &oldValue)
00190     { m_oldValue = oldValue; }
00191 
00192     inline QVariant newValue() const
00193     { return m_newValue; }
00194 
00195     inline void setNewValue(const QVariant &newValue)
00196     { m_newValue = newValue; }
00197 
00198     virtual void redo();
00199     virtual void undo();
00200 
00201     virtual int id() const;
00202     virtual bool mergeWith(const QUndoCommand *other);
00203 
00204 private:
00205     QWidget* containerWindow(QWidget *widget);
00206     void updateFormWindowGeometry(const QVariant &value);
00207 
00208 private:
00209     int m_index;
00210     bool m_changed;
00211     QDesignerPropertySheetExtension *m_propertySheet;
00212     QString m_propertyName;
00213     QVariant m_oldValue;
00214     QVariant m_newValue;
00215 };
00216 
00217 class QDESIGNER_SHARED_EXPORT ResetPropertyCommand: public QDesignerFormWindowCommand
00218 {
00219 
00220 public:
00221     ResetPropertyCommand(QDesignerFormWindowInterface *formWindow);
00222 
00223     void init(QObject *object, const QString &propertyName);
00224 
00225     QObject *object() const;
00226     QObject *parentObject() const;
00227 
00228     inline QString propertyName() const
00229     { return m_propertyName; }
00230 
00231     inline QVariant oldValue() const
00232     { return m_oldValue; }
00233 
00234     inline void setOldValue(const QVariant &oldValue)
00235     { m_oldValue = oldValue; }
00236 
00237     virtual void redo();
00238     virtual void undo();
00239 
00240 protected:
00241     virtual bool mergeWith(const QUndoCommand *other) { Q_UNUSED(other); return false; }
00242 
00243 private:
00244     QString m_propertyName;
00245     int m_index;
00246     QPointer<QObject> m_object;
00247     QPointer<QObject> m_parentObject;
00248     QDesignerPropertySheetExtension *m_propertySheet;
00249     QVariant m_oldValue;
00250     bool m_changed;
00251 };
00252 
00253 class QDESIGNER_SHARED_EXPORT InsertWidgetCommand: public QDesignerFormWindowCommand
00254 {
00255 
00256 public:
00257     InsertWidgetCommand(QDesignerFormWindowInterface *formWindow);
00258 
00259     void init(QWidget *widget, bool already_in_form = false);
00260 
00261     virtual void redo();
00262     virtual void undo();
00263 
00264 private:
00265     QPointer<QWidget> m_widget;
00266     QDesignerLayoutDecorationExtension::InsertMode m_insertMode;
00267     QPair<int, int> m_cell;
00268     bool m_widgetWasManaged;
00269 };
00270 
00271 class QDESIGNER_SHARED_EXPORT RaiseWidgetCommand: public QDesignerFormWindowCommand
00272 {
00273 
00274 public:
00275     RaiseWidgetCommand(QDesignerFormWindowInterface *formWindow);
00276 
00277     void init(QWidget *widget);
00278 
00279     virtual void redo();
00280     virtual void undo();
00281 
00282 private:
00283     QPointer<QWidget> m_widget;
00284 };
00285 
00286 class QDESIGNER_SHARED_EXPORT LowerWidgetCommand: public QDesignerFormWindowCommand
00287 {
00288 
00289 public:
00290     LowerWidgetCommand(QDesignerFormWindowInterface *formWindow);
00291 
00292     void init(QWidget *widget);
00293 
00294     virtual void redo();
00295     virtual void undo();
00296 
00297 private:
00298     QPointer<QWidget> m_widget;
00299 };
00300 
00301 class QDESIGNER_SHARED_EXPORT AdjustWidgetSizeCommand: public QDesignerFormWindowCommand
00302 {
00303 
00304 public:
00305     AdjustWidgetSizeCommand(QDesignerFormWindowInterface *formWindow);
00306 
00307     void init(QWidget *widget);
00308 
00309     virtual void redo();
00310     virtual void undo();
00311 
00312 private:
00313     QPointer<QWidget> m_widget;
00314     QRect m_geometry;
00315 };
00316 
00317 class QDESIGNER_SHARED_EXPORT DeleteWidgetCommand: public QDesignerFormWindowCommand
00318 {
00319 
00320 public:
00321     DeleteWidgetCommand(QDesignerFormWindowInterface *formWindow);
00322 
00323     void init(QWidget *widget);
00324 
00325     virtual void redo();
00326     virtual void undo();
00327 
00328 private:
00329     QPointer<QWidget> m_widget;
00330     QPointer<QWidget> m_parentWidget;
00331     QRect m_geometry;
00332     LayoutInfo::Type m_layoutType;
00333     int m_index;
00334     int m_row, m_col;
00335     int m_rowspan, m_colspan;
00336     QDesignerMetaDataBaseItemInterface *m_formItem;
00337     int m_tabOrderIndex;
00338     QList<QPointer<QWidget> > m_managedChildren;
00339 };
00340 
00341 class QDESIGNER_SHARED_EXPORT ReparentWidgetCommand: public QDesignerFormWindowCommand
00342 {
00343 
00344 public:
00345     ReparentWidgetCommand(QDesignerFormWindowInterface *formWindow);
00346 
00347     void init(QWidget *widget, QWidget *parentWidget);
00348 
00349     virtual void redo();
00350     virtual void undo();
00351 
00352 private:
00353     QPointer<QWidget> m_widget;
00354     QPoint m_oldPos;
00355     QPoint m_newPos;
00356     QPointer<QWidget> m_oldParentWidget;
00357     QPointer<QWidget> m_newParentWidget;
00358 };
00359 
00360 class QDESIGNER_SHARED_EXPORT ChangeLayoutItemGeometry: public QDesignerFormWindowCommand
00361 {
00362 
00363 public:
00364     ChangeLayoutItemGeometry(QDesignerFormWindowInterface *formWindow);
00365 
00366     void init(QWidget *widget, int row, int column, int rowspan, int colspan);
00367 
00368     virtual void redo();
00369     virtual void undo();
00370 
00371 protected:
00372     void changeItemPosition(const QRect &g);
00373 
00374 private:
00375     QPointer<QWidget> m_widget;
00376     QRect m_oldInfo;
00377     QRect m_newInfo;
00378 };
00379 
00380 class QDESIGNER_SHARED_EXPORT InsertRowCommand: public QDesignerFormWindowCommand
00381 {
00382 
00383 public:
00384     InsertRowCommand(QDesignerFormWindowInterface *formWindow);
00385 
00386     void init(QWidget *widget, int row);
00387 
00388     virtual void redo();
00389     virtual void undo();
00390 
00391 private:
00392     QPointer<QWidget> m_widget;
00393     int m_row;
00394 };
00395 
00396 
00397 class QDESIGNER_SHARED_EXPORT TabOrderCommand: public QDesignerFormWindowCommand
00398 {
00399 
00400 public:
00401     TabOrderCommand(QDesignerFormWindowInterface *formWindow);
00402 
00403     void init(const QList<QWidget*> &newTabOrder);
00404 
00405     inline QList<QWidget*> oldTabOrder() const
00406     { return m_oldTabOrder; }
00407 
00408     inline QList<QWidget*> newTabOrder() const
00409     { return m_newTabOrder; }
00410 
00411     virtual void redo();
00412     virtual void undo();
00413 
00414 private:
00415     QDesignerMetaDataBaseItemInterface *m_widgetItem;
00416     QList<QWidget*> m_oldTabOrder;
00417     QList<QWidget*> m_newTabOrder;
00418 };
00419 
00420 class QDESIGNER_SHARED_EXPORT PromoteToCustomWidgetCommand : public QDesignerFormWindowCommand
00421 {
00422 public:
00423     PromoteToCustomWidgetCommand(QDesignerFormWindowInterface *formWindow);
00424     void init(QDesignerWidgetDataBaseItemInterface *item, QWidget *widget);
00425     virtual void redo();
00426     virtual void undo();
00427 private:
00428     QWidget *m_widget;
00429     QDesignerPromotedWidget *m_promoted;
00430     friend class DemoteFromCustomWidgetCommand;
00431 };
00432 
00433 class QDESIGNER_SHARED_EXPORT DemoteFromCustomWidgetCommand : public QDesignerFormWindowCommand
00434 {
00435 public:
00436     DemoteFromCustomWidgetCommand(QDesignerFormWindowInterface *formWindow);
00437     void init(QDesignerPromotedWidget *promoted);
00438     virtual void redo();
00439     virtual void undo();
00440 private:
00441     PromoteToCustomWidgetCommand *m_promote_cmd;
00442 };
00443 
00444 class QDESIGNER_SHARED_EXPORT LayoutCommand: public QDesignerFormWindowCommand
00445 {
00446 
00447 public:
00448     LayoutCommand(QDesignerFormWindowInterface *formWindow);
00449     virtual ~LayoutCommand();
00450 
00451     inline QList<QWidget*> widgets() const
00452     { return m_widgets; }
00453 
00454     void init(QWidget *parentWidget, const QList<QWidget*> &widgets, LayoutInfo::Type layoutType,
00455         QWidget *layoutBase = 0, bool splitter = false);
00456 
00457     virtual void redo();
00458     virtual void undo();
00459 
00460 private:
00461     QPointer<QWidget> m_parentWidget;
00462     QList<QWidget*> m_widgets;
00463     QPointer<QWidget> m_layoutBase;
00464     QPointer<Layout> m_layout;
00465 };
00466 
00467 class QDESIGNER_SHARED_EXPORT BreakLayoutCommand: public QDesignerFormWindowCommand
00468 {
00469 
00470 public:
00471     BreakLayoutCommand(QDesignerFormWindowInterface *formWindow);
00472     virtual ~BreakLayoutCommand();
00473 
00474     inline QList<QWidget*> widgets() const
00475     { return m_widgets; }
00476 
00477     void init(const QList<QWidget*> &widgets, QWidget *layoutBase);
00478 
00479     virtual void redo();
00480     virtual void undo();
00481 
00482 private:
00483     QList<QWidget*> m_widgets;
00484     QPointer<QWidget> m_layoutBase;
00485     QPointer<Layout> m_layout;
00486     int m_margin;
00487     int m_spacing;
00488 };
00489 
00490 class QDESIGNER_SHARED_EXPORT ToolBoxCommand: public QDesignerFormWindowCommand
00491 {
00492 
00493 public:
00494     ToolBoxCommand(QDesignerFormWindowInterface *formWindow);
00495     virtual ~ToolBoxCommand();
00496 
00497     void init(QToolBox *toolBox);
00498 
00499     virtual void removePage();
00500     virtual void addPage();
00501 
00502 protected:
00503     QPointer<QToolBox> m_toolBox;
00504     QPointer<QWidget> m_widget;
00505     int m_index;
00506     QString m_itemText;
00507     QIcon m_itemIcon;
00508 };
00509 
00510 class QDESIGNER_SHARED_EXPORT MoveToolBoxPageCommand: public ToolBoxCommand
00511 {
00512 
00513 public:
00514     MoveToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);
00515     virtual ~MoveToolBoxPageCommand();
00516 
00517     void init(QToolBox *toolBox, QWidget *page, int newIndex);
00518 
00519     virtual void redo();
00520     virtual void undo();
00521 
00522 private:
00523     int m_newIndex;
00524     int m_oldIndex;
00525 };
00526 
00527 class QDESIGNER_SHARED_EXPORT DeleteToolBoxPageCommand: public ToolBoxCommand
00528 {
00529 
00530 public:
00531     DeleteToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);
00532     virtual ~DeleteToolBoxPageCommand();
00533 
00534     void init(QToolBox *toolBox);
00535 
00536     virtual void redo();
00537     virtual void undo();
00538 };
00539 
00540 class QDESIGNER_SHARED_EXPORT AddToolBoxPageCommand: public ToolBoxCommand
00541 {
00542 
00543 public:
00544     enum InsertionMode {
00545         InsertBefore,
00546         InsertAfter
00547     };
00548     AddToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);
00549     virtual ~AddToolBoxPageCommand();
00550 
00551     void init(QToolBox *toolBox);
00552     void init(QToolBox *toolBox, InsertionMode mode);
00553 
00554     virtual void redo();
00555     virtual void undo();
00556 };
00557 
00558 class QDESIGNER_SHARED_EXPORT TabWidgetCommand: public QDesignerFormWindowCommand
00559 {
00560 
00561 public:
00562     TabWidgetCommand(QDesignerFormWindowInterface *formWindow);
00563     virtual ~TabWidgetCommand();
00564 
00565     void init(QTabWidget *tabWidget);
00566 
00567     virtual void removePage();
00568     virtual void addPage();
00569 
00570 protected:
00571     QPointer<QTabWidget> m_tabWidget;
00572     QPointer<QWidget> m_widget;
00573     int m_index;
00574     QString m_itemText;
00575     QIcon m_itemIcon;
00576 };
00577 
00578 class QDESIGNER_SHARED_EXPORT DeleteTabPageCommand: public TabWidgetCommand
00579 {
00580 
00581 public:
00582     DeleteTabPageCommand(QDesignerFormWindowInterface *formWindow);
00583     virtual ~DeleteTabPageCommand();
00584 
00585     void init(QTabWidget *tabWidget);
00586 
00587     virtual void redo();
00588     virtual void undo();
00589 };
00590 
00591 class QDESIGNER_SHARED_EXPORT AddTabPageCommand: public TabWidgetCommand
00592 {
00593 
00594 public:
00595     enum InsertionMode {
00596         InsertBefore,
00597         InsertAfter
00598     };
00599     AddTabPageCommand(QDesignerFormWindowInterface *formWindow);
00600     virtual ~AddTabPageCommand();
00601 
00602     void init(QTabWidget *tabWidget);
00603     void init(QTabWidget *tabWidget, InsertionMode mode);
00604 
00605     virtual void redo();
00606     virtual void undo();
00607 };
00608 
00609 class QDESIGNER_SHARED_EXPORT MoveTabPageCommand: public TabWidgetCommand
00610 {
00611 
00612 public:
00613     MoveTabPageCommand(QDesignerFormWindowInterface *formWindow);
00614     virtual ~MoveTabPageCommand();
00615 
00616     void init(QTabWidget *tabWidget, QWidget *page,
00617                       const QIcon &icon, const QString &label,
00618                       int index, int newIndex);
00619 
00620     virtual void redo();
00621     virtual void undo();
00622 
00623 private:
00624     int m_newIndex;
00625     int m_oldIndex;
00626     QPointer<QWidget> m_page;
00627     QString m_label;
00628     QIcon m_icon;
00629 };
00630 
00631 class QDESIGNER_SHARED_EXPORT StackedWidgetCommand: public QDesignerFormWindowCommand
00632 {
00633 
00634 public:
00635     StackedWidgetCommand(QDesignerFormWindowInterface *formWindow);
00636     virtual ~StackedWidgetCommand();
00637 
00638     void init(QStackedWidget *stackedWidget);
00639 
00640     virtual void removePage();
00641     virtual void addPage();
00642 
00643 protected:
00644     QPointer<QStackedWidget> m_stackedWidget;
00645     QPointer<QWidget> m_widget;
00646     int m_index;
00647 };
00648 
00649 class QDESIGNER_SHARED_EXPORT MoveStackedWidgetCommand: public StackedWidgetCommand
00650 {
00651 
00652 public:
00653     MoveStackedWidgetCommand(QDesignerFormWindowInterface *formWindow);
00654     virtual ~MoveStackedWidgetCommand();
00655 
00656     void init(QStackedWidget *stackedWidget, QWidget *page, int newIndex);
00657 
00658     virtual void redo();
00659     virtual void undo();
00660 
00661 private:
00662     int m_newIndex;
00663     int m_oldIndex;
00664 };
00665 
00666 class QDESIGNER_SHARED_EXPORT DeleteStackedWidgetPageCommand: public StackedWidgetCommand
00667 {
00668 
00669 public:
00670     DeleteStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow);
00671     virtual ~DeleteStackedWidgetPageCommand();
00672 
00673     void init(QStackedWidget *stackedWidget);
00674 
00675     virtual void redo();
00676     virtual void undo();
00677 };
00678 
00679 class QDESIGNER_SHARED_EXPORT AddStackedWidgetPageCommand: public StackedWidgetCommand
00680 {
00681 
00682 public:
00683     enum InsertionMode {
00684         InsertBefore,
00685         InsertAfter
00686     };
00687     AddStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow);
00688     virtual ~AddStackedWidgetPageCommand();
00689 
00690     void init(QStackedWidget *stackedWidget);
00691     void init(QStackedWidget *stackedWidget, InsertionMode mode);
00692 
00693     virtual void redo();
00694     virtual void undo();
00695 };
00696 
00697 class QDESIGNER_SHARED_EXPORT CreateMenuBarCommand: public QDesignerFormWindowCommand
00698 {
00699 
00700 public:
00701     CreateMenuBarCommand(QDesignerFormWindowInterface *formWindow);
00702 
00703     void init(QMainWindow *mainWindow);
00704 
00705     virtual void undo();
00706     virtual void redo();
00707 
00708 private:
00709     QPointer<QMainWindow> m_mainWindow;
00710     QPointer<QMenuBar> m_menuBar;
00711 };
00712 
00713 class QDESIGNER_SHARED_EXPORT DeleteMenuBarCommand: public QDesignerFormWindowCommand
00714 {
00715 
00716 public:
00717     DeleteMenuBarCommand(QDesignerFormWindowInterface *formWindow);
00718 
00719     void init(QMenuBar *menuBar);
00720 
00721     virtual void undo();
00722     virtual void redo();
00723 
00724 private:
00725     QPointer<QMainWindow> m_mainWindow;
00726     QPointer<QMenuBar> m_menuBar;
00727 };
00728 
00729 class QDESIGNER_SHARED_EXPORT CreateStatusBarCommand: public QDesignerFormWindowCommand
00730 {
00731 
00732 public:
00733     CreateStatusBarCommand(QDesignerFormWindowInterface *formWindow);
00734 
00735     void init(QMainWindow *mainWindow);
00736 
00737     virtual void undo();
00738     virtual void redo();
00739 
00740 private:
00741     QPointer<QMainWindow> m_mainWindow;
00742     QPointer<QStatusBar> m_statusBar;
00743 };
00744 
00745 class QDESIGNER_SHARED_EXPORT DeleteStatusBarCommand: public QDesignerFormWindowCommand
00746 {
00747 
00748 public:
00749     DeleteStatusBarCommand(QDesignerFormWindowInterface *formWindow);
00750 
00751     void init(QStatusBar *statusBar);
00752 
00753     virtual void undo();
00754     virtual void redo();
00755 
00756 private:
00757     QPointer<QMainWindow> m_mainWindow;
00758     QPointer<QStatusBar> m_statusBar;
00759 };
00760 
00761 class QDESIGNER_SHARED_EXPORT AddToolBarCommand: public QDesignerFormWindowCommand
00762 {
00763 
00764 public:
00765     AddToolBarCommand(QDesignerFormWindowInterface *formWindow);
00766 
00767     void init(QMainWindow *mainWindow);
00768 
00769     virtual void undo();
00770     virtual void redo();
00771 
00772 private:
00773     QPointer<QMainWindow> m_mainWindow;
00774     QPointer<QToolBar> m_toolBar;
00775 };
00776 
00777 class QDESIGNER_SHARED_EXPORT DeleteToolBarCommand: public QDesignerFormWindowCommand
00778 {
00779 
00780 public:
00781     DeleteToolBarCommand(QDesignerFormWindowInterface *formWindow);
00782 
00783     void init(QToolBar *toolBar);
00784 
00785     virtual void undo();
00786     virtual void redo();
00787 
00788 private:
00789     QPointer<QMainWindow> m_mainWindow;
00790     QPointer<QToolBar> m_toolBar;
00791 };
00792 
00793 class QDESIGNER_SHARED_EXPORT DockWidgetCommand: public QDesignerFormWindowCommand
00794 {
00795 
00796 public:
00797     DockWidgetCommand(const QString &description, QDesignerFormWindowInterface *formWindow);
00798     virtual ~DockWidgetCommand();
00799 
00800     void init(QDockWidget *dockWidget);
00801 
00802 protected:
00803     QPointer<QDockWidget> m_dockWidget;
00804 };
00805 
00806 class QDESIGNER_SHARED_EXPORT SetDockWidgetCommand: public DockWidgetCommand
00807 {
00808 
00809 public:
00810     SetDockWidgetCommand(QDesignerFormWindowInterface *formWindow);
00811 
00812     void init(QDockWidget *dockWidget, QWidget *widget);
00813 
00814     virtual void undo();
00815     virtual void redo();
00816 
00817 private:
00818     QPointer<QWidget> m_widget;
00819     QPointer<QWidget> m_oldWidget;
00820 };
00821 
00822 class QDESIGNER_SHARED_EXPORT AddDockWidgetCommand: public QDesignerFormWindowCommand
00823 {
00824 
00825 public:
00826     AddDockWidgetCommand(QDesignerFormWindowInterface *formWindow);
00827 
00828     void init(QMainWindow *mainWindow, QDockWidget *dockWidget);
00829     void init(QMainWindow *mainWindow);
00830 
00831     virtual void undo();
00832     virtual void redo();
00833 
00834 private:
00835     QPointer<QMainWindow> m_mainWindow;
00836     QPointer<QDockWidget> m_dockWidget;
00837 };
00838 
00839 class QDESIGNER_SHARED_EXPORT ContainerWidgetCommand: public QDesignerFormWindowCommand
00840 {
00841 
00842 public:
00843     ContainerWidgetCommand(QDesignerFormWindowInterface *formWindow);
00844     virtual ~ContainerWidgetCommand();
00845 
00846     QDesignerContainerExtension *containerExtension() const;
00847 
00848     void init(QWidget *containerWidget);
00849 
00850     virtual void removePage();
00851     virtual void addPage();
00852 
00853 protected:
00854     QPointer<QWidget> m_containerWidget;
00855     QPointer<QWidget> m_widget;
00856     int m_index;
00857 };
00858 
00859 class QDESIGNER_SHARED_EXPORT DeleteContainerWidgetPageCommand: public ContainerWidgetCommand
00860 {
00861 
00862 public:
00863     DeleteContainerWidgetPageCommand(QDesignerFormWindowInterface *formWindow);
00864     virtual ~DeleteContainerWidgetPageCommand();
00865 
00866     void init(QWidget *containerWidget);
00867 
00868     virtual void redo();
00869     virtual void undo();
00870 };
00871 
00872 class QDESIGNER_SHARED_EXPORT AddContainerWidgetPageCommand: public ContainerWidgetCommand
00873 {
00874 
00875 public:
00876     enum InsertionMode {
00877         InsertBefore,
00878         InsertAfter
00879     };
00880     AddContainerWidgetPageCommand(QDesignerFormWindowInterface *formWindow);
00881     virtual ~AddContainerWidgetPageCommand();
00882 
00883     void init(QWidget *containerWidget);
00884     void init(QWidget *containerWidget, InsertionMode mode);
00885 
00886     virtual void redo();
00887     virtual void undo();
00888 };
00889 
00890 class QDESIGNER_SHARED_EXPORT ChangeTableContentsCommand: public QDesignerFormWindowCommand
00891 {
00892 
00893 public:
00894     ChangeTableContentsCommand(QDesignerFormWindowInterface *formWindow);
00895 
00896     void init(QTableWidget *tableWidget, QTableWidget *fromTableWidget);
00897     virtual void redo();
00898     virtual void undo();
00899 private:
00900     void changeContents(QTableWidget *tableWidget,
00901         int rowCount, int columnCount,
00902         const QMap<int, QPair<QString, QIcon> > &horizontalHeaderState,
00903         const QMap<int, QPair<QString, QIcon> > &verticalHeaderState,
00904         const QMap<QPair<int, int>, QPair<QString, QIcon> > &itemsState) const;
00905 
00906     QPointer<QTableWidget> m_tableWidget;
00907     QMap<QPair<int, int>, QPair<QString, QIcon> > m_oldItemsState;
00908     QMap<QPair<int, int>, QPair<QString, QIcon> > m_newItemsState;
00909     QMap<int, QPair<QString, QIcon> > m_oldHorizontalHeaderState;
00910     QMap<int, QPair<QString, QIcon> > m_newHorizontalHeaderState;
00911     QMap<int, QPair<QString, QIcon> > m_oldVerticalHeaderState;
00912     QMap<int, QPair<QString, QIcon> > m_newVerticalHeaderState;
00913     int m_oldColumnCount;
00914     int m_newColumnCount;
00915     int m_oldRowCount;
00916     int m_newRowCount;
00917 };
00918 
00919 class QDESIGNER_SHARED_EXPORT ChangeTreeContentsCommand: public QDesignerFormWindowCommand
00920 {
00921 
00922 public:
00923     ChangeTreeContentsCommand(QDesignerFormWindowInterface *formWindow);
00924     ~ChangeTreeContentsCommand();
00925 
00926     void init(QTreeWidget *treeWidget, QTreeWidget *fromTreeWidget);
00927     virtual void redo();
00928     virtual void undo();
00929 private:
00930     void initState(QList<QTreeWidgetItem *> &itemsState,
00931                 QTreeWidgetItem *&headerItemState, QTreeWidget *fromTreeWidget) const;
00932     void changeContents(QTreeWidget *treeWidget, int columnCount,
00933                 const QList<QTreeWidgetItem *> &itemsState,
00934                 const QTreeWidgetItem *headerItemState) const;
00935     void clearState(QList<QTreeWidgetItem *> &itemsState,
00936                 QTreeWidgetItem *&headerItemState) const;
00937 
00938     QPointer<QTreeWidget> m_treeWidget;
00939     QTreeWidgetItem *m_oldHeaderItemState;
00940     QTreeWidgetItem *m_newHeaderItemState;
00941     QList<QTreeWidgetItem *> m_oldItemsState;
00942     QList<QTreeWidgetItem *> m_newItemsState;
00943     int m_oldColumnCount;
00944     int m_newColumnCount;
00945 };
00946 
00947 class QDESIGNER_SHARED_EXPORT ChangeListContentsCommand: public QDesignerFormWindowCommand
00948 {
00949 
00950 public:
00951     ChangeListContentsCommand(QDesignerFormWindowInterface *formWindow);
00952 
00953     void init(QListWidget *listWidget, const QList<QPair<QString, QIcon> > &items);
00954     void init(QComboBox *comboBox, const QList<QPair<QString, QIcon> > &items);
00955     virtual void redo();
00956     virtual void undo();
00957 private:
00958     void changeContents(QListWidget *listWidget,
00959         const QList<QPair<QString, QIcon> > &itemsState) const;
00960     void changeContents(QComboBox *comboBox,
00961         const QList<QPair<QString, QIcon> > &itemsState) const;
00962 
00963     QPointer<QListWidget> m_listWidget;
00964     QPointer<QComboBox> m_comboBox;
00965     QList<QPair<QString, QIcon> > m_oldItemsState;
00966     QList<QPair<QString, QIcon> > m_newItemsState;
00967 };
00968 
00969 class QDESIGNER_SHARED_EXPORT AddActionCommand : public QDesignerFormWindowCommand
00970 {
00971 
00972 public:
00973     AddActionCommand(QDesignerFormWindowInterface *formWindow);
00974     void init(QAction *action);
00975     virtual void redo();
00976     virtual void undo();
00977 private:
00978     QAction *m_action;
00979 };
00980 
00981 class QDESIGNER_SHARED_EXPORT RemoveActionCommand : public QDesignerFormWindowCommand
00982 {
00983 
00984 public:
00985     RemoveActionCommand(QDesignerFormWindowInterface *formWindow);
00986     void init(QAction *action);
00987     virtual void redo();
00988     virtual void undo();
00989 
00990     struct ActionDataItem {
00991         ActionDataItem(QAction *_before = 0, QWidget *_widget = 0)
00992             : before(_before), widget(_widget) {}
00993         QAction *before;
00994         QWidget *widget;
00995     };
00996     typedef QList<ActionDataItem> ActionData;
00997 
00998 private:
00999     QAction *m_action;
01000 
01001     ActionData m_actionData;
01002 };
01003 
01004 class QDESIGNER_SHARED_EXPORT InsertActionIntoCommand : public QDesignerFormWindowCommand
01005 {
01006 
01007 public:
01008     InsertActionIntoCommand(QDesignerFormWindowInterface *formWindow);
01009 
01010     void init(QWidget *parentWidget, QAction *action, QAction *beforeAction, bool update = true);
01011     virtual void redo();
01012     virtual void undo();
01013 
01014 private:
01015     QWidget *m_parentWidget;
01016     QAction *m_action;
01017     QAction *m_beforeAction;
01018     bool m_update;
01019 };
01020 
01021 class QDESIGNER_SHARED_EXPORT RemoveActionFromCommand : public QDesignerFormWindowCommand
01022 {
01023 
01024 public:
01025     RemoveActionFromCommand(QDesignerFormWindowInterface *formWindow);
01026 
01027     void init(QWidget *parentWidget, QAction *action, QAction *beforeAction, bool update = true);
01028     virtual void redo();
01029     virtual void undo();
01030 
01031 private:
01032     QWidget *m_parentWidget;
01033     QAction *m_action;
01034     QAction *m_beforeAction;
01035     bool m_update;
01036 };
01037 
01038 class QDESIGNER_SHARED_EXPORT AddMenuActionCommand : public QDesignerFormWindowCommand
01039 {
01040 
01041 public:
01042     AddMenuActionCommand(QDesignerFormWindowInterface *formWindow);
01043     void init(QAction *action, QWidget *parent);
01044     virtual void redo();
01045     virtual void undo();
01046 private:
01047     QAction *m_action;
01048     QWidget *m_parent;
01049 };
01050 
01051 class QDESIGNER_SHARED_EXPORT RemoveMenuActionCommand : public QDesignerFormWindowCommand
01052 {
01053 
01054 public:
01055     RemoveMenuActionCommand(QDesignerFormWindowInterface *formWindow);
01056     void init(QAction *action, QWidget *parent);
01057     virtual void redo();
01058     virtual void undo();
01059 private:
01060     QAction *m_action;
01061     QWidget *m_parent;
01062 };
01063 
01064 class QDESIGNER_SHARED_EXPORT CreateSubmenuCommand : public QDesignerFormWindowCommand
01065 {
01066 
01067 public:
01068     CreateSubmenuCommand(QDesignerFormWindowInterface *formWindow);
01069     void init(QDesignerMenu *menu, QAction *action);
01070     virtual void redo();
01071     virtual void undo();
01072 private:
01073     QAction *m_action;
01074     QDesignerMenu *m_menu;
01075 };
01076 
01077 } // namespace qdesigner_internal
01078 
01079 #endif // QDESIGNER_COMMAND_H

Generated on Thu Mar 15 12:01:27 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1