VirtualBox

Changeset 77892 in vbox for trunk


Ignore:
Timestamp:
Mar 26, 2019 6:02:47 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Chooser pane: Cleanup for UIChooserAbstractModel classes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r77891 r77892  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIChooserModel class implementation.
     3 * VBox Qt GUI - UIChooserAbstractModel class implementation.
    44 */
    55
     
    3838UIChooserAbstractModel:: UIChooserAbstractModel(UIChooser *pParent)
    3939    : QObject(pParent)
     40    , m_pParent(pParent)
    4041    , m_pInvisibleRootNode(0)
    4142{
     
    5152void UIChooserAbstractModel::deinit()
    5253{
    53     /* Currently we are not saving group descriptors
    54      * (which reflecting group toggle-state) on-the-fly,
    55      * so, for now we are additionally save group orders
    56      * when exiting application: */
     54    // WORKAROUND:
     55    // Currently we are not saving group descriptors
     56    // (which reflecting group toggle-state) on-the-fly,
     57    // so for now we are additionally save group orders
     58    // when exiting application:
    5759    saveGroupOrders();
    5860
     
    7375void UIChooserAbstractModel::wipeOutEmptyGroups()
    7476{
    75     wipeOutEmptyGroups(invisibleRoot());
     77    wipeOutEmptyGroupsStartingFrom(invisibleRoot());
    7678}
    7779
     
    101103    }
    102104
    103     /* Prepare result: */
     105    /* Prepare/return result: */
    104106    QString strResult = strMinimumName;
    105107    if (iMinimumPossibleNumber)
     
    110112void UIChooserAbstractModel::saveGroupSettings()
    111113{
    112     emit sigGroupSavingStarted();
     114    emit sigStartGroupSaving();
    113115}
    114116
     
    182184}
    183185
    184 void UIChooserAbstractModel::sltGroupSavingStart()
     186void UIChooserAbstractModel::sltStartGroupSaving()
    185187{
    186188    saveGroupDefinitions();
     
    208210{
    209211    /* Setup parent connections: */
    210     connect(this, SIGNAL(sigGroupSavingStateChanged()),
    211             parent(), SIGNAL(sigGroupSavingStateChanged()));
     212    connect(this, &UIChooserAbstractModel::sigGroupSavingStateChanged,
     213            m_pParent, &UIChooser::sigGroupSavingStateChanged);
    212214
    213215    /* Setup global connections: */
    214     connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QUuid, KMachineState)),
    215             this, SLOT(sltMachineStateChanged(QUuid, KMachineState)));
    216     connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QUuid)),
    217             this, SLOT(sltMachineDataChanged(QUuid)));
    218     connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QUuid, bool)),
    219             this, SLOT(sltMachineRegistered(QUuid, bool)));
    220     connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QUuid, KSessionState)),
    221             this, SLOT(sltSessionStateChanged(QUuid, KSessionState)));
    222     connect(gVBoxEvents, SIGNAL(sigSnapshotTake(QUuid, QUuid)),
    223             this, SLOT(sltSnapshotChanged(QUuid, QUuid)));
    224     connect(gVBoxEvents, SIGNAL(sigSnapshotDelete(QUuid, QUuid)),
    225             this, SLOT(sltSnapshotChanged(QUuid, QUuid)));
    226     connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QUuid, QUuid)),
    227             this, SLOT(sltSnapshotChanged(QUuid, QUuid)));
    228     connect(gVBoxEvents, SIGNAL(sigSnapshotRestore(QUuid, QUuid)),
    229             this, SLOT(sltSnapshotChanged(QUuid, QUuid)));
     216    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange,
     217            this, &UIChooserAbstractModel::sltMachineStateChanged);
     218    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange,
     219            this, &UIChooserAbstractModel::sltMachineDataChanged);
     220    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered,
     221            this, &UIChooserAbstractModel::sltMachineRegistered);
     222    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
     223            this, &UIChooserAbstractModel::sltSessionStateChanged);
     224    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotTake,
     225            this, &UIChooserAbstractModel::sltSnapshotChanged);
     226    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotDelete,
     227            this, &UIChooserAbstractModel::sltSnapshotChanged);
     228    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotChange,
     229            this, &UIChooserAbstractModel::sltSnapshotChanged);
     230    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotRestore,
     231            this, &UIChooserAbstractModel::sltSnapshotChanged);
    230232
    231233    /* Setup group saving connections: */
    232     connect(this, &UIChooserAbstractModel::sigGroupSavingStarted,
    233             this, &UIChooserAbstractModel::sltGroupSavingStart,
     234    connect(this, &UIChooserAbstractModel::sigStartGroupSaving,
     235            this, &UIChooserAbstractModel::sltStartGroupSaving,
    234236            Qt::QueuedConnection);
    235237}
     
    342344        new UIChooserNodeGroup(pParentNode,
    343345                               false /* favorite */,
    344                                getDesiredPosition(pParentNode, UIChooserItemType_Group, strSecondSubName),
     346                               getDesiredNodePosition(pParentNode, UIChooserItemType_Group, strSecondSubName),
    345347                               strSecondSubName,
    346                                fAllGroupsOpened || shouldBeGroupOpened(pParentNode, strSecondSubName));
     348                               fAllGroupsOpened || shouldGroupNodeBeOpened(pParentNode, strSecondSubName));
    347349    return strSecondSuffix.isEmpty() ? pNewGroupNode : getGroupNode(strFirstSuffix, pNewGroupNode, fAllGroupsOpened);
    348350}
    349351
    350 bool UIChooserAbstractModel::shouldBeGroupOpened(UIChooserNode *pParentNode, const QString &strName)
     352bool UIChooserAbstractModel::shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName)
    351353{
    352354    /* Read group definitions: */
     
    376378}
    377379
    378 void UIChooserAbstractModel::wipeOutEmptyGroups(UIChooserNode *pParent)
     380void UIChooserAbstractModel::wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParent)
    379381{
    380382    /* Cleanup all the group-items recursively first: */
    381383    foreach (UIChooserNode *pNode, pParent->nodes(UIChooserItemType_Group))
    382         wipeOutEmptyGroups(pNode);
     384        wipeOutEmptyGroupsStartingFrom(pNode);
    383385    /* If parent has no nodes: */
    384386    if (!pParent->hasNodes())
     
    421423}
    422424
    423 int UIChooserAbstractModel::getDesiredPosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName)
     425int UIChooserAbstractModel::getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName)
    424426{
    425427    /* End of list (by default)? */
    426428    int iNewNodeDesiredPosition = -1;
    427429    /* Which position should be new node placed by definitions: */
    428     int iNewNodeDefinitionPosition = positionFromDefinitions(pParentNode, enmType, strName);
     430    int iNewNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmType, strName);
    429431    /* If some position wanted: */
    430432    if (iNewNodeDefinitionPosition != -1)
     
    443445                                        QString();
    444446            AssertMsg(!strDefinitionName.isEmpty(), ("Wrong definition name!"));
    445             int iNodeDefinitionPosition = positionFromDefinitions(pParentNode, enmType, strDefinitionName);
     447            int iNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmType, strDefinitionName);
    446448            /* If some position wanted: */
    447449            if (iNodeDefinitionPosition != -1)
     
    460462}
    461463
    462 int UIChooserAbstractModel::positionFromDefinitions(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName)
     464int UIChooserAbstractModel::getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName)
    463465{
    464466    /* Read group definitions: */
     
    509511    new UIChooserNodeMachine(pParentNode,
    510512                             false /* favorite */,
    511                              getDesiredPosition(pParentNode, UIChooserItemType_Machine, toOldStyleUuid(comMachine.GetId())),
     513                             getDesiredNodePosition(pParentNode, UIChooserItemType_Machine, toOldStyleUuid(comMachine.GetId())),
    512514                             comMachine);
    513515}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r77891 r77892  
    4949    /** @name Group saving stuff.
    5050      * @{ */
    51         /** Notifies about group saving started. */
    52         void sigGroupSavingStarted();
     51        /** Commands to start group saving. */
     52        void sigStartGroupSaving();
    5353        /** Notifies about group saving state changed. */
    5454        void sigGroupSavingStateChanged();
     
    115115      * @{ */
    116116        /** Handles request to start group saving. */
    117         void sltGroupSavingStart();
     117        void sltStartGroupSaving();
    118118        /** Handles group definition saving complete. */
    119119        void sltGroupDefinitionsSaveComplete();
     
    143143          * @param  fAllGroupsOpened  Brings whether we should open all the groups till the required one. */
    144144        UIChooserNode *getGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
    145         /** Returns whether group with certain @a strName should be opened, searching starting from the passed @a pParentItem. */
    146         bool shouldBeGroupOpened(UIChooserNode *pParentNode, const QString &strName);
     145        /** Returns whether group node with certain @a strName should be opened, searching starting from the passed @a pParentItem. */
     146        bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName);
    147147
    148148        /** Wipes out empty groups starting from @a pParentItem. */
    149         void wipeOutEmptyGroups(UIChooserNode *pParentNode);
     149        void wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParentNode);
    150150
    151151        /** Returns whether global node within the @a pParentNode is favorite. */
     
    153153
    154154        /** Acquires desired position for a child of @a pParentNode with specified @a enmType and @a strName. */
    155         int getDesiredPosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName);
    156         /** Acquires saved position for a child of @a pParentNode with specified @a enmType and @a strName. */
    157         int positionFromDefinitions(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName);
     155        int getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName);
     156        /** Acquires defined position for a child of @a pParentNode with specified @a enmType and @a strName. */
     157        int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserItemType enmType, const QString &strName);
    158158
    159159        /** Creates machine node based on certain @a comMachine as a child of specified @a pParentNode. */
     
    181181          * @note  Required for backward compatibility after QString=>QUuid change. */
    182182        static QString toOldStyleUuid(const QUuid &uId);
     183    /** @} */
     184
     185    /** @name General stuff.
     186      * @{ */
     187        /** Holds the parent widget reference. */
     188        UIChooser *m_pParent;
    183189    /** @} */
    184190
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette