qdesigner_command_p.h

来自「QT 开发环境里面一个很重要的文件」· C头文件 代码 · 共 1,080 行 · 第 1/2 页

H
1,080
字号
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the Qt Designer of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/////  W A R N I N G//  -------------//// This file is not part of the Qt API.  It exists for the convenience// of Qt Designer.  This header// file may change from version to version without notice, or even be removed.//// We mean it.//#ifndef QDESIGNER_COMMAND_H#define QDESIGNER_COMMAND_H#include "shared_global_p.h"#include "layoutinfo_p.h"#include <QtDesigner/layoutdecoration.h>#include <QtGui/QUndoCommand>#include <QtGui/QIcon>#include <QtCore/QObject>#include <QtCore/QPointer>#include <QtCore/QPair>#include <QtCore/QVariant>class QDesignerFormEditorInterface;class QDesignerFormWindowManagerInterface;class QDesignerFormWindowInterface;class QDesignerWidgetDataBaseItemInterface;class QDesignerContainerExtension;class QDesignerPropertySheetExtension;class QDesignerMetaDataBaseItemInterface;class QDesignerMenu;class QMenuBar;class QStatusBar;class QToolBar;class QToolBox;class QTabWidget;class QTableWidget;class QTreeWidget;class QTreeWidgetItem;class QListWidget;class QComboBox;class QStackedWidget;class QDockWidget;class QMainWindow;namespace qdesigner_internal {class QDesignerPromotedWidget;class Layout;class QDESIGNER_SHARED_EXPORT QDesignerFormEditorCommand: public QUndoCommand{public:    QDesignerFormEditorCommand(const QString &description, QDesignerFormEditorInterface *core);    QDesignerFormEditorInterface *core() const;private:    QPointer<QDesignerFormEditorInterface> m_core;};class QDESIGNER_SHARED_EXPORT QDesignerFormWindowManagerCommand: public QUndoCommand{public:    QDesignerFormWindowManagerCommand(const QString &description, QDesignerFormWindowManagerInterface *formWindowManager);    QDesignerFormWindowManagerInterface *formWindowManager() const;private:    QPointer<QDesignerFormWindowManagerInterface> m_formWindowManager;};class QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand: public QUndoCommand{public:    QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow);    QDesignerFormWindowInterface *formWindow() const;    QDesignerFormEditorInterface *core() const;    virtual void undo();    virtual void redo();protected:    void checkObjectName(QObject *object);    void updateBuddies(const QString &old_name, const QString &new_name);    void checkSelection(QWidget *widget);    void checkParent(QWidget *widget, QWidget *parentWidget);    bool hasLayout(QWidget *widget) const;    void cheapUpdate();private:    QPointer<QDesignerFormWindowInterface> m_formWindow;};class QDESIGNER_SHARED_EXPORT SetPropertyCommand: public QDesignerFormWindowCommand{public:    SetPropertyCommand(QDesignerFormWindowInterface *formWindow);    void init(QObject *object, const QString &propertyName, const QVariant &newValue);    QObject *object() const;    QWidget *widget() const;    QWidget *parentWidget() const;    inline QString propertyName() const    { return m_propertyName; }    inline QVariant oldValue() const    { return m_oldValue; }    inline void setOldValue(const QVariant &oldValue)    { m_oldValue = oldValue; }    inline QVariant newValue() const    { return m_newValue; }    inline void setNewValue(const QVariant &newValue)    { m_newValue = newValue; }    virtual void redo();    virtual void undo();    virtual int id() const;    virtual bool mergeWith(const QUndoCommand *other);private:    QString m_propertyName;    int m_index;    QPointer<QObject> m_object;    QPointer<QWidget> m_parentWidget;    QDesignerPropertySheetExtension *m_propertySheet;    QVariant m_oldValue;    QVariant m_newValue;    bool m_changed;};class QDESIGNER_SHARED_EXPORT SetFormPropertyCommand: public QDesignerFormWindowCommand{public:    SetFormPropertyCommand(QDesignerFormWindowInterface *formWindow);    void init(QObject *object, const QString &propertyName, const QVariant &newValue);    inline QString propertyName() const    { return m_propertyName; }    inline QVariant oldValue() const    { return m_oldValue; }    inline void setOldValue(const QVariant &oldValue)    { m_oldValue = oldValue; }    inline QVariant newValue() const    { return m_newValue; }    inline void setNewValue(const QVariant &newValue)    { m_newValue = newValue; }    virtual void redo();    virtual void undo();    virtual int id() const;    virtual bool mergeWith(const QUndoCommand *other);private:    QWidget* containerWindow(QWidget *widget);    void updateFormWindowGeometry(const QVariant &value);private:    int m_index;    bool m_changed;    QDesignerPropertySheetExtension *m_propertySheet;    QString m_propertyName;    QVariant m_oldValue;    QVariant m_newValue;};class QDESIGNER_SHARED_EXPORT ResetPropertyCommand: public QDesignerFormWindowCommand{public:    ResetPropertyCommand(QDesignerFormWindowInterface *formWindow);    void init(QObject *object, const QString &propertyName);    QObject *object() const;    QObject *parentObject() const;    inline QString propertyName() const    { return m_propertyName; }    inline QVariant oldValue() const    { return m_oldValue; }    inline void setOldValue(const QVariant &oldValue)    { m_oldValue = oldValue; }    virtual void redo();    virtual void undo();protected:    virtual bool mergeWith(const QUndoCommand *other) { Q_UNUSED(other); return false; }private:    QString m_propertyName;    int m_index;    QPointer<QObject> m_object;    QPointer<QObject> m_parentObject;    QDesignerPropertySheetExtension *m_propertySheet;    QVariant m_oldValue;    bool m_changed;};class QDESIGNER_SHARED_EXPORT InsertWidgetCommand: public QDesignerFormWindowCommand{public:    InsertWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget, bool already_in_form = false);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;    QDesignerLayoutDecorationExtension::InsertMode m_insertMode;    QPair<int, int> m_cell;    bool m_widgetWasManaged;};class QDESIGNER_SHARED_EXPORT RaiseWidgetCommand: public QDesignerFormWindowCommand{public:    RaiseWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;};class QDESIGNER_SHARED_EXPORT LowerWidgetCommand: public QDesignerFormWindowCommand{public:    LowerWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;};class QDESIGNER_SHARED_EXPORT AdjustWidgetSizeCommand: public QDesignerFormWindowCommand{public:    AdjustWidgetSizeCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;    QRect m_geometry;};class QDESIGNER_SHARED_EXPORT DeleteWidgetCommand: public QDesignerFormWindowCommand{public:    DeleteWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;    QPointer<QWidget> m_parentWidget;    QRect m_geometry;    LayoutInfo::Type m_layoutType;    int m_index;    int m_row, m_col;    int m_rowspan, m_colspan;    QDesignerMetaDataBaseItemInterface *m_formItem;    int m_tabOrderIndex;    QList<QPointer<QWidget> > m_managedChildren;};class QDESIGNER_SHARED_EXPORT ReparentWidgetCommand: public QDesignerFormWindowCommand{public:    ReparentWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget, QWidget *parentWidget);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;    QPoint m_oldPos;    QPoint m_newPos;    QPointer<QWidget> m_oldParentWidget;    QPointer<QWidget> m_newParentWidget;};class QDESIGNER_SHARED_EXPORT ChangeLayoutItemGeometry: public QDesignerFormWindowCommand{public:    ChangeLayoutItemGeometry(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget, int row, int column, int rowspan, int colspan);    virtual void redo();    virtual void undo();protected:    void changeItemPosition(const QRect &g);private:    QPointer<QWidget> m_widget;    QRect m_oldInfo;    QRect m_newInfo;};class QDESIGNER_SHARED_EXPORT InsertRowCommand: public QDesignerFormWindowCommand{public:    InsertRowCommand(QDesignerFormWindowInterface *formWindow);    void init(QWidget *widget, int row);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_widget;    int m_row;};class QDESIGNER_SHARED_EXPORT TabOrderCommand: public QDesignerFormWindowCommand{public:    TabOrderCommand(QDesignerFormWindowInterface *formWindow);    void init(const QList<QWidget*> &newTabOrder);    inline QList<QWidget*> oldTabOrder() const    { return m_oldTabOrder; }    inline QList<QWidget*> newTabOrder() const    { return m_newTabOrder; }    virtual void redo();    virtual void undo();private:    QDesignerMetaDataBaseItemInterface *m_widgetItem;    QList<QWidget*> m_oldTabOrder;    QList<QWidget*> m_newTabOrder;};class QDESIGNER_SHARED_EXPORT PromoteToCustomWidgetCommand : public QDesignerFormWindowCommand{public:    PromoteToCustomWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QDesignerWidgetDataBaseItemInterface *item, QWidget *widget);    virtual void redo();    virtual void undo();private:    QWidget *m_widget;    QDesignerPromotedWidget *m_promoted;    friend class DemoteFromCustomWidgetCommand;};class QDESIGNER_SHARED_EXPORT DemoteFromCustomWidgetCommand : public QDesignerFormWindowCommand{public:    DemoteFromCustomWidgetCommand(QDesignerFormWindowInterface *formWindow);    void init(QDesignerPromotedWidget *promoted);    virtual void redo();    virtual void undo();private:    PromoteToCustomWidgetCommand *m_promote_cmd;};class QDESIGNER_SHARED_EXPORT LayoutCommand: public QDesignerFormWindowCommand{public:    LayoutCommand(QDesignerFormWindowInterface *formWindow);    virtual ~LayoutCommand();    inline QList<QWidget*> widgets() const    { return m_widgets; }    void init(QWidget *parentWidget, const QList<QWidget*> &widgets, LayoutInfo::Type layoutType,        QWidget *layoutBase = 0, bool splitter = false);    virtual void redo();    virtual void undo();private:    QPointer<QWidget> m_parentWidget;    QList<QWidget*> m_widgets;    QPointer<QWidget> m_layoutBase;    QPointer<Layout> m_layout;};class QDESIGNER_SHARED_EXPORT BreakLayoutCommand: public QDesignerFormWindowCommand{public:    BreakLayoutCommand(QDesignerFormWindowInterface *formWindow);    virtual ~BreakLayoutCommand();    inline QList<QWidget*> widgets() const    { return m_widgets; }    void init(const QList<QWidget*> &widgets, QWidget *layoutBase);    virtual void redo();    virtual void undo();private:    QList<QWidget*> m_widgets;    QPointer<QWidget> m_layoutBase;    QPointer<Layout> m_layout;    int m_margin;    int m_spacing;};class QDESIGNER_SHARED_EXPORT ToolBoxCommand: public QDesignerFormWindowCommand{public:    ToolBoxCommand(QDesignerFormWindowInterface *formWindow);    virtual ~ToolBoxCommand();    void init(QToolBox *toolBox);    virtual void removePage();    virtual void addPage();protected:    QPointer<QToolBox> m_toolBox;    QPointer<QWidget> m_widget;    int m_index;    QString m_itemText;    QIcon m_itemIcon;};class QDESIGNER_SHARED_EXPORT MoveToolBoxPageCommand: public ToolBoxCommand{public:    MoveToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);    virtual ~MoveToolBoxPageCommand();    void init(QToolBox *toolBox, QWidget *page, int newIndex);    virtual void redo();    virtual void undo();private:    int m_newIndex;    int m_oldIndex;};class QDESIGNER_SHARED_EXPORT DeleteToolBoxPageCommand: public ToolBoxCommand{public:    DeleteToolBoxPageCommand(QDesignerFormWindowInterface *formWindow);    virtual ~DeleteToolBoxPageCommand();    void init(QToolBox *toolBox);    virtual void redo();    virtual void undo();};class QDESIGNER_SHARED_EXPORT AddToolBoxPageCommand: public ToolBoxCommand

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?