VirtualBox

Changeset 103338 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 13, 2024 4:37:06 PM (12 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161647
Message:

FE/Qt: Medium related stuff: Moving getFormatsForDeviceType from UIMediumDefs to UIFDCreationDialog to avoid unwanted dependencies; This stuff is used just in one place after all.

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

Legend:

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

    r100896 r103338  
    104104    /* Acquire medium path & formats: */
    105105    const QString strMediumLocation = m_pFilePathSelector->path();
    106     const QVector<CMediumFormat> mediumFormats = UIMediumDefs::getFormatsForDeviceType(KDeviceType_Floppy);
     106    const QVector<CMediumFormat> mediumFormats = getFormatsForDeviceType(KDeviceType_Floppy);
    107107    /* Make sure we have both path and formats selected: */
    108108    if (strMediumLocation.isEmpty() || mediumFormats.isEmpty())
     
    173173}
    174174
     175void UIFDCreationDialog::sltHandleMediumCreated(const CMedium &comMedium)
     176{
     177    /* Store the ID of the newly created medium: */
     178    m_uMediumID = comMedium.GetId();
     179
     180    /* Close the dialog now: */
     181    QDialog::accept();
     182}
     183
    175184void UIFDCreationDialog::sltPathChanged(const QString &strPath)
    176185{
     
    180189    if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Ok))
    181190        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(fIsFileUnique);
    182 }
    183 
    184 bool UIFDCreationDialog::checkFilePath(const QString &strPath) const
    185 {
    186     return !QFileInfo(strPath).exists();
    187 }
    188 
    189 void UIFDCreationDialog::sltHandleMediumCreated(const CMedium &comMedium)
    190 {
    191     /* Store the ID of the newly created medium: */
    192     m_uMediumID = comMedium.GetId();
    193 
    194     /* Close the dialog now: */
    195     QDialog::accept();
    196191}
    197192
     
    312307    return strDefaultFilePath;
    313308}
     309
     310bool UIFDCreationDialog::checkFilePath(const QString &strPath) const
     311{
     312    return !QFileInfo(strPath).exists();
     313}
     314
     315/* static */
     316QVector<CMediumFormat> UIFDCreationDialog::getFormatsForDeviceType(KDeviceType enmDeviceType)
     317{
     318    CSystemProperties comSystemProperties = uiCommon().virtualBox().GetSystemProperties();
     319    QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats();
     320    QVector<CMediumFormat> formatList;
     321    for (int i = 0; i < mediumFormats.size(); ++i)
     322    {
     323        /* File extensions */
     324        QVector<QString> fileExtensions;
     325        QVector<KDeviceType> deviceTypes;
     326
     327        mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes);
     328        if (deviceTypes.contains(enmDeviceType))
     329            formatList.push_back(mediumFormats[i]);
     330    }
     331    return formatList;
     332}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.h

    r98103 r103338  
    3939#include "QIWithRetranslateUI.h"
    4040
     41/* COM includes: */
     42#include "COMEnums.h"
     43#include "CMediumFormat.h"
     44
    4145/* Forward declarations: */
    4246class QCheckBox;
     
    7074      * returns the UUID of the newly created medium if successful, a null QUuid otherwise.*/
    7175    static QUuid createFloppyDisk(QWidget *pParent, const QString &strDefaultFolder = QString(),
    72                            const QString &strMachineName = QString());
    73 
     76                                  const QString &strMachineName = QString());
    7477
    7578public slots:
    7679
    7780    /** Creates the floppy disc image, asynchronously. */
    78     virtual void accept() /* override final */;
     81    virtual void accept() RT_OVERRIDE;
    7982
    8083protected:
    8184
    8285    /** Handles translation event. */
    83     virtual void retranslateUi() /* override final */;
     86    virtual void retranslateUi() RT_OVERRIDE;
    8487
    8588private slots:
     
    109112    bool checkFilePath(const QString &strPath) const;
    110113
     114    /** Returns a list of formats for certain @a enmDeviceType. */
     115    static QVector<CMediumFormat> getFormatsForDeviceType(KDeviceType enmDeviceType);
     116
    111117    /** Holds the default folder. */
    112118    QString  m_strDefaultFolder;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.cpp

    r98103 r103338  
    135135    return QString();
    136136}
    137 
    138 QVector<CMediumFormat> UIMediumDefs::getFormatsForDeviceType(KDeviceType enmDeviceType)
    139 {
    140     CSystemProperties comSystemProperties = uiCommon().virtualBox().GetSystemProperties();
    141     QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats();
    142     QVector<CMediumFormat> formatList;
    143     for (int i = 0; i < mediumFormats.size(); ++i)
    144     {
    145         /* File extensions */
    146         QVector <QString> fileExtensions;
    147         QVector <KDeviceType> deviceTypes;
    148 
    149         mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes);
    150         if (deviceTypes.contains(enmDeviceType))
    151             formatList.push_back(mediumFormats[i]);
    152     }
    153     return formatList;
    154 }
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h

    r98103 r103338  
    4040/* COM includes: */
    4141#include "COMEnums.h"
    42 #include "CVirtualBox.h"
    4342
    4443/* Other VBox includes: */
     
    8988    /** Returns the first file extension of the list of file extension support for the @a enmDeviceType. */
    9089   QString getPreferredExtensionForMedium(KDeviceType enmDeviceType);
    91    QVector<CMediumFormat>  getFormatsForDeviceType(KDeviceType enmDeviceType);
    9290}
    9391/* Using this namespace globally: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.h

    r103309 r103338  
    3131# pragma once
    3232#endif
     33
     34/* Qt includes: */
     35#include <QUuid>
    3336
    3437/* GUI includes: */
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