Changeset 81098 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 2, 2019 12:50:50 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133709
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r81095 r81098 149 149 /** Constructs data. */ 150 150 UIDataSettingsMachineStorageAttachment() 151 : m_ attachmentType(KDeviceType_Null)152 , m_i AttachmentPort(-1)153 , m_i AttachmentDevice(-1)154 , m_u AttachmentMediumId(QUuid())155 , m_f AttachmentPassthrough(false)156 , m_f AttachmentTempEject(false)157 , m_f AttachmentNonRotational(false)158 , m_f AttachmentHotPluggable(false)151 : m_enmDeviceType(KDeviceType_Null) 152 , m_iPort(-1) 153 , m_iDevice(-1) 154 , m_uMediumId(QUuid()) 155 , m_fPassthrough(false) 156 , m_fTempEject(false) 157 , m_fNonRotational(false) 158 , m_fHotPluggable(false) 159 159 {} 160 160 161 161 /** Returns whether @a another passed data is equal to this one. */ 162 bool equal(const UIDataSettingsMachineStorageAttachment & other) const162 bool equal(const UIDataSettingsMachineStorageAttachment &another) const 163 163 { 164 164 return true 165 && (m_ attachmentType == other.m_attachmentType)166 && (m_i AttachmentPort == other.m_iAttachmentPort)167 && (m_i AttachmentDevice == other.m_iAttachmentDevice)168 && (m_u AttachmentMediumId == other.m_uAttachmentMediumId)169 && (m_f AttachmentPassthrough == other.m_fAttachmentPassthrough)170 && (m_f AttachmentTempEject == other.m_fAttachmentTempEject)171 && (m_f AttachmentNonRotational == other.m_fAttachmentNonRotational)172 && (m_f AttachmentHotPluggable == other.m_fAttachmentHotPluggable)165 && (m_enmDeviceType == another.m_enmDeviceType) 166 && (m_iPort == another.m_iPort) 167 && (m_iDevice == another.m_iDevice) 168 && (m_uMediumId == another.m_uMediumId) 169 && (m_fPassthrough == another.m_fPassthrough) 170 && (m_fTempEject == another.m_fTempEject) 171 && (m_fNonRotational == another.m_fNonRotational) 172 && (m_fHotPluggable == another.m_fHotPluggable) 173 173 ; 174 174 } 175 175 176 176 /** Returns whether @a another passed data is equal to this one. */ 177 bool operator==(const UIDataSettingsMachineStorageAttachment & other) const { return equal(other); }177 bool operator==(const UIDataSettingsMachineStorageAttachment &another) const { return equal(another); } 178 178 /** Returns whether @a another passed data is different from this one. */ 179 bool operator!=(const UIDataSettingsMachineStorageAttachment & other) const { return !equal(other); }180 181 /** Holds the attachmenttype. */182 KDeviceType m_ attachmentType;183 /** Holds the attachmentport. */184 LONG m_i AttachmentPort;185 /** Holds the attachmentdevice. */186 LONG m_i AttachmentDevice;187 /** Holds the attachmentmedium ID. */188 QUuid m_u AttachmentMediumId;179 bool operator!=(const UIDataSettingsMachineStorageAttachment &another) const { return !equal(another); } 180 181 /** Holds the device type. */ 182 KDeviceType m_enmDeviceType; 183 /** Holds the port. */ 184 LONG m_iPort; 185 /** Holds the device. */ 186 LONG m_iDevice; 187 /** Holds the medium ID. */ 188 QUuid m_uMediumId; 189 189 /** Holds whether the attachment being passed through. */ 190 bool m_f AttachmentPassthrough;190 bool m_fPassthrough; 191 191 /** Holds whether the attachment being temporarily eject. */ 192 bool m_f AttachmentTempEject;192 bool m_fTempEject; 193 193 /** Holds whether the attachment is solid-state. */ 194 bool m_f AttachmentNonRotational;194 bool m_fNonRotational; 195 195 /** Holds whether the attachment is hot-pluggable. */ 196 bool m_f AttachmentHotPluggable;196 bool m_fHotPluggable; 197 197 }; 198 198 … … 203 203 /** Constructs data. */ 204 204 UIDataSettingsMachineStorageController() 205 : m_str ControllerName(QString())206 , m_ controllerBus(KStorageBus_Null)207 , m_ controllerType(KStorageControllerType_Null)205 : m_strName(QString()) 206 , m_enmBus(KStorageBus_Null) 207 , m_enmType(KStorageControllerType_Null) 208 208 , m_uPortCount(0) 209 209 , m_fUseHostIOCache(false) … … 211 211 212 212 /** Returns whether @a another passed data is equal to this one. */ 213 bool equal(const UIDataSettingsMachineStorageController & other) const213 bool equal(const UIDataSettingsMachineStorageController &another) const 214 214 { 215 215 return true 216 && (m_str ControllerName == other.m_strControllerName)217 && (m_ controllerBus == other.m_controllerBus)218 && (m_ controllerType == other.m_controllerType)219 && (m_uPortCount == other.m_uPortCount)220 && (m_fUseHostIOCache == other.m_fUseHostIOCache)216 && (m_strName == another.m_strName) 217 && (m_enmBus == another.m_enmBus) 218 && (m_enmType == another.m_enmType) 219 && (m_uPortCount == another.m_uPortCount) 220 && (m_fUseHostIOCache == another.m_fUseHostIOCache) 221 221 ; 222 222 } 223 223 224 224 /** Returns whether @a another passed data is equal to this one. */ 225 bool operator==(const UIDataSettingsMachineStorageController & other) const { return equal(other); }225 bool operator==(const UIDataSettingsMachineStorageController &another) const { return equal(another); } 226 226 /** Returns whether @a another passed data is different from this one. */ 227 bool operator!=(const UIDataSettingsMachineStorageController & other) const { return !equal(other); }228 229 /** Holds the controllername. */230 QString m_str ControllerName;231 /** Holds the controllerbus. */232 KStorageBus m_ controllerBus;233 /** Holds the controllertype. */234 KStorageControllerType m_ controllerType;235 /** Holds the controllerport count. */227 bool operator!=(const UIDataSettingsMachineStorageController &another) const { return !equal(another); } 228 229 /** Holds the name. */ 230 QString m_strName; 231 /** Holds the bus. */ 232 KStorageBus m_enmBus; 233 /** Holds the type. */ 234 KStorageControllerType m_enmType; 235 /** Holds the port count. */ 236 236 uint m_uPortCount; 237 237 /** Holds whether the controller uses host IO cache. */ … … 247 247 248 248 /** Returns whether @a another passed data is equal to this one. */ 249 bool operator==(const UIDataSettingsMachineStorage & /* other */) const { return true; }249 bool operator==(const UIDataSettingsMachineStorage & /* another */) const { return true; } 250 250 /** Returns whether @a another passed data is different from this one. */ 251 bool operator!=(const UIDataSettingsMachineStorage & /* other */) const { return false; }251 bool operator!=(const UIDataSettingsMachineStorage & /* another */) const { return false; } 252 252 }; 253 253 … … 266 266 267 267 /** Returns pixmap corresponding to passed @a enmPixmapType. */ 268 QPixmap pixmap(PixmapType pixmapType) const;269 /** Returns icon (probably merged) corresponding to passed @a enmPixmapType and @a pixmapDisabledType. */270 QIcon icon(PixmapType pixmapType, PixmapType pixmapDisabledType = InvalidPixmap) const;268 QPixmap pixmap(PixmapType enmPixmapType) const; 269 /** Returns icon (probably merged) corresponding to passed @a enmPixmapType and @a enmPixmapDisabledType. */ 270 QIcon icon(PixmapType enmPixmapType, PixmapType enmPixmapDisabledType = InvalidPixmap) const; 271 271 272 272 private: … … 278 278 279 279 /** Icon-pool instance. */ 280 static UIIconPoolStorageSettings * m_spInstance;280 static UIIconPoolStorageSettings *s_pInstance; 281 281 /** Icon-pool names cache. */ 282 282 QMap<PixmapType, QString> m_names; … … 303 303 }; 304 304 305 /** Constructs top-level item passing @a pParent to the base-class. */306 AbstractItem(QITreeView *pParent );305 /** Constructs top-level item passing @a pParentTree to the base-class. */ 306 AbstractItem(QITreeView *pParentTree); 307 307 /** Constructs sub-level item passing @a pParentItem to the base-class. */ 308 308 AbstractItem(AbstractItem *pParentItem); … … 317 317 /** Returns machine ID. */ 318 318 QUuid machineId() const; 319 /** Defines @a uM chineId. */320 void setMachineId (const QUuid &uMchineId);319 /** Defines @a uMachineId. */ 320 void setMachineId(const QUuid &uMachineId); 321 321 322 322 /** Returns runtime type information. */ 323 323 virtual ItemType rtti() const = 0; 324 324 /** Returns child item with specified @a iIndex. */ 325 virtual AbstractItem* childItem (int aIndex) const = 0;325 virtual AbstractItem* childItem (int iIndex) const = 0; 326 326 /** Returns child item with specified @a uId. */ 327 327 virtual AbstractItem* childItemById (const QUuid &uId) const = 0; 328 328 /** Returns position of specified child @a pItem. */ 329 virtual int posOfChild (AbstractItem * aItem) const = 0;329 virtual int posOfChild (AbstractItem *pItem) const = 0; 330 330 /** Returns tool-tip information. */ 331 virtual QString t ip() const = 0;331 virtual QString toolTip() const = 0; 332 332 /** Returns pixmap information for specified @a enmState. */ 333 virtual QPixmap pixmap (ItemState aState = State_DefaultItem) = 0;333 virtual QPixmap pixmap (ItemState enmState = State_DefaultItem) = 0; 334 334 335 335 protected: 336 336 337 337 /** Adds a child @a pItem. */ 338 virtual void addChild (AbstractItem * aItem) = 0;338 virtual void addChild (AbstractItem *pItem) = 0; 339 339 /** Removes the child @a pItem. */ 340 virtual void delChild (AbstractItem * aItem) = 0;340 virtual void delChild (AbstractItem *pItem) = 0; 341 341 342 342 /** Holds the parent item reference. */ 343 343 AbstractItem *m_pParentItem; 344 344 /** Holds the item ID. */ 345 QUuid m Id;345 QUuid m_uId; 346 346 /** Holds the item machine ID. */ 347 QUuid m MachineId;347 QUuid m_uMachineId; 348 348 }; 349 349 Q_DECLARE_METATYPE (AbstractItem::ItemType); … … 357 357 public: 358 358 359 /** Constructs top-level item passing @a pParent to the base-class. */360 RootItem(QITreeView *pParent );359 /** Constructs top-level item passing @a pParentTree to the base-class. */ 360 RootItem(QITreeView *pParentTree); 361 361 /** Destructs item. */ 362 362 ~RootItem(); 363 363 364 /** Returns a number of shildren of certain @a enmBus type. */365 ULONG childCount (KStorageBus aBus) const;364 /** Returns a number of children of certain @a enmBus type. */ 365 ULONG childCount (KStorageBus enmBus) const; 366 366 367 367 private: … … 370 370 ItemType rtti() const; 371 371 /** Returns child item with specified @a iIndex. */ 372 AbstractItem* childItem (int aIndex) const;372 AbstractItem* childItem (int iIndex) const; 373 373 /** Returns child item with specified @a uId. */ 374 374 AbstractItem* childItemById (const QUuid &uId) const; 375 375 /** Returns position of specified child @a pItem. */ 376 int posOfChild (AbstractItem * aItem) const;376 int posOfChild (AbstractItem *pItem) const; 377 377 /** Returns the number of children. */ 378 378 int childCount() const; … … 380 380 QString text() const; 381 381 /** Returns tool-tip information. */ 382 QString t ip() const;382 QString toolTip() const; 383 383 /** Returns pixmap information for specified @a enmState. */ 384 QPixmap pixmap (ItemState aState);384 QPixmap pixmap (ItemState enmState); 385 385 /** Adds a child @a pItem. */ 386 void addChild (AbstractItem * aItem);386 void addChild (AbstractItem *pItem); 387 387 /** Removes the child @a pItem. */ 388 void delChild (AbstractItem * aItem);388 void delChild (AbstractItem *pItem); 389 389 390 390 /** Holds the list of controller items. */ 391 QList <AbstractItem*> m Controllers;391 QList <AbstractItem*> m_controllers; 392 392 }; 393 393 … … 400 400 public: 401 401 402 /** Constructs sub-level item passing @a pParent to the base-class.403 * @param strName Brings the controllername.404 * @param enmBus Brings the controllerbus.405 * @param enmType Brings the controllertype. */406 ControllerItem (AbstractItem *aParent, const QString &aName, KStorageBus aBusType,407 KStorageControllerType aControllerType);402 /** Constructs sub-level item passing @a pParentItem to the base-class. 403 * @param strName Brings the name. 404 * @param enmBus Brings the bus. 405 * @param enmType Brings the type. */ 406 ControllerItem(AbstractItem *pParentItem, const QString &strName, 407 KStorageBus enmBus, KStorageControllerType enmType); 408 408 /** Destructs item. */ 409 409 ~ControllerItem(); 410 410 411 411 /** Returns bus. */ 412 KStorageBus ctrBusType() const;412 KStorageBus bus() const; 413 413 /** Returns possible buses to switch from current one. */ 414 ControllerBusList ctrBusTypes() const;415 /** Returns old controllername. */416 QString old CtrName() const;417 /** Returns current controllername. */418 QString ctrName() const;414 ControllerBusList buses() const; 415 /** Returns old name. */ 416 QString oldName() const; 417 /** Returns current name. */ 418 QString name() const; 419 419 /** Returns type. */ 420 KStorageControllerType ctrType() const;420 KStorageControllerType type() const; 421 421 /** Returns possible types to switch from current one. */ 422 ControllerTypeList ctrTypes() const;422 ControllerTypeList types() const; 423 423 /** Returns current port count. */ 424 424 uint portCount(); … … 426 426 uint maxPortCount(); 427 427 /** Returns whether controller uses IO cache. */ 428 bool ctrUseIoCache() const;428 bool useIoCache() const; 429 429 430 430 /** Defines @a enmBus. */ 431 void set CtrBusType(KStorageBus enmCtrBusType);432 /** Defines @a strName. */433 void set CtrName (const QString &aCtrName);431 void setBus(KStorageBus enmBus); 432 /** Defines current @a strName. */ 433 void setName(const QString &strName); 434 434 /** Defines @a enmType. */ 435 void set CtrType (KStorageControllerType aCtrType);436 /** Defines @a uPortCount. */437 void setPortCount (uint aPortCount);435 void setType(KStorageControllerType enmType); 436 /** Defines current @a uPortCount. */ 437 void setPortCount(uint uPortCount); 438 438 /** Defines whether controller @a fUseIoCache. */ 439 void set CtrUseIoCache (bool aUseIoCache);439 void setUseIoCache(bool fUseIoCache); 440 440 441 441 /** Returns possible controller slots. */ 442 SlotsList ctrAllSlots() const;442 SlotsList allSlots() const; 443 443 /** Returns used controller slots. */ 444 SlotsList ctrUsedSlots() const;444 SlotsList usedSlots() const; 445 445 /** Returns supported device type list. */ 446 DeviceTypeList ctrDeviceTypeList() const;446 DeviceTypeList deviceTypeList() const; 447 447 448 448 /** Returns an ID list of attached media of specified @a enmType. */ … … 450 450 451 451 /** Returns a list of attachments. */ 452 QList<AbstractItem*> attachments() const { return m Attachments; }452 QList<AbstractItem*> attachments() const { return m_attachments; } 453 453 /** Defines a list of @a attachments. */ 454 void setAttachments(const QList<AbstractItem*> &attachments) { m Attachments = attachments; }454 void setAttachments(const QList<AbstractItem*> &attachments) { m_attachments = attachments; } 455 455 456 456 private: … … 459 459 ItemType rtti() const; 460 460 /** Returns child item with specified @a iIndex. */ 461 AbstractItem* childItem (int aIndex) const;461 AbstractItem* childItem (int iIndex) const; 462 462 /** Returns child item with specified @a uId. */ 463 463 AbstractItem* childItemById (const QUuid &uId) const; 464 464 /** Returns position of specified child @a pItem. */ 465 int posOfChild (AbstractItem * aItem) const;465 int posOfChild (AbstractItem *pItem) const; 466 466 /** Returns the number of children. */ 467 467 int childCount() const; … … 469 469 QString text() const; 470 470 /** Returns tool-tip information. */ 471 QString t ip() const;471 QString toolTip() const; 472 472 /** Returns pixmap information for specified @a enmState. */ 473 QPixmap pixmap (ItemState aState);473 QPixmap pixmap (ItemState enmState); 474 474 /** Adds a child @a pItem. */ 475 void addChild (AbstractItem * aItem);475 void addChild (AbstractItem *pItem); 476 476 /** Removes the child @a pItem. */ 477 void delChild (AbstractItem * aItem);477 void delChild (AbstractItem *pItem); 478 478 479 479 /** Updates possible buses. */ … … 485 485 486 486 /** Holds the bus. */ 487 KStorageBus m BusType;487 KStorageBus m_enmBus; 488 488 /** Holds the type. */ 489 KStorageControllerType m CtrType;489 KStorageControllerType m_enmType; 490 490 491 491 /** Holds the possible buses. */ … … 497 497 498 498 /** Holds the old name. */ 499 QString m OldCtrName;499 QString m_strOldName; 500 500 /** Holds the current name. */ 501 QString m CtrName;501 QString m_strName; 502 502 /** Holds the current port count. */ 503 uint m PortCount;503 uint m_uPortCount; 504 504 /** Holds whether controller uses IO cache. */ 505 bool m UseIoCache;505 bool m_fUseIoCache; 506 506 /** Holds the list of attachments. */ 507 QList <AbstractItem*> mAttachments;507 QList<AbstractItem*> m_attachments; 508 508 }; 509 509 … … 516 516 public: 517 517 518 /** Constructs sub-level item passing @a pParent to the base-class.518 /** Constructs sub-level item passing @a pParentItem to the base-class. 519 519 * @param enmDeviceType Brings the attachment device type. */ 520 AttachmentItem (AbstractItem *aParent, KDeviceType aDeviceType);520 AttachmentItem(AbstractItem *pParentItem, KDeviceType enmDeviceType); 521 521 522 522 /** Returns storage slot. */ 523 StorageSlot attSlot() const;523 StorageSlot storageSlot() const; 524 524 /** Returns possible storage slots. */ 525 SlotsList attSlots() const;525 SlotsList storageSlots() const; 526 526 /** Returns device type. */ 527 KDeviceType attDeviceType() const;527 KDeviceType deviceType() const; 528 528 /** Returns possible device types. */ 529 DeviceTypeList attDeviceTypes() const;529 DeviceTypeList deviceTypes() const; 530 530 /** Returns the medium id. */ 531 QUuid attMediumId() const;531 QUuid mediumId() const; 532 532 /** Returns whether attachment is a host drive. */ 533 bool attIsHostDrive() const;533 bool isHostDrive() const; 534 534 /** Returns whether attachment is passthrough. */ 535 bool attIsPassthrough() const;535 bool isPassthrough() const; 536 536 /** Returns whether attachment is temporary ejectable. */ 537 bool attIsTempEject() const;537 bool isTempEject() const; 538 538 /** Returns whether attachment is non-rotational. */ 539 bool attIsNonRotational() const;539 bool isNonRotational() const; 540 540 /** Returns whether attachment is hot-pluggable. */ 541 bool attIsHotPluggable() const;541 bool isHotPluggable() const; 542 542 543 543 /** Defines storage @a slot. */ 544 void set AttSlot (const StorageSlot &aAttSlot);544 void setStorageSlot(const StorageSlot &slot); 545 545 /** Defines @a enmDeviceType. */ 546 void set AttDevice (KDeviceType aAttDeviceType);546 void setDeviceType(KDeviceType enmDeviceType); 547 547 /** Defines @a uMediumId. */ 548 void set AttMediumId (const QUuid &uAttMediumId);548 void setMediumId(const QUuid &uMediumId); 549 549 /** Defines whether attachment is @a fPassthrough. */ 550 void set AttIsPassthrough (bool aPassthrough);550 void setPassthrough(bool fPassthrough); 551 551 /** Defines whether attachment is @a fTemporaryEjectable. */ 552 void set AttIsTempEject (bool aTempEject);552 void setTempEject(bool fTemporaryEjectable); 553 553 /** Defines whether attachment is @a fNonRotational. */ 554 void set AttIsNonRotational (bool aNonRotational);554 void setNonRotational(bool fNonRotational); 555 555 /** Returns whether attachment is @a fIsHotPluggable. */ 556 void set AttIsHotPluggable(bool fIsHotPluggable);556 void setHotPluggable(bool fIsHotPluggable); 557 557 558 558 /** Returns medium size. */ 559 QString attSize() const;559 QString size() const; 560 560 /** Returns logical medium size. */ 561 QString attLogicalSize() const;561 QString logicalSize() const; 562 562 /** Returns medium location. */ 563 QString attLocation() const;563 QString location() const; 564 564 /** Returns medium format. */ 565 QString attFormat() const;565 QString format() const; 566 566 /** Returns medium details. */ 567 QString attDetails() const;567 QString details() const; 568 568 /** Returns medium usage. */ 569 QString attUsage() const;569 QString usage() const; 570 570 /** Returns medium encryption password ID. */ 571 QString attEncryptionPasswordID() const;571 QString encryptionPasswordId() const; 572 572 573 573 private: … … 579 579 ItemType rtti() const; 580 580 /** Returns child item with specified @a iIndex. */ 581 AbstractItem* childItem (int aIndex) const;581 AbstractItem* childItem (int iIndex) const; 582 582 /** Returns child item with specified @a uId. */ 583 583 AbstractItem* childItemById (const QUuid &uId) const; 584 584 /** Returns position of specified child @a pItem. */ 585 int posOfChild (AbstractItem * aItem) const;585 int posOfChild (AbstractItem *pItem) const; 586 586 /** Returns the number of children. */ 587 587 int childCount() const; … … 589 589 QString text() const; 590 590 /** Returns tool-tip information. */ 591 QString t ip() const;591 QString toolTip() const; 592 592 /** Returns pixmap information for specified @a enmState. */ 593 QPixmap pixmap (ItemState aState);593 QPixmap pixmap (ItemState enmState); 594 594 /** Adds a child @a pItem. */ 595 void addChild (AbstractItem * aItem);595 void addChild (AbstractItem *pItem); 596 596 /** Removes the child @a pItem. */ 597 void delChild (AbstractItem * aItem);597 void delChild (AbstractItem *pItem); 598 598 599 599 /** Holds the device type. */ 600 KDeviceType m AttDeviceType;600 KDeviceType m_enmDeviceType; 601 601 602 602 /** Holds the storage slot. */ 603 StorageSlot m AttSlot;603 StorageSlot m_storageSlot; 604 604 /** Holds the medium ID. */ 605 QUuid m AttMediumId;605 QUuid m_uMediumId; 606 606 /** Holds whether attachment is a host drive. */ 607 bool m AttIsHostDrive;607 bool m_fHostDrive; 608 608 /** Holds whether attachment is passthrough. */ 609 bool m AttIsPassthrough;609 bool m_fPassthrough; 610 610 /** Holds whether attachment is temporary ejectable. */ 611 bool m AttIsTempEject;611 bool m_fTempEject; 612 612 /** Holds whether attachment is non-rotational. */ 613 bool m AttIsNonRotational;613 bool m_fNonRotational; 614 614 /** Holds whether attachment is hot-pluggable. */ 615 bool m_f IsHotPluggable;615 bool m_fHotPluggable; 616 616 617 617 /** Holds the name. */ 618 QString m AttName;618 QString m_strName; 619 619 /** Holds the tool-tip. */ 620 QString m AttTip;620 QString m_strTip; 621 621 /** Holds the pixmap. */ 622 QPixmap m AttPixmap;622 QPixmap m_strPixmap; 623 623 624 624 /** Holds the medium size. */ 625 QString m AttSize;625 QString m_strSize; 626 626 /** Holds the logical medium size. */ 627 QString m AttLogicalSize;627 QString m_strLogicalSize; 628 628 /** Holds the medium location. */ 629 QString m AttLocation;629 QString m_strLocation; 630 630 /** Holds the medium format. */ 631 QString m AttFormat;631 QString m_strFormat; 632 632 /** Holds the medium details. */ 633 QString m AttDetails;633 QString m_strDetails; 634 634 /** Holds the medium usage. */ 635 QString m AttUsage;635 QString m_strUsage; 636 636 /** Holds the medium encryption password ID. */ 637 637 QString m_strAttEncryptionPasswordID; … … 727 727 }; 728 728 729 /** Constructs storage model passing @a pParent to the base-class. */730 StorageModel(QITreeView *pParent );729 /** Constructs storage model passing @a pParentTree to the base-class. */ 730 StorageModel(QITreeView *pParentTree); 731 731 /** Destructs storage model. */ 732 732 ~StorageModel(); 733 733 734 734 /** Returns row count for the passed @a parentIndex. */ 735 int rowCount (const QModelIndex & aParent= QModelIndex()) const;735 int rowCount (const QModelIndex &parentIndex = QModelIndex()) const; 736 736 /** Returns column count for the passed @a parentIndex. */ 737 int columnCount (const QModelIndex & aParent= QModelIndex()) const;737 int columnCount (const QModelIndex &parentIndex = QModelIndex()) const; 738 738 739 739 /** Returns root item. */ 740 740 QModelIndex root() const; 741 741 /** Returns item specified by @a iRow, @a iColum and @a parentIndex. */ 742 QModelIndex index (int aRow, int aColumn, const QModelIndex &aParent= QModelIndex()) const;742 QModelIndex index (int iRow, int iColumn, const QModelIndex &parentIndex = QModelIndex()) const; 743 743 /** Returns parent item of specified @a index item. */ 744 QModelIndex parent (const QModelIndex & aIndex) const;744 QModelIndex parent (const QModelIndex &index) const; 745 745 746 746 /** Returns model data for specified @a index and @a iRole. */ 747 QVariant data (const QModelIndex & aIndex, int aRole) const;747 QVariant data (const QModelIndex &index, int iRole) const; 748 748 /** Defines model data for specified @a index and @a iRole as @a value. */ 749 bool setData (const QModelIndex & aIndex, const QVariant &aValue, int aRole);749 bool setData (const QModelIndex &index, const QVariant &value, int iRole); 750 750 751 751 /** Adds controller with certain @a strCtrName, @a enmBus and @a enmType. */ 752 QModelIndex addController (const QString & aCtrName, KStorageBus aBusType, KStorageControllerType aCtrType);752 QModelIndex addController (const QString &strCtrName, KStorageBus enmBus, KStorageControllerType enmType); 753 753 /** Deletes controller with certain @a uCtrId. */ 754 754 void delController (const QUuid &uCtrId); 755 755 756 756 /** Adds attachment with certain @a enmDeviceType and @a uMediumId to controller with certain @a uCtrId. */ 757 QModelIndex addAttachment (const QUuid &uCtrId, KDeviceType aDeviceType, const QUuid &uMediumId);757 QModelIndex addAttachment (const QUuid &uCtrId, KDeviceType enmDeviceType, const QUuid &uMediumId); 758 758 /** Deletes attachment with certain @a uAttId from controller with certain @a uCtrId. */ 759 759 void delAttachment (const QUuid &uCtrId, const QUuid &uAttId); … … 765 765 766 766 /** Sorts the contents of model by @a iColumn and @a enmOrder. */ 767 void sort(int iColumn = 0, Qt::SortOrder order = Qt::AscendingOrder);767 void sort(int iColumn = 0, Qt::SortOrder enmOrder = Qt::AscendingOrder); 768 768 /** Returns attachment index by specified @a controllerIndex and @a attachmentStorageSlot. */ 769 769 QModelIndex attachmentBySlot(QModelIndex controllerIndex, StorageSlot attachmentStorageSlot); … … 771 771 /** Returns chipset type. */ 772 772 KChipsetType chipsetType() const; 773 /** Defines chipset @a enmType. */774 void setChipsetType(KChipsetType type);775 776 /** Defines @a newConfigurationAccessLevel. */777 void setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel);773 /** Defines @a enmChipsetType. */ 774 void setChipsetType(KChipsetType enmChipsetType); 775 776 /** Defines @a enmConfigurationAccessLevel. */ 777 void setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel); 778 778 779 779 /** Clears model of all contents. */ … … 788 788 789 789 /** Returns model flags for specified @a index. */ 790 Qt::ItemFlags flags (const QModelIndex & aIndex) const;790 Qt::ItemFlags flags (const QModelIndex &index) const; 791 791 792 792 /** Holds the root item instance. */ 793 AbstractItem *m RootItem;793 AbstractItem *m_pRootItem; 794 794 795 795 /** Holds the enabled plus pixmap instance. */ 796 QPixmap m PlusPixmapEn;796 QPixmap m_pixmapPlusEn; 797 797 /** Holds the disabled plus pixmap instance. */ 798 QPixmap m PlusPixmapDis;798 QPixmap m_pixmapPlusDis; 799 799 800 800 /** Holds the enabled minus pixmap instance. */ 801 QPixmap m MinusPixmapEn;801 QPixmap m_pixmapMinusEn; 802 802 /** Holds the disabled minus pixmap instance. */ 803 QPixmap m MinusPixmapDis;803 QPixmap m_pixmapMinusDis; 804 804 805 805 /** Holds the tool-tip type. */ 806 ToolTipType m ToolTipType;806 ToolTipType m_enmToolTipType; 807 807 808 808 /** Holds the chipset type. */ 809 KChipsetType m_ chipsetType;809 KChipsetType m_enmChipsetType; 810 810 811 811 /** Holds configuration access level. */ 812 ConfigurationAccessLevel m_ configurationAccessLevel;812 ConfigurationAccessLevel m_enmConfigurationAccessLevel; 813 813 }; 814 814 Q_DECLARE_METATYPE (StorageModel::ToolTipType); … … 823 823 824 824 /** Constructs storage delegate passing @a pParent to the base-class. */ 825 StorageDelegate (QObject * aParent);825 StorageDelegate (QObject *pParent); 826 826 827 827 private: 828 828 829 829 /** Paints @a index item with specified @a option using specified @a pPainter. */ 830 void paint (QPainter * aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const;830 void paint (QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const; 831 831 }; 832 832 … … 850 850 851 851 /** Returns medium device type. */ 852 UIMediumDeviceType type() const { return m_ type; }852 UIMediumDeviceType type() const { return m_enmType; } 853 853 /** Defines medium device @a enmType. */ 854 void setType(UIMediumDeviceType type) { m_type = type; }854 void setType(UIMediumDeviceType enmType) { m_enmType = enmType; } 855 855 856 856 /** Returns whether medium ID is null. */ … … 867 867 QUuid m_uId; 868 868 /** Holds the medium device type. */ 869 UIMediumDeviceType m_ type;869 UIMediumDeviceType m_enmType; 870 870 }; 871 871 872 872 873 QString compressText (const QString &aText)874 { 875 return QString ("<nobr><compact elipsis=\"end\">%1</compact></nobr>").arg (aText);873 QString compressText(const QString &strText) 874 { 875 return QString("<nobr><compact elipsis=\"end\">%1</compact></nobr>").arg(strText); 876 876 } 877 877 … … 882 882 883 883 /* static */ 884 UIIconPoolStorageSettings* UIIconPoolStorageSettings:: m_spInstance = 0;885 UIIconPoolStorageSettings* UIIconPoolStorageSettings::instance() { return m_spInstance; }884 UIIconPoolStorageSettings* UIIconPoolStorageSettings::s_pInstance = 0; 885 UIIconPoolStorageSettings* UIIconPoolStorageSettings::instance() { return s_pInstance; } 886 886 void UIIconPoolStorageSettings::create() { new UIIconPoolStorageSettings; } 887 void UIIconPoolStorageSettings::destroy() { delete m_spInstance; }888 889 QPixmap UIIconPoolStorageSettings::pixmap(PixmapType pixmapType) const887 void UIIconPoolStorageSettings::destroy() { delete s_pInstance; } 888 889 QPixmap UIIconPoolStorageSettings::pixmap(PixmapType enmPixmapType) const 890 890 { 891 891 /* Prepare fallback pixmap: */ … … 893 893 894 894 /* If we do NOT have that 'pixmap type' icon cached already: */ 895 if (!m_icons.contains( pixmapType))895 if (!m_icons.contains(enmPixmapType)) 896 896 { 897 897 /* Compose proper icon if we have that 'pixmap type' known: */ 898 if (m_names.contains( pixmapType))899 m_icons[ pixmapType] = iconSet(m_names[pixmapType]);898 if (m_names.contains(enmPixmapType)) 899 m_icons[enmPixmapType] = iconSet(m_names[enmPixmapType]); 900 900 /* Assign fallback icon if we do NOT have that 'pixmap type' known: */ 901 901 else 902 m_icons[ pixmapType] = iconSet(nullPixmap);902 m_icons[enmPixmapType] = iconSet(nullPixmap); 903 903 } 904 904 905 905 /* Retrieve corresponding icon: */ 906 const QIcon &icon = m_icons[ pixmapType];906 const QIcon &icon = m_icons[enmPixmapType]; 907 907 AssertMsgReturn(!icon.isNull(), 908 ("Undefined icon for type '%d'.", (int) pixmapType),908 ("Undefined icon for type '%d'.", (int)enmPixmapType), 909 909 nullPixmap); 910 910 … … 912 912 const QList<QSize> availableSizes = icon.availableSizes(); 913 913 AssertMsgReturn(!availableSizes.isEmpty(), 914 ("Undefined icon for type '%s'.", (int) pixmapType),914 ("Undefined icon for type '%s'.", (int)enmPixmapType), 915 915 nullPixmap); 916 916 … … 923 923 } 924 924 925 QIcon UIIconPoolStorageSettings::icon(PixmapType pixmapType,926 PixmapType pixmapDisabledType /* = InvalidPixmap */) const925 QIcon UIIconPoolStorageSettings::icon(PixmapType enmPixmapType, 926 PixmapType enmPixmapDisabledType /* = InvalidPixmap */) const 927 927 { 928 928 /* Prepare fallback pixmap: */ … … 932 932 933 933 /* If we do NOT have that 'pixmap type' icon cached already: */ 934 if (!m_icons.contains( pixmapType))934 if (!m_icons.contains(enmPixmapType)) 935 935 { 936 936 /* Compose proper icon if we have that 'pixmap type' known: */ 937 if (m_names.contains( pixmapType))938 m_icons[ pixmapType] = iconSet(m_names[pixmapType]);937 if (m_names.contains(enmPixmapType)) 938 m_icons[enmPixmapType] = iconSet(m_names[enmPixmapType]); 939 939 /* Assign fallback icon if we do NOT have that 'pixmap type' known: */ 940 940 else 941 m_icons[ pixmapType] = iconSet(nullPixmap);941 m_icons[enmPixmapType] = iconSet(nullPixmap); 942 942 } 943 943 944 944 /* Retrieve normal icon: */ 945 const QIcon &icon = m_icons[ pixmapType];945 const QIcon &icon = m_icons[enmPixmapType]; 946 946 AssertMsgReturn(!icon.isNull(), 947 ("Undefined icon for type '%d'.", (int) pixmapType),947 ("Undefined icon for type '%d'.", (int)enmPixmapType), 948 948 nullIcon); 949 949 950 950 /* If 'disabled' icon is invalid => just return 'normal' icon: */ 951 if ( pixmapDisabledType == InvalidPixmap)951 if (enmPixmapDisabledType == InvalidPixmap) 952 952 return icon; 953 953 954 954 /* If we do NOT have that 'pixmap disabled type' icon cached already: */ 955 if (!m_icons.contains( pixmapDisabledType))955 if (!m_icons.contains(enmPixmapDisabledType)) 956 956 { 957 957 /* Compose proper icon if we have that 'pixmap disabled type' known: */ 958 if (m_names.contains( pixmapDisabledType))959 m_icons[ pixmapDisabledType] = iconSet(m_names[pixmapDisabledType]);958 if (m_names.contains(enmPixmapDisabledType)) 959 m_icons[enmPixmapDisabledType] = iconSet(m_names[enmPixmapDisabledType]); 960 960 /* Assign fallback icon if we do NOT have that 'pixmap disabled type' known: */ 961 961 else 962 m_icons[ pixmapDisabledType] = iconSet(nullPixmap);962 m_icons[enmPixmapDisabledType] = iconSet(nullPixmap); 963 963 } 964 964 965 965 /* Retrieve disabled icon: */ 966 const QIcon &iconDisabled = m_icons[ pixmapDisabledType];966 const QIcon &iconDisabled = m_icons[enmPixmapDisabledType]; 967 967 AssertMsgReturn(!iconDisabled.isNull(), 968 ("Undefined icon for type '%d'.", (int) pixmapDisabledType),968 ("Undefined icon for type '%d'.", (int)enmPixmapDisabledType), 969 969 nullIcon); 970 970 … … 979 979 { 980 980 /* Connect instance: */ 981 m_spInstance = this;981 s_pInstance = this; 982 982 983 983 /* Controller file-names: */ … … 1058 1058 { 1059 1059 /* Disconnect instance: */ 1060 m_spInstance = 0;1060 s_pInstance = 0; 1061 1061 } 1062 1062 … … 1066 1066 *********************************************************************************************************************************/ 1067 1067 1068 AbstractItem::AbstractItem(QITreeView *pParent )1069 : QITreeViewItem(pParent )1068 AbstractItem::AbstractItem(QITreeView *pParentTree) 1069 : QITreeViewItem(pParentTree) 1070 1070 , m_pParentItem(0) 1071 , m Id(QUuid::createUuid())1071 , m_uId(QUuid::createUuid()) 1072 1072 { 1073 1073 if (m_pParentItem) … … 1078 1078 : QITreeViewItem(pParentItem) 1079 1079 , m_pParentItem(pParentItem) 1080 , m Id(QUuid::createUuid())1080 , m_uId(QUuid::createUuid()) 1081 1081 { 1082 1082 if (m_pParentItem) … … 1097 1097 QUuid AbstractItem::id() const 1098 1098 { 1099 return m Id;1099 return m_uId; 1100 1100 } 1101 1101 1102 1102 QUuid AbstractItem::machineId() const 1103 1103 { 1104 return m MachineId;1104 return m_uMachineId; 1105 1105 } 1106 1106 1107 1107 void AbstractItem::setMachineId (const QUuid &uMachineId) 1108 1108 { 1109 m MachineId = uMachineId;1109 m_uMachineId = uMachineId; 1110 1110 } 1111 1111 … … 1115 1115 *********************************************************************************************************************************/ 1116 1116 1117 RootItem::RootItem(QITreeView *pParent )1118 : AbstractItem(pParent )1117 RootItem::RootItem(QITreeView *pParentTree) 1118 : AbstractItem(pParentTree) 1119 1119 { 1120 1120 } … … 1122 1122 RootItem::~RootItem() 1123 1123 { 1124 while (!m Controllers.isEmpty())1125 delete m Controllers.first();1126 } 1127 1128 ULONG RootItem::childCount (KStorageBus aBus) const1129 { 1130 ULONG result = 0;1131 foreach (AbstractItem * item, mControllers)1132 { 1133 ControllerItem * ctrItem = qobject_cast<ControllerItem*>(item);1134 if ( ctrItem->ctrBusType() == aBus)1135 ++ result;1136 } 1137 return result;1124 while (!m_controllers.isEmpty()) 1125 delete m_controllers.first(); 1126 } 1127 1128 ULONG RootItem::childCount (KStorageBus enmBus) const 1129 { 1130 ULONG uResult = 0; 1131 foreach (AbstractItem *pItem, m_controllers) 1132 { 1133 ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem); 1134 if (pItemController->bus() == enmBus) 1135 ++ uResult; 1136 } 1137 return uResult; 1138 1138 } 1139 1139 … … 1143 1143 } 1144 1144 1145 AbstractItem* RootItem::childItem (int aIndex) const1146 { 1147 return m Controllers [aIndex];1145 AbstractItem* RootItem::childItem (int iIndex) const 1146 { 1147 return m_controllers [iIndex]; 1148 1148 } 1149 1149 … … 1151 1151 { 1152 1152 for (int i = 0; i < childCount(); ++ i) 1153 if (m Controllers [i]->id() == uId)1154 return m Controllers [i];1153 if (m_controllers [i]->id() == uId) 1154 return m_controllers [i]; 1155 1155 return 0; 1156 1156 } 1157 1157 1158 int RootItem::posOfChild (AbstractItem * aItem) const1159 { 1160 return m Controllers.indexOf (aItem);1158 int RootItem::posOfChild (AbstractItem *pItem) const 1159 { 1160 return m_controllers.indexOf (pItem); 1161 1161 } 1162 1162 1163 1163 int RootItem::childCount() const 1164 1164 { 1165 return m Controllers.size();1165 return m_controllers.size(); 1166 1166 } 1167 1167 … … 1171 1171 } 1172 1172 1173 QString RootItem::t ip() const1173 QString RootItem::toolTip() const 1174 1174 { 1175 1175 return QString(); 1176 1176 } 1177 1177 1178 QPixmap RootItem::pixmap (ItemState /* aState */)1178 QPixmap RootItem::pixmap (ItemState /* enmState */) 1179 1179 { 1180 1180 return QPixmap(); 1181 1181 } 1182 1182 1183 void RootItem::addChild (AbstractItem * aItem)1184 { 1185 m Controllers << aItem;1186 } 1187 1188 void RootItem::delChild (AbstractItem * aItem)1189 { 1190 m Controllers.removeAll (aItem);1183 void RootItem::addChild (AbstractItem *pItem) 1184 { 1185 m_controllers << pItem; 1186 } 1187 1188 void RootItem::delChild (AbstractItem *pItem) 1189 { 1190 m_controllers.removeAll (pItem); 1191 1191 } 1192 1192 … … 1196 1196 *********************************************************************************************************************************/ 1197 1197 1198 ControllerItem::ControllerItem (AbstractItem * aParent, const QString &aName,1199 KStorageBus aBusType, KStorageControllerType aControllerType)1200 : AbstractItem ( aParent)1201 , m BusType (aBusType)1202 , m CtrType (aControllerType)1203 , m OldCtrName (aName)1204 , m CtrName (aName)1205 , m PortCount (0)1206 , m UseIoCache (false)1198 ControllerItem::ControllerItem (AbstractItem *pParentItem, const QString &strName, 1199 KStorageBus enmBus, KStorageControllerType enmType) 1200 : AbstractItem (pParentItem) 1201 , m_enmBus (enmBus) 1202 , m_enmType (enmType) 1203 , m_strOldName (strName) 1204 , m_strName (strName) 1205 , m_uPortCount (0) 1206 , m_fUseIoCache (false) 1207 1207 { 1208 1208 /* Check for proper parent type */ 1209 AssertMsg( m_pParentItem->rtti() == AbstractItem::Type_RootItem, ("Incorrect parent type!\n"));1210 1211 AssertMsg (m BusType != KStorageBus_Null, ("Wrong Bus Type {%d}!\n", mBusType));1212 AssertMsg (m CtrType != KStorageControllerType_Null, ("Wrong Controller Type {%d}!\n", mCtrType));1209 AssertMsg(parent()->rtti() == AbstractItem::Type_RootItem, ("Incorrect parent type!\n")); 1210 1211 AssertMsg (m_enmBus != KStorageBus_Null, ("Wrong Bus Type {%d}!\n", m_enmBus)); 1212 AssertMsg (m_enmType != KStorageControllerType_Null, ("Wrong Controller Type {%d}!\n", m_enmType)); 1213 1213 1214 1214 updateBusInfo(); … … 1216 1216 updatePixmaps(); 1217 1217 1218 m UseIoCache = uiCommon().virtualBox().GetSystemProperties().GetDefaultIoCacheSettingForStorageController (aControllerType);1218 m_fUseIoCache = uiCommon().virtualBox().GetSystemProperties().GetDefaultIoCacheSettingForStorageController (enmType); 1219 1219 } 1220 1220 1221 1221 ControllerItem::~ControllerItem() 1222 1222 { 1223 while (!m Attachments.isEmpty())1224 delete m Attachments.first();1225 } 1226 1227 KStorageBus ControllerItem:: ctrBusType() const1228 { 1229 return m BusType;1230 } 1231 1232 ControllerBusList ControllerItem:: ctrBusTypes() const1223 while (!m_attachments.isEmpty()) 1224 delete m_attachments.first(); 1225 } 1226 1227 KStorageBus ControllerItem::bus() const 1228 { 1229 return m_enmBus; 1230 } 1231 1232 ControllerBusList ControllerItem::buses() const 1233 1233 { 1234 1234 return m_buses; 1235 1235 } 1236 1236 1237 QString ControllerItem:: oldCtrName() const1238 { 1239 return m OldCtrName;1240 } 1241 1242 QString ControllerItem:: ctrName() const1243 { 1244 return m CtrName;1245 } 1246 1247 KStorageControllerType ControllerItem:: ctrType() const1248 { 1249 return m CtrType;1250 } 1251 1252 ControllerTypeList ControllerItem:: ctrTypes() const1237 QString ControllerItem::name() const 1238 { 1239 return m_strName; 1240 } 1241 1242 QString ControllerItem::oldName() const 1243 { 1244 return m_strOldName; 1245 } 1246 1247 KStorageControllerType ControllerItem::type() const 1248 { 1249 return m_enmType; 1250 } 1251 1252 ControllerTypeList ControllerItem::types() const 1253 1253 { 1254 1254 return m_types; … … 1258 1258 { 1259 1259 /* Recalculate actual port count: */ 1260 for (int i = 0; i < m Attachments.size(); ++i)1261 { 1262 AttachmentItem *pItem = qobject_cast<AttachmentItem*>(m Attachments.at(i));1263 if (m PortCount < (uint)pItem->attSlot().port + 1)1264 m PortCount = (uint)pItem->attSlot().port + 1;1265 } 1266 return m PortCount;1260 for (int i = 0; i < m_attachments.size(); ++i) 1261 { 1262 AttachmentItem *pItem = qobject_cast<AttachmentItem*>(m_attachments.at(i)); 1263 if (m_uPortCount < (uint)pItem->storageSlot().port + 1) 1264 m_uPortCount = (uint)pItem->storageSlot().port + 1; 1265 } 1266 return m_uPortCount; 1267 1267 } 1268 1268 1269 1269 uint ControllerItem::maxPortCount() 1270 1270 { 1271 return (uint)uiCommon().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus( ctrBusType());1272 } 1273 1274 bool ControllerItem:: ctrUseIoCache() const1275 { 1276 return m UseIoCache;1277 } 1278 1279 void ControllerItem::set CtrBusType(KStorageBus enmCtrBusType)1280 { 1281 m BusType = enmCtrBusType;1271 return (uint)uiCommon().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(bus()); 1272 } 1273 1274 bool ControllerItem::useIoCache() const 1275 { 1276 return m_fUseIoCache; 1277 } 1278 1279 void ControllerItem::setBus(KStorageBus enmBus) 1280 { 1281 m_enmBus = enmBus; 1282 1282 1283 1283 updateBusInfo(); … … 1286 1286 } 1287 1287 1288 void ControllerItem::set CtrName (const QString &aCtrName)1289 { 1290 m CtrName = aCtrName;1291 } 1292 1293 void ControllerItem::set CtrType (KStorageControllerType aCtrType)1294 { 1295 m CtrType = aCtrType;1296 } 1297 1298 void ControllerItem::setPortCount (uint aPortCount)1288 void ControllerItem::setName (const QString &strName) 1289 { 1290 m_strName = strName; 1291 } 1292 1293 void ControllerItem::setType (KStorageControllerType enmType) 1294 { 1295 m_enmType = enmType; 1296 } 1297 1298 void ControllerItem::setPortCount (uint uPortCount) 1299 1299 { 1300 1300 /* Limit maximum port count: */ 1301 m PortCount = qMin(aPortCount, (uint)uiCommon().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(ctrBusType()));1302 } 1303 1304 void ControllerItem::set CtrUseIoCache (bool aUseIoCache)1305 { 1306 m UseIoCache = aUseIoCache;1307 } 1308 1309 SlotsList ControllerItem:: ctrAllSlots() const1301 m_uPortCount = qMin(uPortCount, (uint)uiCommon().virtualBox().GetSystemProperties().GetMaxPortCountForStorageBus(bus())); 1302 } 1303 1304 void ControllerItem::setUseIoCache (bool fUseIoCache) 1305 { 1306 m_fUseIoCache = fUseIoCache; 1307 } 1308 1309 SlotsList ControllerItem::allSlots() const 1310 1310 { 1311 1311 SlotsList allSlots; 1312 CSystemProperties sp= uiCommon().virtualBox().GetSystemProperties();1313 for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus (ctrBusType()); ++ i)1314 for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus (ctrBusType()); ++ j)1315 allSlots << StorageSlot ( ctrBusType(), i, j);1312 CSystemProperties comProps = uiCommon().virtualBox().GetSystemProperties(); 1313 for (ULONG i = 0; i < comProps.GetMaxPortCountForStorageBus (bus()); ++ i) 1314 for (ULONG j = 0; j < comProps.GetMaxDevicesPerPortForStorageBus (bus()); ++ j) 1315 allSlots << StorageSlot (bus(), i, j); 1316 1316 return allSlots; 1317 1317 } 1318 1318 1319 SlotsList ControllerItem:: ctrUsedSlots() const1319 SlotsList ControllerItem::usedSlots() const 1320 1320 { 1321 1321 SlotsList usedSlots; 1322 for (int i = 0; i < m Attachments.size(); ++ i)1323 usedSlots << qobject_cast<AttachmentItem*>(m Attachments.at(i))->attSlot();1322 for (int i = 0; i < m_attachments.size(); ++ i) 1323 usedSlots << qobject_cast<AttachmentItem*>(m_attachments.at(i))->storageSlot(); 1324 1324 return usedSlots; 1325 1325 } 1326 1326 1327 DeviceTypeList ControllerItem:: ctrDeviceTypeList() const1328 { 1329 return uiCommon().virtualBox().GetSystemProperties().GetDeviceTypesForStorageBus (m BusType).toList();1327 DeviceTypeList ControllerItem::deviceTypeList() const 1328 { 1329 return uiCommon().virtualBox().GetSystemProperties().GetDeviceTypesForStorageBus (m_enmBus).toList(); 1330 1330 } 1331 1331 … … 1333 1333 { 1334 1334 QList<QUuid> ids; 1335 foreach (AbstractItem *pItem, m Attachments)1335 foreach (AbstractItem *pItem, m_attachments) 1336 1336 { 1337 1337 AttachmentItem *pItemAttachment = qobject_cast<AttachmentItem*>(pItem); 1338 1338 if ( enmType == KDeviceType_Null 1339 || pItemAttachment-> attDeviceType() == enmType)1339 || pItemAttachment->deviceType() == enmType) 1340 1340 ids << pItem->id(); 1341 1341 } … … 1348 1348 } 1349 1349 1350 AbstractItem* ControllerItem::childItem (int aIndex) const1351 { 1352 return m Attachments [aIndex];1350 AbstractItem* ControllerItem::childItem (int iIndex) const 1351 { 1352 return m_attachments [iIndex]; 1353 1353 } 1354 1354 … … 1356 1356 { 1357 1357 for (int i = 0; i < childCount(); ++ i) 1358 if (m Attachments [i]->id() == uId)1359 return m Attachments [i];1358 if (m_attachments [i]->id() == uId) 1359 return m_attachments [i]; 1360 1360 return 0; 1361 1361 } 1362 1362 1363 int ControllerItem::posOfChild (AbstractItem * aItem) const1364 { 1365 return m Attachments.indexOf (aItem);1363 int ControllerItem::posOfChild (AbstractItem *pItem) const 1364 { 1365 return m_attachments.indexOf (pItem); 1366 1366 } 1367 1367 1368 1368 int ControllerItem::childCount() const 1369 1369 { 1370 return m Attachments.size();1370 return m_attachments.size(); 1371 1371 } 1372 1372 1373 1373 QString ControllerItem::text() const 1374 1374 { 1375 return UIMachineSettingsStorage::tr("Controller: %1").arg( ctrName());1376 } 1377 1378 QString ControllerItem::t ip() const1375 return UIMachineSettingsStorage::tr("Controller: %1").arg(name()); 1376 } 1377 1378 QString ControllerItem::toolTip() const 1379 1379 { 1380 1380 return UIMachineSettingsStorage::tr ("<nobr><b>%1</b></nobr><br>" 1381 1381 "<nobr>Bus: %2</nobr><br>" 1382 1382 "<nobr>Type: %3</nobr>") 1383 .arg (m CtrName)1384 .arg (gpConverter->toString ( ctrBusType()))1385 .arg (gpConverter->toString ( ctrType()));1386 } 1387 1388 QPixmap ControllerItem::pixmap (ItemState aState)1389 { 1390 return iconPool()->pixmap(m_pixmaps.at( aState));1391 } 1392 1393 void ControllerItem::addChild (AbstractItem * aItem)1394 { 1395 m Attachments << aItem;1396 } 1397 1398 void ControllerItem::delChild (AbstractItem * aItem)1399 { 1400 m Attachments.removeAll (aItem);1383 .arg (m_strName) 1384 .arg (gpConverter->toString (bus())) 1385 .arg (gpConverter->toString (type())); 1386 } 1387 1388 QPixmap ControllerItem::pixmap (ItemState enmState) 1389 { 1390 return iconPool()->pixmap(m_pixmaps.at(enmState)); 1391 } 1392 1393 void ControllerItem::addChild (AbstractItem *pItem) 1394 { 1395 m_attachments << pItem; 1396 } 1397 1398 void ControllerItem::delChild (AbstractItem *pItem) 1399 { 1400 m_attachments.removeAll (pItem); 1401 1401 } 1402 1402 … … 1405 1405 m_buses.clear(); 1406 1406 1407 switch (m BusType)1407 switch (m_enmBus) 1408 1408 { 1409 1409 case KStorageBus_IDE: … … 1417 1417 m_buses << KStorageBus_IDE << KStorageBus_SATA << KStorageBus_SCSI << KStorageBus_SAS 1418 1418 << KStorageBus_USB << KStorageBus_PCIe << KStorageBus_VirtioSCSI; 1419 m_buses.removeAll(m BusType);1419 m_buses.removeAll(m_enmBus); 1420 1420 } 1421 1421 RT_FALL_THRU(); 1422 1422 default: 1423 1423 { 1424 m_buses.prepend(m BusType);1424 m_buses.prepend(m_enmBus); 1425 1425 break; 1426 1426 } … … 1433 1433 1434 1434 KStorageControllerType enmFirstType = KStorageControllerType_Null; 1435 switch (m BusType)1435 switch (m_enmBus) 1436 1436 { 1437 1437 case KStorageBus_IDE: enmFirstType = KStorageControllerType_PIIX3; break; … … 1448 1448 1449 1449 uint uTypeAmount = 0; 1450 switch (m BusType)1450 switch (m_enmBus) 1451 1451 { 1452 1452 case KStorageBus_IDE: uTypeAmount = 3; break; … … 1473 1473 { 1474 1474 m_pixmaps << InvalidPixmap; 1475 switch (m BusType)1475 switch (m_enmBus) 1476 1476 { 1477 1477 case KStorageBus_IDE: m_pixmaps[i] = static_cast<PixmapType>(IDEControllerNormal + i); break; … … 1494 1494 *********************************************************************************************************************************/ 1495 1495 1496 AttachmentItem::AttachmentItem (AbstractItem * aParent, KDeviceType aDeviceType)1497 : AbstractItem ( aParent)1498 , m AttDeviceType (aDeviceType)1499 , m AttIsHostDrive (false)1500 , m AttIsPassthrough (false)1501 , m AttIsTempEject (false)1502 , m AttIsNonRotational (false)1503 , m_f IsHotPluggable(false)1496 AttachmentItem::AttachmentItem (AbstractItem *pParentItem, KDeviceType enmDeviceType) 1497 : AbstractItem (pParentItem) 1498 , m_enmDeviceType (enmDeviceType) 1499 , m_fHostDrive (false) 1500 , m_fPassthrough (false) 1501 , m_fTempEject (false) 1502 , m_fNonRotational (false) 1503 , m_fHotPluggable(false) 1504 1504 { 1505 1505 /* Check for proper parent type */ 1506 AssertMsg( m_pParentItem->rtti() == AbstractItem::Type_ControllerItem, ("Incorrect parent type!\n"));1506 AssertMsg(parent()->rtti() == AbstractItem::Type_ControllerItem, ("Incorrect parent type!\n")); 1507 1507 1508 1508 /* Select default slot */ 1509 AssertMsg (! attSlots().isEmpty(), ("There should be at least one available slot!\n"));1510 m AttSlot = attSlots() [0];1511 } 1512 1513 StorageSlot AttachmentItem:: attSlot() const1514 { 1515 return m AttSlot;1516 } 1517 1518 SlotsList AttachmentItem:: attSlots() const1519 { 1520 ControllerItem * ctr = qobject_cast<ControllerItem*>(m_pParentItem);1509 AssertMsg (!storageSlots().isEmpty(), ("There should be at least one available slot!\n")); 1510 m_storageSlot = storageSlots() [0]; 1511 } 1512 1513 StorageSlot AttachmentItem::storageSlot() const 1514 { 1515 return m_storageSlot; 1516 } 1517 1518 SlotsList AttachmentItem::storageSlots() const 1519 { 1520 ControllerItem *pItemController = qobject_cast<ControllerItem*>(parent()); 1521 1521 1522 1522 /* Filter list from used slots */ 1523 SlotsList allSlots ( ctr->ctrAllSlots());1524 SlotsList usedSlots ( ctr->ctrUsedSlots());1523 SlotsList allSlots (pItemController->allSlots()); 1524 SlotsList usedSlots (pItemController->usedSlots()); 1525 1525 foreach (StorageSlot usedSlot, usedSlots) 1526 if (usedSlot != m AttSlot)1526 if (usedSlot != m_storageSlot) 1527 1527 allSlots.removeAll (usedSlot); 1528 1528 … … 1530 1530 } 1531 1531 1532 KDeviceType AttachmentItem:: attDeviceType() const1533 { 1534 return m AttDeviceType;1535 } 1536 1537 DeviceTypeList AttachmentItem:: attDeviceTypes() const1538 { 1539 return qobject_cast<ControllerItem*>( m_pParentItem)->ctrDeviceTypeList();1540 } 1541 1542 QUuid AttachmentItem:: attMediumId() const1543 { 1544 return m AttMediumId;1545 } 1546 1547 bool AttachmentItem:: attIsHostDrive() const1548 { 1549 return m AttIsHostDrive;1550 } 1551 1552 bool AttachmentItem:: attIsPassthrough() const1553 { 1554 return m AttIsPassthrough;1555 } 1556 1557 bool AttachmentItem:: attIsTempEject() const1558 { 1559 return m AttIsTempEject;1560 } 1561 1562 bool AttachmentItem:: attIsNonRotational() const1563 { 1564 return m AttIsNonRotational;1565 } 1566 1567 bool AttachmentItem:: attIsHotPluggable() const1568 { 1569 return m_f IsHotPluggable;1570 } 1571 1572 void AttachmentItem::set AttSlot (const StorageSlot &aAttSlot)1573 { 1574 m AttSlot = aAttSlot;1575 } 1576 1577 void AttachmentItem::set AttDevice (KDeviceType aAttDeviceType)1578 { 1579 m AttDeviceType = aAttDeviceType;1580 } 1581 1582 void AttachmentItem::set AttMediumId (const QUuid &uAttMediumId)1532 KDeviceType AttachmentItem::deviceType() const 1533 { 1534 return m_enmDeviceType; 1535 } 1536 1537 DeviceTypeList AttachmentItem::deviceTypes() const 1538 { 1539 return qobject_cast<ControllerItem*>(parent())->deviceTypeList(); 1540 } 1541 1542 QUuid AttachmentItem::mediumId() const 1543 { 1544 return m_uMediumId; 1545 } 1546 1547 bool AttachmentItem::isHostDrive() const 1548 { 1549 return m_fHostDrive; 1550 } 1551 1552 bool AttachmentItem::isPassthrough() const 1553 { 1554 return m_fPassthrough; 1555 } 1556 1557 bool AttachmentItem::isTempEject() const 1558 { 1559 return m_fTempEject; 1560 } 1561 1562 bool AttachmentItem::isNonRotational() const 1563 { 1564 return m_fNonRotational; 1565 } 1566 1567 bool AttachmentItem::isHotPluggable() const 1568 { 1569 return m_fHotPluggable; 1570 } 1571 1572 void AttachmentItem::setStorageSlot (const StorageSlot &storageSlot) 1573 { 1574 m_storageSlot = storageSlot; 1575 } 1576 1577 void AttachmentItem::setDeviceType (KDeviceType enmDeviceType) 1578 { 1579 m_enmDeviceType = enmDeviceType; 1580 } 1581 1582 void AttachmentItem::setMediumId (const QUuid &uMediumId) 1583 1583 { 1584 1584 /// @todo is this required? 1585 1585 //AssertMsg(!aAttMediumId.isNull(), ("Medium ID value can't be null!\n")); 1586 m AttMediumId = uiCommon().medium(uAttMediumId).id();1586 m_uMediumId = uiCommon().medium(uMediumId).id(); 1587 1587 cache(); 1588 1588 } 1589 1589 1590 void AttachmentItem::set AttIsPassthrough (bool aIsAttPassthrough)1591 { 1592 m AttIsPassthrough = aIsAttPassthrough;1593 } 1594 1595 void AttachmentItem::set AttIsTempEject (bool aIsAttTempEject)1596 { 1597 m AttIsTempEject = aIsAttTempEject;1598 } 1599 1600 void AttachmentItem::set AttIsNonRotational (bool aIsAttNonRotational)1601 { 1602 m AttIsNonRotational = aIsAttNonRotational;1603 } 1604 1605 void AttachmentItem::set AttIsHotPluggable(bool fIsHotPluggable)1606 { 1607 m_f IsHotPluggable = fIsHotPluggable;1608 } 1609 1610 QString AttachmentItem:: attSize() const1611 { 1612 return m AttSize;1613 } 1614 1615 QString AttachmentItem:: attLogicalSize() const1616 { 1617 return m AttLogicalSize;1618 } 1619 1620 QString AttachmentItem:: attLocation() const1621 { 1622 return m AttLocation;1623 } 1624 1625 QString AttachmentItem:: attFormat() const1626 { 1627 return m AttFormat;1628 } 1629 1630 QString AttachmentItem:: attDetails() const1631 { 1632 return m AttDetails;1633 } 1634 1635 QString AttachmentItem:: attUsage() const1636 { 1637 return m AttUsage;1638 } 1639 1640 QString AttachmentItem:: attEncryptionPasswordID() const1590 void AttachmentItem::setPassthrough (bool fPassthrough) 1591 { 1592 m_fPassthrough = fPassthrough; 1593 } 1594 1595 void AttachmentItem::setTempEject (bool fTempEject) 1596 { 1597 m_fTempEject = fTempEject; 1598 } 1599 1600 void AttachmentItem::setNonRotational (bool fNonRotational) 1601 { 1602 m_fNonRotational = fNonRotational; 1603 } 1604 1605 void AttachmentItem::setHotPluggable(bool fHotPluggable) 1606 { 1607 m_fHotPluggable = fHotPluggable; 1608 } 1609 1610 QString AttachmentItem::size() const 1611 { 1612 return m_strSize; 1613 } 1614 1615 QString AttachmentItem::logicalSize() const 1616 { 1617 return m_strLogicalSize; 1618 } 1619 1620 QString AttachmentItem::location() const 1621 { 1622 return m_strLocation; 1623 } 1624 1625 QString AttachmentItem::format() const 1626 { 1627 return m_strFormat; 1628 } 1629 1630 QString AttachmentItem::details() const 1631 { 1632 return m_strDetails; 1633 } 1634 1635 QString AttachmentItem::usage() const 1636 { 1637 return m_strUsage; 1638 } 1639 1640 QString AttachmentItem::encryptionPasswordId() const 1641 1641 { 1642 1642 return m_strAttEncryptionPasswordID; … … 1645 1645 void AttachmentItem::cache() 1646 1646 { 1647 UIMedium medium = uiCommon().medium(mAttMediumId);1647 UIMedium guiMedium = uiCommon().medium(m_uMediumId); 1648 1648 1649 1649 /* Cache medium information */ 1650 m AttName = medium.name (true);1651 m AttTip = medium.toolTipCheckRO (true, mAttDeviceType != KDeviceType_HardDisk);1652 m AttPixmap = medium.iconCheckRO (true);1653 m AttIsHostDrive = medium.isHostDrive();1650 m_strName = guiMedium.name (true); 1651 m_strTip = guiMedium.toolTipCheckRO (true, m_enmDeviceType != KDeviceType_HardDisk); 1652 m_strPixmap = guiMedium.iconCheckRO (true); 1653 m_fHostDrive = guiMedium.isHostDrive(); 1654 1654 1655 1655 /* Cache additional information */ 1656 m AttSize = medium.size (true);1657 m AttLogicalSize = medium.logicalSize (true);1658 m AttLocation = medium.location (true);1656 m_strSize = guiMedium.size (true); 1657 m_strLogicalSize = guiMedium.logicalSize (true); 1658 m_strLocation = guiMedium.location (true); 1659 1659 m_strAttEncryptionPasswordID = QString("--"); 1660 if ( medium.isNull())1661 { 1662 m AttFormat = QString("--");1660 if (guiMedium.isNull()) 1661 { 1662 m_strFormat = QString("--"); 1663 1663 } 1664 1664 else 1665 1665 { 1666 switch (m AttDeviceType)1666 switch (m_enmDeviceType) 1667 1667 { 1668 1668 case KDeviceType_HardDisk: 1669 1669 { 1670 m AttFormat = QString("%1 (%2)").arg(medium.hardDiskType(true)).arg(medium.hardDiskFormat(true));1671 m AttDetails = medium.storageDetails();1672 const QString strAttEncryptionPasswordID = medium.encryptionPasswordID();1670 m_strFormat = QString("%1 (%2)").arg(guiMedium.hardDiskType(true)).arg(guiMedium.hardDiskFormat(true)); 1671 m_strDetails = guiMedium.storageDetails(); 1672 const QString strAttEncryptionPasswordID = guiMedium.encryptionPasswordID(); 1673 1673 if (!strAttEncryptionPasswordID.isNull()) 1674 1674 m_strAttEncryptionPasswordID = strAttEncryptionPasswordID; … … 1678 1678 case KDeviceType_Floppy: 1679 1679 { 1680 m AttFormat = mAttIsHostDrive ? UIMachineSettingsStorage::tr("Host Drive") : UIMachineSettingsStorage::tr("Image", "storage image");1680 m_strFormat = m_fHostDrive ? UIMachineSettingsStorage::tr("Host Drive") : UIMachineSettingsStorage::tr("Image", "storage image"); 1681 1681 break; 1682 1682 } … … 1685 1685 } 1686 1686 } 1687 m AttUsage = medium.usage (true);1687 m_strUsage = guiMedium.usage (true); 1688 1688 1689 1689 /* Fill empty attributes */ 1690 if (m AttUsage.isEmpty())1691 m AttUsage = QString ("--");1690 if (m_strUsage.isEmpty()) 1691 m_strUsage = QString ("--"); 1692 1692 } 1693 1693 … … 1697 1697 } 1698 1698 1699 AbstractItem* AttachmentItem::childItem (int /* aIndex */) const1699 AbstractItem* AttachmentItem::childItem (int /* iIndex */) const 1700 1700 { 1701 1701 return 0; … … 1707 1707 } 1708 1708 1709 int AttachmentItem::posOfChild (AbstractItem* /* aItem */) const1709 int AttachmentItem::posOfChild (AbstractItem* /* pItem */) const 1710 1710 { 1711 1711 return 0; … … 1719 1719 QString AttachmentItem::text() const 1720 1720 { 1721 return m AttName;1722 } 1723 1724 QString AttachmentItem::t ip() const1725 { 1726 return m AttTip;1727 } 1728 1729 QPixmap AttachmentItem::pixmap (ItemState /* aState */)1730 { 1731 if (m AttPixmap.isNull())1732 { 1733 switch (m AttDeviceType)1721 return m_strName; 1722 } 1723 1724 QString AttachmentItem::toolTip() const 1725 { 1726 return m_strTip; 1727 } 1728 1729 QPixmap AttachmentItem::pixmap (ItemState /* enmState */) 1730 { 1731 if (m_strPixmap.isNull()) 1732 { 1733 switch (m_enmDeviceType) 1734 1734 { 1735 1735 case KDeviceType_HardDisk: 1736 m AttPixmap = iconPool()->pixmap(HDAttachmentNormal);1736 m_strPixmap = iconPool()->pixmap(HDAttachmentNormal); 1737 1737 break; 1738 1738 case KDeviceType_DVD: 1739 m AttPixmap = iconPool()->pixmap(CDAttachmentNormal);1739 m_strPixmap = iconPool()->pixmap(CDAttachmentNormal); 1740 1740 break; 1741 1741 case KDeviceType_Floppy: 1742 m AttPixmap = iconPool()->pixmap(FDAttachmentNormal);1742 m_strPixmap = iconPool()->pixmap(FDAttachmentNormal); 1743 1743 break; 1744 1744 default: … … 1746 1746 } 1747 1747 } 1748 return m AttPixmap;1749 } 1750 1751 void AttachmentItem::addChild (AbstractItem* /* aItem */)1752 { 1753 } 1754 1755 void AttachmentItem::delChild (AbstractItem* /* aItem */)1748 return m_strPixmap; 1749 } 1750 1751 void AttachmentItem::addChild (AbstractItem* /* pItem */) 1752 { 1753 } 1754 1755 void AttachmentItem::delChild (AbstractItem* /* pItem */) 1756 1756 { 1757 1757 } … … 1762 1762 *********************************************************************************************************************************/ 1763 1763 1764 StorageModel::StorageModel(QITreeView *pParent )1765 : QAbstractItemModel(pParent )1766 , m RootItem(new RootItem(pParent))1767 , m ToolTipType(DefaultToolTip)1768 , m_ chipsetType(KChipsetType_PIIX3)1769 , m_ configurationAccessLevel(ConfigurationAccessLevel_Null)1764 StorageModel::StorageModel(QITreeView *pParentTree) 1765 : QAbstractItemModel(pParentTree) 1766 , m_pRootItem(new RootItem(pParentTree)) 1767 , m_enmToolTipType(DefaultToolTip) 1768 , m_enmChipsetType(KChipsetType_PIIX3) 1769 , m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null) 1770 1770 { 1771 1771 } … … 1773 1773 StorageModel::~StorageModel() 1774 1774 { 1775 delete m RootItem;1776 } 1777 1778 int StorageModel::rowCount (const QModelIndex & aParent) const1779 { 1780 return ! aParent.isValid() ? 1 /* only root item has invalid parent */ :1781 static_cast <AbstractItem*> ( aParent.internalPointer())->childCount();1782 } 1783 1784 int StorageModel::columnCount (const QModelIndex & /* aParent*/) const1775 delete m_pRootItem; 1776 } 1777 1778 int StorageModel::rowCount (const QModelIndex &parentIndex) const 1779 { 1780 return !parentIndex.isValid() ? 1 /* only root item has invalid parent */ : 1781 static_cast <AbstractItem*> (parentIndex.internalPointer())->childCount(); 1782 } 1783 1784 int StorageModel::columnCount (const QModelIndex & /* parentIndex */) const 1785 1785 { 1786 1786 return 1; … … 1792 1792 } 1793 1793 1794 QModelIndex StorageModel::index (int aRow, int aColumn, const QModelIndex &aParent) const1795 { 1796 if (!hasIndex ( aRow, aColumn, aParent))1794 QModelIndex StorageModel::index (int iRow, int iColumn, const QModelIndex &parentIndex) const 1795 { 1796 if (!hasIndex (iRow, iColumn, parentIndex)) 1797 1797 return QModelIndex(); 1798 1798 1799 AbstractItem * item = !aParent.isValid() ? mRootItem :1800 static_cast <AbstractItem*> ( aParent.internalPointer())->childItem (aRow);1801 1802 return item ? createIndex (aRow, aColumn, item) : QModelIndex();1803 } 1804 1805 QModelIndex StorageModel::parent (const QModelIndex & aIndex) const1806 { 1807 if (! aIndex.isValid())1799 AbstractItem *pItem = !parentIndex.isValid() ? m_pRootItem : 1800 static_cast <AbstractItem*> (parentIndex.internalPointer())->childItem (iRow); 1801 1802 return pItem ? createIndex (iRow, iColumn, pItem) : QModelIndex(); 1803 } 1804 1805 QModelIndex StorageModel::parent (const QModelIndex &index) const 1806 { 1807 if (!index.isValid()) 1808 1808 return QModelIndex(); 1809 1809 1810 AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer());1811 AbstractItem *p arentOfItem = item->parent();1812 AbstractItem *p arentOfParent = parentOfItem ? parentOfItem->parent() : 0;1813 int position = parentOfParent ? parentOfParent->posOfChild (parentOfItem) : 0;1814 1815 if (p arentOfItem)1816 return createIndex ( position, 0, parentOfItem);1810 AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer()); 1811 AbstractItem *pParentOfItem = pItem->parent(); 1812 AbstractItem *pParentOfParent = pParentOfItem ? pParentOfItem->parent() : 0; 1813 int iPosition = pParentOfParent ? pParentOfParent->posOfChild (pParentOfItem) : 0; 1814 1815 if (pParentOfItem) 1816 return createIndex (iPosition, 0, pParentOfItem); 1817 1817 else 1818 1818 return QModelIndex(); 1819 1819 } 1820 1820 1821 QVariant StorageModel::data (const QModelIndex & aIndex, int aRole) const1822 { 1823 if (! aIndex.isValid())1821 QVariant StorageModel::data (const QModelIndex &index, int iRole) const 1822 { 1823 if (!index.isValid()) 1824 1824 return QVariant(); 1825 1825 1826 switch ( aRole)1826 switch (iRole) 1827 1827 { 1828 1828 /* Basic Attributes: */ … … 1833 1833 case Qt::SizeHintRole: 1834 1834 { 1835 QFontMetrics fm (data ( aIndex, Qt::FontRole).value <QFont>());1836 int minimumHeight = qMax (fm.height(), data (aIndex, R_IconSize).toInt());1837 int margin = data (aIndex, R_Margin).toInt();1838 return QSize (1 /* ignoring width */, 2 * margin + minimumHeight);1835 QFontMetrics fm (data (index, Qt::FontRole).value <QFont>()); 1836 int iMinimumHeight = qMax (fm.height(), data (index, R_IconSize).toInt()); 1837 int iMargin = data (index, R_Margin).toInt(); 1838 return QSize (1 /* ignoring width */, 2 * iMargin + iMinimumHeight); 1839 1839 } 1840 1840 case Qt::ToolTipRole: 1841 1841 { 1842 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1842 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1843 1843 { 1844 if ( item->rtti() == AbstractItem::Type_ControllerItem)1844 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 1845 1845 { 1846 QString tip (item->tip());1847 switch (m ToolTipType)1846 QString strTip (pItem->toolTip()); 1847 switch (m_enmToolTipType) 1848 1848 { 1849 1849 case ExpanderToolTip: 1850 if ( aIndex.child (0, 0).isValid())1851 tip = UIMachineSettingsStorage::tr("<nobr>Expands/Collapses item.</nobr>");1850 if (index.child (0, 0).isValid()) 1851 strTip = UIMachineSettingsStorage::tr("<nobr>Expands/Collapses item.</nobr>"); 1852 1852 break; 1853 1853 case HDAdderToolTip: 1854 tip = UIMachineSettingsStorage::tr("<nobr>Adds hard disk.</nobr>");1854 strTip = UIMachineSettingsStorage::tr("<nobr>Adds hard disk.</nobr>"); 1855 1855 break; 1856 1856 case CDAdderToolTip: 1857 tip = UIMachineSettingsStorage::tr("<nobr>Adds optical drive.</nobr>");1857 strTip = UIMachineSettingsStorage::tr("<nobr>Adds optical drive.</nobr>"); 1858 1858 break; 1859 1859 case FDAdderToolTip: 1860 tip = UIMachineSettingsStorage::tr("<nobr>Adds floppy drive.</nobr>");1860 strTip = UIMachineSettingsStorage::tr("<nobr>Adds floppy drive.</nobr>"); 1861 1861 break; 1862 1862 default: 1863 1863 break; 1864 1864 } 1865 return tip;1865 return strTip; 1866 1866 } 1867 return item->tip();1867 return pItem->toolTip(); 1868 1868 } 1869 1869 return QString(); … … 1873 1873 case R_ItemId: 1874 1874 { 1875 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1876 return item->id();1875 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1876 return pItem->id(); 1877 1877 return QUuid(); 1878 1878 } 1879 1879 case R_ItemPixmap: 1880 1880 { 1881 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1881 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1882 1882 { 1883 ItemState state = State_DefaultItem;1884 if (hasChildren ( aIndex))1883 ItemState enmState = State_DefaultItem; 1884 if (hasChildren (index)) 1885 1885 if (QTreeView *view = qobject_cast<QTreeView*>(QObject::parent())) 1886 state = view->isExpanded (aIndex) ? State_ExpandedItem : State_CollapsedItem;1887 return item->pixmap (state);1886 enmState = view->isExpanded (index) ? State_ExpandedItem : State_CollapsedItem; 1887 return pItem->pixmap (enmState); 1888 1888 } 1889 1889 return QPixmap(); … … 1891 1891 case R_ItemPixmapRect: 1892 1892 { 1893 int margin = data (aIndex, R_Margin).toInt();1894 int width = data (aIndex, R_IconSize).toInt();1895 return QRect ( margin, margin, width, width);1893 int iMargin = data (index, R_Margin).toInt(); 1894 int iWidth = data (index, R_IconSize).toInt(); 1895 return QRect (iMargin, iMargin, iWidth, iWidth); 1896 1896 } 1897 1897 case R_ItemName: 1898 1898 { 1899 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1900 return item->text();1899 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1900 return pItem->text(); 1901 1901 return QString(); 1902 1902 } 1903 1903 case R_ItemNamePoint: 1904 1904 { 1905 int margin = data (aIndex, R_Margin).toInt();1906 int spacing = data (aIndex, R_Spacing).toInt();1907 int width = data (aIndex, R_IconSize).toInt();1908 QFontMetrics fm (data ( aIndex, Qt::FontRole).value <QFont>());1909 QSize sizeHint = data ( aIndex, Qt::SizeHintRole).toSize();1910 return QPoint ( margin + width + 2 * spacing,1905 int iMargin = data (index, R_Margin).toInt(); 1906 int iSpacing = data (index, R_Spacing).toInt(); 1907 int iWidth = data (index, R_IconSize).toInt(); 1908 QFontMetrics fm (data (index, Qt::FontRole).value <QFont>()); 1909 QSize sizeHint = data (index, Qt::SizeHintRole).toSize(); 1910 return QPoint (iMargin + iWidth + 2 * iSpacing, 1911 1911 sizeHint.height() / 2 + fm.ascent() / 2 - 1 /* base line */); 1912 1912 } … … 1914 1914 { 1915 1915 QVariant result (QVariant::fromValue (AbstractItem::Type_InvalidItem)); 1916 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1917 result.setValue ( item->rtti());1916 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1917 result.setValue (pItem->rtti()); 1918 1918 return result; 1919 1919 } 1920 1920 case R_IsController: 1921 1921 { 1922 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1923 return item->rtti() == AbstractItem::Type_ControllerItem;1922 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1923 return pItem->rtti() == AbstractItem::Type_ControllerItem; 1924 1924 return false; 1925 1925 } 1926 1926 case R_IsAttachment: 1927 1927 { 1928 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1929 return item->rtti() == AbstractItem::Type_AttachmentItem;1928 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1929 return pItem->rtti() == AbstractItem::Type_AttachmentItem; 1930 1930 return false; 1931 1931 } … … 1933 1933 case R_ToolTipType: 1934 1934 { 1935 return QVariant::fromValue (m ToolTipType);1935 return QVariant::fromValue (m_enmToolTipType); 1936 1936 } 1937 1937 case R_IsMoreIDEControllersPossible: 1938 1938 { 1939 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1940 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_IDE) <1939 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1940 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_IDE) < 1941 1941 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_IDE)); 1942 1942 } 1943 1943 case R_IsMoreSATAControllersPossible: 1944 1944 { 1945 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1946 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_SATA) <1945 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1946 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_SATA) < 1947 1947 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SATA)); 1948 1948 } 1949 1949 case R_IsMoreSCSIControllersPossible: 1950 1950 { 1951 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1952 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_SCSI) <1951 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1952 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_SCSI) < 1953 1953 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SCSI)); 1954 1954 } 1955 1955 case R_IsMoreFloppyControllersPossible: 1956 1956 { 1957 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1958 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_Floppy) <1957 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1958 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_Floppy) < 1959 1959 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_Floppy)); 1960 1960 } 1961 1961 case R_IsMoreSASControllersPossible: 1962 1962 { 1963 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1964 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_SAS) <1963 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1964 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_SAS) < 1965 1965 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SAS)); 1966 1966 } 1967 1967 case R_IsMoreUSBControllersPossible: 1968 1968 { 1969 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1970 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_USB) <1969 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1970 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_USB) < 1971 1971 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_USB)); 1972 1972 } 1973 1973 case R_IsMoreNVMeControllersPossible: 1974 1974 { 1975 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1976 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_PCIe) <1975 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1976 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_PCIe) < 1977 1977 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_PCIe)); 1978 1978 } 1979 1979 case R_IsMoreVirtioSCSIControllersPossible: 1980 1980 { 1981 return (m_ configurationAccessLevel == ConfigurationAccessLevel_Full) &&1982 (qobject_cast<RootItem*>(m RootItem)->childCount(KStorageBus_VirtioSCSI) <1981 return (m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full) && 1982 (qobject_cast<RootItem*>(m_pRootItem)->childCount(KStorageBus_VirtioSCSI) < 1983 1983 uiCommon().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_VirtioSCSI)); 1984 1984 } 1985 1985 case R_IsMoreAttachmentsPossible: 1986 1986 { 1987 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))1987 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 1988 1988 { 1989 if ( item->rtti() == AbstractItem::Type_ControllerItem)1989 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 1990 1990 { 1991 ControllerItem * ctr = qobject_cast<ControllerItem*>(item);1992 CSystemProperties sp= uiCommon().virtualBox().GetSystemProperties();1993 const bool fIsMoreAttachmentsPossible = (ULONG)rowCount( aIndex) <1994 ( sp.GetMaxPortCountForStorageBus(ctr->ctrBusType()) *1995 sp.GetMaxDevicesPerPortForStorageBus(ctr->ctrBusType()));1991 ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem); 1992 CSystemProperties comProps = uiCommon().virtualBox().GetSystemProperties(); 1993 const bool fIsMoreAttachmentsPossible = (ULONG)rowCount(index) < 1994 (comProps.GetMaxPortCountForStorageBus(pItemController->bus()) * 1995 comProps.GetMaxDevicesPerPortForStorageBus(pItemController->bus())); 1996 1996 if (fIsMoreAttachmentsPossible) 1997 1997 { 1998 switch (m_ configurationAccessLevel)1998 switch (m_enmConfigurationAccessLevel) 1999 1999 { 2000 2000 case ConfigurationAccessLevel_Full: … … 2002 2002 case ConfigurationAccessLevel_Partial_Running: 2003 2003 { 2004 switch ( ctr->ctrBusType())2004 switch (pItemController->bus()) 2005 2005 { 2006 2006 case KStorageBus_USB: 2007 2007 return true; 2008 2008 case KStorageBus_SATA: 2009 return (uint)rowCount( aIndex) < ctr->portCount();2009 return (uint)rowCount(index) < pItemController->portCount(); 2010 2010 default: 2011 2011 break; … … 2023 2023 case R_CtrOldName: 2024 2024 { 2025 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2026 if ( item->rtti() == AbstractItem::Type_ControllerItem)2027 return qobject_cast<ControllerItem*>( item)->oldCtrName();2025 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2026 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2027 return qobject_cast<ControllerItem*>(pItem)->oldName(); 2028 2028 return QString(); 2029 2029 } 2030 2030 case R_CtrName: 2031 2031 { 2032 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2033 if ( item->rtti() == AbstractItem::Type_ControllerItem)2034 return qobject_cast<ControllerItem*>( item)->ctrName();2032 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2033 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2034 return qobject_cast<ControllerItem*>(pItem)->name(); 2035 2035 return QString(); 2036 2036 } … … 2038 2038 { 2039 2039 QVariant result (QVariant::fromValue (KStorageControllerType_Null)); 2040 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2041 if ( item->rtti() == AbstractItem::Type_ControllerItem)2042 result.setValue (qobject_cast<ControllerItem*>( item)->ctrType());2040 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2041 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2042 result.setValue (qobject_cast<ControllerItem*>(pItem)->type()); 2043 2043 return result; 2044 2044 } … … 2046 2046 { 2047 2047 QVariant result (QVariant::fromValue (ControllerTypeList())); 2048 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2049 if ( item->rtti() == AbstractItem::Type_ControllerItem)2050 result.setValue (qobject_cast<ControllerItem*>( item)->ctrTypes());2048 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2049 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2050 result.setValue (qobject_cast<ControllerItem*>(pItem)->types()); 2051 2051 return result; 2052 2052 } … … 2054 2054 { 2055 2055 QVariant result (QVariant::fromValue (DeviceTypeList())); 2056 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2057 if ( item->rtti() == AbstractItem::Type_ControllerItem)2058 result.setValue (qobject_cast<ControllerItem*>( item)->ctrDeviceTypeList());2056 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2057 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2058 result.setValue (qobject_cast<ControllerItem*>(pItem)->deviceTypeList()); 2059 2059 return result; 2060 2060 } … … 2062 2062 { 2063 2063 QVariant result (QVariant::fromValue (KStorageBus_Null)); 2064 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2065 if ( item->rtti() == AbstractItem::Type_ControllerItem)2066 result.setValue (qobject_cast<ControllerItem*>( item)->ctrBusType());2064 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2065 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2066 result.setValue (qobject_cast<ControllerItem*>(pItem)->bus()); 2067 2067 return result; 2068 2068 } … … 2070 2070 { 2071 2071 QVariant result(QVariant::fromValue(ControllerBusList())); 2072 if (AbstractItem *pItem = static_cast<AbstractItem*>( aIndex.internalPointer()))2072 if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer())) 2073 2073 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2074 result.setValue(qobject_cast<ControllerItem*>(pItem)-> ctrBusTypes());2074 result.setValue(qobject_cast<ControllerItem*>(pItem)->buses()); 2075 2075 return result; 2076 2076 } 2077 2077 case R_CtrPortCount: 2078 2078 { 2079 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2080 if ( item->rtti() == AbstractItem::Type_ControllerItem)2081 return qobject_cast<ControllerItem*>( item)->portCount();2079 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2080 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2081 return qobject_cast<ControllerItem*>(pItem)->portCount(); 2082 2082 return 0; 2083 2083 } 2084 2084 case R_CtrMaxPortCount: 2085 2085 { 2086 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2087 if ( item->rtti() == AbstractItem::Type_ControllerItem)2088 return qobject_cast<ControllerItem*>( item)->maxPortCount();2086 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2087 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2088 return qobject_cast<ControllerItem*>(pItem)->maxPortCount(); 2089 2089 return 0; 2090 2090 } 2091 2091 case R_CtrIoCache: 2092 2092 { 2093 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2094 if ( item->rtti() == AbstractItem::Type_ControllerItem)2095 return qobject_cast<ControllerItem*>( item)->ctrUseIoCache();2093 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2094 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2095 return qobject_cast<ControllerItem*>(pItem)->useIoCache(); 2096 2096 return false; 2097 2097 } … … 2100 2100 { 2101 2101 QVariant result (QVariant::fromValue (StorageSlot())); 2102 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2103 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2104 result.setValue(qobject_cast<AttachmentItem*>( item)->attSlot());2102 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2103 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2104 result.setValue(qobject_cast<AttachmentItem*>(pItem)->storageSlot()); 2105 2105 return result; 2106 2106 } … … 2108 2108 { 2109 2109 QVariant result (QVariant::fromValue (SlotsList())); 2110 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2111 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2112 result.setValue(qobject_cast<AttachmentItem*>( item)->attSlots());2110 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2111 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2112 result.setValue(qobject_cast<AttachmentItem*>(pItem)->storageSlots()); 2113 2113 return result; 2114 2114 } … … 2116 2116 { 2117 2117 QVariant result (QVariant::fromValue (KDeviceType_Null)); 2118 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2119 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2120 result.setValue(qobject_cast<AttachmentItem*>( item)->attDeviceType());2118 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2119 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2120 result.setValue(qobject_cast<AttachmentItem*>(pItem)->deviceType()); 2121 2121 return result; 2122 2122 } 2123 2123 case R_AttMediumId: 2124 2124 { 2125 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2126 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2127 return qobject_cast<AttachmentItem*>( item)->attMediumId();2125 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2126 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2127 return qobject_cast<AttachmentItem*>(pItem)->mediumId(); 2128 2128 return QUuid(); 2129 2129 } 2130 2130 case R_AttIsHostDrive: 2131 2131 { 2132 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2133 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2134 return qobject_cast<AttachmentItem*>( item)->attIsHostDrive();2132 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2133 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2134 return qobject_cast<AttachmentItem*>(pItem)->isHostDrive(); 2135 2135 return false; 2136 2136 } 2137 2137 case R_AttIsPassthrough: 2138 2138 { 2139 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2140 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2141 return qobject_cast<AttachmentItem*>( item)->attIsPassthrough();2139 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2140 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2141 return qobject_cast<AttachmentItem*>(pItem)->isPassthrough(); 2142 2142 return false; 2143 2143 } 2144 2144 case R_AttIsTempEject: 2145 2145 { 2146 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2147 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2148 return qobject_cast<AttachmentItem*>( item)->attIsTempEject();2146 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2147 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2148 return qobject_cast<AttachmentItem*>(pItem)->isTempEject(); 2149 2149 return false; 2150 2150 } 2151 2151 case R_AttIsNonRotational: 2152 2152 { 2153 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2154 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2155 return qobject_cast<AttachmentItem*>( item)->attIsNonRotational();2153 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2154 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2155 return qobject_cast<AttachmentItem*>(pItem)->isNonRotational(); 2156 2156 return false; 2157 2157 } 2158 2158 case R_AttIsHotPluggable: 2159 2159 { 2160 if (AbstractItem * item = static_cast<AbstractItem*>(aIndex.internalPointer()))2161 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2162 return qobject_cast<AttachmentItem*>( item)->attIsHotPluggable();2160 if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer())) 2161 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2162 return qobject_cast<AttachmentItem*>(pItem)->isHotPluggable(); 2163 2163 return false; 2164 2164 } 2165 2165 case R_AttSize: 2166 2166 { 2167 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2168 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2169 return qobject_cast<AttachmentItem*>( item)->attSize();2167 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2168 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2169 return qobject_cast<AttachmentItem*>(pItem)->size(); 2170 2170 return QString(); 2171 2171 } 2172 2172 case R_AttLogicalSize: 2173 2173 { 2174 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2175 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2176 return qobject_cast<AttachmentItem*>( item)->attLogicalSize();2174 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2175 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2176 return qobject_cast<AttachmentItem*>(pItem)->logicalSize(); 2177 2177 return QString(); 2178 2178 } 2179 2179 case R_AttLocation: 2180 2180 { 2181 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2182 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2183 return qobject_cast<AttachmentItem*>( item)->attLocation();2181 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2182 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2183 return qobject_cast<AttachmentItem*>(pItem)->location(); 2184 2184 return QString(); 2185 2185 } 2186 2186 case R_AttFormat: 2187 2187 { 2188 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2189 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2190 return qobject_cast<AttachmentItem*>( item)->attFormat();2188 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2189 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2190 return qobject_cast<AttachmentItem*>(pItem)->format(); 2191 2191 return QString(); 2192 2192 } 2193 2193 case R_AttDetails: 2194 2194 { 2195 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2196 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2197 return qobject_cast<AttachmentItem*>( item)->attDetails();2195 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2196 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2197 return qobject_cast<AttachmentItem*>(pItem)->details(); 2198 2198 return QString(); 2199 2199 } 2200 2200 case R_AttUsage: 2201 2201 { 2202 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2203 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2204 return qobject_cast<AttachmentItem*>( item)->attUsage();2202 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2203 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2204 return qobject_cast<AttachmentItem*>(pItem)->usage(); 2205 2205 return QString(); 2206 2206 } 2207 2207 case R_AttEncryptionPasswordID: 2208 2208 { 2209 if (AbstractItem *pItem = static_cast<AbstractItem*>( aIndex.internalPointer()))2209 if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer())) 2210 2210 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2211 return qobject_cast<AttachmentItem*>(pItem)-> attEncryptionPasswordID();2211 return qobject_cast<AttachmentItem*>(pItem)->encryptionPasswordId(); 2212 2212 return QString(); 2213 2213 } … … 2264 2264 case R_HDPixmapRect: 2265 2265 { 2266 int margin = data (aIndex, R_Margin).toInt();2267 int width = data (aIndex, R_IconSize).toInt();2268 return QRect (0 - width - margin, margin, width, width);2266 int iMargin = data (index, R_Margin).toInt(); 2267 int iWidth = data (index, R_IconSize).toInt(); 2268 return QRect (0 - iWidth - iMargin, iMargin, iWidth, iWidth); 2269 2269 } 2270 2270 case R_CDPixmapRect: 2271 2271 { 2272 int margin = data (aIndex, R_Margin).toInt();2273 int spacing = data (aIndex, R_Spacing).toInt();2274 int width = data (aIndex, R_IconSize).toInt();2275 return QRect (0 - width - spacing - width - margin, margin, width, width);2272 int iMargin = data (index, R_Margin).toInt(); 2273 int iSpacing = data (index, R_Spacing).toInt(); 2274 int iWidth = data (index, R_IconSize).toInt(); 2275 return QRect (0 - iWidth - iSpacing - iWidth - iMargin, iMargin, iWidth, iWidth); 2276 2276 } 2277 2277 case R_FDPixmapRect: 2278 2278 { 2279 int margin = data (aIndex, R_Margin).toInt();2280 int width = data (aIndex, R_IconSize).toInt();2281 return QRect (0 - width - margin, margin, width, width);2279 int iMargin = data (index, R_Margin).toInt(); 2280 int iWidth = data (index, R_IconSize).toInt(); 2281 return QRect (0 - iWidth - iMargin, iMargin, iWidth, iWidth); 2282 2282 } 2283 2283 … … 2288 2288 } 2289 2289 2290 bool StorageModel::setData (const QModelIndex & aIndex, const QVariant &aValue, int aRole)2291 { 2292 if (! aIndex.isValid())2293 return QAbstractItemModel::setData ( aIndex, aValue, aRole);2294 2295 switch ( aRole)2290 bool StorageModel::setData (const QModelIndex &index, const QVariant &aValue, int iRole) 2291 { 2292 if (!index.isValid()) 2293 return QAbstractItemModel::setData (index, aValue, iRole); 2294 2295 switch (iRole) 2296 2296 { 2297 2297 case R_ToolTipType: 2298 2298 { 2299 m ToolTipType = aValue.value <ToolTipType>();2300 emit dataChanged ( aIndex, aIndex);2299 m_enmToolTipType = aValue.value <ToolTipType>(); 2300 emit dataChanged (index, index); 2301 2301 return true; 2302 2302 } 2303 2303 case R_CtrName: 2304 2304 { 2305 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2306 if ( item->rtti() == AbstractItem::Type_ControllerItem)2305 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2306 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2307 2307 { 2308 qobject_cast<ControllerItem*>( item)->setCtrName(aValue.toString());2309 emit dataChanged ( aIndex, aIndex);2308 qobject_cast<ControllerItem*>(pItem)->setName(aValue.toString()); 2309 emit dataChanged (index, index); 2310 2310 return true; 2311 2311 } … … 2314 2314 case R_CtrBusType: 2315 2315 { 2316 if (AbstractItem *pItem = static_cast<AbstractItem*>( aIndex.internalPointer()))2316 if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer())) 2317 2317 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2318 2318 { … … 2350 2350 2351 2351 /* Push new bus/controller type: */ 2352 pItemController->set CtrBusType(enmNewCtrBusType);2353 pItemController->set CtrType(pItemController->ctrTypes().first());2354 emit dataChanged( aIndex, aIndex);2352 pItemController->setBus(enmNewCtrBusType); 2353 pItemController->setType(pItemController->types().first()); 2354 emit dataChanged(index, index); 2355 2355 2356 2356 /* Make sure each of remaining attachments has valid slot: */ … … 2358 2358 { 2359 2359 AttachmentItem *pChildItemAttachment = qobject_cast<AttachmentItem*>(pChildItem); 2360 const SlotsList availableSlots = pChildItemAttachment-> attSlots();2361 const StorageSlot currentSlot = pChildItemAttachment-> attSlot();2360 const SlotsList availableSlots = pChildItemAttachment->storageSlots(); 2361 const StorageSlot currentSlot = pChildItemAttachment->storageSlot(); 2362 2362 if (!availableSlots.isEmpty() && !availableSlots.contains(currentSlot)) 2363 pChildItemAttachment->set AttSlot(availableSlots.first());2363 pChildItemAttachment->setStorageSlot(availableSlots.first()); 2364 2364 } 2365 2365 … … 2371 2371 case R_CtrType: 2372 2372 { 2373 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2374 if ( item->rtti() == AbstractItem::Type_ControllerItem)2373 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2374 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2375 2375 { 2376 qobject_cast<ControllerItem*>( item)->setCtrType(aValue.value<KStorageControllerType>());2377 emit dataChanged ( aIndex, aIndex);2376 qobject_cast<ControllerItem*>(pItem)->setType(aValue.value<KStorageControllerType>()); 2377 emit dataChanged (index, index); 2378 2378 return true; 2379 2379 } … … 2382 2382 case R_CtrPortCount: 2383 2383 { 2384 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2385 if ( item->rtti() == AbstractItem::Type_ControllerItem)2384 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2385 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2386 2386 { 2387 qobject_cast<ControllerItem*>( item)->setPortCount(aValue.toUInt());2388 emit dataChanged ( aIndex, aIndex);2387 qobject_cast<ControllerItem*>(pItem)->setPortCount(aValue.toUInt()); 2388 emit dataChanged (index, index); 2389 2389 return true; 2390 2390 } … … 2393 2393 case R_CtrIoCache: 2394 2394 { 2395 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2396 if ( item->rtti() == AbstractItem::Type_ControllerItem)2395 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2396 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2397 2397 { 2398 qobject_cast<ControllerItem*>( item)->setCtrUseIoCache(aValue.toBool());2399 emit dataChanged ( aIndex, aIndex);2398 qobject_cast<ControllerItem*>(pItem)->setUseIoCache(aValue.toBool()); 2399 emit dataChanged (index, index); 2400 2400 return true; 2401 2401 } … … 2404 2404 case R_AttSlot: 2405 2405 { 2406 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2407 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2406 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2407 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2408 2408 { 2409 qobject_cast<AttachmentItem*>( item)->setAttSlot(aValue.value<StorageSlot>());2410 emit dataChanged ( aIndex, aIndex);2409 qobject_cast<AttachmentItem*>(pItem)->setStorageSlot(aValue.value<StorageSlot>()); 2410 emit dataChanged (index, index); 2411 2411 sort(); 2412 2412 return true; … … 2416 2416 case R_AttDevice: 2417 2417 { 2418 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2419 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2418 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2419 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2420 2420 { 2421 qobject_cast<AttachmentItem*>( item)->setAttDevice(aValue.value<KDeviceType>());2422 emit dataChanged ( aIndex, aIndex);2421 qobject_cast<AttachmentItem*>(pItem)->setDeviceType(aValue.value<KDeviceType>()); 2422 emit dataChanged (index, index); 2423 2423 return true; 2424 2424 } … … 2427 2427 case R_AttMediumId: 2428 2428 { 2429 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2430 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2429 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2430 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2431 2431 { 2432 qobject_cast<AttachmentItem*>( item)->setAttMediumId(aValue.toUuid());2433 emit dataChanged ( aIndex, aIndex);2432 qobject_cast<AttachmentItem*>(pItem)->setMediumId(aValue.toUuid()); 2433 emit dataChanged (index, index); 2434 2434 return true; 2435 2435 } … … 2438 2438 case R_AttIsPassthrough: 2439 2439 { 2440 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2441 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2440 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2441 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2442 2442 { 2443 qobject_cast<AttachmentItem*>( item)->setAttIsPassthrough(aValue.toBool());2444 emit dataChanged ( aIndex, aIndex);2443 qobject_cast<AttachmentItem*>(pItem)->setPassthrough(aValue.toBool()); 2444 emit dataChanged (index, index); 2445 2445 return true; 2446 2446 } … … 2449 2449 case R_AttIsTempEject: 2450 2450 { 2451 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2452 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2451 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2452 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2453 2453 { 2454 qobject_cast<AttachmentItem*>( item)->setAttIsTempEject(aValue.toBool());2455 emit dataChanged ( aIndex, aIndex);2454 qobject_cast<AttachmentItem*>(pItem)->setTempEject(aValue.toBool()); 2455 emit dataChanged (index, index); 2456 2456 return true; 2457 2457 } … … 2460 2460 case R_AttIsNonRotational: 2461 2461 { 2462 if (AbstractItem * item = static_cast <AbstractItem*> (aIndex.internalPointer()))2463 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2462 if (AbstractItem *pItem = static_cast <AbstractItem*> (index.internalPointer())) 2463 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2464 2464 { 2465 qobject_cast<AttachmentItem*>( item)->setAttIsNonRotational(aValue.toBool());2466 emit dataChanged ( aIndex, aIndex);2465 qobject_cast<AttachmentItem*>(pItem)->setNonRotational(aValue.toBool()); 2466 emit dataChanged (index, index); 2467 2467 return true; 2468 2468 } … … 2471 2471 case R_AttIsHotPluggable: 2472 2472 { 2473 if (AbstractItem * item = static_cast<AbstractItem*>(aIndex.internalPointer()))2474 if ( item->rtti() == AbstractItem::Type_AttachmentItem)2473 if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer())) 2474 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2475 2475 { 2476 qobject_cast<AttachmentItem*>( item)->setAttIsHotPluggable(aValue.toBool());2477 emit dataChanged( aIndex, aIndex);2476 qobject_cast<AttachmentItem*>(pItem)->setHotPluggable(aValue.toBool()); 2477 emit dataChanged(index, index); 2478 2478 return true; 2479 2479 } … … 2487 2487 } 2488 2488 2489 QModelIndex StorageModel::addController (const QString &aCtrName, KStorageBus aBusType, KStorageControllerType aCtrType)2490 { 2491 beginInsertRows (root(), m RootItem->childCount(), mRootItem->childCount());2492 new ControllerItem (m RootItem, aCtrName, aBusType, aCtrType);2489 QModelIndex StorageModel::addController (const QString &aCtrName, KStorageBus enmBus, KStorageControllerType enmType) 2490 { 2491 beginInsertRows (root(), m_pRootItem->childCount(), m_pRootItem->childCount()); 2492 new ControllerItem (m_pRootItem, aCtrName, enmBus, enmType); 2493 2493 endInsertRows(); 2494 return index (m RootItem->childCount() - 1, 0, root());2494 return index (m_pRootItem->childCount() - 1, 0, root()); 2495 2495 } 2496 2496 2497 2497 void StorageModel::delController (const QUuid &uCtrId) 2498 2498 { 2499 if (AbstractItem * item = mRootItem->childItemById (uCtrId))2500 { 2501 int itemPosition = m RootItem->posOfChild (item);2499 if (AbstractItem *pItem = m_pRootItem->childItemById (uCtrId)) 2500 { 2501 int itemPosition = m_pRootItem->posOfChild (pItem); 2502 2502 beginRemoveRows (root(), itemPosition, itemPosition); 2503 delete item;2503 delete pItem; 2504 2504 endRemoveRows(); 2505 2505 } 2506 2506 } 2507 2507 2508 QModelIndex StorageModel::addAttachment (const QUuid &uCtrId, KDeviceType aDeviceType, const QUuid &uMediumId)2509 { 2510 if (AbstractItem *p arent = mRootItem->childItemById (uCtrId))2511 { 2512 int parentPosition = mRootItem->posOfChild (parent);2513 QModelIndex parentIndex = index ( parentPosition, 0, root());2514 beginInsertRows (parentIndex, p arent->childCount(), parent->childCount());2515 AttachmentItem *pItem = new AttachmentItem (p arent, aDeviceType);2516 pItem->set AttIsHotPluggable(m_configurationAccessLevel != ConfigurationAccessLevel_Full);2517 pItem->set AttMediumId(uMediumId);2508 QModelIndex StorageModel::addAttachment (const QUuid &uCtrId, KDeviceType enmDeviceType, const QUuid &uMediumId) 2509 { 2510 if (AbstractItem *pParentItem = m_pRootItem->childItemById (uCtrId)) 2511 { 2512 int iParentPosition = m_pRootItem->posOfChild (pParentItem); 2513 QModelIndex parentIndex = index (iParentPosition, 0, root()); 2514 beginInsertRows (parentIndex, pParentItem->childCount(), pParentItem->childCount()); 2515 AttachmentItem *pItem = new AttachmentItem (pParentItem, enmDeviceType); 2516 pItem->setHotPluggable(m_enmConfigurationAccessLevel != ConfigurationAccessLevel_Full); 2517 pItem->setMediumId(uMediumId); 2518 2518 endInsertRows(); 2519 return index (p arent->childCount() - 1, 0, parentIndex);2519 return index (pParentItem->childCount() - 1, 0, parentIndex); 2520 2520 } 2521 2521 return QModelIndex(); … … 2524 2524 void StorageModel::delAttachment (const QUuid &uCtrId, const QUuid &uAttId) 2525 2525 { 2526 if (AbstractItem *p arent = mRootItem->childItemById (uCtrId))2527 { 2528 int parentPosition = mRootItem->posOfChild (parent);2529 if (AbstractItem * item = parent->childItemById (uAttId))2530 { 2531 int itemPosition = p arent->posOfChild (item);2532 beginRemoveRows (index ( parentPosition, 0, root()), itemPosition, itemPosition);2533 delete item;2526 if (AbstractItem *pParentItem = m_pRootItem->childItemById (uCtrId)) 2527 { 2528 int iParentPosition = m_pRootItem->posOfChild (pParentItem); 2529 if (AbstractItem *pItem = pParentItem->childItemById (uAttId)) 2530 { 2531 int itemPosition = pParentItem->posOfChild (pItem); 2532 beginRemoveRows (index (iParentPosition, 0, root()), itemPosition, itemPosition); 2533 delete pItem; 2534 2534 endRemoveRows(); 2535 2535 } … … 2544 2544 2545 2545 /* First of all we are looking for old controller item: */ 2546 AbstractItem *pOldItem = m RootItem->childItemById(uCtrOldId);2546 AbstractItem *pOldItem = m_pRootItem->childItemById(uCtrOldId); 2547 2547 if (pOldItem) 2548 2548 { 2549 2549 /* And acquire controller position: */ 2550 const int iOldCtrPosition = m RootItem->posOfChild(pOldItem);2550 const int iOldCtrPosition = m_pRootItem->posOfChild(pOldItem); 2551 2551 2552 2552 /* Then we are looking for an attachment item: */ … … 2558 2558 { 2559 2559 /* This way we can acquire actual attachment device type and medium ID: */ 2560 enmDeviceType = pSubItemAttachment-> attDeviceType();2561 uMediumId = pSubItemAttachment-> attMediumId();2560 enmDeviceType = pSubItemAttachment->deviceType(); 2561 uMediumId = pSubItemAttachment->mediumId(); 2562 2562 2563 2563 /* And delete atachment item finally: */ … … 2571 2571 2572 2572 /* As the last step we are looking for new controller item: */ 2573 AbstractItem *pNewItem = m RootItem->childItemById(uCtrNewId);2573 AbstractItem *pNewItem = m_pRootItem->childItemById(uCtrNewId); 2574 2574 if (pNewItem) 2575 2575 { 2576 2576 /* And acquire controller position: */ 2577 const int iNewCtrPosition = m RootItem->posOfChild(pNewItem);2577 const int iNewCtrPosition = m_pRootItem->posOfChild(pNewItem); 2578 2578 2579 2579 /* Then we have to make sure moved attachment is valid: */ … … 2584 2584 beginInsertRows(newCtrIndex, pNewItem->childCount(), pNewItem->childCount()); 2585 2585 AttachmentItem *pItem = new AttachmentItem(pNewItem, enmDeviceType); 2586 pItem->set AttIsHotPluggable(m_configurationAccessLevel != ConfigurationAccessLevel_Full);2587 pItem->set AttMediumId(uMediumId);2586 pItem->setHotPluggable(m_enmConfigurationAccessLevel != ConfigurationAccessLevel_Full); 2587 pItem->setMediumId(uMediumId); 2588 2588 endInsertRows(); 2589 2589 } … … 2593 2593 void StorageModel::setMachineId (const QUuid &uMachineId) 2594 2594 { 2595 m RootItem->setMachineId (uMachineId);2596 } 2597 2598 void StorageModel::sort(int /* iColumn */, Qt::SortOrder order)2595 m_pRootItem->setMachineId (uMachineId); 2596 } 2597 2598 void StorageModel::sort(int /* iColumn */, Qt::SortOrder enmOrder) 2599 2599 { 2600 2600 /* Count of controller items: */ 2601 int iItemLevel1Count = m RootItem->childCount();2601 int iItemLevel1Count = m_pRootItem->childCount(); 2602 2602 /* For each of controller items: */ 2603 2603 for (int iItemLevel1Pos = 0; iItemLevel1Pos < iItemLevel1Count; ++iItemLevel1Pos) 2604 2604 { 2605 2605 /* Get iterated controller item: */ 2606 AbstractItem *pItemLevel1 = m RootItem->childItem(iItemLevel1Pos);2606 AbstractItem *pItemLevel1 = m_pRootItem->childItem(iItemLevel1Pos); 2607 2607 ControllerItem *pControllerItem = qobject_cast<ControllerItem*>(pItemLevel1); 2608 2608 /* Count of attachment items: */ … … 2617 2617 AttachmentItem *pAttachmentItem = qobject_cast<AttachmentItem*>(pItemLevel2); 2618 2618 /* Get iterated attachment storage slot: */ 2619 StorageSlot attachmentSlot = pAttachmentItem-> attSlot();2619 StorageSlot attachmentSlot = pAttachmentItem->storageSlot(); 2620 2620 int iInsertPosition = 0; 2621 2621 for (; iInsertPosition < newAttachments.size(); ++iInsertPosition) … … 2625 2625 AttachmentItem *pNewAttachmentItem = qobject_cast<AttachmentItem*>(pNewItemLevel2); 2626 2626 /* Get sorted attachment storage slot: */ 2627 StorageSlot newAttachmentSlot = pNewAttachmentItem-> attSlot();2627 StorageSlot newAttachmentSlot = pNewAttachmentItem->storageSlot(); 2628 2628 /* Apply sorting rule: */ 2629 if ((( order == Qt::AscendingOrder) && (attachmentSlot < newAttachmentSlot)) ||2630 (( order == Qt::DescendingOrder) && (attachmentSlot > newAttachmentSlot)))2629 if (((enmOrder == Qt::AscendingOrder) && (attachmentSlot < newAttachmentSlot)) || 2630 ((enmOrder == Qt::DescendingOrder) && (attachmentSlot > newAttachmentSlot))) 2631 2631 break; 2632 2632 } … … 2673 2673 KChipsetType StorageModel::chipsetType() const 2674 2674 { 2675 return m_ chipsetType;2676 } 2677 2678 void StorageModel::setChipsetType(KChipsetType type)2679 { 2680 m_ chipsetType = type;2681 } 2682 2683 void StorageModel::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel)2684 { 2685 m_ configurationAccessLevel = newConfigurationAccessLevel;2675 return m_enmChipsetType; 2676 } 2677 2678 void StorageModel::setChipsetType(KChipsetType enmChipsetType) 2679 { 2680 m_enmChipsetType = enmChipsetType; 2681 } 2682 2683 void StorageModel::setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel) 2684 { 2685 m_enmConfigurationAccessLevel = enmConfigurationAccessLevel; 2686 2686 } 2687 2687 2688 2688 void StorageModel::clear() 2689 2689 { 2690 while (m RootItem->childCount())2690 while (m_pRootItem->childCount()) 2691 2691 { 2692 2692 beginRemoveRows(root(), 0, 0); 2693 delete m RootItem->childItem(0);2693 delete m_pRootItem->childItem(0); 2694 2694 endRemoveRows(); 2695 2695 } … … 2702 2702 { 2703 2703 currentMap.insert((KStorageBus)iStorageBusType, 2704 qobject_cast<RootItem*>(m RootItem)->childCount((KStorageBus)iStorageBusType));2704 qobject_cast<RootItem*>(m_pRootItem)->childCount((KStorageBus)iStorageBusType)); 2705 2705 } 2706 2706 return currentMap; … … 2718 2718 } 2719 2719 2720 Qt::ItemFlags StorageModel::flags (const QModelIndex & aIndex) const2721 { 2722 return ! aIndex.isValid() ? QAbstractItemModel::flags (aIndex) :2720 Qt::ItemFlags StorageModel::flags (const QModelIndex &index) const 2721 { 2722 return !index.isValid() ? QAbstractItemModel::flags (index) : 2723 2723 Qt::ItemIsEnabled | Qt::ItemIsSelectable; 2724 2724 } … … 2729 2729 *********************************************************************************************************************************/ 2730 2730 2731 StorageDelegate::StorageDelegate (QObject * aParent)2732 : QItemDelegate ( aParent)2733 { 2734 } 2735 2736 void StorageDelegate::paint (QPainter * aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const2737 { 2738 if (! aIndex.isValid()) return;2731 StorageDelegate::StorageDelegate (QObject *pParent) 2732 : QItemDelegate (pParent) 2733 { 2734 } 2735 2736 void StorageDelegate::paint (QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const 2737 { 2738 if (!index.isValid()) return; 2739 2739 2740 2740 /* Initialize variables */ 2741 QStyle::State state = aOption.state;2742 QRect rect = aOption.rect;2743 const StorageModel * model = qobject_cast<const StorageModel*>(aIndex.model());2744 Assert ( model);2745 2746 aPainter->save();2741 QStyle::State enmState = option.state; 2742 QRect rect = option.rect; 2743 const StorageModel *pModel = qobject_cast<const StorageModel*>(index.model()); 2744 Assert (pModel); 2745 2746 pPainter->save(); 2747 2747 2748 2748 /* Draw item background */ 2749 QItemDelegate::drawBackground ( aPainter, aOption, aIndex);2749 QItemDelegate::drawBackground (pPainter, option, index); 2750 2750 2751 2751 /* Setup foreground settings */ 2752 QPalette::ColorGroup cg = state & QStyle::State_Active ? QPalette::Active : QPalette::Inactive;2753 bool isSelected = state & QStyle::State_Selected;2754 bool isFocused = state & QStyle::State_HasFocus;2755 bool isGrayOnLoosingFocus = QApplication::style()->styleHint (QStyle::SH_ItemView_ChangeHighlightOnFocus, &aOption) != 0;2756 aPainter->setPen (aOption.palette.color (cg, isSelected && (isFocused || !isGrayOnLoosingFocus) ?2752 QPalette::ColorGroup cg = enmState & QStyle::State_Active ? QPalette::Active : QPalette::Inactive; 2753 bool fSelected = enmState & QStyle::State_Selected; 2754 bool fFocused = enmState & QStyle::State_HasFocus; 2755 bool fGrayOnLoosingFocus = QApplication::style()->styleHint (QStyle::SH_ItemView_ChangeHighlightOnFocus, &option) != 0; 2756 pPainter->setPen (option.palette.color (cg, fSelected && (fFocused || !fGrayOnLoosingFocus) ? 2757 2757 QPalette::HighlightedText : QPalette::Text)); 2758 2758 2759 aPainter->translate (rect.x(), rect.y());2759 pPainter->translate (rect.x(), rect.y()); 2760 2760 2761 2761 /* Draw Item Pixmap */ 2762 aPainter->drawPixmap (model->data (aIndex, StorageModel::R_ItemPixmapRect).toRect().topLeft(),2763 model->data (aIndex, StorageModel::R_ItemPixmap).value <QPixmap>());2762 pPainter->drawPixmap (pModel->data (index, StorageModel::R_ItemPixmapRect).toRect().topLeft(), 2763 pModel->data (index, StorageModel::R_ItemPixmap).value <QPixmap>()); 2764 2764 2765 2765 /* Draw compressed item name */ 2766 int margin = model->data (aIndex, StorageModel::R_Margin).toInt();2767 int i conWidth = model->data (aIndex, StorageModel::R_IconSize).toInt();2768 int spacing = model->data (aIndex, StorageModel::R_Spacing).toInt();2769 QPoint textPosition = model->data (aIndex, StorageModel::R_ItemNamePoint).toPoint();2770 int textWidth = rect.width() - textPosition.x();2771 if ( model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected)2772 { 2773 textWidth -= (2 * spacing + iconWidth + margin);2774 if ( model->data (aIndex, StorageModel::R_CtrBusType).value <KStorageBus>() != KStorageBus_Floppy)2775 textWidth -= (spacing + iconWidth);2776 } 2777 QString text (model->data (aIndex, StorageModel::R_ItemName).toString());2778 QString s hortText (text);2779 QFont font = model->data (aIndex, Qt::FontRole).value <QFont>();2766 int iMargin = pModel->data (index, StorageModel::R_Margin).toInt(); 2767 int iIconWidth = pModel->data (index, StorageModel::R_IconSize).toInt(); 2768 int iSpacing = pModel->data (index, StorageModel::R_Spacing).toInt(); 2769 QPoint textPosition = pModel->data (index, StorageModel::R_ItemNamePoint).toPoint(); 2770 int iTextWidth = rect.width() - textPosition.x(); 2771 if (pModel->data (index, StorageModel::R_IsController).toBool() && enmState & QStyle::State_Selected) 2772 { 2773 iTextWidth -= (2 * iSpacing + iIconWidth + iMargin); 2774 if (pModel->data (index, StorageModel::R_CtrBusType).value <KStorageBus>() != KStorageBus_Floppy) 2775 iTextWidth -= (iSpacing + iIconWidth); 2776 } 2777 QString strText (pModel->data (index, StorageModel::R_ItemName).toString()); 2778 QString strShortText (strText); 2779 QFont font = pModel->data (index, Qt::FontRole).value <QFont>(); 2780 2780 QFontMetrics fm (font); 2781 while ((s hortText.size() > 1) && (fm.width (shortText) + fm.width ("...") > textWidth))2782 s hortText.truncate (shortText.size() - 1);2783 if (s hortText != text)2784 s hortText += "...";2785 aPainter->setFont (font);2786 aPainter->drawText (textPosition, shortText);2781 while ((strShortText.size() > 1) && (fm.width (strShortText) + fm.width ("...") > iTextWidth)) 2782 strShortText.truncate (strShortText.size() - 1); 2783 if (strShortText != strText) 2784 strShortText += "..."; 2785 pPainter->setFont (font); 2786 pPainter->drawText (textPosition, strShortText); 2787 2787 2788 2788 /* Draw Controller Additions */ 2789 if ( model->data (aIndex, StorageModel::R_IsController).toBool() && state & QStyle::State_Selected)2790 { 2791 DeviceTypeList devicesList ( model->data (aIndex, StorageModel::R_CtrDevices).value <DeviceTypeList>());2789 if (pModel->data (index, StorageModel::R_IsController).toBool() && enmState & QStyle::State_Selected) 2790 { 2791 DeviceTypeList devicesList (pModel->data (index, StorageModel::R_CtrDevices).value <DeviceTypeList>()); 2792 2792 for (int i = 0; i < devicesList.size(); ++ i) 2793 2793 { 2794 KDeviceType deviceType = devicesList [i];2794 KDeviceType enmDeviceType = devicesList [i]; 2795 2795 2796 2796 QRect deviceRect; 2797 2797 QPixmap devicePixmap; 2798 switch ( deviceType)2798 switch (enmDeviceType) 2799 2799 { 2800 2800 case KDeviceType_HardDisk: 2801 2801 { 2802 deviceRect = model->data (aIndex, StorageModel::R_HDPixmapRect).value <QRect>();2803 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ?2804 model->data (aIndex, StorageModel::R_HDPixmapAddEn).value <QPixmap>() :2805 model->data (aIndex, StorageModel::R_HDPixmapAddDis).value <QPixmap>();2802 deviceRect = pModel->data (index, StorageModel::R_HDPixmapRect).value <QRect>(); 2803 devicePixmap = pModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 2804 pModel->data (index, StorageModel::R_HDPixmapAddEn).value <QPixmap>() : 2805 pModel->data (index, StorageModel::R_HDPixmapAddDis).value <QPixmap>(); 2806 2806 break; 2807 2807 } 2808 2808 case KDeviceType_DVD: 2809 2809 { 2810 deviceRect = model->data (aIndex, StorageModel::R_CDPixmapRect).value <QRect>();2811 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ?2812 model->data (aIndex, StorageModel::R_CDPixmapAddEn).value <QPixmap>() :2813 model->data (aIndex, StorageModel::R_CDPixmapAddDis).value <QPixmap>();2810 deviceRect = pModel->data (index, StorageModel::R_CDPixmapRect).value <QRect>(); 2811 devicePixmap = pModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 2812 pModel->data (index, StorageModel::R_CDPixmapAddEn).value <QPixmap>() : 2813 pModel->data (index, StorageModel::R_CDPixmapAddDis).value <QPixmap>(); 2814 2814 break; 2815 2815 } 2816 2816 case KDeviceType_Floppy: 2817 2817 { 2818 deviceRect = model->data (aIndex, StorageModel::R_FDPixmapRect).value <QRect>();2819 devicePixmap = model->data (aIndex, StorageModel::R_IsMoreAttachmentsPossible).toBool() ?2820 model->data (aIndex, StorageModel::R_FDPixmapAddEn).value <QPixmap>() :2821 model->data (aIndex, StorageModel::R_FDPixmapAddDis).value <QPixmap>();2818 deviceRect = pModel->data (index, StorageModel::R_FDPixmapRect).value <QRect>(); 2819 devicePixmap = pModel->data (index, StorageModel::R_IsMoreAttachmentsPossible).toBool() ? 2820 pModel->data (index, StorageModel::R_FDPixmapAddEn).value <QPixmap>() : 2821 pModel->data (index, StorageModel::R_FDPixmapAddDis).value <QPixmap>(); 2822 2822 break; 2823 2823 } … … 2826 2826 } 2827 2827 2828 aPainter->drawPixmap (QPoint (rect.width() + deviceRect.x(), deviceRect.y()), devicePixmap);2829 } 2830 } 2831 2832 aPainter->restore();2833 2834 drawFocus ( aPainter, aOption, rect);2828 pPainter->drawPixmap (QPoint (rect.width() + deviceRect.x(), deviceRect.y()), devicePixmap); 2829 } 2830 } 2831 2832 pPainter->restore(); 2833 2834 drawFocus (pPainter, option, rect); 2835 2835 } 2836 2836 … … 2841 2841 2842 2842 /* static */ 2843 const QString UIMachineSettingsStorage:: ControllerMimeType = QString("application/virtualbox;value=StorageControllerID");2844 const QString UIMachineSettingsStorage:: AttachmentMimeType = QString("application/virtualbox;value=StorageAttachmentID");2843 const QString UIMachineSettingsStorage::s_strControllerMimeType = QString("application/virtualbox;value=StorageControllerID"); 2844 const QString UIMachineSettingsStorage::s_strAttachmentMimeType = QString("application/virtualbox;value=StorageAttachmentID"); 2845 2845 2846 2846 UIMachineSettingsStorage::UIMachineSettingsStorage() … … 2914 2914 { 2915 2915 /* Gather old controller data: */ 2916 oldControllerData.m_str ControllerName = comController.GetName();2917 oldControllerData.m_ controllerBus = comController.GetBus();2918 oldControllerData.m_ controllerType = comController.GetControllerType();2916 oldControllerData.m_strName = comController.GetName(); 2917 oldControllerData.m_enmBus = comController.GetBus(); 2918 oldControllerData.m_enmType = comController.GetControllerType(); 2919 2919 oldControllerData.m_uPortCount = comController.GetPortCount(); 2920 2920 oldControllerData.m_fUseHostIOCache = comController.GetUseHostIOCache(); 2921 2921 /* Override controller cache key: */ 2922 strControllerKey = oldControllerData.m_str ControllerName;2922 strControllerKey = oldControllerData.m_strName; 2923 2923 2924 2924 /* Sort attachments before caching/fetching: */ 2925 2925 const CMediumAttachmentVector &attachmentVector = 2926 m_machine.GetMediumAttachmentsOfController(oldControllerData.m_str ControllerName);2926 m_machine.GetMediumAttachmentsOfController(oldControllerData.m_strName); 2927 2927 QMap<StorageSlot, CMediumAttachment> attachmentMap; 2928 2928 foreach (const CMediumAttachment &comAttachment, attachmentVector) 2929 2929 { 2930 const StorageSlot storageSlot(oldControllerData.m_ controllerBus,2930 const StorageSlot storageSlot(oldControllerData.m_enmBus, 2931 2931 comAttachment.GetPort(), comAttachment.GetDevice()); 2932 2932 attachmentMap.insert(storageSlot, comAttachment); … … 2946 2946 { 2947 2947 /* Gather old attachment data: */ 2948 oldAttachmentData.m_ attachmentType = comAttachment.GetType();2949 oldAttachmentData.m_i AttachmentPort = comAttachment.GetPort();2950 oldAttachmentData.m_i AttachmentDevice = comAttachment.GetDevice();2951 oldAttachmentData.m_f AttachmentPassthrough = comAttachment.GetPassthrough();2952 oldAttachmentData.m_f AttachmentTempEject = comAttachment.GetTemporaryEject();2953 oldAttachmentData.m_f AttachmentNonRotational = comAttachment.GetNonRotational();2954 oldAttachmentData.m_f AttachmentHotPluggable = comAttachment.GetHotPluggable();2948 oldAttachmentData.m_enmDeviceType = comAttachment.GetType(); 2949 oldAttachmentData.m_iPort = comAttachment.GetPort(); 2950 oldAttachmentData.m_iDevice = comAttachment.GetDevice(); 2951 oldAttachmentData.m_fPassthrough = comAttachment.GetPassthrough(); 2952 oldAttachmentData.m_fTempEject = comAttachment.GetTemporaryEject(); 2953 oldAttachmentData.m_fNonRotational = comAttachment.GetNonRotational(); 2954 oldAttachmentData.m_fHotPluggable = comAttachment.GetHotPluggable(); 2955 2955 const CMedium comMedium = comAttachment.GetMedium(); 2956 oldAttachmentData.m_u AttachmentMediumId = comMedium.isNull() ? UIMedium::nullID() : comMedium.GetId();2956 oldAttachmentData.m_uMediumId = comMedium.isNull() ? UIMedium::nullID() : comMedium.GetId(); 2957 2957 /* Override controller cache key: */ 2958 strAttachmentKey = QString("%1:%2").arg(oldAttachmentData.m_i AttachmentPort).arg(oldAttachmentData.m_iAttachmentDevice);2958 strAttachmentKey = QString("%1:%2").arg(oldAttachmentData.m_iPort).arg(oldAttachmentData.m_iDevice); 2959 2959 } 2960 2960 … … 2992 2992 2993 2993 /* Load old controller data from the cache: */ 2994 const QModelIndex controllerIndex = m_pModelStorage->addController(oldControllerData.m_str ControllerName,2995 oldControllerData.m_ controllerBus,2996 oldControllerData.m_ controllerType);2994 const QModelIndex controllerIndex = m_pModelStorage->addController(oldControllerData.m_strName, 2995 oldControllerData.m_enmBus, 2996 oldControllerData.m_enmType); 2997 2997 const QUuid controllerId = QUuid(m_pModelStorage->data(controllerIndex, StorageModel::R_ItemId).toString()); 2998 2998 m_pModelStorage->setData(controllerIndex, oldControllerData.m_uPortCount, StorageModel::R_CtrPortCount); … … 3009 3009 /* Load old attachment data from the cache: */ 3010 3010 const QModelIndex attachmentIndex = m_pModelStorage->addAttachment(controllerId, 3011 oldAttachmentData.m_ attachmentType,3012 oldAttachmentData.m_u AttachmentMediumId);3013 const StorageSlot attachmentStorageSlot(oldControllerData.m_ controllerBus,3014 oldAttachmentData.m_i AttachmentPort,3015 oldAttachmentData.m_i AttachmentDevice);3011 oldAttachmentData.m_enmDeviceType, 3012 oldAttachmentData.m_uMediumId); 3013 const StorageSlot attachmentStorageSlot(oldControllerData.m_enmBus, 3014 oldAttachmentData.m_iPort, 3015 oldAttachmentData.m_iDevice); 3016 3016 m_pModelStorage->setData(attachmentIndex, QVariant::fromValue(attachmentStorageSlot), StorageModel::R_AttSlot); 3017 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_f AttachmentPassthrough, StorageModel::R_AttIsPassthrough);3018 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_f AttachmentTempEject, StorageModel::R_AttIsTempEject);3019 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_f AttachmentNonRotational, StorageModel::R_AttIsNonRotational);3020 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_f AttachmentHotPluggable, StorageModel::R_AttIsHotPluggable);3017 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fPassthrough, StorageModel::R_AttIsPassthrough); 3018 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fTempEject, StorageModel::R_AttIsTempEject); 3019 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fNonRotational, StorageModel::R_AttIsNonRotational); 3020 m_pModelStorage->setData(attachmentIndex, oldAttachmentData.m_fHotPluggable, StorageModel::R_AttIsHotPluggable); 3021 3021 } 3022 3022 } … … 3050 3050 /* Gather new controller data & cache key from model: */ 3051 3051 const QModelIndex controllerIndex = m_pModelStorage->index(iControllerIndex, 0, rootIndex); 3052 newControllerData.m_str ControllerName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString();3053 newControllerData.m_ controllerBus = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrBusType).value<KStorageBus>();3054 newControllerData.m_ controllerType = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrType).value<KStorageControllerType>();3052 newControllerData.m_strName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString(); 3053 newControllerData.m_enmBus = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrBusType).value<KStorageBus>(); 3054 newControllerData.m_enmType = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrType).value<KStorageControllerType>(); 3055 3055 newControllerData.m_uPortCount = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrPortCount).toUInt(); 3056 3056 newControllerData.m_fUseHostIOCache = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrIoCache).toBool(); … … 3065 3065 /* Gather new attachment data & cache key from model: */ 3066 3066 const QModelIndex attachmentIndex = m_pModelStorage->index(iAttachmentIndex, 0, controllerIndex); 3067 newAttachmentData.m_ attachmentType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>();3067 newAttachmentData.m_enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>(); 3068 3068 const StorageSlot attachmentSlot = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttSlot).value<StorageSlot>(); 3069 newAttachmentData.m_i AttachmentPort = attachmentSlot.port;3070 newAttachmentData.m_i AttachmentDevice = attachmentSlot.device;3071 newAttachmentData.m_f AttachmentPassthrough = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsPassthrough).toBool();3072 newAttachmentData.m_f AttachmentTempEject = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsTempEject).toBool();3073 newAttachmentData.m_f AttachmentNonRotational = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsNonRotational).toBool();3074 newAttachmentData.m_f AttachmentHotPluggable = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsHotPluggable).toBool();3075 newAttachmentData.m_u AttachmentMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString();3076 const QString strAttachmentKey = QString("%1:%2").arg(newAttachmentData.m_i AttachmentPort).arg(newAttachmentData.m_iAttachmentDevice);3069 newAttachmentData.m_iPort = attachmentSlot.port; 3070 newAttachmentData.m_iDevice = attachmentSlot.device; 3071 newAttachmentData.m_fPassthrough = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsPassthrough).toBool(); 3072 newAttachmentData.m_fTempEject = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsTempEject).toBool(); 3073 newAttachmentData.m_fNonRotational = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsNonRotational).toBool(); 3074 newAttachmentData.m_fHotPluggable = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttIsHotPluggable).toBool(); 3075 newAttachmentData.m_uMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString(); 3076 const QString strAttachmentKey = QString("%1:%2").arg(newAttachmentData.m_iPort).arg(newAttachmentData.m_iDevice); 3077 3077 3078 3078 /* Cache new attachment data: */ … … 3116 3116 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 3117 3117 { 3118 const QModelIndex c trIndex = rootIndex.child(i, 0);3119 const QString ctrName = m_pModelStorage->data(c trIndex, StorageModel::R_CtrName).toString();3118 const QModelIndex controllerIndex = rootIndex.child(i, 0); 3119 const QString ctrName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString(); 3120 3120 3121 3121 /* Check for name emptiness: */ … … 3136 3136 3137 3137 /* For each attachment: */ 3138 for (int j = 0; j < m_pModelStorage->rowCount(c trIndex); ++j)3139 { 3140 const QModelIndex att Index = ctrIndex.child(j, 0);3141 const StorageSlot attSlot = m_pModelStorage->data(att Index, StorageModel::R_AttSlot).value <StorageSlot>();3142 const KDeviceType enm AttDevice = m_pModelStorage->data(attIndex, StorageModel::R_AttDevice).value <KDeviceType>();3143 const QString key(m_pModelStorage->data(att Index, StorageModel::R_AttMediumId).toString());3138 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 3139 { 3140 const QModelIndex attachmentIndex = controllerIndex.child(j, 0); 3141 const StorageSlot attSlot = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttSlot).value <StorageSlot>(); 3142 const KDeviceType enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value <KDeviceType>(); 3143 const QString key(m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString()); 3144 3144 const QString value(QString("%1 (%2)").arg(ctrName, gpConverter->toString(attSlot))); 3145 3145 /* Check for emptiness: */ 3146 if (uiCommon().medium(key).isNull() && enm AttDevice == KDeviceType_HardDisk)3146 if (uiCommon().medium(key).isNull() && enmDeviceType == KDeviceType_HardDisk) 3147 3147 { 3148 3148 message.second << tr("No hard disk is selected for <i>%1</i>.").arg(value); … … 3249 3249 /* Declare required variables: */ 3250 3250 const QModelIndex index = m_pTreeStorage->currentIndex(); 3251 const KDeviceType enmDevice = m_pModelStorage->data(index, StorageModel::R_AttDevice).value<KDeviceType>();3251 const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value<KDeviceType>(); 3252 3252 3253 3253 /* Polish left pane availability: */ … … 3273 3273 /* Polish attachments pane availability: */ 3274 3274 mLsAttributes->setEnabled(isMachineInValidMode()); 3275 mLbMedium->setEnabled(isMachineOffline() || (isMachineOnline() && enmDevice != KDeviceType_HardDisk));3275 mLbMedium->setEnabled(isMachineOffline() || (isMachineOnline() && enmDeviceType != KDeviceType_HardDisk)); 3276 3276 mCbSlot->setEnabled(isMachineOffline()); 3277 mTbOpen->setEnabled(isMachineOffline() || (isMachineOnline() && enmDevice != KDeviceType_HardDisk));3277 mTbOpen->setEnabled(isMachineOffline() || (isMachineOnline() && enmDeviceType != KDeviceType_HardDisk)); 3278 3278 mCbPassthrough->setEnabled(isMachineOffline()); 3279 3279 mCbTempEject->setEnabled(isMachineInValidMode()); … … 3324 3324 foreach (QLabel *label, labelsList) 3325 3325 { 3326 int width = metrics.width(label->text());3327 maxWidth = width > maxWidth ? width : maxWidth;3326 int iWidth = metrics.width(label->text()); 3327 maxWidth = iWidth > maxWidth ? iWidth : maxWidth; 3328 3328 } 3329 3329 mLtAttachment->setColumnMinimumWidth(1, maxWidth); … … 3343 3343 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 3344 3344 { 3345 const QModelIndex c trIndex = rootIndex.child(i, 0);3346 for (int j = 0; j < m_pModelStorage->rowCount(c trIndex); ++j)3347 { 3348 const QModelIndex att Index = ctrIndex.child(j, 0);3349 const QUuid attMediumId = m_pModelStorage->data(att Index, StorageModel::R_AttMediumId).toString();3345 const QModelIndex controllerIndex = rootIndex.child(i, 0); 3346 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 3347 { 3348 const QModelIndex attachmentIndex = controllerIndex.child(j, 0); 3349 const QUuid attMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString(); 3350 3350 if (attMediumId == medium.id()) 3351 3351 { 3352 m_pModelStorage->setData(att Index, attMediumId, StorageModel::R_AttMediumId);3352 m_pModelStorage->setData(attachmentIndex, attMediumId, StorageModel::R_AttMediumId); 3353 3353 3354 3354 /* Revalidate: */ … … 3364 3364 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 3365 3365 { 3366 QModelIndex c trIndex = rootIndex.child(i, 0);3367 for (int j = 0; j < m_pModelStorage->rowCount(c trIndex); ++j)3368 { 3369 QModelIndex att Index = ctrIndex.child(j, 0);3370 QUuid attMediumId = m_pModelStorage->data(att Index, StorageModel::R_AttMediumId).toString();3366 QModelIndex controllerIndex = rootIndex.child(i, 0); 3367 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 3368 { 3369 QModelIndex attachmentIndex = controllerIndex.child(j, 0); 3370 QUuid attMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString(); 3371 3371 if (attMediumId == uMediumId) 3372 3372 { 3373 m_pModelStorage->setData(att Index, UIMedium().id(), StorageModel::R_AttMediumId);3373 m_pModelStorage->setData(attachmentIndex, UIMedium().id(), StorageModel::R_AttMediumId); 3374 3374 3375 3375 /* Revalidate: */ … … 3456 3456 const bool fShowMenu = deviceTypeList.size() > 1; 3457 3457 QMenu menu; 3458 foreach (const KDeviceType & deviceType, deviceTypeList)3459 { 3460 switch ( deviceType)3458 foreach (const KDeviceType &enmDeviceType, deviceTypeList) 3459 { 3460 switch (enmDeviceType) 3461 3461 { 3462 3462 case KDeviceType_HardDisk: … … 3505 3505 const QModelIndex index = m_pTreeStorage->currentIndex(); 3506 3506 3507 const KDeviceType enmDevice = m_pModelStorage->data(index, StorageModel::R_AttDevice).value <KDeviceType>();3507 const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value <KDeviceType>(); 3508 3508 /* Check if this would be the last DVD. If so let the user confirm this again. */ 3509 if ( enmDevice == KDeviceType_DVD3509 if ( enmDeviceType == KDeviceType_DVD 3510 3510 && deviceCount(KDeviceType_DVD) == 1) 3511 3511 { … … 3514 3514 } 3515 3515 3516 const QModelIndex parent = index.parent();3517 if (!index.isValid() || !parent .isValid() ||3516 const QModelIndex parentIndex = index.parent(); 3517 if (!index.isValid() || !parentIndex.isValid() || 3518 3518 !m_pModelStorage->data(index, StorageModel::R_IsAttachment).toBool() || 3519 !m_pModelStorage->data(parent , StorageModel::R_IsController).toBool())3519 !m_pModelStorage->data(parentIndex, StorageModel::R_IsController).toBool()) 3520 3520 return; 3521 3521 3522 m_pModelStorage->delAttachment(QUuid(m_pModelStorage->data(parent , StorageModel::R_ItemId).toString()),3522 m_pModelStorage->delAttachment(QUuid(m_pModelStorage->data(parentIndex, StorageModel::R_ItemId).toString()), 3523 3523 QUuid(m_pModelStorage->data(index, StorageModel::R_ItemId).toString())); 3524 3524 emit sigStorageChanged(); … … 3594 3594 3595 3595 /* Getting Attachment Medium: */ 3596 const KDeviceType enmDevice = m_pModelStorage->data(index, StorageModel::R_AttDevice).value <KDeviceType>();3597 switch (enmDevice )3596 const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value <KDeviceType>(); 3597 switch (enmDeviceType) 3598 3598 { 3599 3599 case KDeviceType_HardDisk: … … 3625 3625 3626 3626 /* Fetch device-type, medium-id: */ 3627 m_pMediumIdHolder->setType(mediumTypeToLocal(enmDevice ));3627 m_pMediumIdHolder->setType(mediumTypeToLocal(enmDeviceType)); 3628 3628 m_pMediumIdHolder->setId(m_pModelStorage->data(index, StorageModel::R_AttMediumId).toString()); 3629 3629 3630 3630 /* Get/fetch editable state: */ 3631 3631 const bool fIsEditable = (isMachineOffline()) 3632 || (isMachineOnline() && enmDevice != KDeviceType_HardDisk)3633 || (isMachineOnline() && enmDevice == KDeviceType_HardDisk && fIsHotPluggable);3632 || (isMachineOnline() && enmDeviceType != KDeviceType_HardDisk) 3633 || (isMachineOnline() && enmDeviceType == KDeviceType_HardDisk && fIsHotPluggable); 3634 3634 mLbMedium->setEnabled(fIsEditable); 3635 3635 mTbOpen->setEnabled(fIsEditable); 3636 3636 3637 3637 /* Getting Passthrough state */ 3638 const bool isHostDrive = m_pModelStorage->data(index, StorageModel::R_AttIsHostDrive).toBool();3639 mCbPassthrough->setVisible(enmDevice == KDeviceType_DVD && isHostDrive);3640 mCbPassthrough->setChecked( isHostDrive && m_pModelStorage->data(index, StorageModel::R_AttIsPassthrough).toBool());3638 const bool fHostDrive = m_pModelStorage->data(index, StorageModel::R_AttIsHostDrive).toBool(); 3639 mCbPassthrough->setVisible(enmDeviceType == KDeviceType_DVD && fHostDrive); 3640 mCbPassthrough->setChecked(fHostDrive && m_pModelStorage->data(index, StorageModel::R_AttIsPassthrough).toBool()); 3641 3641 3642 3642 /* Getting TempEject state */ 3643 mCbTempEject->setVisible(enmDevice == KDeviceType_DVD && !isHostDrive);3644 mCbTempEject->setChecked(! isHostDrive && m_pModelStorage->data(index, StorageModel::R_AttIsTempEject).toBool());3643 mCbTempEject->setVisible(enmDeviceType == KDeviceType_DVD && !fHostDrive); 3644 mCbTempEject->setChecked(!fHostDrive && m_pModelStorage->data(index, StorageModel::R_AttIsTempEject).toBool()); 3645 3645 3646 3646 /* Getting NonRotational state */ 3647 mCbNonRotational->setVisible(enmDevice == KDeviceType_HardDisk);3647 mCbNonRotational->setVisible(enmDeviceType == KDeviceType_HardDisk); 3648 3648 mCbNonRotational->setChecked(m_pModelStorage->data(index, StorageModel::R_AttIsNonRotational).toBool()); 3649 3649 … … 3653 3653 3654 3654 /* Update optional widgets visibility */ 3655 updateAdditionalDetails(enmDevice );3655 updateAdditionalDetails(enmDeviceType); 3656 3656 3657 3657 /* Getting Other Information */ … … 3687 3687 return; 3688 3688 3689 QObject *pS dr = sender();3689 QObject *pSender = sender(); 3690 3690 switch (m_pModelStorage->data(index, StorageModel::R_ItemType).value <AbstractItem::ItemType>()) 3691 3691 { … … 3693 3693 { 3694 3694 /* Setting Controller Name: */ 3695 if (pS dr == mLeName)3695 if (pSender == mLeName) 3696 3696 m_pModelStorage->setData(index, mLeName->text(), StorageModel::R_CtrName); 3697 3697 /* Setting Controller Bus-Type: */ 3698 else if (pS dr == mCbBus)3698 else if (pSender == mCbBus) 3699 3699 m_pModelStorage->setData(index, QVariant::fromValue(gpConverter->fromString<KStorageBus>(mCbBus->currentText())), 3700 3700 StorageModel::R_CtrBusType); 3701 3701 /* Setting Controller Sub-Type: */ 3702 else if (pS dr == mCbType)3702 else if (pSender == mCbType) 3703 3703 m_pModelStorage->setData(index, QVariant::fromValue(gpConverter->fromString<KStorageControllerType>(mCbType->currentText())), 3704 3704 StorageModel::R_CtrType); 3705 else if (pS dr == mSbPortCount)3705 else if (pSender == mSbPortCount) 3706 3706 m_pModelStorage->setData(index, mSbPortCount->value(), StorageModel::R_CtrPortCount); 3707 else if (pS dr == mCbIoCache)3707 else if (pSender == mCbIoCache) 3708 3708 m_pModelStorage->setData(index, mCbIoCache->isChecked(), StorageModel::R_CtrIoCache); 3709 3709 break; … … 3712 3712 { 3713 3713 /* Setting Attachment Slot: */ 3714 if (pS dr == mCbSlot)3714 if (pSender == mCbSlot) 3715 3715 { 3716 3716 QModelIndex controllerIndex = m_pModelStorage->parent(index); … … 3722 3722 } 3723 3723 /* Setting Attachment Medium: */ 3724 else if (pS dr == m_pMediumIdHolder)3724 else if (pSender == m_pMediumIdHolder) 3725 3725 m_pModelStorage->setData(index, m_pMediumIdHolder->id(), StorageModel::R_AttMediumId); 3726 else if (pS dr == mCbPassthrough)3726 else if (pSender == mCbPassthrough) 3727 3727 { 3728 3728 if (m_pModelStorage->data(index, StorageModel::R_AttIsHostDrive).toBool()) 3729 3729 m_pModelStorage->setData(index, mCbPassthrough->isChecked(), StorageModel::R_AttIsPassthrough); 3730 3730 } 3731 else if (pS dr == mCbTempEject)3731 else if (pSender == mCbTempEject) 3732 3732 { 3733 3733 if (!m_pModelStorage->data(index, StorageModel::R_AttIsHostDrive).toBool()) 3734 3734 m_pModelStorage->setData(index, mCbTempEject->isChecked(), StorageModel::R_AttIsTempEject); 3735 3735 } 3736 else if (pS dr == mCbNonRotational)3736 else if (pSender == mCbNonRotational) 3737 3737 { 3738 3738 m_pModelStorage->setData(index, mCbNonRotational->isChecked(), StorageModel::R_AttIsNonRotational); 3739 3739 } 3740 else if (pS dr == m_pCheckBoxHotPluggable)3740 else if (pSender == m_pCheckBoxHotPluggable) 3741 3741 { 3742 3742 m_pModelStorage->setData(index, m_pCheckBoxHotPluggable->isChecked(), StorageModel::R_AttIsHotPluggable); … … 3919 3919 } 3920 3920 3921 void UIMachineSettingsStorage::sltHandleRowInsertion(const QModelIndex &parent , int iPosition)3922 { 3923 const QModelIndex index = m_pModelStorage->index(iPosition, 0, parent );3921 void UIMachineSettingsStorage::sltHandleRowInsertion(const QModelIndex &parentIndex, int iPosition) 3922 { 3923 const QModelIndex index = m_pModelStorage->index(iPosition, 0, parentIndex); 3924 3924 3925 3925 switch (m_pModelStorage->data(index, StorageModel::R_ItemType).value<AbstractItem::ItemType>()) … … 3934 3934 { 3935 3935 /* Expand parent if it is not expanded yet: */ 3936 if (!m_pTreeStorage->isExpanded(parent ))3937 m_pTreeStorage->setExpanded(parent , true);3936 if (!m_pTreeStorage->isExpanded(parentIndex)) 3937 m_pTreeStorage->setExpanded(parentIndex, true); 3938 3938 break; 3939 3939 } … … 3973 3973 { 3974 3974 const DeviceTypeList deviceTypeList(m_pModelStorage->data(index, StorageModel::R_CtrDevices).value<DeviceTypeList>()); 3975 foreach (KDeviceType deviceType, deviceTypeList)3975 foreach (KDeviceType enmDeviceType, deviceTypeList) 3976 3976 { 3977 switch ( deviceType)3977 switch (enmDeviceType) 3978 3978 { 3979 3979 case KDeviceType_HardDisk: … … 4140 4140 if (pMimeData) 4141 4141 { 4142 pMimeData->setData( ControllerMimeType, pItemAttachment->parent()->id().toString().toLatin1());4143 pMimeData->setData( AttachmentMimeType, pItemAttachment->id().toString().toLatin1());4142 pMimeData->setData(s_strControllerMimeType, pItemAttachment->parent()->id().toString().toLatin1()); 4143 pMimeData->setData(s_strAttachmentMimeType, pItemAttachment->id().toString().toLatin1()); 4144 4144 pDrag->setMimeData(pMimeData); 4145 4145 } … … 4242 4242 4243 4243 /* Make sure mime-data format is valid: */ 4244 if ( !pMimeData->hasFormat(UIMachineSettingsStorage:: ControllerMimeType)4245 || !pMimeData->hasFormat(UIMachineSettingsStorage:: AttachmentMimeType))4244 if ( !pMimeData->hasFormat(UIMachineSettingsStorage::s_strControllerMimeType) 4245 || !pMimeData->hasFormat(UIMachineSettingsStorage::s_strAttachmentMimeType)) 4246 4246 return; 4247 4247 4248 4248 /* Get controller id: */ 4249 const QString strControllerId = pMimeData->data(UIMachineSettingsStorage:: ControllerMimeType);4249 const QString strControllerId = pMimeData->data(UIMachineSettingsStorage::s_strControllerMimeType); 4250 4250 4251 4251 /* Check what item we are hovering currently: */ … … 4281 4281 { 4282 4282 /* Get controller/attachment ids: */ 4283 const QString strControllerId = pMimeData->data(UIMachineSettingsStorage:: ControllerMimeType);4284 const QString strAttachmentId = pMimeData->data(UIMachineSettingsStorage:: AttachmentMimeType);4283 const QString strControllerId = pMimeData->data(UIMachineSettingsStorage::s_strControllerMimeType); 4284 const QString strAttachmentId = pMimeData->data(UIMachineSettingsStorage::s_strAttachmentMimeType); 4285 4285 m_pModelStorage->moveAttachment(strAttachmentId, strControllerId, pItemController->id()); 4286 4286 } … … 4746 4746 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 4747 4747 { 4748 const QModelIndex c trIndex = rootIndex.child(i, 0);4749 const QString ctrName = m_pModelStorage->data(ctrIndex, StorageModel::R_CtrName).toString();4750 if ( ctrName.startsWith(strTemplate))4751 { 4752 const QString str ingNumber(ctrName.right(ctrName.size() - strTemplate.size()));4748 const QModelIndex controllerIndex = rootIndex.child(i, 0); 4749 const QString strName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString(); 4750 if (strName.startsWith(strTemplate)) 4751 { 4752 const QString strNumber(strName.right(strName.size() - strTemplate.size())); 4753 4753 bool fConverted = false; 4754 const int iNumber = str ingNumber.toInt(&fConverted);4754 const int iNumber = strNumber.toInt(&fConverted); 4755 4755 iMaxNumber = fConverted && (iNumber > iMaxNumber) ? iNumber : 1; 4756 4756 } … … 4765 4765 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 4766 4766 { 4767 const QModelIndex c trIndex = rootIndex.child(i, 0);4768 for (int j = 0; j < m_pModelStorage->rowCount(c trIndex); ++j)4769 { 4770 const QModelIndex att Index = ctrIndex.child(j, 0);4771 const KDeviceType enm AttDevice = m_pModelStorage->data(attIndex, StorageModel::R_AttDevice).value<KDeviceType>();4772 if (enm AttDevice == enmType)4767 const QModelIndex controllerIndex = rootIndex.child(i, 0); 4768 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 4769 { 4770 const QModelIndex attachmentIndex = controllerIndex.child(j, 0); 4771 const KDeviceType enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>(); 4772 if (enmDeviceType == enmType) 4773 4773 ++cDevices; 4774 4774 } … … 4789 4789 foreach (const QUuid &uMediumId, uiCommon().mediumIDs()) 4790 4790 { 4791 const UIMedium medium = uiCommon().medium(uMediumId);4792 if ( medium.isHostDrive() && m_pMediumIdHolder->type() == medium.type())4793 { 4794 QAction *pHostDriveAction = pOpenMediumMenu->addAction( medium.name());4795 pHostDriveAction->setData( medium.id());4791 const UIMedium guiMedium = uiCommon().medium(uMediumId); 4792 if (guiMedium.isHostDrive() && m_pMediumIdHolder->type() == guiMedium.type()) 4793 { 4794 QAction *pHostDriveAction = pOpenMediumMenu->addAction(guiMedium.name()); 4795 pHostDriveAction->setData(guiMedium.id()); 4796 4796 connect(pHostDriveAction, &QAction::triggered, this, &UIMachineSettingsStorage::sltChooseHostDrive); 4797 4797 } … … 4894 4894 4895 4895 /* Search for a controller with the same name: */ 4896 const CStorageController &comController = m_machine.GetStorageControllerByName(oldControllerData.m_str ControllerName);4896 const CStorageController &comController = m_machine.GetStorageControllerByName(oldControllerData.m_strName); 4897 4897 fSuccess = m_machine.isOk() && comController.isNotNull(); 4898 4898 … … 4901 4901 { 4902 4902 /* Remove controller with all the attachments at one shot: */ 4903 m_machine.RemoveStorageController(oldControllerData.m_str ControllerName);4903 m_machine.RemoveStorageController(oldControllerData.m_strName); 4904 4904 fSuccess = m_machine.isOk(); 4905 4905 } … … 4925 4925 /* Search for a controller with the same name: */ 4926 4926 const CMachine comMachine(m_machine); 4927 CStorageController comController = comMachine.GetStorageControllerByName(newControllerData.m_str ControllerName);4927 CStorageController comController = comMachine.GetStorageControllerByName(newControllerData.m_strName); 4928 4928 fSuccess = !comMachine.isOk() && comController.isNull(); 4929 4929 AssertReturn(fSuccess, false); … … 4933 4933 { 4934 4934 /* Create controller: */ 4935 comController = m_machine.AddStorageController(newControllerData.m_str ControllerName, newControllerData.m_controllerBus);4935 comController = m_machine.AddStorageController(newControllerData.m_strName, newControllerData.m_enmBus); 4936 4936 fSuccess = m_machine.isOk() && comController.isNotNull(); 4937 4937 } … … 4945 4945 if (fSuccess) 4946 4946 { 4947 comController.SetControllerType(newControllerData.m_ controllerType);4947 comController.SetControllerType(newControllerData.m_enmType); 4948 4948 fSuccess = comController.isOk(); 4949 4949 } … … 4956 4956 /* Save controller port number: */ 4957 4957 if ( fSuccess 4958 && ( newControllerData.m_ controllerBus == KStorageBus_SATA4959 || newControllerData.m_ controllerBus == KStorageBus_SAS4960 || newControllerData.m_ controllerBus == KStorageBus_PCIe4961 || newControllerData.m_ controllerBus == KStorageBus_VirtioSCSI))4958 && ( newControllerData.m_enmBus == KStorageBus_SATA 4959 || newControllerData.m_enmBus == KStorageBus_SAS 4960 || newControllerData.m_enmBus == KStorageBus_PCIe 4961 || newControllerData.m_enmBus == KStorageBus_VirtioSCSI)) 4962 4962 { 4963 4963 ULONG uNewPortCount = newControllerData.m_uPortCount; … … 5013 5013 5014 5014 /* Search for a controller with the same name: */ 5015 CStorageController comController = m_machine.GetStorageControllerByName(oldControllerData.m_str ControllerName);5015 CStorageController comController = m_machine.GetStorageControllerByName(oldControllerData.m_strName); 5016 5016 fSuccess = m_machine.isOk() && comController.isNotNull(); 5017 5017 … … 5022 5022 { 5023 5023 /* Save controller type: */ 5024 if (fSuccess && newControllerData.m_ controllerType != oldControllerData.m_controllerType)5024 if (fSuccess && newControllerData.m_enmType != oldControllerData.m_enmType) 5025 5025 { 5026 comController.SetControllerType(newControllerData.m_ controllerType);5026 comController.SetControllerType(newControllerData.m_enmType); 5027 5027 fSuccess = comController.isOk(); 5028 5028 } … … 5036 5036 if ( fSuccess 5037 5037 && newControllerData.m_uPortCount != oldControllerData.m_uPortCount 5038 && ( newControllerData.m_ controllerBus == KStorageBus_SATA5039 || newControllerData.m_ controllerBus == KStorageBus_SAS5040 || newControllerData.m_ controllerBus == KStorageBus_PCIe5041 || newControllerData.m_ controllerBus == KStorageBus_VirtioSCSI))5038 && ( newControllerData.m_enmBus == KStorageBus_SATA 5039 || newControllerData.m_enmBus == KStorageBus_SAS 5040 || newControllerData.m_enmBus == KStorageBus_PCIe 5041 || newControllerData.m_enmBus == KStorageBus_VirtioSCSI)) 5042 5042 { 5043 5043 ULONG uNewPortCount = newControllerData.m_uPortCount; … … 5117 5117 5118 5118 /* Search for an attachment with the same parameters: */ 5119 const CMediumAttachment &comAttachment = m_machine.GetMediumAttachment(oldControllerData.m_str ControllerName,5120 oldAttachmentData.m_i AttachmentPort,5121 oldAttachmentData.m_i AttachmentDevice);5119 const CMediumAttachment &comAttachment = m_machine.GetMediumAttachment(oldControllerData.m_strName, 5120 oldAttachmentData.m_iPort, 5121 oldAttachmentData.m_iDevice); 5122 5122 fSuccess = m_machine.isOk() && comAttachment.isNotNull(); 5123 5123 … … 5126 5126 { 5127 5127 /* Remove attachment: */ 5128 m_machine.DetachDevice(oldControllerData.m_str ControllerName,5129 oldAttachmentData.m_i AttachmentPort,5130 oldAttachmentData.m_i AttachmentDevice);5128 m_machine.DetachDevice(oldControllerData.m_strName, 5129 oldAttachmentData.m_iPort, 5130 oldAttachmentData.m_iDevice); 5131 5131 fSuccess = m_machine.isOk(); 5132 5132 } … … 5155 5155 /* Search for an attachment with the same parameters: */ 5156 5156 const CMachine comMachine(m_machine); 5157 const CMediumAttachment &comAttachment = comMachine.GetMediumAttachment(newControllerData.m_str ControllerName,5158 newAttachmentData.m_i AttachmentPort,5159 newAttachmentData.m_i AttachmentDevice);5157 const CMediumAttachment &comAttachment = comMachine.GetMediumAttachment(newControllerData.m_strName, 5158 newAttachmentData.m_iPort, 5159 newAttachmentData.m_iDevice); 5160 5160 fSuccess = !comMachine.isOk() && comAttachment.isNull(); 5161 5161 AssertReturn(fSuccess, false); … … 5165 5165 { 5166 5166 /* Create attachment: */ 5167 const UIMedium vboxMedium = uiCommon().medium(newAttachmentData.m_u AttachmentMediumId);5167 const UIMedium vboxMedium = uiCommon().medium(newAttachmentData.m_uMediumId); 5168 5168 const CMedium comMedium = vboxMedium.medium(); 5169 m_machine.AttachDevice(newControllerData.m_str ControllerName,5170 newAttachmentData.m_i AttachmentPort,5171 newAttachmentData.m_i AttachmentDevice,5172 newAttachmentData.m_ attachmentType,5169 m_machine.AttachDevice(newControllerData.m_strName, 5170 newAttachmentData.m_iPort, 5171 newAttachmentData.m_iDevice, 5172 newAttachmentData.m_enmDeviceType, 5173 5173 comMedium); 5174 5174 fSuccess = m_machine.isOk(); 5175 5175 } 5176 5176 5177 if (newAttachmentData.m_ attachmentType == KDeviceType_DVD)5177 if (newAttachmentData.m_enmDeviceType == KDeviceType_DVD) 5178 5178 { 5179 5179 /* Save whether this is a passthrough device: */ 5180 5180 if (fSuccess && isMachineOffline()) 5181 5181 { 5182 m_machine.PassthroughDevice(newControllerData.m_str ControllerName,5183 newAttachmentData.m_i AttachmentPort,5184 newAttachmentData.m_i AttachmentDevice,5185 newAttachmentData.m_f AttachmentPassthrough);5182 m_machine.PassthroughDevice(newControllerData.m_strName, 5183 newAttachmentData.m_iPort, 5184 newAttachmentData.m_iDevice, 5185 newAttachmentData.m_fPassthrough); 5186 5186 fSuccess = m_machine.isOk(); 5187 5187 } … … 5189 5189 if (fSuccess) 5190 5190 { 5191 m_machine.TemporaryEjectDevice(newControllerData.m_str ControllerName,5192 newAttachmentData.m_i AttachmentPort,5193 newAttachmentData.m_i AttachmentDevice,5194 newAttachmentData.m_f AttachmentTempEject);5191 m_machine.TemporaryEjectDevice(newControllerData.m_strName, 5192 newAttachmentData.m_iPort, 5193 newAttachmentData.m_iDevice, 5194 newAttachmentData.m_fTempEject); 5195 5195 fSuccess = m_machine.isOk(); 5196 5196 } 5197 5197 } 5198 else if (newAttachmentData.m_ attachmentType == KDeviceType_HardDisk)5198 else if (newAttachmentData.m_enmDeviceType == KDeviceType_HardDisk) 5199 5199 { 5200 5200 /* Save whether this is a ssd device: */ 5201 5201 if (fSuccess && isMachineOffline()) 5202 5202 { 5203 m_machine.NonRotationalDevice(newControllerData.m_str ControllerName,5204 newAttachmentData.m_i AttachmentPort,5205 newAttachmentData.m_i AttachmentDevice,5206 newAttachmentData.m_f AttachmentNonRotational);5203 m_machine.NonRotationalDevice(newControllerData.m_strName, 5204 newAttachmentData.m_iPort, 5205 newAttachmentData.m_iDevice, 5206 newAttachmentData.m_fNonRotational); 5207 5207 fSuccess = m_machine.isOk(); 5208 5208 } 5209 5209 } 5210 5210 5211 if (newControllerData.m_ controllerBus == KStorageBus_SATA || newControllerData.m_controllerBus == KStorageBus_USB)5211 if (newControllerData.m_enmBus == KStorageBus_SATA || newControllerData.m_enmBus == KStorageBus_USB) 5212 5212 { 5213 5213 /* Save whether this device is hot-pluggable: */ 5214 5214 if (fSuccess && isMachineOffline()) 5215 5215 { 5216 m_machine.SetHotPluggableForDevice(newControllerData.m_str ControllerName,5217 newAttachmentData.m_i AttachmentPort,5218 newAttachmentData.m_i AttachmentDevice,5219 newAttachmentData.m_f AttachmentHotPluggable);5216 m_machine.SetHotPluggableForDevice(newControllerData.m_strName, 5217 newAttachmentData.m_iPort, 5218 newAttachmentData.m_iDevice, 5219 newAttachmentData.m_fHotPluggable); 5220 5220 fSuccess = m_machine.isOk(); 5221 5221 } … … 5244 5244 5245 5245 /* Search for an attachment with the same parameters: */ 5246 const CMediumAttachment &comAttachment = m_machine.GetMediumAttachment(newControllerData.m_str ControllerName,5247 newAttachmentData.m_i AttachmentPort,5248 newAttachmentData.m_i AttachmentDevice);5246 const CMediumAttachment &comAttachment = m_machine.GetMediumAttachment(newControllerData.m_strName, 5247 newAttachmentData.m_iPort, 5248 newAttachmentData.m_iDevice); 5249 5249 fSuccess = m_machine.isOk() && comAttachment.isNotNull(); 5250 5250 … … 5253 5253 { 5254 5254 /* Remount attachment: */ 5255 const UIMedium vboxMedium = uiCommon().medium(newAttachmentData.m_u AttachmentMediumId);5255 const UIMedium vboxMedium = uiCommon().medium(newAttachmentData.m_uMediumId); 5256 5256 const CMedium comMedium = vboxMedium.medium(); 5257 m_machine.MountMedium(newControllerData.m_str ControllerName,5258 newAttachmentData.m_i AttachmentPort,5259 newAttachmentData.m_i AttachmentDevice,5257 m_machine.MountMedium(newControllerData.m_strName, 5258 newAttachmentData.m_iPort, 5259 newAttachmentData.m_iDevice, 5260 5260 comMedium, 5261 5261 true /* force? */); … … 5263 5263 } 5264 5264 5265 if (newAttachmentData.m_ attachmentType == KDeviceType_DVD)5265 if (newAttachmentData.m_enmDeviceType == KDeviceType_DVD) 5266 5266 { 5267 5267 /* Save whether this is a passthrough device: */ 5268 5268 if (fSuccess && isMachineOffline()) 5269 5269 { 5270 m_machine.PassthroughDevice(newControllerData.m_str ControllerName,5271 newAttachmentData.m_i AttachmentPort,5272 newAttachmentData.m_i AttachmentDevice,5273 newAttachmentData.m_f AttachmentPassthrough);5270 m_machine.PassthroughDevice(newControllerData.m_strName, 5271 newAttachmentData.m_iPort, 5272 newAttachmentData.m_iDevice, 5273 newAttachmentData.m_fPassthrough); 5274 5274 fSuccess = m_machine.isOk(); 5275 5275 } … … 5277 5277 if (fSuccess) 5278 5278 { 5279 m_machine.TemporaryEjectDevice(newControllerData.m_str ControllerName,5280 newAttachmentData.m_i AttachmentPort,5281 newAttachmentData.m_i AttachmentDevice,5282 newAttachmentData.m_f AttachmentTempEject);5279 m_machine.TemporaryEjectDevice(newControllerData.m_strName, 5280 newAttachmentData.m_iPort, 5281 newAttachmentData.m_iDevice, 5282 newAttachmentData.m_fTempEject); 5283 5283 fSuccess = m_machine.isOk(); 5284 5284 } 5285 5285 } 5286 else if (newAttachmentData.m_ attachmentType == KDeviceType_HardDisk)5286 else if (newAttachmentData.m_enmDeviceType == KDeviceType_HardDisk) 5287 5287 { 5288 5288 /* Save whether this is a ssd device: */ 5289 5289 if (fSuccess && isMachineOffline()) 5290 5290 { 5291 m_machine.NonRotationalDevice(newControllerData.m_str ControllerName,5292 newAttachmentData.m_i AttachmentPort,5293 newAttachmentData.m_i AttachmentDevice,5294 newAttachmentData.m_f AttachmentNonRotational);5291 m_machine.NonRotationalDevice(newControllerData.m_strName, 5292 newAttachmentData.m_iPort, 5293 newAttachmentData.m_iDevice, 5294 newAttachmentData.m_fNonRotational); 5295 5295 fSuccess = m_machine.isOk(); 5296 5296 } 5297 5297 } 5298 5298 5299 if (newControllerData.m_ controllerBus == KStorageBus_SATA || newControllerData.m_controllerBus == KStorageBus_USB)5299 if (newControllerData.m_enmBus == KStorageBus_SATA || newControllerData.m_enmBus == KStorageBus_USB) 5300 5300 { 5301 5301 /* Save whether this device is hot-pluggable: */ 5302 5302 if (fSuccess && isMachineOffline()) 5303 5303 { 5304 m_machine.SetHotPluggableForDevice(newControllerData.m_str ControllerName,5305 newAttachmentData.m_i AttachmentPort,5306 newAttachmentData.m_i AttachmentDevice,5307 newAttachmentData.m_f AttachmentHotPluggable);5304 m_machine.SetHotPluggableForDevice(newControllerData.m_strName, 5305 newAttachmentData.m_iPort, 5306 newAttachmentData.m_iDevice, 5307 newAttachmentData.m_fHotPluggable); 5308 5308 fSuccess = m_machine.isOk(); 5309 5309 } … … 5328 5328 const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data(); 5329 5329 return true 5330 && (newControllerData.m_str ControllerName == oldControllerData.m_strControllerName)5331 && (newControllerData.m_ controllerBus == oldControllerData.m_controllerBus)5330 && (newControllerData.m_strName == oldControllerData.m_strName) 5331 && (newControllerData.m_enmBus == oldControllerData.m_enmBus) 5332 5332 ; 5333 5333 } … … 5342 5342 const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data(); 5343 5343 return true 5344 && (newAttachmentData.m_ attachmentType == oldAttachmentData.m_attachmentType)5345 && (newAttachmentData.m_i AttachmentPort == oldAttachmentData.m_iAttachmentPort)5346 && (newAttachmentData.m_i AttachmentDevice == oldAttachmentData.m_iAttachmentDevice)5347 && (newAttachmentData.m_ attachmentType == KDeviceType_Floppy || newAttachmentData.m_attachmentType == KDeviceType_DVD)5344 && (newAttachmentData.m_enmDeviceType == oldAttachmentData.m_enmDeviceType) 5345 && (newAttachmentData.m_iPort == oldAttachmentData.m_iPort) 5346 && (newAttachmentData.m_iDevice == oldAttachmentData.m_iDevice) 5347 && (newAttachmentData.m_enmDeviceType == KDeviceType_Floppy || newAttachmentData.m_enmDeviceType == KDeviceType_DVD) 5348 5348 ; 5349 5349 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h
r81095 r81098 52 52 53 53 /** Holds the controller mime-type for the D&D system. */ 54 static const QString ControllerMimeType;54 static const QString s_strControllerMimeType; 55 55 /** Holds the attachment mime-type for the D&D system. */ 56 static const QString AttachmentMimeType;56 static const QString s_strAttachmentMimeType; 57 57 58 58 /** Constructs Storage settings page. */ … … 158 158 void sltUpdateActionStates(); 159 159 160 /** Handles row insertion into @a parent on @a iPosition. */161 void sltHandleRowInsertion(const QModelIndex &parent , int iPosition);160 /** Handles row insertion into @a parentIndex on @a iPosition. */ 161 void sltHandleRowInsertion(const QModelIndex &parentIndex, int iPosition); 162 162 /** Handles row removal. */ 163 163 void sltHandleRowRemoval();
Note:
See TracChangeset
for help on using the changeset viewer.