VirtualBox

Changeset 72822 in vbox


Ignore:
Timestamp:
Jul 3, 2018 1:43:06 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: Move/rework MediumBackends functionality out of VBoxGlobal to UIMediumDefs.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r72821 r72822  
    9090# include "CExtPackManager.h"
    9191# include "CMachine.h"
    92 # include "CSystemProperties.h"
    9392# include "CUSBDevice.h"
    9493# include "CUSBDeviceFilters.h"
     
    104103# include "CHostUSBDevice.h"
    105104# include "CHostVideoInputDevice.h"
    106 # include "CMediumFormat.h"
    107105# include "CSharedFolder.h"
    108106# include "CConsole.h"
     
    179177/* Namespaces: */
    180178using namespace UIExtraDataDefs;
     179using namespace UIMediumDefs;
    181180
    182181
     
    24152414}
    24162415
    2417 QList<QPair<QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType) const
    2418 {
    2419     /* Prepare a list of pairs with the form <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. */
    2420     CSystemProperties comSystemProperties = virtualBox().GetSystemProperties();
    2421     QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats();
    2422     QList< QPair<QString, QString> > backendPropList;
    2423     for (int i = 0; i < mediumFormats.size(); ++i)
    2424     {
    2425         /* File extensions */
    2426         QVector <QString> fileExtensions;
    2427         QVector <KDeviceType> deviceTypes;
    2428 
    2429         mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes);
    2430 
    2431         QStringList f;
    2432         for (int a = 0; a < fileExtensions.size(); ++a)
    2433             if (deviceTypes[a] == enmType)
    2434                 f << QString("*.%1").arg(fileExtensions[a]);
    2435         /* Create a pair out of the backend description and all suffix's. */
    2436         if (!f.isEmpty())
    2437             backendPropList << QPair<QString, QString>(mediumFormats[i].GetName(), f.join(" "));
    2438     }
    2439     return backendPropList;
    2440 }
    2441 
    2442 /* static */
    2443 QList<QPair<QString, QString> > VBoxGlobal::HDDBackends() const
    2444 {
    2445     return MediumBackends(KDeviceType_HardDisk);
    2446 }
    2447 
    2448 /* static */
    2449 QList<QPair<QString, QString> > VBoxGlobal::DVDBackends() const
    2450 {
    2451     return MediumBackends(KDeviceType_DVD);
    2452 }
    2453 
    2454 /* static */
    2455 QList<QPair<QString, QString> > VBoxGlobal::FloppyBackends() const
    2456 {
    2457     return MediumBackends(KDeviceType_Floppy);
    2458 }
    2459 
    24602416void VBoxGlobal::startMediumEnumeration()
    24612417{
     
    26262582        case UIMediumType_HardDisk:
    26272583        {
    2628             filters = HDDBackends();
     2584            filters = HDDBackends(virtualBox());
    26292585            strTitle = tr("Please choose a virtual hard disk file");
    26302586            allType = tr("All virtual hard disk files (%1)");
     
    26382594        case UIMediumType_DVD:
    26392595        {
    2640             filters = DVDBackends();
     2596            filters = DVDBackends(virtualBox());
    26412597            strTitle = tr("Please choose a virtual optical disk file");
    26422598            allType = tr("All virtual optical disk files (%1)");
     
    26502606        case UIMediumType_Floppy:
    26512607        {
    2652             filters = FloppyBackends();
     2608            filters = FloppyBackends(virtualBox());
    26532609            strTitle = tr("Please choose a virtual floppy disk file");
    26542610            allType = tr("All virtual floppy disk files (%1)");
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r72821 r72822  
    475475    /** @name COM: Virtual Media stuff.
    476476     * @{ */
    477         /** Returns medium formats which are currently supported by VirtualBox for the given @a enmDeviceType. */
    478         QList<QPair<QString, QString> > MediumBackends(KDeviceType enmDeviceType) const;
    479         /** Returns which hard disk formats are currently supported by VirtualBox. */
    480         QList<QPair<QString, QString> > HDDBackends() const;
    481         /** Returns which optical disk formats are currently supported by VirtualBox. */
    482         QList<QPair<QString, QString> > DVDBackends() const;
    483         /** Returns which floppy disk formats are currently supported by VirtualBox. */
    484         QList<QPair<QString, QString> > FloppyBackends() const;
    485 
    486477        /** Starts medium enumeration. */
    487478        void startMediumEnumeration();
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.cpp

    r69500 r72822  
    2222/* GUI includes: */
    2323# include "UIMediumDefs.h"
     24
     25/* COM includes: */
     26# include "CMediumFormat.h"
     27# include "CSystemProperties.h"
     28# include "CVirtualBox.h"
    2429
    2530#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    6065}
    6166
     67QList<QPair<QString, QString> > UIMediumDefs::MediumBackends(const CVirtualBox &comVBox, KDeviceType enmType)
     68{
     69    /* Prepare a list of pairs with the form <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. */
     70    const CSystemProperties comSystemProperties = comVBox.GetSystemProperties();
     71    QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats();
     72    QList<QPair<QString, QString> > backendPropList;
     73    for (int i = 0; i < mediumFormats.size(); ++i)
     74    {
     75        /* Acquire file extensions & device types: */
     76        QVector<QString> fileExtensions;
     77        QVector<KDeviceType> deviceTypes;
     78        mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes);
     79
     80        /* Compose filters list: */
     81        QStringList filters;
     82        for (int iExtensionIndex = 0; iExtensionIndex < fileExtensions.size(); ++iExtensionIndex)
     83            if (deviceTypes[iExtensionIndex] == enmType)
     84                filters << QString("*.%1").arg(fileExtensions[iExtensionIndex]);
     85        /* Create a pair out of the backend description and all suffix's. */
     86        if (!filters.isEmpty())
     87            backendPropList << QPair<QString, QString>(mediumFormats[i].GetName(), filters.join(" "));
     88    }
     89    return backendPropList;
     90}
     91
     92QList<QPair<QString, QString> > UIMediumDefs::HDDBackends(const CVirtualBox &comVBox)
     93{
     94    return MediumBackends(comVBox, KDeviceType_HardDisk);
     95}
     96
     97QList<QPair<QString, QString> > UIMediumDefs::DVDBackends(const CVirtualBox &comVBox)
     98{
     99    return MediumBackends(comVBox, KDeviceType_DVD);
     100}
     101
     102QList<QPair<QString, QString> > UIMediumDefs::FloppyBackends(const CVirtualBox &comVBox)
     103{
     104    return MediumBackends(comVBox, KDeviceType_Floppy);
     105}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h

    r72821 r72822  
    2727/* COM includes: */
    2828#include "COMEnums.h"
     29#include "CVirtualBox.h"
    2930
    3031/* Other VBox includes: */
    3132#include <VBox/com/defs.h>
     33
     34/* Forward declarations: */
     35class CVirtualBox;
    3236
    3337
     
    5862    /** Converts global medium type (KDeviceType) to local (UIMediumType). */
    5963    SHARED_LIBRARY_STUFF UIMediumType mediumTypeToLocal(KDeviceType globalType);
    60 
    6164    /** Convert local medium type (UIMediumType) to global (KDeviceType). */
    6265    SHARED_LIBRARY_STUFF KDeviceType mediumTypeToGlobal(UIMediumType localType);
     66
     67    /** Returns medium formats which are currently supported by @a comVBox for the given @a enmDeviceType. */
     68    QList<QPair<QString, QString> > MediumBackends(const CVirtualBox &comVBox, KDeviceType enmDeviceType);
     69    /** Returns which hard disk formats are currently supported by @a comVBox. */
     70    QList<QPair<QString, QString> > HDDBackends(const CVirtualBox &comVBox);
     71    /** Returns which optical disk formats are currently supported by @a comVBox. */
     72    QList<QPair<QString, QString> > DVDBackends(const CVirtualBox &comVBox);
     73    /** Returns which floppy disk formats are currently supported by @a comVBox. */
     74    QList<QPair<QString, QString> > FloppyBackends(const CVirtualBox &comVBox);
    6375}
    6476/* Using this namespace globally: */
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