// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page creator-editor-quick-fixes.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-edit

    \title Apply quick fixes

    To apply quick fixes while refactoring code, select them in a context menu
    in the code editor. The fixes available depend on the position of the
    cursor in the code editor.

    \list 1
        \li To apply quick fixes:
            \list
                \li In C++ code, right-click an operand, conditional statement,
                    string, or name.
                \li In QML code, right-click an item ID or name.
            \endlist
        \li In the context menu, go to \uicontrol {Refactoring} and then select a
            quick fix.
    \endlist

    Or, select \key {Alt+Enter} to open a context menu that has
    quick fixes available in the current cursor position.

    By default, the refactored files are saved automatically. To turn off
    this feature, go to \preferences > \uicontrol Environment >
    \uicontrol System and clear \uicontrol {Auto-save files after refactoring}.

    \section1 Create functions

    Apply quick fixes to implement member functions, insert
    virtual functions of base classes, create getter and setter functions,
    and generate constructors. Specify settings for generating the
    functions either globally for all projects or separately for each project
    in the \l{Building and running projects}{build and run} settings of the project.

    \section2 Implement member functions

    Apply the \uicontrol {Create Implementations for Member Functions}
    quick fix to create implementations for all member functions in
    one go. In the \uicontrol {Member Function Implementations} dialog,
    specify whether the member functions are generated inline or outside the
    class.

    \image {qtcreator-refactoring-member-function-implementations.png} {Implement Member Functions dialog}

    \section2 Insert virtual functions

    Apply the \uicontrol {Insert Virtual Functions of Base Classes}
    quick fix to insert declarations and the corresponding definitions
    inside or outside the class or in an implementation file (if it exists).

    \image {qtcreator-refactoring-virtual-function-dialog.png} {Insert Virtual Functions dialog}

    Select the functions to insert in the list of available functions.
    Filter the list and hide reimplemented functions from it.

    You can add \e virtual or the \e override equivalent to the function
    declaration.

    \section2 Create getters and setters

    Apply the \uicontrol {Create Getter and Setter Member Functions}
    quick fix to create either both getter and setter member functions
    for member variables or only a getter or setter.

    \image {qtcreator-refactoring-getters-and-setters.png} {Getters and Setters dialog}

    \section2 Generate constructors

    Apply the \uicontrol {Generate Constructor} quick fix to
    create a public, protected, or private constructor for a class. Select the
    class members to initialize in the constructor. Drag the parameters
    to specify their order in the constructor.

    \image {qtcreator-refactoring-constructor.png} {Constructor dialog}

    \sa {Find symbols}, {Specify settings for quick fixes},
    {Quick Fixes}, {C++ quick fixes}

    \section1 Move classes to separate files

    Apply the \uicontrol {Move Class to a Dedicated Set of Source Files} quick
    fix to move a class to a separate set of header and implementation files.

    \image {qtcreator-move-class-to-separate-files.webp} {Give names to header and implementation files}

    Specify paths and file names for the header and implementation file.

    To omit the implementation file, select \uicontrol {Header file only}.

    \sa {Rename symbols}, {QML quick fixes}
*/

/*!
    \page creator-reference-qml-quick-fixes.html
    \previouspage creator-reference.html

    \ingroup creator-reference-editors

    \title QML quick fixes

    \brief Summary of quick fixes for QML code.

    Apply the following types of quick fixes to QML code:

    \list
        \li Rename IDs
        \li Split initializers
        \li Move a QML type into a separate file to reuse it in other \c .qml files
    \endlist

    The following table summarizes the quick fixes for QML code. The
    action is available when the cursor is in the position described in the
    Activation column.

    \table
        \header
            \li Quick Fix
            \li Description
            \li Activation

        \row
            \li Move Component into Separate File
            \li Moves a QML type into a separate file. Give the new component a
                name and select whether properties are set for the new component
                or for the original one.

                \image {qtcreator-move-component-into-separate-file.webp} {Move Component into Separate File dialog}

            \li QML type name.
                This action is also available in the \uicontrol {2D} view.
        \row
            \li Split Initializer
            \li Reformats a one-line type into a multi-line type. For example,
                rewrites

    \code
    Item { x: 10; y: 20; width: 10 }
    \endcode

                as

    \code
    Item {
        x: 10;
        y: 20;
        width: 10
    }
    \endcode

            \li QML type property
        \row
            \li Wrap Component in Loader
            \li Wraps the type in a Component type and loads it dynamically in a
                Loader type. This is usually done to improve startup time.
            \li QML type name
        \row
            \li Add a message suppression comment
            \li Prepends the line with an annotation comment that stops the
                message from being generated.
            \li Error, warning or hint from static analysis

    \endtable

    \sa {Apply quick fixes}, {Exclude files from to-do lists}, {Find symbols},
    {Rename symbols}, {Specify settings for quick fixes},
    {Quick Fixes}, {C++ quick fixes}
*/
