VirtualBox

Changeset 48278 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Sep 4, 2013 5:15:43 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: UIMedium: Cleanup/rework (part 1).

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

Legend:

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

    r48272 r48278  
    2828#include "UIMedium.h"
    2929#include "VBoxGlobal.h"
     30#include "UIConverter.h"
    3031#include "UIMessageCenter.h"
    31 #include "UIConverter.h"
    3232
    3333/* COM includes: */
     
    3939QString UIMedium::m_sstrTable = QString("<table>%1</table>");
    4040QString UIMedium::m_sstrRow = QString("<tr><td>%1</td></tr>");
     41
     42UIMedium::UIMedium()
     43    : m_type(UIMediumType_Invalid)
     44    , m_state(KMediumState_NotCreated)
     45    , m_pParent(0)
     46{
     47    refresh();
     48//    printf("UIMedium: New NULL medium created.\n");
     49}
     50
     51UIMedium::UIMedium(const CMedium &medium, UIMediumType type, UIMedium *pParent /*= 0*/)
     52    : m_medium(medium)
     53    , m_type(type)
     54    , m_state(KMediumState_NotCreated)
     55    , m_pParent(pParent)
     56{
     57    refresh();
     58//    printf("UIMedium: New medium with ID={%s} created.\n", id().toAscii().constData());
     59}
     60
     61UIMedium::UIMedium(const CMedium &medium, UIMediumType type, KMediumState state)
     62    : m_medium(medium)
     63    , m_type(type)
     64    , m_state(state)
     65    , m_pParent(0)
     66{
     67    refresh();
     68//    printf("UIMedium: New medium with ID={%s} created (with known state).\n", id().toAscii().constData());
     69}
     70
     71UIMedium::UIMedium(const UIMedium &other)
     72{
     73    *this = other;
     74}
    4175
    4276UIMedium& UIMedium::operator=(const UIMedium &other)
     
    132166    m_fHostDrive = false;
    133167
    134     /* Detect basic parameters */
    135     m_strId = m_medium.isNull() ? QUuid().toString().remove ('{').remove ('}') : m_medium.GetId();
     168    /* Detect basic parameters... */
     169
     170    m_strId = m_medium.isNull() ? nullID() : m_medium.GetId();
    136171
    137172    m_fHostDrive = m_medium.isNull() ? false : m_medium.GetHostDrive();
     
    252287                QString strSnapshots;
    253288
    254                 QVector <QString> snapIds = m_medium.GetSnapshotIds(strMachineID);
    255                 for (QVector <QString>::ConstIterator jt = snapIds.begin(); jt != snapIds.end(); ++jt)
     289                foreach (const QString &strSnapshotID, m_medium.GetSnapshotIds(strMachineID))
    256290                {
    257                     if (*jt == strMachineID)
     291                    if (strSnapshotID == strMachineID)
    258292                    {
    259293                        /* The medium is attached to the machine in the current
    260294                         * state, we don't distinguish this for now by always
    261295                         * giving the VM name in front of snapshot names. */
    262                         m_curStateMachineIds.push_back(*jt);
     296                        m_curStateMachineIds.push_back(strSnapshotID);
    263297                        continue;
    264298                    }
    265299
    266                     CSnapshot snapshot = machine.FindSnapshot(*jt);
     300                    CSnapshot snapshot = machine.FindSnapshot(strSnapshotID);
    267301                    if (!snapshot.isNull()) // can be NULL while takeSnaphot is in progress
    268302                    {
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.h

    r48272 r48278  
    8383public:
    8484
    85     /**
    86      * Creates a null medium descriptor which is not associated with any medium.
    87      * The state field is set to KMediumState_NotCreated.
    88      */
    89     UIMedium()
    90         : m_type(UIMediumType_Invalid)
    91         , m_state(KMediumState_NotCreated)
    92         , m_pParent(0) { refresh(); }
    93 
    94     /**
    95      * Creates a media descriptor associated with the given medium.
    96      *
    97      * The state field remain KMediumState_NotCreated until #blockAndQueryState()
    98      * is called. All precomposed strings are filled up by implicitly calling
    99      * #refresh(), see the #refresh() details for more info.
    100      *
    101      * One of the hardDisk, dvdImage, or floppyImage members is assigned from
    102      * medium according to type. @a pParent must be always NULL for non-hard
    103      * disk media.
    104      */
    105     UIMedium(const CMedium &medium, UIMediumType type, UIMedium *pParent = 0)
    106         : m_medium(medium)
    107         , m_type(type)
    108         , m_state(KMediumState_NotCreated)
    109         , m_pParent(pParent) { refresh(); }
    110 
    111     /**
    112      * Similar to the other non-null constructor but sets the media state to
    113      * @a state. Suitable when the media state is known such as right after
    114      * creation.
    115      */
    116     UIMedium(const CMedium &medium, UIMediumType type, KMediumState state)
    117         : m_medium(medium)
    118         , m_type(type)
    119         , m_state(state)
    120         , m_pParent(0) { refresh(); }
    121 
     85    /* Default (NULL) constructor:
     86     * Creates NULL uimedium which is not associated with any medium. */
     87    UIMedium();
     88
     89    /* Lazy wrapping constructor:
     90     * Creates a uimedium associated with the given medium. */
     91    UIMedium(const CMedium &medium, UIMediumType type, UIMedium *pParent = 0);
     92
     93    /* Wrapping constructor with known medium state:
     94     * Similar to previous one but sets the uimedium state to passed one.
     95     * Suitable when the medium-state is known such as right after medium creation. */
     96    UIMedium(const CMedium &medium, UIMediumType type, KMediumState state);
     97
     98    /* Copy-constructor: */
     99    UIMedium(const UIMedium &other);
     100
     101    /* API: Operator=: */
    122102    UIMedium& operator=(const UIMedium &other);
    123103
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