1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef ABSTRACTFORMWINDOW_H
43 #define ABSTRACTFORMWINDOW_H
44 
45 #include <QtDesigner/sdk_global.h>
46 
47 #include <QtGui/QWidget>
48 
49 QT_BEGIN_HEADER
50 
51 QT_BEGIN_NAMESPACE
52 
53 class QDesignerFormEditorInterface;
54 class QDesignerFormWindowCursorInterface;
55 class QDesignerFormWindowToolInterface;
56 class DomUI;
57 class QUndoStack;
58 class QDir;
59 
60 class QDESIGNER_SDK_EXPORT QDesignerFormWindowInterface: public QWidget
61 {
62     Q_OBJECT
63 public:
64     enum FeatureFlag
65     {
66         EditFeature = 0x01,
67         GridFeature = 0x02,
68         TabOrderFeature = 0x04,
69         DefaultFeature = EditFeature | GridFeature
70     };
71     Q_DECLARE_FLAGS(Feature, FeatureFlag)
72 
73 public:
74     QDesignerFormWindowInterface(QWidget *parent = 0, Qt::WindowFlags flags = 0);
75     virtual ~QDesignerFormWindowInterface();
76 
77     virtual QString fileName() const = 0;
78     virtual QDir absoluteDir() const = 0;
79 
80     virtual QString contents() const = 0;
81     virtual void setContents(QIODevice *dev) = 0;
82 
83     virtual Feature features() const = 0;
84     virtual bool hasFeature(Feature f) const = 0;
85 
86     virtual QString author() const = 0;
87     virtual void setAuthor(const QString &author) = 0;
88 
89     virtual QString comment() const = 0;
90     virtual void setComment(const QString &comment) = 0;
91 
92     virtual void layoutDefault(int *margin, int *spacing) = 0;
93     virtual void setLayoutDefault(int margin, int spacing) = 0;
94 
95     virtual void layoutFunction(QString *margin, QString *spacing) = 0;
96     virtual void setLayoutFunction(const QString &margin, const QString &spacing) = 0;
97 
98     virtual QString pixmapFunction() const = 0;
99     virtual void setPixmapFunction(const QString &pixmapFunction) = 0;
100 
101     virtual QString exportMacro() const = 0;
102     virtual void setExportMacro(const QString &exportMacro) = 0;
103 
104     virtual QStringList includeHints() const = 0;
105     virtual void setIncludeHints(const QStringList &includeHints) = 0;
106 
107     virtual QDesignerFormEditorInterface *core() const;
108     virtual QDesignerFormWindowCursorInterface *cursor() const = 0;
109 
110     virtual int toolCount() const = 0;
111 
112     virtual int currentTool() const = 0;
113     virtual void setCurrentTool(int index) = 0;
114 
115     virtual QDesignerFormWindowToolInterface *tool(int index) const = 0;
116     virtual void registerTool(QDesignerFormWindowToolInterface *tool) = 0;
117 
118     virtual QPoint grid() const = 0;
119 
120     virtual QWidget *mainContainer() const = 0;
121     virtual void setMainContainer(QWidget *mainContainer) = 0;
122 
123     virtual bool isManaged(QWidget *widget) const = 0;
124 
125     virtual bool isDirty() const = 0;
126 
127     static QDesignerFormWindowInterface *findFormWindow(QWidget *w);
128     static QDesignerFormWindowInterface *findFormWindow(QObject *obj);
129 
130     virtual QUndoStack *commandHistory() const = 0;
131     virtual void beginCommand(const QString &description) = 0;
132     virtual void endCommand() = 0;
133 
134     virtual void simplifySelection(QList<QWidget*> *widgets) const = 0;
135 
136     // notifications
137     virtual void emitSelectionChanged() = 0;
138 
139     virtual QStringList resourceFiles() const = 0;
140     virtual void addResourceFile(const QString &path) = 0;
141     virtual void removeResourceFile(const QString &path) = 0;
142 
143     virtual void ensureUniqueObjectName(QObject *object) = 0;
144 
145 public Q_SLOTS:
146     virtual void manageWidget(QWidget *widget) = 0;
147     virtual void unmanageWidget(QWidget *widget) = 0;
148 
149     virtual void setFeatures(Feature f) = 0;
150     virtual void setDirty(bool dirty) = 0;
151     virtual void clearSelection(bool changePropertyDisplay = true) = 0;
152     virtual void selectWidget(QWidget *w, bool select = true) = 0;
153     virtual void setGrid(const QPoint &grid) = 0;
154     virtual void setFileName(const QString &fileName) = 0;
155     virtual void setContents(const QString &contents) = 0;
156 
157     virtual void editWidgets() = 0;
158 
159 Q_SIGNALS:
160     void mainContainerChanged(QWidget *mainContainer);
161     void toolChanged(int toolIndex);
162     void fileNameChanged(const QString &fileName);
163     void featureChanged(Feature f);
164     void selectionChanged();
165     void geometryChanged();
166 
167     void resourceFilesChanged();
168 
169     void widgetManaged(QWidget *widget);
170     void widgetUnmanaged(QWidget *widget);
171     void aboutToUnmanageWidget(QWidget *widget);
172     void activated(QWidget *widget);
173 
174     void changed();
175     void widgetRemoved(QWidget *w);
176     void objectRemoved(QObject *o);
177 };
178 
179 QT_END_NAMESPACE
180 
181 QT_END_HEADER
182 
183 #endif // ABSTRACTFORMWINDOW_H
184