VirtualBox

Ignore:
Timestamp:
Jul 7, 2017 2:12:58 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116809
Message:

FE/Qt: bugref:8400: Cache medium-type inside UIMedium; move related code from VBoxGlobal to UIMedium as well.

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

Legend:

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

    r67277 r67854  
    697697
    698698/**
    699  * Similar to toString (KMediumType), but returns 'Differencing' for
    700  * normal hard disks that have a parent.
    701  */
    702 QString VBoxGlobal::mediumTypeString(const CMedium &medium) const
    703 {
    704     if (!medium.GetParent().isNull())
    705     {
    706         Assert(medium.GetType() == KMediumType_Normal);
    707         return mDiskTypes_Differencing;
    708     }
    709     return gpConverter->toString(medium.GetType());
    710 }
    711 
    712 /**
    713699 *  Returns the list of the standard COM port names (i.e. "COMx").
    714700 */
     
    16331619void VBoxGlobal::retranslateUi()
    16341620{
    1635     mDiskTypes_Differencing = tr ("Differencing", "DiskType");
    1636 
    16371621    mUserDefinedPortName = tr ("User-defined", "serial port");
    16381622
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r67277 r67854  
    271271        return tr("%n second(s)", "", cVal);
    272272    }
    273 
    274     QString differencingMediumTypeName() const { return mDiskTypes_Differencing; }
    275 
    276     /**
    277      * Similar to toString (KMediumType), but returns 'Differencing' for
    278      * normal hard disks that have a parent.
    279      */
    280     QString mediumTypeString(const CMedium &medium) const;
    281273
    282274    QStringList COMPortNames() const;
     
    629621    int m3DAvailable;
    630622
    631     QString mDiskTypes_Differencing;
    632 
    633623    QString mUserDefinedPortName;
    634624
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.cpp

    r63567 r67854  
    4141    , m_medium(CMedium())
    4242    , m_state(KMediumState_NotCreated)
     43    , m_enmMediumType(KMediumType_Max)
    4344{
    4445    refresh();
     
    4950    , m_medium(medium)
    5051    , m_state(KMediumState_NotCreated)
     52    , m_enmMediumType(KMediumType_Max)
    5153{
    5254    refresh();
     
    5759    , m_medium(medium)
    5860    , m_state(state)
     61    , m_enmMediumType(KMediumType_Max)
    5962{
    6063    refresh();
     
    8790    m_strSize = other.size();
    8891    m_strLogicalSize = other.logicalSize();
     92
     93    m_enmMediumType = other.mediumType();
    8994
    9095    m_strHardDiskType = other.hardDiskType();
     
    147152    m_strName = VBoxGlobal::tr("Empty", "medium");
    148153    m_strLocation = m_strSize = m_strLogicalSize = QString("--");
     154
     155    /* Reset medium type parameter: */
     156    m_enmMediumType = KMediumType_Max;
    149157
    150158    /* Reset hard drive related parameters: */
     
    211219        }
    212220
     221        /* Refresh medium type: */
     222        m_enmMediumType = m_medium.GetType();
     223
    213224        /* For hard drive medium: */
    214225        if (m_type == UIMediumType_HardDisk)
    215226        {
    216227            /* Refresh hard drive disk type: */
    217             m_strHardDiskType = vboxGlobal().mediumTypeString(m_medium);
     228            m_strHardDiskType = mediumTypeToString(m_medium);
    218229            /* Refresh hard drive format: */
    219230            m_strHardDiskFormat = m_medium.GetFormat();
     
    610621}
    611622
     623/* static */
     624QString UIMedium::mediumTypeToString(const CMedium &comMedium)
     625{
     626    if (!comMedium.GetParent().isNull())
     627    {
     628        Assert(comMedium.GetType() == KMediumType_Normal);
     629        return QApplication::translate("VBoxGlobal", "Differencing", "MediumType");
     630    }
     631    return gpConverter->toString(comMedium.GetType());
     632}
     633
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.h

    r62493 r67854  
    187187    QString logicalSize(bool fNoDiffs = false) const { return fNoDiffs ? root().m_strLogicalSize : m_strLogicalSize; }
    188188
     189    /** Returns the medium disk type.
     190      * @param fNoDiffs @c true to enable user-friendly "don't show diffs" mode.
     191      * @note  In "don't show diffs" mode, this method returns the disk type of root in the given hard drive chain. */
     192    KMediumType mediumType(bool fNoDiffs = false) const { return fNoDiffs ? root().m_enmMediumType : m_enmMediumType; }
     193
    189194    /** Returns the hard drive medium disk type.
    190195      * @param fNoDiffs @c true to enable user-friendly "don't show diffs" mode.
     
    307312    void checkNoDiffs(bool fNoDiffs);
    308313
     314    /** Returns string representation for passed @a comMedium type. */
     315    static QString mediumTypeToString(const CMedium &comMedium);
     316
    309317    /** Holds the type of UIMedium object. */
    310318    UIMediumType m_type;
     
    339347    /** Holds the medium logical size. */
    340348    QString m_strLogicalSize;
     349
     350    /** Holds the medium disk type. */
     351    KMediumType m_enmMediumType;
    341352
    342353    /** Holds the hard drive medium disk type. */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r67810 r67854  
    384384    m_enmType = m_guiMedium.type();
    385385    /* Gather medium options data: */
    386     m_options.m_enmType = m_guiMedium.medium().GetType(); /// @todo: Cache it in UIMedium class!
     386    m_options.m_enmType = m_guiMedium.mediumType();
    387387    /* Gather medium details data: */
    388388    m_details.m_aFields.clear();
Note: See TracChangeset for help on using the changeset viewer.

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