Пример #1
0
void FormWindowCursor::setProperty(const QString &name, const QVariant &value)
{

    // build selection
    const int N = selectedWidgetCount();
    Q_ASSERT(N);
    
    SetPropertyCommand::ObjectList selection;
    for (int i=0; i<N; ++i) 
         selection.push_back(selectedWidget(i));

    
    SetPropertyCommand* setPropertyCommand = new SetPropertyCommand(m_formWindow);
    if (setPropertyCommand->init(selection, name, value, current())) {
        m_formWindow->commandHistory()->push(setPropertyCommand);
    } else {
        delete setPropertyCommand;
        qDebug() << "Unable to set property " << name << '.';
    }
}
Пример #2
0
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 lib/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;
}