VirtualBox

Ignore:
Timestamp:
Jun 14, 2019 1:12:21 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:7127: A bit of fefactoring for UIMediumEnumerator: Rework r131292 and r131293 to be more clear.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.cpp

    r79131 r79150  
    387387             uMachineId.toString().toUtf8().constData()));
    388388
    389     /* Parse machine ID: */
     389    /* Enumerate all the media of machine with this ID: */
    390390    QList<QUuid> result;
    391     parseMachineId(uMachineId, result);
     391    enumerateAllMediaOfMachineWithId(uMachineId, result);
    392392}
    393393
     
    414414void UIMediumEnumerator::sltHandleMediumChange(CMediumAttachment comAttachment)
    415415{
    416     //printf("OnMediumChanged\n");
    417     LogRel2(("GUI: UIMediumEnumerator: OnMediumChanged event received\n"));
     416    //printf("MediumChanged\n");
     417    LogRel2(("GUI: UIMediumEnumerator: MediumChanged event received\n"));
    418418
    419419    /* Parse attachment: */
     
    424424void UIMediumEnumerator::sltHandleMediumConfigChange(CMedium comMedium)
    425425{
    426     //printf("OnMediumConfigChanged\n");
    427     LogRel2(("GUI: UIMediumEnumerator: OnMediumConfigChanged event received\n"));
     426    //printf("MediumConfigChanged\n");
     427    LogRel2(("GUI: UIMediumEnumerator: MediumConfigChanged event received\n"));
    428428
    429429    /* Parse medium: */
     
    434434void UIMediumEnumerator::sltHandleMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered)
    435435{
    436     //printf("OnMediumRegistered: medium-id=%s, medium-type=%d, registered=%d\n",
     436    //printf("MediumRegistered: medium-id=%s, medium-type=%d, registered=%d\n",
    437437    //       uMediumId.toString().toUtf8().constData(), enmMediumType, fRegistered);
    438438    //printf(" Medium to recache: %s\n",
    439439    //       uMediumId.toString().toUtf8().constData());
    440     LogRel2(("GUI: UIMediumEnumerator: OnMediumRegistered event received, Medium ID = {%s}, Medium type = {%d}, Registered = {%d}\n",
     440    LogRel2(("GUI: UIMediumEnumerator: MediumRegistered event received, Medium ID = {%s}, Medium type = {%d}, Registered = {%d}\n",
    441441             uMediumId.toString().toUtf8().constData(), enmMediumType, fRegistered));
    442442
     
    775775
    776776#else /* VBOX_GUI_WITH_NEW_MEDIA_EVENTS */
    777 
    778 void UIMediumEnumerator::parseMachineId(const QUuid &uMachineId, QList<QUuid> &result)
    779 {
    780     /* For each the cached UIMedium we have: */
    781     foreach (const QUuid &uMediumId, mediumIDs())
    782     {
    783         /* Check if medium isn't NULL, used by our
    784          * machine and wasn't already enumerated. */
    785         const UIMedium guiMedium = medium(uMediumId);
    786         if (   !guiMedium.isNull()
    787             && guiMedium.machineIds().contains(uMachineId)
    788             && !result.contains(uMediumId))
    789         {
    790             /* Enumerate corresponding UIMedium: */
    791             LogRel2(("GUI: UIMediumEnumerator:  Medium {%s} of machine {%s} will be enumerated..\n",
    792                      uMediumId.toString().toUtf8().constData(),
    793                      uMachineId.toString().toUtf8().constData()));
    794             createMediumEnumerationTask(guiMedium);
    795             result << uMediumId;
    796         }
    797     }
    798 }
    799777
    800778void UIMediumEnumerator::parseAttachment(CMediumAttachment comAttachment, QList<QUuid> &result)
     
    844822                else
    845823                {
    846                     /* Parse machine ID: */
    847                     parseMachineId(uMachineId, result);
     824                    /* Enumerate all the media of machine with this ID: */
     825                    enumerateAllMediaOfMachineWithId(uMachineId, result);
    848826                }
    849827            }
     
    895873}
    896874
     875void UIMediumEnumerator::enumerateAllMediaOfMachineWithId(const QUuid &uMachineId, QList<QUuid> &result)
     876{
     877    /* For each the cached UIMedium we have: */
     878    foreach (const QUuid &uMediumId, mediumIDs())
     879    {
     880        /* Check if medium isn't NULL, used by our
     881         * machine and wasn't already enumerated. */
     882        const UIMedium guiMedium = medium(uMediumId);
     883        if (   !guiMedium.isNull()
     884            && guiMedium.machineIds().contains(uMachineId)
     885            && !result.contains(uMediumId))
     886        {
     887            /* Enumerate corresponding UIMedium: */
     888            printf(" Medium to recache: %s\n",
     889                   uMediumId.toString().toUtf8().constData());
     890            LogRel2(("GUI: UIMediumEnumerator:  Medium {%s} of machine {%s} will be enumerated..\n",
     891                     uMediumId.toString().toUtf8().constData(),
     892                     uMachineId.toString().toUtf8().constData()));
     893            createMediumEnumerationTask(guiMedium);
     894            result << uMediumId;
     895        }
     896    }
     897}
     898
    897899#endif /* VBOX_GUI_WITH_NEW_MEDIA_EVENTS */
    898900
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumEnumerator.h

    r79131 r79150  
    186186                                const QList<QUuid> &currentCMediumIDs);
    187187#else /* VBOX_GUI_WITH_NEW_MEDIA_EVENTS */
    188     /** Parses machine with incoming @a uMachineId, enumerating ONLY KNOWN media it has.
    189       * @param  result  Brings the list of previously enumerated media
    190       *                 IDs to be appended with newly enumerated. */
    191     void parseMachineId(const QUuid &uMachineId, QList<QUuid> &result);
    192188    /** Parses incoming @a comAttachment, enumerating the media it has attached.
    193189      * @param  result  Brings the list of previously enumerated media
     
    198194      *                 IDs to be appended with newly enumerated. */
    199195    void parseMedium(CMedium comMedium, QList<QUuid> &result);
     196
     197    /** Enumerates all the known media attached to machine with certain @a uMachineId.
     198      * @param  result  Brings the list of previously enumerated media
     199      *                 IDs to be appended with newly enumerated. */
     200    void enumerateAllMediaOfMachineWithId(const QUuid &uMachineId, QList<QUuid> &result);
    200201#endif /* VBOX_GUI_WITH_NEW_MEDIA_EVENTS */
    201202
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