Changeset 24294 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 3, 2009 4:13:57 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 54287
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMedium.h
r23585 r24294 32 32 33 33 /** 34 * Cache used to override some attributes in the user-friendly "don't show diffs" mode. 35 */ 36 struct NoDiffsCache 37 { 38 NoDiffsCache() : isSet (false), state (KMediumState_NotCreated) {} 39 NoDiffsCache& operator= (const NoDiffsCache &aOther) 40 { 41 isSet = aOther.isSet; 42 state = aOther.state; 43 result = aOther.result; 44 toolTip = aOther.toolTip; 45 return *this; 46 } 47 48 bool isSet : 1; 49 50 KMediumState state; 51 COMResult result; 52 QString toolTip; 53 }; 54 55 /** 34 56 * Media descriptor for the GUI. 35 57 * … … 100 122 , mParent (0) { refresh(); } 101 123 124 VBoxMedium& operator= (const VBoxMedium &aOther); 125 102 126 void blockAndQueryState(); 103 127 void refresh(); … … 138 162 QString name (bool aNoDiffs = false) const { return aNoDiffs ? root().mName : mName; } 139 163 QString location (bool aNoDiffs = false) const { return aNoDiffs ? root().mLocation : mLocation; } 164 140 165 QString size (bool aNoDiffs = false) const { return aNoDiffs ? root().mSize : mSize; } 141 166 QString logicalSize (bool aNoDiffs = false) const { return aNoDiffs ? root().mLogicalSize : mLogicalSize; } 167 142 168 QString hardDiskFormat (bool aNoDiffs = false) const { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; } 143 169 QString hardDiskType (bool aNoDiffs = false) const { return aNoDiffs ? root().mHardDiskType : mHardDiskType; } 170 144 171 QString usage (bool aNoDiffs = false) const { return aNoDiffs ? root().mUsage : mUsage; } 172 QString tip() const { return mToolTip; } 173 174 const NoDiffsCache& cache() const { return mNoDiffs; } 145 175 146 176 /** … … 182 212 * Returns a parent medium. For non-hard disk media, this is always NULL. 183 213 */ 184 VBoxMedium *parent() const { return mParent; }185 186 VBoxMedium &root() const;214 VBoxMedium* parent() const { return mParent; } 215 216 VBoxMedium& root() const; 187 217 188 218 QString toolTip (bool aNoDiffs = false, bool aCheckRO = false, bool aNullAllowed = false) const; … … 216 246 217 247 QString mId; 248 QString mName; 218 249 QString mLocation; 219 QString mName; 250 220 251 QString mSize; 252 QString mLogicalSize; 221 253 222 254 QString mHardDiskFormat; 223 255 QString mHardDiskType; 224 QString mLogicalSize;225 256 226 257 QString mUsage; … … 235 266 VBoxMedium *mParent; 236 267 237 /** 238 * Used to override some attributes in the user-friendly "don't show diffs" 239 * mode. 240 */ 241 struct NoDiffs 242 { 243 NoDiffs() : isSet (false), state (KMediumState_NotCreated) {} 244 245 bool isSet : 1; 246 247 KMediumState state; 248 COMResult result; 249 QString toolTip; 250 } 251 mNoDiffs; 268 NoDiffsCache mNoDiffs; 269 270 static QString mTable; 271 static QString mRow; 252 272 }; 253 273 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.cpp
r24258 r24294 28 28 #include "VBoxGlobal.h" 29 29 #include "VBoxProblemReporter.h" 30 31 QString VBoxMedium::mTable = QString ("<table>%1</table>"); 32 QString VBoxMedium::mRow = QString ("<tr><td>%1</td></tr>"); 33 34 VBoxMedium& VBoxMedium::operator= (const VBoxMedium &aOther) 35 { 36 mMedium = aOther.medium(); 37 mType = aOther.type(); 38 mState = aOther.state(); 39 mLastAccessError = aOther.lastAccessError(); 40 mResult = aOther.result(); 41 42 mId = aOther.id(); 43 mName = aOther.name(); 44 mLocation = aOther.location(); 45 46 mSize = aOther.size(); 47 mLogicalSize = aOther.logicalSize(); 48 49 mHardDiskFormat = aOther.hardDiskFormat(); 50 mHardDiskType = aOther.hardDiskType(); 51 52 mUsage = aOther.usage(); 53 mToolTip = aOther.tip(); 54 55 mIsReadOnly = aOther.isReadOnly(); 56 mIsUsedInSnapshots = aOther.isUsedInSnapshots(); 57 mIsHostDrive = aOther.isHostDrive(); 58 59 mCurStateMachineIds = aOther.curStateMachineIds(); 60 61 mParent = aOther.parent(); 62 63 mNoDiffs = aOther.cache(); 64 65 return *this; 66 } 30 67 31 68 /** … … 97 134 mIsReadOnly = mMedium.GetReadOnly(); 98 135 99 /* Adjust the parent if necessary (note that mParent must always point 100 * to an item from VBoxGlobal::currentMediaList()) */ 136 /* Adjust the parent if its possible */ 101 137 CMedium parent = mMedium.GetParent(); 102 138 Assert (!parent.isNull() || mParent == NULL); … … 104 140 if (!parent.isNull() && (mParent == NULL || mParent->mMedium != parent)) 105 141 { 106 /* Search for the parent (m ust be there) */142 /* Search for the parent (might be there) */ 107 143 const VBoxMediaList &list = vboxGlobal().currentMediaList(); 108 144 for (VBoxMediaList::const_iterator it = list.begin(); it != list.end(); ++ it) … … 117 153 } 118 154 } 119 120 // Assert(mParent != NULL);121 // Assert(mParent->mMedium == parent);122 155 } 123 156 } … … 167 200 if (*jt == *it) 168 201 { 169 /* the medium is attached to the machine in the current202 /* The medium is attached to the machine in the current 170 203 * state, we don't distinguish this for now by always 171 204 * giving the VM name in front of snapshot names. */ 172 173 205 mCurStateMachineIds.push_back (*jt); 174 206 continue; … … 203 235 if (!mMedium.isNull()) 204 236 { 205 mToolTip = QString ("<nobr><b>%1</b></nobr>").arg (mIsHostDrive ? mName : mLocation);237 mToolTip = mRow.arg (QString ("<p style=white-space:pre><b>%1</b></p>").arg (mIsHostDrive ? mName : mLocation)); 206 238 207 239 if (mType == VBoxDefs::MediumType_HardDisk) 208 240 { 209 mToolTip += VBoxGlobal::tr ( 210 "<br><nobr>Type (Format): %2 (%3)</nobr>", "hard disk") 211 .arg (mHardDiskType).arg (mHardDiskFormat); 212 } 213 214 mToolTip += VBoxGlobal::tr ( 215 "<br><nobr>Attached to: %1</nobr>", "medium") 216 .arg (mUsage.isNull() ? VBoxGlobal::tr ("<i>Not Attached</i>", "medium") : mUsage); 241 mToolTip += mRow.arg (VBoxGlobal::tr ("<p style=white-space:pre>Type (Format): %1 (%2)</p>", "medium") 242 .arg (mHardDiskType).arg (mHardDiskFormat)); 243 } 244 245 mToolTip += mRow.arg (VBoxGlobal::tr ("<p style=white-space:pre>Attached to: %1</p>", "image") 246 .arg (mUsage.isNull() ? VBoxGlobal::tr ("<i>Not Attached</i>", "image") : mUsage)); 217 247 218 248 switch (mState) … … 220 250 case KMediumState_NotCreated: 221 251 { 222 mToolTip += VBoxGlobal::tr ("<br><i>Checking accessibility...</i>", "medium");252 mToolTip += mRow.arg (VBoxGlobal::tr ("<i>Checking accessibility...</i>", "medium")); 223 253 break; 224 254 } … … 227 257 if (mResult.isOk()) 228 258 { 229 /* not accessibile */ 230 mToolTip += QString ("<hr>%1"). 231 arg (VBoxGlobal::highlight (mLastAccessError, 232 true /* aToolTip */)); 259 /* Not Accessibile */ 260 mToolTip += mRow.arg ("<hr>") + mRow.arg (VBoxGlobal::highlight (mLastAccessError, true /* aToolTip */)); 233 261 } 234 262 else 235 263 { 236 /* accessibility check (eg GetState()) itself failed */ 237 mToolTip = VBoxGlobal::tr ( 238 "<hr>Failed to check media accessibility.<br>%1.", "medium"). 239 arg (VBoxProblemReporter::formatErrorInfo (mResult)); 264 /* Accessibility check (eg GetState()) itself failed */ 265 mToolTip += mRow.arg ("<hr>") + mRow.arg (VBoxGlobal::tr ("Failed to check media accessibility.", "medium")) + 266 mRow.arg (VBoxProblemReporter::formatErrorInfo (mResult) + "."); 240 267 } 241 268 break; … … 244 271 break; 245 272 } 246 247 mToolTip = QString ("<p style='white-space:pre'>%1</p>").arg (mToolTip); 248 } 249 250 /* reset mNoDiffs */ 273 } 274 275 /* Reset mNoDiffs */ 251 276 mNoDiffs.isSet = false; 252 277 } … … 266 291 267 292 /** 268 * Returns atooltip for this medium.293 * Returns generated tooltip for this medium. 269 294 * 270 295 * In "don't show diffs" mode (where the attributes of the base hard disk are … … 277 302 * accordingly. 278 303 */ 279 QString VBoxMedium::toolTip (bool aNoDiffs /* = false*/, bool aCheckRO /*= false*/, bool aNullAllowed /*= false*/) const304 QString VBoxMedium::toolTip (bool aNoDiffs /* = false */, bool aCheckRO /* = false */, bool aNullAllowed /* = false */) const 280 305 { 281 306 QString tip; … … 283 308 if (mMedium.isNull()) 284 309 { 285 tip = aNullAllowed ? VBoxGlobal::tr ("<nobr><b>Not Set</b></nobr><br>"286 "Required virtual image or host-drive could be mounted at runtime.") :287 VBoxGlobal::tr ("<nobr><b>Not Available</b></nobr><br>"288 "Use the Virtual Media Manager to add image of the corresponding type.");310 tip = aNullAllowed ? mRow.arg (VBoxGlobal::tr ("<b>Not Set</b>", "medium")) + 311 mRow.arg (VBoxGlobal::tr ("Required virtual image or host-drive could be mounted at runtime.")) : 312 mRow.arg (VBoxGlobal::tr ("<b>Not Available</b>", "medium")) + 313 mRow.arg (VBoxGlobal::tr ("Use the Virtual Media Manager to add image of the corresponding type.")); 289 314 } 290 315 else … … 295 320 296 321 if (aCheckRO && mIsReadOnly) 297 tip += VBoxGlobal::tr ("<hr><img src=%1/> Attaching this hard disk will "298 "be performed indirectly using a newly created"299 "differencing hard disk.", "medium").arg (":/new_16px.png");300 } 301 302 return tip;322 tip += mRow.arg ("<hr>") + 323 mRow.arg (VBoxGlobal::tr ("Attaching this hard disk will be performed indirectly using " 324 "a newly created differencing hard disk.", "medium")); 325 } 326 327 return mTable.arg (tip); 303 328 } 304 329 … … 317 342 * accordingly. 318 343 */ 319 QPixmap VBoxMedium::icon (bool aNoDiffs /*= false*/, 320 bool aCheckRO /*= false*/) const 344 QPixmap VBoxMedium::icon (bool aNoDiffs /* = false */, bool aCheckRO /* = false */) const 321 345 { 322 346 QPixmap icon; … … 355 379 * an empty string. 356 380 */ 357 QString VBoxMedium::details (bool aNoDiffs /* = false*/,358 bool aPredictDiff /* = false*/,359 bool aUseHTML /* = false */) const360 { 361 // @todo ***the below check is rough; if mMedium becomes uninitialized, any381 QString VBoxMedium::details (bool aNoDiffs /* = false */, 382 bool aPredictDiff /* = false */, 383 bool aUseHTML /* = false */) const 384 { 385 // @todo the below check is rough; if mMedium becomes uninitialized, any 362 386 // of getters called afterwards will also fail. The same relates to the 363 387 // root hard disk object (that will be the hard disk itself in case of … … 397 421 QString ("%1, ").arg (root->mHardDiskType); 398 422 399 /* overall (worst) state */400 423 state = this->state (true /* aNoDiffs */); 401 424 402 /* we cannot get the logical size if the root is not checked yet */403 425 if (root->mState == KMediumState_NotCreated) 404 426 state = KMediumState_NotCreated; … … 410 432 } 411 433 412 /// @todo prepend the details with the warning/error 413 // icon when not accessible 434 // @todo prepend the details with the warning/error icon when not accessible 414 435 415 436 switch (state) … … 424 445 break; 425 446 default: 426 details += mType == VBoxDefs::MediumType_HardDisk ? 427 root->mLogicalSize : root->mSize; 447 details += mType == VBoxDefs::MediumType_HardDisk ? root->mLogicalSize : root->mSize; 428 448 break; 429 449 } 430 450 431 451 details = aUseHTML ? 432 QString ("%1 (<nobr>%2</nobr>)"). 433 arg (VBoxGlobal::locationForHTML (root->mName), details) : 434 QString ("%1 (%2)"). 435 arg (VBoxGlobal::locationForHTML (root->mName), details); 452 QString ("%1 (<nobr>%2</nobr>)").arg (VBoxGlobal::locationForHTML (root->mName), details) : 453 QString ("%1 (%2)").arg (VBoxGlobal::locationForHTML (root->mName), details); 436 454 437 455 return details; … … 448 466 return; 449 467 450 /* fill mNoDiffs */451 452 468 mNoDiffs.toolTip = QString::null; 453 469 454 /* detect the overall (worst) state of the given hard disk chain */455 470 mNoDiffs.state = mState; 456 471 for (VBoxMedium *cur = mParent; cur != NULL; cur = cur->mParent) … … 461 476 462 477 if (mNoDiffs.toolTip.isNull()) 463 mNoDiffs.toolTip = VBoxGlobal::tr ( 464 "<hr>Some of the media in this hard disk chain are " 465 "inaccessible. Please use the Virtual Media Manager " 466 "in <b>Show Differencing Hard Disks</b> mode to inspect " 467 "these media."); 478 mNoDiffs.toolTip = mRow.arg (VBoxGlobal::tr ("Some of the mediums in this hard disk chain " 479 "are inaccessible. Please use the Virtual Media " 480 "Manager in <b>Show Differencing Hard Disks</b> " 481 "mode to inspect these mediums.", "medium")); 468 482 469 483 if (!cur->mResult.isOk()) … … 472 486 break; 473 487 } 474 475 /* comtinue looking for another !cur->mResult.isOk() */476 488 } 477 489 } … … 479 491 if (mParent != NULL && !mIsReadOnly) 480 492 { 481 mNoDiffs.toolTip = VBoxGlobal::tr ( 482 "%1" 483 "<hr>This base hard disk is indirectly attached using the " 484 "following differencing hard disk:<br>" 485 "%2%3"). 486 arg (root().toolTip(), mToolTip, mNoDiffs.toolTip); 493 mNoDiffs.toolTip = root().tip() + 494 mRow.arg ("<hr>") + 495 mRow.arg (VBoxGlobal::tr ("This base hard disk is indirectly attached using " 496 "the following differencing hard disk:", "medium")) + 497 mToolTip + mNoDiffs.toolTip; 487 498 } 488 499
Note:
See TracChangeset
for help on using the changeset viewer.