VirtualBox

Changeset 55099 in vbox


Ignore:
Timestamp:
Apr 3, 2015 6:15:39 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99394
Message:

FE/Qt: 7127: Medium-enumeration improvements: UIMedium source doxy and coding style fixes.

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

Legend:

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

    r52730 r55099  
    55
    66/*
    7  * Copyright (C) 2009-2013 Oracle Corporation
     7 * Copyright (C) 2009-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919# include <precomp.h>
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    21 
    2221/* Qt includes: */
    2322# include <QDir>
    24 
    2523/* GUI includes: */
    2624# include "UIMedium.h"
     
    3028# include "UIExtraDataManager.h"
    3129# include "UIIconPool.h"
    32 
    3330/* COM includes: */
    3431# include "CMachine.h"
    3532# include "CSnapshot.h"
    36 
    3733#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    38 
    3934
    4035QString UIMedium::m_sstrNullID = QUuid().toString().remove('{').remove('}');
     
    4439UIMedium::UIMedium()
    4540    : m_type(UIMediumType_Invalid)
     41    , m_medium(CMedium())
    4642    , m_state(KMediumState_NotCreated)
    4743{
    4844    refresh();
    49 //    printf("UIMedium: New NULL medium created.\n");
    5045}
    5146
    5247UIMedium::UIMedium(const CMedium &medium, UIMediumType type)
    53     : m_medium(medium)
    54     , m_type(type)
     48    : m_type(type)
     49    , m_medium(medium)
    5550    , m_state(KMediumState_NotCreated)
    5651{
    5752    refresh();
    58 //    printf("UIMedium: New medium with ID={%s} created.\n", id().toAscii().constData());
    5953}
    6054
    6155UIMedium::UIMedium(const CMedium &medium, UIMediumType type, KMediumState state)
    62     : m_medium(medium)
    63     , m_type(type)
     56    : m_type(type)
     57    , m_medium(medium)
    6458    , m_state(state)
    6559{
    6660    refresh();
    67 //    printf("UIMedium: New medium with ID={%s} created (with known state).\n", id().toAscii().constData());
    6861}
    6962
     
    7568UIMedium& UIMedium::operator=(const UIMedium &other)
    7669{
     70    m_type = other.type();
     71
    7772    m_medium = other.medium();
    78     m_type = other.type();
     73
    7974    m_state = other.state();
     75    m_result = other.result();
    8076    m_strLastAccessError = other.lastAccessError();
    81     m_result = other.result();
     77
     78    m_strId = other.id();
     79    m_strRootId = other.rootID();
     80    m_strParentId = other.parentID();
    8281
    8382    m_strKey = other.key();
    84     m_strId = other.id();
     83
    8584    m_strName = other.name();
    8685    m_strLocation = other.location();
     
    8988    m_strLogicalSize = other.logicalSize();
    9089
     90    m_strHardDiskType = other.hardDiskType();
    9191    m_strHardDiskFormat = other.hardDiskFormat();
    92     m_strHardDiskType = other.hardDiskType();
    93 
    9492    m_strStorageDetails = other.storageDetails();
    9593
    9694    m_strUsage = other.usage();
    9795    m_strToolTip = other.tip();
     96    m_machineIds = other.machineIds();
     97    m_curStateMachineIds = other.curStateMachineIds();
     98
     99    m_noDiffs = other.cache();
    98100
    99101    m_fHidden = other.m_fHidden;
     
    103105    m_fHostDrive = other.isHostDrive();
    104106
    105     m_machineIds = other.machineIds();
    106     m_curStateMachineIds = other.curStateMachineIds();
    107 
    108     m_strParentID = other.parentID();
    109     m_strRootID = other.rootID();
    110 
    111     m_noDiffs = other.cache();
    112 
    113107    return *this;
    114108}
    115109
    116 /**
    117  * Queries the medium state. Call this and then read the state field instead
    118  * of calling GetState() on medium directly as it will properly handle the
    119  * situation when GetState() itself fails by setting state to Inaccessible
    120  * and memorizing the error info describing why GetState() failed.
    121  *
    122  * As the last step, this method calls #refresh() to refresh all precomposed
    123  * strings.
    124  *
    125  * @note This method blocks for the duration of the state check. Since this
    126  *       check may take quite a while (e.g. for a medium located on a
    127  *       network share), the calling thread must not be the UI thread. You
    128  *       have been warned.
    129  */
    130110void UIMedium::blockAndQueryState()
    131111{
     
    149129}
    150130
    151 /**
    152  * Refreshes the precomposed strings containing such media parameters as
    153  * location, size by querying the respective data from the associated
    154  * media object.
    155  *
    156  * Note that some string such as #size() are meaningless if the media state is
    157  * KMediumState_NotCreated (i.e. the medium has not yet been checked for
    158  * accessibility).
    159  */
    160131void UIMedium::refresh()
    161132{
     
    199170
    200171    /* Initialize parent/root IDs: */
    201     m_strParentID = nullID();
    202     m_strRootID = m_strId;
     172    m_strParentId = nullID();
     173    m_strRootId = m_strId;
    203174    if (m_type == UIMediumType_HardDisk)
    204175    {
     
    217188        CMedium parentMedium = m_medium.GetParent();
    218189        if (!parentMedium.isNull())
    219             m_strParentID = parentMedium.GetId();
     190            m_strParentId = parentMedium.GetId();
    220191        while (!parentMedium.isNull())
    221192        {
    222             m_strRootID = parentMedium.GetId();
     193            m_strRootId = parentMedium.GetId();
    223194            parentMedium = parentMedium.GetParent();
    224195        }
     
    369340void UIMedium::updateParentID()
    370341{
    371     m_strParentID = nullID();
     342    m_strParentId = nullID();
    372343    if (m_type == UIMediumType_HardDisk)
    373344    {
    374345        CMedium parentMedium = m_medium.GetParent();
    375346        if (!parentMedium.isNull())
    376             m_strParentID = parentMedium.GetId();
     347            m_strParentId = parentMedium.GetId();
    377348    }
    378349}
     
    381352{
    382353    /* Redirect call to VBoxGlobal: */
    383     return vboxGlobal().medium(m_strParentID);
     354    return vboxGlobal().medium(m_strParentId);
    384355}
    385356
     
    387358{
    388359    /* Redirect call to VBoxGlobal: */
    389     return vboxGlobal().medium(m_strRootID);
    390 }
    391 
    392 /**
    393  * Returns generated tooltip for this medium.
    394  *
    395  * In "don't show diffs" mode (where the attributes of the base hard disk are
    396  * shown instead of the attributes of the differencing hard disk), extra
    397  * information will be added to the tooltip to give the user a hint that the
    398  * medium is actually a differencing hard disk.
    399  *
    400  * @param fNoDiffs  @c true to enable user-friendly "don't show diffs" mode.
    401  * @param fCheckRO  @c true to perform the #readOnly() check and add a notice
    402  *                  accordingly.
    403  */
    404 QString UIMedium::toolTip (bool fNoDiffs /* = false */, bool fCheckRO /* = false */, bool fNullAllowed /* = false */) const
     360    return vboxGlobal().medium(m_strRootId);
     361}
     362
     363QString UIMedium::toolTip(bool fNoDiffs /* = false */, bool fCheckRO /* = false */, bool fNullAllowed /* = false */) const
    405364{
    406365    QString strTip;
     
    428387}
    429388
    430 /**
    431  * Returns an icon corresponding to the media state. Distinguishes between
    432  * the Inaccessible state and the situation when querying the state itself
    433  * failed.
    434  *
    435  * In "don't show diffs" mode (where the attributes of the base hard disk are
    436  * shown instead of the attributes of the differencing hard disk), the most
    437  * worst media state on the given hard disk chain will be used to select the
    438  * media icon.
    439  *
    440  * @param fNoDiffs  @c true to enable user-friendly "don't show diffs" mode.
    441  * @param fCheckRO  @c true to perform the #readOnly() check and change the icon
    442  *                  accordingly.
    443  */
    444389QPixmap UIMedium::icon(bool fNoDiffs /* = false */, bool fCheckRO /* = false */) const
    445390{
     
    458403}
    459404
    460 /**
    461  * Returns the details of this medium as a single-line string
    462  *
    463  * For hard disks, the details include the location, type and the logical size
    464  * of the hard disk. Note that if @a fNoDiffs is @c true, these properties are
    465  * queried on the root hard disk of the given hard disk because the primary
    466  * purpose of the returned string is to be human readable (so that seeing a
    467  * complex diff hard disk name is usually not desirable).
    468  *
    469  * For other media types, the location and the actual size are returned.
    470  * Arguments @a fPredictDiff and @a aNoRoot are ignored in this case.
    471  *
    472  * @param fNoDiffs      @c true to enable user-friendly "don't show diffs" mode.
    473  * @param fPredictDiff  @c true to mark the hard disk as differencing if
    474  *                      attaching it would create a differencing hard disk (not
    475  *                      used when @a aNoRoot is true).
    476  * @param fUseHTML      @c true to allow for emphasizing using bold and italics.
    477  *
    478  * @note Use #detailsHTML() instead of passing @c true for @a fUseHTML.
    479  *
    480  * @note The media object may become uninitialized by a third party while this
    481  *       method is reading its properties. In this case, the method will return
    482  *       an empty string.
    483  */
    484405QString UIMedium::details(bool fNoDiffs /* = false */,
    485406                          bool fPredictDiff /* = false */,
     
    583504}
    584505
    585 /**
    586  * Checks if m_noDiffs is filled in and does it if not.
    587  *
    588  * @param fNoDiffs  @if false, this method immediately returns.
    589  */
    590506void UIMedium::checkNoDiffs(bool fNoDiffs)
    591507{
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.h

    r55098 r55099  
    151151
    152152    /** Returns the medium root ID. */
    153     QString rootID() const { return m_strRootID; }
     153    QString rootID() const { return m_strRootId; }
    154154    /** Returns the medium parent ID. */
    155     QString parentID() const { return m_strParentID; }
     155    QString parentID() const { return m_strParentId; }
    156156
    157157    /** Returns medium root. */
     
    309309    QString m_strId;
    310310    /** Holds the medium root ID. */
    311     QString m_strRootID;
     311    QString m_strRootId;
    312312    /** Holds the medium parent ID. */
    313     QString m_strParentID;
     313    QString m_strParentId;
    314314
    315315    /** Holds the medium cache key. */
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