1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt Designer of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "abstractformwindowmanager.h"
|
---|
43 |
|
---|
44 | #include <QtCore/QMap>
|
---|
45 |
|
---|
46 | QT_BEGIN_NAMESPACE
|
---|
47 |
|
---|
48 | /*!
|
---|
49 | \class QDesignerFormWindowManagerInterface
|
---|
50 |
|
---|
51 | \brief The QDesignerFormWindowManagerInterface class allows you to
|
---|
52 | manipulate the collection of form windows in Qt Designer, and
|
---|
53 | control Qt Designer's form editing actions.
|
---|
54 |
|
---|
55 | \inmodule QtDesigner
|
---|
56 |
|
---|
57 | QDesignerFormWindowManagerInterface is not intended to be
|
---|
58 | instantiated directly. \QD uses the form window manager to
|
---|
59 | control the various form windows in its workspace. You can
|
---|
60 | retrieve an interface to \QD's form window manager using
|
---|
61 | the QDesignerFormEditorInterface::formWindowManager()
|
---|
62 | function. For example:
|
---|
63 |
|
---|
64 | \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp 0
|
---|
65 |
|
---|
66 | When implementing a custom widget plugin, a pointer to \QD's
|
---|
67 | current QDesignerFormEditorInterface object (\c formEditor in the
|
---|
68 | example above) is provided by the
|
---|
69 | QDesignerCustomWidgetInterface::initialize() function's parameter.
|
---|
70 | You must subclass the QDesignerCustomWidgetInterface to expose
|
---|
71 | your plugin to Qt Designer.
|
---|
72 |
|
---|
73 | The form window manager interface provides the createFormWindow()
|
---|
74 | function that enables you to create a new form window which you
|
---|
75 | can add to the collection of form windows that the manager
|
---|
76 | maintains, using the addFormWindow() slot. It also provides the
|
---|
77 | formWindowCount() function returning the number of form windows
|
---|
78 | currently under the manager's control, the formWindow() function
|
---|
79 | returning the form window associated with a given index, and the
|
---|
80 | activeFormWindow() function returning the currently selected form
|
---|
81 | window. The removeFormWindow() slot allows you to reduce the
|
---|
82 | number of form windows the manager must maintain, and the
|
---|
83 | setActiveFormWindow() slot allows you to change the form window
|
---|
84 | focus in \QD's workspace.
|
---|
85 |
|
---|
86 | In addition, QDesignerFormWindowManagerInterface contains a
|
---|
87 | collection of functions that enables you to intervene and control
|
---|
88 | \QD's form editing actions. All these functions return the
|
---|
89 | original action, making it possible to propagate the function
|
---|
90 | further after intervention.
|
---|
91 |
|
---|
92 | Finally, the interface provides three signals which are emitted
|
---|
93 | when a form window is added, when the currently selected form
|
---|
94 | window changes, or when a form window is removed, respectively. All
|
---|
95 | the signals carry the form window in question as their parameter.
|
---|
96 |
|
---|
97 | \sa QDesignerFormEditorInterface, QDesignerFormWindowInterface
|
---|
98 | */
|
---|
99 |
|
---|
100 | // ------------- QDesignerFormWindowManagerInterfacePrivate
|
---|
101 |
|
---|
102 | struct QDesignerFormWindowManagerInterfacePrivate {
|
---|
103 | QDesignerFormWindowManagerInterfacePrivate();
|
---|
104 | QAction *m_simplifyLayoutAction;
|
---|
105 | QAction *m_formLayoutAction;
|
---|
106 | };
|
---|
107 |
|
---|
108 | QDesignerFormWindowManagerInterfacePrivate::QDesignerFormWindowManagerInterfacePrivate() :
|
---|
109 | m_simplifyLayoutAction(0),
|
---|
110 | m_formLayoutAction(0)
|
---|
111 | {
|
---|
112 | }
|
---|
113 |
|
---|
114 | typedef QMap<const QDesignerFormWindowManagerInterface *, QDesignerFormWindowManagerInterfacePrivate *> FormWindowManagerPrivateMap;
|
---|
115 |
|
---|
116 | Q_GLOBAL_STATIC(FormWindowManagerPrivateMap, g_FormWindowManagerPrivateMap)
|
---|
117 |
|
---|
118 | /*!
|
---|
119 | Constructs an interface with the given \a parent for the form window
|
---|
120 | manager.
|
---|
121 | */
|
---|
122 | QDesignerFormWindowManagerInterface::QDesignerFormWindowManagerInterface(QObject *parent)
|
---|
123 | : QObject(parent)
|
---|
124 | {
|
---|
125 | g_FormWindowManagerPrivateMap()->insert(this, new QDesignerFormWindowManagerInterfacePrivate);
|
---|
126 | }
|
---|
127 |
|
---|
128 | /*!
|
---|
129 | Destroys the interface for the form window manager.
|
---|
130 | */
|
---|
131 | QDesignerFormWindowManagerInterface::~QDesignerFormWindowManagerInterface()
|
---|
132 | {
|
---|
133 | FormWindowManagerPrivateMap *fwmpm = g_FormWindowManagerPrivateMap();
|
---|
134 | const FormWindowManagerPrivateMap::iterator it = fwmpm->find(this);
|
---|
135 | Q_ASSERT(it != fwmpm->end());
|
---|
136 | delete it.value();
|
---|
137 | fwmpm->erase(it);
|
---|
138 | }
|
---|
139 |
|
---|
140 | /*!
|
---|
141 | Allows you to intervene and control \QD's "cut" action. The function
|
---|
142 | returns the original action.
|
---|
143 |
|
---|
144 | \sa QAction
|
---|
145 | */
|
---|
146 | QAction *QDesignerFormWindowManagerInterface::actionCut() const
|
---|
147 | {
|
---|
148 | return 0;
|
---|
149 | }
|
---|
150 |
|
---|
151 | /*!
|
---|
152 | Allows you to intervene and control \QD's "copy" action. The
|
---|
153 | function returns the original action.
|
---|
154 |
|
---|
155 | \sa QAction
|
---|
156 | */
|
---|
157 | QAction *QDesignerFormWindowManagerInterface::actionCopy() const
|
---|
158 | {
|
---|
159 | return 0;
|
---|
160 | }
|
---|
161 |
|
---|
162 | /*!
|
---|
163 | Allows you to intervene and control \QD's "paste" action. The
|
---|
164 | function returns the original action.
|
---|
165 |
|
---|
166 | \sa QAction
|
---|
167 | */
|
---|
168 | QAction *QDesignerFormWindowManagerInterface::actionPaste() const
|
---|
169 | {
|
---|
170 | return 0;
|
---|
171 | }
|
---|
172 |
|
---|
173 | /*!
|
---|
174 | Allows you to intervene and control \QD's "delete" action. The function
|
---|
175 | returns the original action.
|
---|
176 |
|
---|
177 | \sa QAction
|
---|
178 | */
|
---|
179 | QAction *QDesignerFormWindowManagerInterface::actionDelete() const
|
---|
180 | {
|
---|
181 | return 0;
|
---|
182 | }
|
---|
183 |
|
---|
184 | /*!
|
---|
185 | Allows you to intervene and control \QD's "select all" action. The
|
---|
186 | function returns the original action.
|
---|
187 |
|
---|
188 | \sa QAction
|
---|
189 | */
|
---|
190 | QAction *QDesignerFormWindowManagerInterface::actionSelectAll() const
|
---|
191 | {
|
---|
192 | return 0;
|
---|
193 | }
|
---|
194 |
|
---|
195 | /*!
|
---|
196 | Allows you to intervene and control the action of lowering a form
|
---|
197 | window in \QD's workspace. The function returns the original
|
---|
198 | action.
|
---|
199 |
|
---|
200 | \sa QAction
|
---|
201 | */
|
---|
202 | QAction *QDesignerFormWindowManagerInterface::actionLower() const
|
---|
203 | {
|
---|
204 | return 0;
|
---|
205 | }
|
---|
206 |
|
---|
207 | /*!
|
---|
208 | Allows you to intervene and control the action of raising of a
|
---|
209 | form window in \QD's workspace. The function returns the original
|
---|
210 | action.
|
---|
211 |
|
---|
212 | \sa QAction
|
---|
213 | */
|
---|
214 | QAction *QDesignerFormWindowManagerInterface::actionRaise() const
|
---|
215 | {
|
---|
216 | return 0;
|
---|
217 | }
|
---|
218 |
|
---|
219 | /*!
|
---|
220 | Allows you to intervene and control a request for horizontal
|
---|
221 | layout for a form window in \QD's workspace. The function returns
|
---|
222 | the original action.
|
---|
223 |
|
---|
224 | \sa QAction
|
---|
225 | */
|
---|
226 | QAction *QDesignerFormWindowManagerInterface::actionHorizontalLayout() const
|
---|
227 | {
|
---|
228 | return 0;
|
---|
229 | }
|
---|
230 |
|
---|
231 | /*!
|
---|
232 | Allows you to intervene and control a request for vertical layout
|
---|
233 | for a form window in \QD's workspace. The function returns the
|
---|
234 | original action.
|
---|
235 |
|
---|
236 | \sa QAction
|
---|
237 | */
|
---|
238 | QAction *QDesignerFormWindowManagerInterface::actionVerticalLayout() const
|
---|
239 | {
|
---|
240 | return 0;
|
---|
241 | }
|
---|
242 |
|
---|
243 | /*!
|
---|
244 | Allows you to intervene and control \QD's "split horizontal"
|
---|
245 | action. The function returns the original action.
|
---|
246 |
|
---|
247 | \sa QAction
|
---|
248 | */
|
---|
249 | QAction *QDesignerFormWindowManagerInterface::actionSplitHorizontal() const
|
---|
250 | {
|
---|
251 | return 0;
|
---|
252 | }
|
---|
253 |
|
---|
254 | /*!
|
---|
255 | Allows you to intervene and control \QD's "split vertical"
|
---|
256 | action. The function returns the original action.
|
---|
257 |
|
---|
258 | \sa QAction
|
---|
259 | */
|
---|
260 | QAction *QDesignerFormWindowManagerInterface::actionSplitVertical() const
|
---|
261 | {
|
---|
262 | return 0;
|
---|
263 | }
|
---|
264 |
|
---|
265 | /*!
|
---|
266 | Allows you to intervene and control a request for grid layout for
|
---|
267 | a form window in \QD's workspace. The function returns the
|
---|
268 | original action.
|
---|
269 |
|
---|
270 | \sa QAction
|
---|
271 | */
|
---|
272 | QAction *QDesignerFormWindowManagerInterface::actionGridLayout() const
|
---|
273 | {
|
---|
274 | return 0;
|
---|
275 | }
|
---|
276 |
|
---|
277 | /*!
|
---|
278 | Allows you to intervene and control \QD's "form layout" action. The
|
---|
279 | function returns the original action.
|
---|
280 |
|
---|
281 | FormWindowManagerPrivateMap *fwmpm = g_FormWindowManagerPrivateMap(); \sa QAction
|
---|
282 | \since 4.4
|
---|
283 | */
|
---|
284 |
|
---|
285 | QAction *QDesignerFormWindowManagerInterface::actionFormLayout() const
|
---|
286 | {
|
---|
287 | const QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
---|
288 | Q_ASSERT(d);
|
---|
289 | return d->m_formLayoutAction;
|
---|
290 | }
|
---|
291 |
|
---|
292 | /*!
|
---|
293 | Sets the "form layout" action to \a action.
|
---|
294 |
|
---|
295 | \internal
|
---|
296 | \since 4.4
|
---|
297 | */
|
---|
298 |
|
---|
299 | void QDesignerFormWindowManagerInterface::setActionFormLayout(QAction *action)
|
---|
300 | {
|
---|
301 | QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
---|
302 | Q_ASSERT(d);
|
---|
303 | d->m_formLayoutAction = action;
|
---|
304 | }
|
---|
305 |
|
---|
306 | /*!
|
---|
307 | Allows you to intervene and control \QD's "break layout" action. The
|
---|
308 | function returns the original action.
|
---|
309 |
|
---|
310 | \sa QAction
|
---|
311 | */
|
---|
312 | QAction *QDesignerFormWindowManagerInterface::actionBreakLayout() const
|
---|
313 | {
|
---|
314 | return 0;
|
---|
315 | }
|
---|
316 |
|
---|
317 | /*!
|
---|
318 | Allows you to intervene and control \QD's "adjust size" action. The
|
---|
319 | function returns the original action.
|
---|
320 |
|
---|
321 | \sa QAction
|
---|
322 | */
|
---|
323 | QAction *QDesignerFormWindowManagerInterface::actionAdjustSize() const
|
---|
324 | {
|
---|
325 | return 0;
|
---|
326 | }
|
---|
327 |
|
---|
328 | /*!
|
---|
329 | Allows you to intervene and control \QD's "simplify layout" action. The
|
---|
330 | function returns the original action.
|
---|
331 |
|
---|
332 | \sa QAction
|
---|
333 | \since 4.4
|
---|
334 | */
|
---|
335 |
|
---|
336 | QAction *QDesignerFormWindowManagerInterface::actionSimplifyLayout() const
|
---|
337 | {
|
---|
338 | const QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
---|
339 | Q_ASSERT(d);
|
---|
340 | return d->m_simplifyLayoutAction;
|
---|
341 | }
|
---|
342 |
|
---|
343 | /*!
|
---|
344 | Sets the "simplify layout" action to \a action.
|
---|
345 |
|
---|
346 | \internal
|
---|
347 | \since 4.4
|
---|
348 | */
|
---|
349 |
|
---|
350 | void QDesignerFormWindowManagerInterface::setActionSimplifyLayout(QAction *action)
|
---|
351 | {
|
---|
352 | QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
---|
353 | Q_ASSERT(d);
|
---|
354 | d->m_simplifyLayoutAction = action;
|
---|
355 | }
|
---|
356 |
|
---|
357 | /*!
|
---|
358 | Returns the currently active form window in \QD's workspace.
|
---|
359 |
|
---|
360 | \sa setActiveFormWindow(), removeFormWindow()
|
---|
361 | */
|
---|
362 | QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::activeFormWindow() const
|
---|
363 | {
|
---|
364 | return 0;
|
---|
365 | }
|
---|
366 |
|
---|
367 | /*!
|
---|
368 | Returns a pointer to \QD's current QDesignerFormEditorInterface
|
---|
369 | object.
|
---|
370 | */
|
---|
371 | QDesignerFormEditorInterface *QDesignerFormWindowManagerInterface::core() const
|
---|
372 | {
|
---|
373 | return 0;
|
---|
374 | }
|
---|
375 |
|
---|
376 | /*!
|
---|
377 | Adds the given \a formWindow to the collection of windows that
|
---|
378 | \QD's form window manager maintains.
|
---|
379 |
|
---|
380 | \sa formWindowAdded()
|
---|
381 | */
|
---|
382 | void QDesignerFormWindowManagerInterface::addFormWindow(QDesignerFormWindowInterface *formWindow)
|
---|
383 | {
|
---|
384 | Q_UNUSED(formWindow);
|
---|
385 | }
|
---|
386 |
|
---|
387 | /*!
|
---|
388 | Removes the given \a formWindow from the collection of windows that
|
---|
389 | \QD's form window manager maintains.
|
---|
390 |
|
---|
391 | \sa formWindow(), formWindowRemoved()
|
---|
392 | */
|
---|
393 | void QDesignerFormWindowManagerInterface::removeFormWindow(QDesignerFormWindowInterface *formWindow)
|
---|
394 | {
|
---|
395 | Q_UNUSED(formWindow);
|
---|
396 | }
|
---|
397 |
|
---|
398 | /*!
|
---|
399 | Sets the given \a formWindow to be the currently active form window in
|
---|
400 | \QD's workspace.
|
---|
401 |
|
---|
402 | \sa activeFormWindow(), activeFormWindowChanged()
|
---|
403 | */
|
---|
404 | void QDesignerFormWindowManagerInterface::setActiveFormWindow(QDesignerFormWindowInterface *formWindow)
|
---|
405 | {
|
---|
406 | Q_UNUSED(formWindow);
|
---|
407 | }
|
---|
408 |
|
---|
409 | /*!
|
---|
410 | Returns the number of form windows maintained by \QD's form window
|
---|
411 | manager.
|
---|
412 | */
|
---|
413 | int QDesignerFormWindowManagerInterface::formWindowCount() const
|
---|
414 | {
|
---|
415 | return 0;
|
---|
416 | }
|
---|
417 |
|
---|
418 | /*!
|
---|
419 | Returns the form window at the given \a index.
|
---|
420 |
|
---|
421 | \sa setActiveFormWindow(), removeFormWindow()
|
---|
422 | */
|
---|
423 | QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::formWindow(int index) const
|
---|
424 | {
|
---|
425 | Q_UNUSED(index);
|
---|
426 | return 0;
|
---|
427 | }
|
---|
428 |
|
---|
429 | /*!
|
---|
430 | \fn QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parent, Qt::WindowFlags flags)
|
---|
431 |
|
---|
432 | Creates a form window with the given \a parent and the given window
|
---|
433 | \a flags.
|
---|
434 |
|
---|
435 | \sa addFormWindow()
|
---|
436 | */
|
---|
437 | QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parentWidget, Qt::WindowFlags flags)
|
---|
438 | {
|
---|
439 | Q_UNUSED(parentWidget);
|
---|
440 | Q_UNUSED(flags);
|
---|
441 | return 0;
|
---|
442 | }
|
---|
443 |
|
---|
444 | /*!
|
---|
445 | Allows you to intervene and control \QD's "undo" action. The
|
---|
446 | function returns the original action.
|
---|
447 |
|
---|
448 | \sa QAction
|
---|
449 | */
|
---|
450 | QAction *QDesignerFormWindowManagerInterface::actionUndo() const
|
---|
451 | {
|
---|
452 | return 0;
|
---|
453 | }
|
---|
454 |
|
---|
455 | /*!
|
---|
456 | Allows you to intervene and control \QD's "redo" action. The
|
---|
457 | function returns the original action.
|
---|
458 |
|
---|
459 | \sa QAction
|
---|
460 | */
|
---|
461 | QAction *QDesignerFormWindowManagerInterface::actionRedo() const
|
---|
462 | {
|
---|
463 | return 0;
|
---|
464 | }
|
---|
465 |
|
---|
466 | /*!
|
---|
467 | \fn void QDesignerFormWindowManagerInterface::formWindowAdded(QDesignerFormWindowInterface *formWindow)
|
---|
468 |
|
---|
469 | This signal is emitted when a new form window is added to the
|
---|
470 | collection of windows that \QD's form window manager maintains. A
|
---|
471 | pointer to the new \a formWindow is passed as an argument.
|
---|
472 |
|
---|
473 | \sa addFormWindow(), setActiveFormWindow()
|
---|
474 | */
|
---|
475 |
|
---|
476 | /*!
|
---|
477 | \fn void QDesignerFormWindowManagerInterface::formWindowRemoved(QDesignerFormWindowInterface *formWindow)
|
---|
478 |
|
---|
479 | This signal is emitted when a form window is removed from the
|
---|
480 | collection of windows that \QD's form window manager maintains. A
|
---|
481 | pointer to the removed \a formWindow is passed as an argument.
|
---|
482 |
|
---|
483 | \sa removeFormWindow()
|
---|
484 | */
|
---|
485 |
|
---|
486 | /*!
|
---|
487 | \fn void QDesignerFormWindowManagerInterface::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
|
---|
488 |
|
---|
489 | This signal is emitted when the contents of the currently active
|
---|
490 | form window in \QD's workspace changed. A pointer to the currently
|
---|
491 | active \a formWindow is passed as an argument.
|
---|
492 |
|
---|
493 | \sa activeFormWindow()
|
---|
494 | */
|
---|
495 |
|
---|
496 | /*!
|
---|
497 | \fn void QDesignerFormWindowManagerInterface::dragItems(const QList<QDesignerDnDItemInterface*> &item_list)
|
---|
498 |
|
---|
499 | \internal
|
---|
500 | */
|
---|
501 |
|
---|
502 | QT_END_NAMESPACE
|
---|