summaryrefslogtreecommitdiff
path: root/tools/designer/src/lib/sdk/abstractformwindowcursor.cpp
blob: 2a8d182ad2b6090f4e4beb4ed23811cda9878d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.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 the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "abstractformwindowcursor.h"

QT_BEGIN_NAMESPACE

/*!
    \class QDesignerFormWindowCursorInterface

    \brief The QDesignerFormWindowCursorInterface class allows you to
    query and modify a form window's widget selection, and in addition
    modify the properties of all the form's widgets.

    \inmodule QtDesigner

    QDesignerFormWindowCursorInterface is a convenience class that
    provides an interface to the associated form window's text cursor;
    it provides a collection of functions that enables you to query a
    given form window's selection and change the selection's focus
    according to defined modes (MoveMode) and movements
    (MoveOperation). You can also use the interface to query the
    form's widgets and change their properties.

    The interface is not intended to be instantiated directly, but to
    provide access to the selections and widgets of \QD's current form
    windows. QDesignerFormWindowInterface always provides an
    associated cursor interface. The form window for a given widget
    can be retrieved using the static
    QDesignerFormWindowInterface::findFormWindow() functions. For
    example:

    \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp 0

    You can retrieve any of \QD's current form windows through
    \QD's \l {QDesignerFormWindowManagerInterface}{form window
    manager}.

    Once you have a form window's cursor interface, you can check if
    the form window has a selection at all using the hasSelection()
    function. You can query the form window for its total
    widgetCount() and selectedWidgetCount(). You can retrieve the
    currently selected widget (or widgets) using the current() or
    selectedWidget() functions.

    You can retrieve any of the form window's widgets using the
    widget() function, and check if a widget is selected using the
    isWidgetSelected() function. You can use the setProperty()
    function to set the selected widget's properties, and the
    setWidgetProperty() or resetWidgetProperty() functions to modify
    the properties of any given widget.

    Finally, you can change the selection by changing the text
    cursor's position() using the setPosition() and movePosition()
    functions.

    \sa QDesignerFormWindowInterface, QDesignerFormWindowManagerInterface
*/

/*!
    \enum QDesignerFormWindowCursorInterface::MoveOperation

    This enum describes the types of text cursor operation that can occur in a form window.

    \value NoMove The cursor does not move.
    \value Start  Moves the cursor to the start of the focus chain.
    \value End    Moves the cursor to the end of the focus chain.
    \value Next   Moves the cursor to the next widget in the focus chain.
    \value Prev   Moves the cursor to the previous widget in the focus chain.
    \value Left   The cursor moves to the left.
    \value Right  The cursor moves to the right.
    \value Up     The cursor moves upwards.
    \value Down   The cursor moves downwards.
*/

/*!
    \enum QDesignerFormWindowCursorInterface::MoveMode

    This enum describes the different modes that are used when the text cursor moves.

    \value MoveAnchor The anchor moves with the cursor to its new location.
    \value KeepAnchor The anchor remains at the cursor's old location.
*/

/*!
    Returns true if the specified \a widget is selected; otherwise
    returns false.
*/
bool QDesignerFormWindowCursorInterface::isWidgetSelected(QWidget *widget) const
{
    for (int index=0; index<selectedWidgetCount(); ++index) {
        if (selectedWidget(index) == widget)
            return true;
    }

    return false;
}

/*!
    \fn virtual QDesignerFormWindowCursorInterface::~QDesignerFormWindowCursorInterface()

    Destroys the cursor interface.
*/

/*!
    \fn virtual QDesignerFormWindowInterface *QDesignerFormWindowCursorInterface::formWindow() const

    Returns the form window interface associated with this cursor interface.
*/

/*!
    \fn virtual bool QDesignerFormWindowCursorInterface::movePosition(MoveOperation operation, MoveMode mode)

    Performs the given \a operation on the cursor using the specified
    \a mode, and returns true if it completed successfully; otherwise
    returns false.

    \sa position(), setPosition()
*/

/*!
    \fn virtual int QDesignerFormWindowCursorInterface::position() const

    Returns the cursor position.

    \sa setPosition(), movePosition()
*/

/*!
    \fn virtual void QDesignerFormWindowCursorInterface::setPosition(int position, MoveMode mode = MoveAnchor)

    Sets the position of the cursor to the given \a position using the
    \a mode to specify how it is moved there.

    \sa position(), movePosition()
*/

/*!
    \fn virtual QWidget *QDesignerFormWindowCursorInterface::current() const

    Returns the currently selected widget in the form window.

    \sa selectedWidget()
*/

/*!
    \fn virtual int QDesignerFormWindowCursorInterface::widgetCount() const

    Returns the number of widgets in the form window.

    \sa selectedWidgetCount()
*/

/*!
    \fn virtual QWidget *QDesignerFormWindowCursorInterface::widget(int index) const

    Returns the widget with the given \a index in the list of widgets
    in the form window.

    \sa selectedWidget()
*/

/*!
    \fn virtual bool QDesignerFormWindowCursorInterface::hasSelection() const

    Returns true if the form window contains a selection; otherwise
    returns false.
*/

/*!
    \fn virtual int QDesignerFormWindowCursorInterface::selectedWidgetCount() const

    Returns the number of selected widgets in the form window.

    \sa widgetCount()
*/

/*!
    \fn virtual QWidget *QDesignerFormWindowCursorInterface::selectedWidget(int index) const

    Returns the widget with the given \a index in the list of selected
    widgets.

    \sa current(), widget()
*/

/*!
    \fn virtual void QDesignerFormWindowCursorInterface::setProperty(const QString &name, const QVariant &value)

    Sets the property with the given \a name for the currently
    selected widget to the specified \a value.

    \sa setWidgetProperty(), resetWidgetProperty()
*/

/*!
    \fn virtual void QDesignerFormWindowCursorInterface::setWidgetProperty(QWidget *widget, const QString &name, const QVariant &value)

    Sets the property with the given \a name for the given \a widget
    to the specified \a value.

    \sa resetWidgetProperty(), setProperty()
*/

/*!
    \fn virtual void QDesignerFormWindowCursorInterface::resetWidgetProperty(QWidget *widget, const QString &name)

    Resets the property with the given \a name for the specified \a
    widget to its default value.

    \sa setProperty(), setWidgetProperty()
*/

QT_END_NAMESPACE