Changeset 55099 in vbox
- Timestamp:
- Apr 3, 2015 6:15:39 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99394
- 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 5 5 6 6 /* 7 * Copyright (C) 2009-201 3Oracle Corporation7 * Copyright (C) 2009-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 # include <precomp.h> 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 22 21 /* Qt includes: */ 23 22 # include <QDir> 24 25 23 /* GUI includes: */ 26 24 # include "UIMedium.h" … … 30 28 # include "UIExtraDataManager.h" 31 29 # include "UIIconPool.h" 32 33 30 /* COM includes: */ 34 31 # include "CMachine.h" 35 32 # include "CSnapshot.h" 36 37 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 38 39 34 40 35 QString UIMedium::m_sstrNullID = QUuid().toString().remove('{').remove('}'); … … 44 39 UIMedium::UIMedium() 45 40 : m_type(UIMediumType_Invalid) 41 , m_medium(CMedium()) 46 42 , m_state(KMediumState_NotCreated) 47 43 { 48 44 refresh(); 49 // printf("UIMedium: New NULL medium created.\n");50 45 } 51 46 52 47 UIMedium::UIMedium(const CMedium &medium, UIMediumType type) 53 : m_ medium(medium)54 , m_ type(type)48 : m_type(type) 49 , m_medium(medium) 55 50 , m_state(KMediumState_NotCreated) 56 51 { 57 52 refresh(); 58 // printf("UIMedium: New medium with ID={%s} created.\n", id().toAscii().constData());59 53 } 60 54 61 55 UIMedium::UIMedium(const CMedium &medium, UIMediumType type, KMediumState state) 62 : m_ medium(medium)63 , m_ type(type)56 : m_type(type) 57 , m_medium(medium) 64 58 , m_state(state) 65 59 { 66 60 refresh(); 67 // printf("UIMedium: New medium with ID={%s} created (with known state).\n", id().toAscii().constData());68 61 } 69 62 … … 75 68 UIMedium& UIMedium::operator=(const UIMedium &other) 76 69 { 70 m_type = other.type(); 71 77 72 m_medium = other.medium(); 78 m_type = other.type(); 73 79 74 m_state = other.state(); 75 m_result = other.result(); 80 76 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(); 82 81 83 82 m_strKey = other.key(); 84 m_strId = other.id(); 83 85 84 m_strName = other.name(); 86 85 m_strLocation = other.location(); … … 89 88 m_strLogicalSize = other.logicalSize(); 90 89 90 m_strHardDiskType = other.hardDiskType(); 91 91 m_strHardDiskFormat = other.hardDiskFormat(); 92 m_strHardDiskType = other.hardDiskType();93 94 92 m_strStorageDetails = other.storageDetails(); 95 93 96 94 m_strUsage = other.usage(); 97 95 m_strToolTip = other.tip(); 96 m_machineIds = other.machineIds(); 97 m_curStateMachineIds = other.curStateMachineIds(); 98 99 m_noDiffs = other.cache(); 98 100 99 101 m_fHidden = other.m_fHidden; … … 103 105 m_fHostDrive = other.isHostDrive(); 104 106 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 113 107 return *this; 114 108 } 115 109 116 /**117 * Queries the medium state. Call this and then read the state field instead118 * of calling GetState() on medium directly as it will properly handle the119 * situation when GetState() itself fails by setting state to Inaccessible120 * and memorizing the error info describing why GetState() failed.121 *122 * As the last step, this method calls #refresh() to refresh all precomposed123 * strings.124 *125 * @note This method blocks for the duration of the state check. Since this126 * check may take quite a while (e.g. for a medium located on a127 * network share), the calling thread must not be the UI thread. You128 * have been warned.129 */130 110 void UIMedium::blockAndQueryState() 131 111 { … … 149 129 } 150 130 151 /**152 * Refreshes the precomposed strings containing such media parameters as153 * location, size by querying the respective data from the associated154 * media object.155 *156 * Note that some string such as #size() are meaningless if the media state is157 * KMediumState_NotCreated (i.e. the medium has not yet been checked for158 * accessibility).159 */160 131 void UIMedium::refresh() 161 132 { … … 199 170 200 171 /* Initialize parent/root IDs: */ 201 m_strParentI D= nullID();202 m_strRootI D= m_strId;172 m_strParentId = nullID(); 173 m_strRootId = m_strId; 203 174 if (m_type == UIMediumType_HardDisk) 204 175 { … … 217 188 CMedium parentMedium = m_medium.GetParent(); 218 189 if (!parentMedium.isNull()) 219 m_strParentI D= parentMedium.GetId();190 m_strParentId = parentMedium.GetId(); 220 191 while (!parentMedium.isNull()) 221 192 { 222 m_strRootI D= parentMedium.GetId();193 m_strRootId = parentMedium.GetId(); 223 194 parentMedium = parentMedium.GetParent(); 224 195 } … … 369 340 void UIMedium::updateParentID() 370 341 { 371 m_strParentI D= nullID();342 m_strParentId = nullID(); 372 343 if (m_type == UIMediumType_HardDisk) 373 344 { 374 345 CMedium parentMedium = m_medium.GetParent(); 375 346 if (!parentMedium.isNull()) 376 m_strParentI D= parentMedium.GetId();347 m_strParentId = parentMedium.GetId(); 377 348 } 378 349 } … … 381 352 { 382 353 /* Redirect call to VBoxGlobal: */ 383 return vboxGlobal().medium(m_strParentI D);354 return vboxGlobal().medium(m_strParentId); 384 355 } 385 356 … … 387 358 { 388 359 /* 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 363 QString UIMedium::toolTip(bool fNoDiffs /* = false */, bool fCheckRO /* = false */, bool fNullAllowed /* = false */) const 405 364 { 406 365 QString strTip; … … 428 387 } 429 388 430 /**431 * Returns an icon corresponding to the media state. Distinguishes between432 * the Inaccessible state and the situation when querying the state itself433 * failed.434 *435 * In "don't show diffs" mode (where the attributes of the base hard disk are436 * shown instead of the attributes of the differencing hard disk), the most437 * worst media state on the given hard disk chain will be used to select the438 * 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 icon442 * accordingly.443 */444 389 QPixmap UIMedium::icon(bool fNoDiffs /* = false */, bool fCheckRO /* = false */) const 445 390 { … … 458 403 } 459 404 460 /**461 * Returns the details of this medium as a single-line string462 *463 * For hard disks, the details include the location, type and the logical size464 * of the hard disk. Note that if @a fNoDiffs is @c true, these properties are465 * queried on the root hard disk of the given hard disk because the primary466 * purpose of the returned string is to be human readable (so that seeing a467 * 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 if474 * attaching it would create a differencing hard disk (not475 * 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 this481 * method is reading its properties. In this case, the method will return482 * an empty string.483 */484 405 QString UIMedium::details(bool fNoDiffs /* = false */, 485 406 bool fPredictDiff /* = false */, … … 583 504 } 584 505 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 */590 506 void UIMedium::checkNoDiffs(bool fNoDiffs) 591 507 { -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMedium.h
r55098 r55099 151 151 152 152 /** Returns the medium root ID. */ 153 QString rootID() const { return m_strRootI D; }153 QString rootID() const { return m_strRootId; } 154 154 /** Returns the medium parent ID. */ 155 QString parentID() const { return m_strParentI D; }155 QString parentID() const { return m_strParentId; } 156 156 157 157 /** Returns medium root. */ … … 309 309 QString m_strId; 310 310 /** Holds the medium root ID. */ 311 QString m_strRootI D;311 QString m_strRootId; 312 312 /** Holds the medium parent ID. */ 313 QString m_strParentI D;313 QString m_strParentId; 314 314 315 315 /** Holds the medium cache key. */
Note:
See TracChangeset
for help on using the changeset viewer.