Changeset 23429 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 30, 2009 9:51:07 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 12 added
- 4 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc
r23333 r23429 206 206 <file alias="ram_16px.png">images/ram_16px.png</file> 207 207 <file alias="ide_16px.png">images/ide_16px.png</file> 208 <file alias="ide_expand_16px.png">images/ide_expand_16px.png</file> 209 <file alias="ide_collapse_16px.png">images/ide_collapse_16px.png</file> 208 210 <file alias="sata_16px.png">images/sata_16px.png</file> 211 <file alias="sata_expand_16px.png">images/sata_expand_16px.png</file> 212 <file alias="sata_collapse_16px.png">images/sata_collapse_16px.png</file> 209 213 <file alias="scsi_16px.png">images/scsi_16px.png</file> 214 <file alias="scsi_expand_16px.png">images/scsi_expand_16px.png</file> 215 <file alias="scsi_collapse_16px.png">images/scsi_collapse_16px.png</file> 210 216 <file alias="floppy_16px.png">images/floppy_16px.png</file> 217 <file alias="floppy_expand_16px.png">images/floppy_expand_16px.png</file> 218 <file alias="floppy_collapse_16px.png">images/floppy_collapse_16px.png</file> 211 219 <file alias="import_16px.png">images/import_16px.png</file> 212 220 <file alias="export_16px.png">images/export_16px.png</file> … … 221 229 <file alias="restore_16px.png">images/restore_16px.png</file> 222 230 <file alias="close_16px.png">images/close_16px.png</file> 223 <file alias="plus_10px.png">images/plus_10px.png</file>224 <file alias="plus_disabled_10px.png">images/plus_disabled_10px.png</file>225 <file alias="minus_10px.png">images/minus_10px.png</file>226 <file alias="minus_disabled_10px.png">images/minus_disabled_10px.png</file>227 231 </qresource> 228 232 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc
r23333 r23429 93 93 <file alias="cd_unmount_16px.png">images/cd_unmount_16px.png</file> 94 94 <file alias="cd_unmount_dis_16px.png">images/cd_unmount_dis_16px.png</file> 95 <file alias="cd_add_16px.png">images/cd_add_16px.png</file> 96 <file alias="cd_add_disabled_16px.png">images/cd_add_disabled_16px.png</file> 95 97 <file alias="fd_16px.png">images/fd_16px.png</file> 96 98 <file alias="fd_disabled_16px.png">images/fd_disabled_16px.png</file> … … 101 103 <file alias="fd_unmount_16px.png">images/fd_unmount_16px.png</file> 102 104 <file alias="fd_unmount_dis_16px.png">images/fd_unmount_dis_16px.png</file> 105 <file alias="fd_add_16px.png">images/fd_add_16px.png</file> 106 <file alias="fd_add_disabled_16px.png">images/fd_add_disabled_16px.png</file> 103 107 <file alias="mouse_16px.png">images/mouse_16px.png</file> 104 108 <file alias="mouse_disabled_16px.png">images/mouse_disabled_16px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsHD.h
r23290 r23429 45 45 Q_DECLARE_METATYPE (ControllerTypeList); 46 46 47 enum ItemState 48 { 49 State_DefaultItem = 0, 50 State_CollapsedItem = 1, 51 State_ExpandedItem = 2, 52 State_MAX 53 }; 54 47 55 /* Pixmap Storage Pool */ 48 56 class PixmapPool : public QObject … … 54 62 enum PixmapType 55 63 { 56 InvalidPixmap = -1, 57 58 AddControllerEn = 0, 59 AddControllerDis = 1, 60 DelControllerEn = 2, 61 DelControllerDis = 3, 62 63 AddAttachmentEn = 4, 64 AddAttachmentDis = 5, 65 DelAttachmentEn = 6, 66 DelAttachmentDis = 7, 67 68 IDEController = 8, 69 SATAController = 9, 70 SCSIController = 10, 71 FloppyController = 11, 72 73 HDAttachmentEn = 12, 74 HDAttachmentDis = 13, 75 CDAttachmentEn = 14, 76 CDAttachmentDis = 15, 77 FDAttachmentEn = 16, 78 FDAttachmentDis = 17, 79 80 PlusEn = 18, 81 PlusDis = 19, 82 MinusEn = 20, 83 MinusDis = 21, 84 85 UnknownEn = 22, 86 87 VMMEn = 23, 88 VMMDis = 24, 64 InvalidPixmap = -1, 65 66 AddControllerEn = 0, 67 AddControllerDis = 1, 68 DelControllerEn = 2, 69 DelControllerDis = 3, 70 71 AddAttachmentEn = 4, 72 AddAttachmentDis = 5, 73 DelAttachmentEn = 6, 74 DelAttachmentDis = 7, 75 76 IDEController = 8, 77 IDEExpand = 9, 78 IDECollapse = 10, 79 SATAController = 11, 80 SATAExpand = 12, 81 SATACollapse = 13, 82 SCSIController = 14, 83 SCSIExpand = 15, 84 SCSICollapse = 16, 85 FloppyController = 17, 86 FloppyExpand = 18, 87 FloppyCollapse = 19, 88 89 HDAttachmentEn = 20, 90 CDAttachmentEn = 21, 91 FDAttachmentEn = 22, 92 93 HDAttachmentAddEn = 23, 94 HDAttachmentAddDis = 24, 95 CDAttachmentAddEn = 25, 96 CDAttachmentAddDis = 26, 97 FDAttachmentAddEn = 27, 98 FDAttachmentAddDis = 28, 99 100 VMMEn = 29, 101 VMMDis = 30, 89 102 90 103 MaxIndex … … 117 130 KStorageControllerType ctrType() const; 118 131 ControllerTypeList ctrTypes() const; 119 PixmapPool::PixmapType pixmap () const;132 PixmapPool::PixmapType pixmap (ItemState aState) const; 120 133 121 134 void setCtrType (KStorageControllerType aCtrType); … … 130 143 KStorageBus mBusType; 131 144 KStorageControllerType mCtrType; 132 PixmapPool::PixmapType mPixmap;145 QList <PixmapPool::PixmapType> mPixmaps; 133 146 }; 134 147 … … 222 235 virtual QString text() const = 0; 223 236 virtual QString tip() const = 0; 224 virtual QPixmap pixmap () = 0;237 virtual QPixmap pixmap (ItemState aState = State_DefaultItem) = 0; 225 238 226 239 protected: … … 242 255 RootItem(); 243 256 ~RootItem(); 257 258 private: 244 259 245 260 ItemType rtti() const; … … 250 265 QString text() const; 251 266 QString tip() const; 252 QPixmap pixmap(); 253 254 private: 255 267 QPixmap pixmap (ItemState aState); 256 268 void addChild (AbstractItem *aItem); 257 269 void delChild (AbstractItem *aItem); … … 268 280 KStorageControllerType aControllerType); 269 281 ~ControllerItem(); 282 283 KStorageBus ctrBusType() const; 284 QString ctrName() const; 285 KStorageControllerType ctrType() const; 286 ControllerTypeList ctrTypes() const; 287 288 void setCtrName (const QString &aCtrName); 289 void setCtrType (KStorageControllerType aCtrType); 290 291 SlotsList ctrAllSlots() const; 292 SlotsList ctrUsedSlots() const; 293 DeviceTypeList ctrDeviceTypeList() const; 294 QStringList ctrAllMediumIds (bool aShowDiffs) const; 295 QStringList ctrUsedMediumIds() const; 296 297 private: 270 298 271 299 ItemType rtti() const; … … 276 304 QString text() const; 277 305 QString tip() const; 278 QPixmap pixmap(); 279 280 KStorageBus ctrBusType() const; 281 QString ctrName() const; 282 KStorageControllerType ctrType() const; 283 ControllerTypeList ctrTypes() const; 284 285 void setCtrName (const QString &aCtrName); 286 void setCtrType (KStorageControllerType aCtrType); 287 288 SlotsList ctrAllSlots() const; 289 SlotsList ctrUsedSlots() const; 290 DeviceTypeList ctrDeviceTypeList() const; 291 QStringList ctrAllMediumIds (bool aShowDiffs) const; 292 QStringList ctrUsedMediumIds() const; 293 294 private: 295 306 QPixmap pixmap (ItemState aState); 296 307 void addChild (AbstractItem *aItem); 297 308 void delChild (AbstractItem *aItem); … … 308 319 309 320 AttachmentItem (AbstractItem *aParent, KDeviceType aDeviceType); 310 311 ItemType rtti() const;312 AbstractItem* childByPos (int aIndex);313 AbstractItem* childById (const QUuid &aId);314 int posOfChild (AbstractItem *aItem) const;315 int childCount() const;316 QString text() const;317 QString tip() const;318 QPixmap pixmap();319 321 320 322 StorageSlot attSlot() const; … … 344 346 void cache(); 345 347 348 ItemType rtti() const; 349 AbstractItem* childByPos (int aIndex); 350 AbstractItem* childById (const QUuid &aId); 351 int posOfChild (AbstractItem *aItem) const; 352 int childCount() const; 353 QString text() const; 354 QString tip() const; 355 QPixmap pixmap (ItemState aState); 346 356 void addChild (AbstractItem *aItem); 347 357 void delChild (AbstractItem *aItem); … … 413 423 414 424 R_HDPixmapEn, 415 R_HDPixmapDis,416 425 R_CDPixmapEn, 417 R_CDPixmapDis,418 426 R_FDPixmapEn, 419 R_FDPixmapDis, 427 428 R_HDPixmapAddEn, 429 R_HDPixmapAddDis, 430 R_CDPixmapAddEn, 431 R_CDPixmapAddDis, 432 R_FDPixmapAddEn, 433 R_FDPixmapAddDis, 420 434 R_HDPixmapRect, 421 435 R_CDPixmapRect, 422 R_FDPixmapRect, 423 424 R_PlusPixmapEn, 425 R_PlusPixmapDis, 426 R_MinusPixmapEn, 427 R_MinusPixmapDis, 428 R_AdderPoint 436 R_FDPixmapRect 429 437 }; 430 438 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp
r23290 r23429 114 114 mPool.resize (MaxIndex); 115 115 116 mPool [AddControllerEn] = QPixmap (":/add_host_iface_16px.png"); // TODO (":/controller_add_16px.png"); 117 mPool [AddControllerDis] = QPixmap (":/add_host_iface_disabled_16px.png"); // TODO (":/controller_add_disabled_16px.png"); 118 mPool [DelControllerEn] = QPixmap (":/remove_host_iface_16px.png"); // TODO (":/controller_remove_16px.png"); 119 mPool [DelControllerDis] = QPixmap (":/remove_host_iface_disabled_16px.png"); // TODO (":/controller_remove_disabled_16px.png"); 120 121 mPool [AddAttachmentEn] = QPixmap (":/attachment_add_16px.png"); 122 mPool [AddAttachmentDis] = QPixmap (":/attachment_add_disabled_16px.png"); 123 mPool [DelAttachmentEn] = QPixmap (":/attachment_remove_16px.png"); 124 mPool [DelAttachmentDis] = QPixmap (":/attachment_remove_disabled_16px.png"); 125 126 mPool [IDEController] = QPixmap (":/ide_16px.png"); 127 mPool [SATAController] = QPixmap (":/sata_16px.png"); 128 mPool [SCSIController] = QPixmap (":/scsi_16px.png"); 129 mPool [FloppyController] = QPixmap (":/floppy_16px.png"); 130 131 mPool [HDAttachmentEn] = QPixmap (":/hd_16px.png"); 132 mPool [HDAttachmentDis] = QPixmap (":/hd_disabled_16px.png"); 133 mPool [CDAttachmentEn] = QPixmap (":/cd_16px.png"); 134 mPool [CDAttachmentDis] = QPixmap (":/cd_disabled_16px.png"); 135 mPool [FDAttachmentEn] = QPixmap (":/fd_16px.png"); 136 mPool [FDAttachmentDis] = QPixmap (":/fd_disabled_16px.png"); 137 138 mPool [PlusEn] = QPixmap (":/plus_10px.png"); 139 mPool [PlusDis] = QPixmap (":/plus_disabled_10px.png"); 140 mPool [MinusEn] = QPixmap (":/minus_10px.png"); 141 mPool [MinusDis] = QPixmap (":/minus_disabled_10px.png"); 142 143 mPool [UnknownEn] = QPixmap (":/help_16px.png"); 144 145 mPool [VMMEn] = QPixmap (":/select_file_16px.png"); 146 mPool [VMMDis] = QPixmap (":/select_file_dis_16px.png"); 116 mPool [AddControllerEn] = QPixmap (":/controller_add_16px.png"); 117 mPool [AddControllerDis] = QPixmap (":/controller_add_disabled_16px.png"); 118 mPool [DelControllerEn] = QPixmap (":/controller_remove_16px.png"); 119 mPool [DelControllerDis] = QPixmap (":/controller_remove_disabled_16px.png"); 120 121 mPool [AddAttachmentEn] = QPixmap (":/attachment_add_16px.png"); 122 mPool [AddAttachmentDis] = QPixmap (":/attachment_add_disabled_16px.png"); 123 mPool [DelAttachmentEn] = QPixmap (":/attachment_remove_16px.png"); 124 mPool [DelAttachmentDis] = QPixmap (":/attachment_remove_disabled_16px.png"); 125 126 mPool [IDEController] = QPixmap (":/ide_16px.png"); 127 mPool [IDEExpand] = QPixmap (":/ide_expand_16px.png"); 128 mPool [IDECollapse] = QPixmap (":/ide_collapse_16px.png"); 129 mPool [SATAController] = QPixmap (":/sata_16px.png"); 130 mPool [SATAExpand] = QPixmap (":/sata_expand_16px.png"); 131 mPool [SATACollapse] = QPixmap (":/sata_collapse_16px.png"); 132 mPool [SCSIController] = QPixmap (":/scsi_16px.png"); 133 mPool [SCSIExpand] = QPixmap (":/scsi_expand_16px.png"); 134 mPool [SCSICollapse] = QPixmap (":/scsi_collapse_16px.png"); 135 mPool [FloppyController] = QPixmap (":/floppy_16px.png"); 136 mPool [FloppyExpand] = QPixmap (":/floppy_expand_16px.png"); 137 mPool [FloppyCollapse] = QPixmap (":/floppy_collapse_16px.png"); 138 139 mPool [HDAttachmentEn] = QPixmap (":/hd_16px.png"); 140 mPool [CDAttachmentEn] = QPixmap (":/cd_16px.png"); 141 mPool [FDAttachmentEn] = QPixmap (":/fd_16px.png"); 142 143 mPool [HDAttachmentAddEn] = QPixmap (":/hd_add_16px.png"); 144 mPool [HDAttachmentAddDis] = QPixmap (":/hd_add_disabled_16px.png"); 145 mPool [CDAttachmentAddEn] = QPixmap (":/cd_add_16px.png"); 146 mPool [CDAttachmentAddDis] = QPixmap (":/cd_add_disabled_16px.png"); 147 mPool [FDAttachmentAddEn] = QPixmap (":/fd_add_16px.png"); 148 mPool [FDAttachmentAddDis] = QPixmap (":/fd_add_disabled_16px.png"); 149 150 mPool [VMMEn] = QPixmap (":/select_file_16px.png"); 151 mPool [VMMDis] = QPixmap (":/select_file_dis_16px.png"); 147 152 } 148 153 … … 156 161 : mBusType (aBusType) 157 162 , mCtrType (aCtrType) 158 , mPixmap (PixmapPool::InvalidPixmap)159 163 { 160 164 AssertMsg (mBusType != KStorageBus_Null, ("Wrong Bus Type {%d}!\n", mBusType)); 161 165 AssertMsg (mCtrType != KStorageControllerType_Null, ("Wrong Controller Type {%d}!\n", mCtrType)); 162 166 163 switch (mBusType) 164 { 165 case KStorageBus_IDE: 166 mPixmap = PixmapPool::IDEController; 167 break; 168 case KStorageBus_SATA: 169 mPixmap = PixmapPool::SATAController; 170 break; 171 case KStorageBus_SCSI: 172 mPixmap = PixmapPool::SCSIController; 173 break; 174 case KStorageBus_Floppy: 175 mPixmap = PixmapPool::FloppyController; 176 break; 177 default: 178 break; 179 } 180 181 AssertMsg (mPixmap != PixmapPool::InvalidPixmap, ("Bus pixmap was not set!\n")); 167 for (int i = 0; i < State_MAX; ++ i) 168 { 169 mPixmaps << PixmapPool::InvalidPixmap; 170 switch (mBusType) 171 { 172 case KStorageBus_IDE: 173 mPixmaps [i] = (PixmapPool::PixmapType) (PixmapPool::IDEController + i); 174 break; 175 case KStorageBus_SATA: 176 mPixmaps [i] = (PixmapPool::PixmapType) (PixmapPool::SATAController + i); 177 break; 178 case KStorageBus_SCSI: 179 mPixmaps [i] = (PixmapPool::PixmapType) (PixmapPool::SCSIController + i); 180 break; 181 case KStorageBus_Floppy: 182 mPixmaps [i] = (PixmapPool::PixmapType) (PixmapPool::FloppyController + i); 183 break; 184 default: 185 break; 186 } 187 AssertMsg (mPixmaps [i] != PixmapPool::InvalidPixmap, ("Item state pixmap was not set!\n")); 188 } 182 189 } 183 190 … … 200 207 } 201 208 202 PixmapPool::PixmapType AbstractControllerType::pixmap () const203 { 204 return mPixmap ;209 PixmapPool::PixmapType AbstractControllerType::pixmap (ItemState aState) const 210 { 211 return mPixmaps [aState]; 205 212 } 206 213 … … 377 384 } 378 385 379 QPixmap RootItem::pixmap ()386 QPixmap RootItem::pixmap (ItemState /* aState */) 380 387 { 381 388 return QPixmap(); … … 428 435 while (!mAttachments.isEmpty()) 429 436 delete mAttachments.first(); 430 }431 432 AbstractItem::ItemType ControllerItem::rtti() const433 {434 return Type_ControllerItem;435 }436 437 AbstractItem* ControllerItem::childByPos (int aIndex)438 {439 return mAttachments [aIndex];440 }441 442 AbstractItem* ControllerItem::childById (const QUuid &aId)443 {444 for (int i = 0; i < childCount(); ++ i)445 if (mAttachments [i]->id() == aId)446 return mAttachments [i];447 return 0;448 }449 450 int ControllerItem::posOfChild (AbstractItem *aItem) const451 {452 return mAttachments.indexOf (aItem);453 }454 455 int ControllerItem::childCount() const456 {457 return mAttachments.size();458 }459 460 QString ControllerItem::text() const461 {462 return ctrName();463 }464 465 QString ControllerItem::tip() const466 {467 return VBoxVMSettingsHD::tr ("<nobr><b>%1</b></nobr><br>"468 "<nobr>Bus: %2</nobr><br>"469 "<nobr>Type: %3</nobr>")470 .arg (mCtrName)471 .arg (vboxGlobal().toString (mCtrType->busType()))472 .arg (vboxGlobal().toString (mCtrType->ctrType()));473 }474 475 QPixmap ControllerItem::pixmap()476 {477 return PixmapPool::pool()->pixmap (mCtrType->pixmap());478 437 } 479 438 … … 563 522 } 564 523 524 AbstractItem::ItemType ControllerItem::rtti() const 525 { 526 return Type_ControllerItem; 527 } 528 529 AbstractItem* ControllerItem::childByPos (int aIndex) 530 { 531 return mAttachments [aIndex]; 532 } 533 534 AbstractItem* ControllerItem::childById (const QUuid &aId) 535 { 536 for (int i = 0; i < childCount(); ++ i) 537 if (mAttachments [i]->id() == aId) 538 return mAttachments [i]; 539 return 0; 540 } 541 542 int ControllerItem::posOfChild (AbstractItem *aItem) const 543 { 544 return mAttachments.indexOf (aItem); 545 } 546 547 int ControllerItem::childCount() const 548 { 549 return mAttachments.size(); 550 } 551 552 QString ControllerItem::text() const 553 { 554 return ctrName(); 555 } 556 557 QString ControllerItem::tip() const 558 { 559 return VBoxVMSettingsHD::tr ("<nobr><b>%1</b></nobr><br>" 560 "<nobr>Bus: %2</nobr><br>" 561 "<nobr>Type: %3</nobr>") 562 .arg (mCtrName) 563 .arg (vboxGlobal().toString (mCtrType->busType())) 564 .arg (vboxGlobal().toString (mCtrType->ctrType())); 565 } 566 567 QPixmap ControllerItem::pixmap (ItemState aState) 568 { 569 return PixmapPool::pool()->pixmap (mCtrType->pixmap (aState)); 570 } 571 565 572 void ControllerItem::addChild (AbstractItem *aItem) 566 573 { … … 608 615 } 609 616 617 StorageSlot AttachmentItem::attSlot() const 618 { 619 return mAttSlot; 620 } 621 622 SlotsList AttachmentItem::attSlots() const 623 { 624 ControllerItem *ctr = static_cast <ControllerItem*> (mParent); 625 626 /* Filter list from used slots */ 627 SlotsList allSlots (ctr->ctrAllSlots()); 628 SlotsList usedSlots (ctr->ctrUsedSlots()); 629 foreach (StorageSlot usedSlot, usedSlots) 630 if (usedSlot != mAttSlot) 631 allSlots.removeAll (usedSlot); 632 633 return allSlots; 634 } 635 636 KDeviceType AttachmentItem::attDeviceType() const 637 { 638 return mAttDeviceType; 639 } 640 641 DeviceTypeList AttachmentItem::attDeviceTypes() const 642 { 643 return static_cast <ControllerItem*> (mParent)->ctrDeviceTypeList(); 644 } 645 646 QString AttachmentItem::attMediumId() const 647 { 648 return mAttMediumId; 649 } 650 651 QStringList AttachmentItem::attMediumIds (bool aFilter) const 652 { 653 ControllerItem *ctr = static_cast <ControllerItem*> (mParent); 654 QStringList allMediumIds; 655 656 /* Populate list of suitable medium ids */ 657 foreach (QString mediumId, ctr->ctrAllMediumIds (mAttIsShowDiffs)) 658 { 659 VBoxMedium medium = vboxGlobal().findMedium (mediumId); 660 if ((medium.isNull() && mAttDeviceType != KDeviceType_HardDisk) || 661 (!medium.isNull() && typeToGlobal (medium.type()) == mAttDeviceType)) 662 allMediumIds << mediumId; 663 } 664 665 if (aFilter) 666 { 667 /* Filter list from used medium ids */ 668 QStringList usedMediumIds (ctr->ctrUsedMediumIds()); 669 foreach (QString usedMediumId, usedMediumIds) 670 if (usedMediumId != mAttMediumId) 671 allMediumIds.removeAll (usedMediumId); 672 } 673 674 return allMediumIds; 675 } 676 677 bool AttachmentItem::attIsShowDiffs() const 678 { 679 return mAttIsShowDiffs; 680 } 681 682 bool AttachmentItem::attIsHostDrive() const 683 { 684 return mAttIsHostDrive; 685 } 686 687 bool AttachmentItem::attIsPassthrough() const 688 { 689 return mAttIsPassthrough; 690 } 691 692 void AttachmentItem::setAttSlot (const StorageSlot &aAttSlot) 693 { 694 mAttSlot = aAttSlot; 695 } 696 697 void AttachmentItem::setAttDevice (KDeviceType aAttDeviceType) 698 { 699 mAttDeviceType = aAttDeviceType; 700 } 701 702 void AttachmentItem::setAttMediumId (const QString &aAttMediumId) 703 { 704 VBoxMedium medium; 705 706 /* Caching first available medium */ 707 if (aAttMediumId == firstAvailableId && !attMediumIds (false).isEmpty()) 708 medium = vboxGlobal().findMedium (attMediumIds (false) [0]); 709 /* Caching passed medium */ 710 else if (!aAttMediumId.isEmpty()) 711 medium = vboxGlobal().findMedium (aAttMediumId); 712 713 mAttMediumId = medium.id(); 714 cache(); 715 } 716 717 void AttachmentItem::setAttIsShowDiffs (bool aAttIsShowDiffs) 718 { 719 mAttIsShowDiffs = aAttIsShowDiffs; 720 cache(); 721 } 722 723 void AttachmentItem::setAttIsPassthrough (bool aIsAttPassthrough) 724 { 725 mAttIsPassthrough = aIsAttPassthrough; 726 } 727 728 QString AttachmentItem::attSize() const 729 { 730 return mAttSize; 731 } 732 733 QString AttachmentItem::attLogicalSize() const 734 { 735 return mAttLogicalSize; 736 } 737 738 QString AttachmentItem::attLocation() const 739 { 740 return mAttLocation; 741 } 742 743 QString AttachmentItem::attFormat() const 744 { 745 return mAttFormat; 746 } 747 748 QString AttachmentItem::attUsage() const 749 { 750 return mAttUsage; 751 } 752 753 void AttachmentItem::cache() 754 { 755 VBoxMedium medium = vboxGlobal().findMedium (mAttMediumId); 756 757 /* Cache medium information */ 758 mAttName = medium.name (!mAttIsShowDiffs); 759 mAttTip = medium.toolTipCheckRO (!mAttIsShowDiffs); 760 mAttPixmap = medium.iconCheckRO (!mAttIsShowDiffs); 761 mAttIsHostDrive = medium.isHostDrive(); 762 763 /* Cache additional information */ 764 mAttSize = medium.size (!mAttIsShowDiffs); 765 mAttLogicalSize = medium.logicalSize (!mAttIsShowDiffs); 766 mAttLocation = medium.location (!mAttIsShowDiffs); 767 mAttFormat = medium.isNull() ? QString ("--") : 768 QString ("%1 (%2)").arg (medium.hardDiskType (!mAttIsShowDiffs)) 769 .arg (medium.hardDiskFormat (!mAttIsShowDiffs)); 770 mAttUsage = medium.usage (!mAttIsShowDiffs); 771 772 /* Fill empty attributes */ 773 if (mAttUsage.isEmpty()) 774 mAttUsage = QString ("--"); 775 } 776 610 777 AbstractItem::ItemType AttachmentItem::rtti() const 611 778 { … … 643 810 } 644 811 645 QPixmap AttachmentItem::pixmap ()812 QPixmap AttachmentItem::pixmap (ItemState /* aState */) 646 813 { 647 814 if (mAttPixmap.isNull()) … … 663 830 } 664 831 return mAttPixmap; 665 }666 667 StorageSlot AttachmentItem::attSlot() const668 {669 return mAttSlot;670 }671 672 SlotsList AttachmentItem::attSlots() const673 {674 ControllerItem *ctr = static_cast <ControllerItem*> (mParent);675 676 /* Filter list from used slots */677 SlotsList allSlots (ctr->ctrAllSlots());678 SlotsList usedSlots (ctr->ctrUsedSlots());679 foreach (StorageSlot usedSlot, usedSlots)680 if (usedSlot != mAttSlot)681 allSlots.removeAll (usedSlot);682 683 return allSlots;684 }685 686 KDeviceType AttachmentItem::attDeviceType() const687 {688 return mAttDeviceType;689 }690 691 DeviceTypeList AttachmentItem::attDeviceTypes() const692 {693 return static_cast <ControllerItem*> (mParent)->ctrDeviceTypeList();694 }695 696 QString AttachmentItem::attMediumId() const697 {698 return mAttMediumId;699 }700 701 QStringList AttachmentItem::attMediumIds (bool aFilter) const702 {703 ControllerItem *ctr = static_cast <ControllerItem*> (mParent);704 QStringList allMediumIds;705 706 /* Populate list of suitable medium ids */707 foreach (QString mediumId, ctr->ctrAllMediumIds (mAttIsShowDiffs))708 {709 VBoxMedium medium = vboxGlobal().findMedium (mediumId);710 if ((medium.isNull() && mAttDeviceType != KDeviceType_HardDisk) ||711 (!medium.isNull() && typeToGlobal (medium.type()) == mAttDeviceType))712 allMediumIds << mediumId;713 }714 715 if (aFilter)716 {717 /* Filter list from used medium ids */718 QStringList usedMediumIds (ctr->ctrUsedMediumIds());719 foreach (QString usedMediumId, usedMediumIds)720 if (usedMediumId != mAttMediumId)721 allMediumIds.removeAll (usedMediumId);722 }723 724 return allMediumIds;725 }726 727 bool AttachmentItem::attIsShowDiffs() const728 {729 return mAttIsShowDiffs;730 }731 732 bool AttachmentItem::attIsHostDrive() const733 {734 return mAttIsHostDrive;735 }736 737 bool AttachmentItem::attIsPassthrough() const738 {739 return mAttIsPassthrough;740 }741 742 void AttachmentItem::setAttSlot (const StorageSlot &aAttSlot)743 {744 mAttSlot = aAttSlot;745 }746 747 void AttachmentItem::setAttDevice (KDeviceType aAttDeviceType)748 {749 mAttDeviceType = aAttDeviceType;750 }751 752 void AttachmentItem::setAttMediumId (const QString &aAttMediumId)753 {754 VBoxMedium medium;755 756 /* Caching first available medium */757 if (aAttMediumId == firstAvailableId && !attMediumIds (false).isEmpty())758 medium = vboxGlobal().findMedium (attMediumIds (false) [0]);759 /* Caching passed medium */760 else if (!aAttMediumId.isEmpty())761 medium = vboxGlobal().findMedium (aAttMediumId);762 763 mAttMediumId = medium.id();764 cache();765 }766 767 void AttachmentItem::setAttIsShowDiffs (bool aAttIsShowDiffs)768 {769 mAttIsShowDiffs = aAttIsShowDiffs;770 cache();771 }772 773 void AttachmentItem::setAttIsPassthrough (bool aIsAttPassthrough)774 {775 mAttIsPassthrough = aIsAttPassthrough;776 }777 778 QString AttachmentItem::attSize() const779 {780 return mAttSize;781 }782 783 QString AttachmentItem::attLogicalSize() const784 {785 return mAttLogicalSize;786 }787 788 QString AttachmentItem::attLocation() const789 {790 return mAttLocation;791 }792 793 QString AttachmentItem::attFormat() const794 {795 return mAttFormat;796 }797 798 QString AttachmentItem::attUsage() const799 {800 return mAttUsage;801 }802 803 void AttachmentItem::cache()804 {805 VBoxMedium medium = vboxGlobal().findMedium (mAttMediumId);806 807 /* Cache medium information */808 mAttName = medium.name (!mAttIsShowDiffs);809 mAttTip = medium.toolTipCheckRO (!mAttIsShowDiffs);810 mAttPixmap = medium.iconCheckRO (!mAttIsShowDiffs);811 mAttIsHostDrive = medium.isHostDrive();812 813 /* Cache additional information */814 mAttSize = medium.size (!mAttIsShowDiffs);815 mAttLogicalSize = medium.logicalSize (!mAttIsShowDiffs);816 mAttLocation = medium.location (!mAttIsShowDiffs);817 mAttFormat = medium.isNull() ? QString ("--") :818 QString ("%1 (%2)").arg (medium.hardDiskType (!mAttIsShowDiffs))819 .arg (medium.hardDiskFormat (!mAttIsShowDiffs));820 mAttUsage = medium.usage (!mAttIsShowDiffs);821 822 /* Fill empty attributes */823 if (mAttUsage.isEmpty())824 mAttUsage = QString ("--");825 832 } 826 833 … … 950 957 { 951 958 if (AbstractItem *item = static_cast <AbstractItem*> (aIndex.internalPointer())) 952 return item->pixmap(); 959 { 960 ItemState state = State_DefaultItem; 961 if (hasChildren (aIndex)) 962 if (QTreeView *view = qobject_cast <QTreeView*> (QObject::parent())) 963 state = view->isExpanded (aIndex) ? State_ExpandedItem : State_CollapsedItem; 964 return item->pixmap (state); 965 } 953 966 return QPixmap(); 954 967 } … … 1170 1183 return PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentEn); 1171 1184 } 1172 case R_HDPixmapDis:1173 {1174 return PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentDis);1175 }1176 1185 case R_CDPixmapEn: 1177 1186 { 1178 1187 return PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentEn); 1179 1188 } 1180 case R_CDPixmapDis:1181 {1182 return PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentDis);1183 }1184 1189 case R_FDPixmapEn: 1185 1190 { 1186 1191 return PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentEn); 1187 1192 } 1188 case R_FDPixmapDis: 1189 { 1190 return PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentDis); 1193 1194 case R_HDPixmapAddEn: 1195 { 1196 return PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentAddEn); 1197 } 1198 case R_HDPixmapAddDis: 1199 { 1200 return PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentAddDis); 1201 } 1202 case R_CDPixmapAddEn: 1203 { 1204 return PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentAddEn); 1205 } 1206 case R_CDPixmapAddDis: 1207 { 1208 return PixmapPool::pool()->pixmap (PixmapPool::CDAttachmentAddDis); 1209 } 1210 case R_FDPixmapAddEn: 1211 { 1212 return PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentAddEn); 1213 } 1214 case R_FDPixmapAddDis: 1215 { 1216 return PixmapPool::pool()->pixmap (PixmapPool::FDAttachmentAddDis); 1191 1217 } 1192 1218 case R_HDPixmapRect: … … 1210 1236 } 1211 1237 1212 case R_PlusPixmapEn:1213 {1214 return PixmapPool::pool()->pixmap (PixmapPool::PlusEn);1215 }1216 case R_PlusPixmapDis:1217 {1218 return PixmapPool::pool()->pixmap (PixmapPool::PlusDis);1219 }1220 case R_MinusPixmapEn:1221 {1222 return PixmapPool::pool()->pixmap (PixmapPool::MinusEn);1223 }1224 case R_MinusPixmapDis:1225 {1226 return PixmapPool::pool()->pixmap (PixmapPool::MinusDis);1227 }1228 case R_AdderPoint:1229 {1230 int margin = data (aIndex, R_Margin).toInt();1231 return QPoint (margin + 6, margin + 6);1232 }1233 1238 default: 1234 1239 break; … … 1411 1416 aPainter->save(); 1412 1417 1413 /* Draw selection backgroung */ 1414 if (state & QStyle::State_Selected) 1415 { 1416 QPalette::ColorGroup cg = (state & QStyle::State_Enabled && state & QStyle::State_Active) ? QPalette::Normal : 1417 (state & QStyle::State_Enabled) ? QPalette::Inactive : QPalette::Disabled; 1418 aPainter->fillRect (rect, aOption.palette.brush (cg, QPalette::Highlight)); 1419 } 1418 /* Draw item background */ 1419 QItemDelegate::drawBackground (aPainter, aOption, aIndex); 1420 1421 /* Setup foregroung settings */ 1422 bool isEnabled = state & QStyle::State_Enabled; 1423 bool isActive = state & QStyle::State_Active; 1424 bool isFocused = state & QStyle::State_HasFocus; 1425 bool isGrayOnLoosingFocus = QApplication::style()->styleHint (QStyle::SH_ItemView_ChangeHighlightOnFocus, &aOption) == 0; 1426 QPalette::ColorGroup cg = isEnabled && (isActive || !isGrayOnLoosingFocus) ? QPalette::Active : 1427 isEnabled ? QPalette::Inactive : QPalette::Disabled; 1428 aPainter->setPen (aOption.palette.color (cg, isFocused ? QPalette::HighlightedText : QPalette::Text)); 1420 1429 1421 1430 aPainter->translate (rect.x(), rect.y()); … … 1424 1433 aPainter->drawPixmap (model->data (aIndex, StorageModel::R_ItemPixmapRect).toRect().topLeft(), 1425 1434 model->data (aIndex, StorageModel::R_ItemPixmap).value <QPixmap>()); 1426 1427 /* Draw expand/collapse Pixmap */1428 if (model->hasChildren (aIndex))1429 {1430 QPixmap expander = state & QStyle::State_Open ?1431 model->data (aIndex, StorageModel::R_MinusPixmapEn).value <QPixmap>() :1432 model->data (aIndex, StorageModel::R_PlusPixmapEn).value <QPixmap>();1433 aPainter->drawPixmap (model->data (aIndex, StorageModel::R_AdderPoint).toPoint(), expander);1434 }1435 1435 1436 1436 /* Draw compressed item name */ … … 1473 1473 deviceRect = model->data (aIndex, StorageModel::R_HDPixmapRect).value <QRect>(); 1474 1474 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1475 model->data (aIndex, StorageModel::R_HDPixmap En).value <QPixmap>() :1476 model->data (aIndex, StorageModel::R_HDPixmap Dis).value <QPixmap>();1475 model->data (aIndex, StorageModel::R_HDPixmapAddEn).value <QPixmap>() : 1476 model->data (aIndex, StorageModel::R_HDPixmapAddDis).value <QPixmap>(); 1477 1477 break; 1478 1478 } … … 1481 1481 deviceRect = model->data (aIndex, StorageModel::R_CDPixmapRect).value <QRect>(); 1482 1482 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1483 model->data (aIndex, StorageModel::R_CDPixmap En).value <QPixmap>() :1484 model->data (aIndex, StorageModel::R_CDPixmap Dis).value <QPixmap>();1483 model->data (aIndex, StorageModel::R_CDPixmapAddEn).value <QPixmap>() : 1484 model->data (aIndex, StorageModel::R_CDPixmapAddDis).value <QPixmap>(); 1485 1485 break; 1486 1486 } … … 1489 1489 deviceRect = model->data (aIndex, StorageModel::R_FDPixmapRect).value <QRect>(); 1490 1490 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 1491 model->data (aIndex, StorageModel::R_FDPixmap En).value <QPixmap>() :1492 model->data (aIndex, StorageModel::R_FDPixmap Dis).value <QPixmap>();1491 model->data (aIndex, StorageModel::R_FDPixmapAddEn).value <QPixmap>() : 1492 model->data (aIndex, StorageModel::R_FDPixmapAddDis).value <QPixmap>(); 1493 1493 break; 1494 1494 } … … 1496 1496 break; 1497 1497 } 1498 QPixmap adderPixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ?1499 model->data (aIndex, StorageModel::R_PlusPixmapEn).value <QPixmap>() :1500 model->data (aIndex, StorageModel::R_PlusPixmapDis).value <QPixmap>();1501 1498 1502 1499 aPainter->drawPixmap (QPoint (rect.width() + deviceRect.x(), deviceRect.y()), devicePixmap); 1503 aPainter->drawPixmap (QPoint (rect.width() + deviceRect.x() + 6, deviceRect.y() + 6), adderPixmap);1504 1500 } 1505 1501 }
Note:
See TracChangeset
for help on using the changeset viewer.