Changeset 13580 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 27, 2008 2:04:18 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 added
- 2 deleted
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r9060 r13580 25 25 LANGUAGE = C++ 26 26 27 FORMS = ui/VBox DiskImageManagerDlg.ui \27 FORMS = ui/VBoxMediaManagerDlg.ui \ 28 28 ui/VBoxVMNetworkSettings.ui \ 29 29 ui/VBoxVMSerialPortSettings.ui \ -
trunk/src/VBox/Frontends/VirtualBox/include/COMDefs.h
r8155 r13580 179 179 180 180 /** 181 * 182 * 181 * Base COM class the CInterface template and all wrapper classes are derived 182 * from. Provides common functionality for all COM wrappers. 183 183 */ 184 184 class COMBase … … 190 190 191 191 /** 192 * Returns the result code of the last interface method called193 * by thewrapper instance or the result of CInterface::createInstance()194 * 192 * Returns the result code of the last interface method called by the 193 * wrapper instance or the result of CInterface::createInstance() 194 * operation. 195 195 */ 196 196 HRESULT lastRC() const { return mRC; } 197 198 /**199 * Returns error info set by the last unsuccessfully invoked interface200 * method. Returned error info is useful only if CInterface::lastRC()201 * represents a failure or a warning (i.e. CInterface::isReallyOk() is202 * false).203 */204 virtual COMErrorInfo errorInfo() const { return COMErrorInfo(); }205 197 206 198 #if !defined (VBOX_WITH_XPCOM) … … 231 223 static void ToSafeArray (const QValueVector <QT> &aVec, com::SafeArray <CT> &aArr) 232 224 { 225 Q_UNUSED (aVec); 226 Q_UNUSED (aArr); 233 227 AssertMsgFailedReturnVoid (("No conversion!\n")); 234 228 } … … 237 231 static void FromSafeArray (const com::SafeArray <CT> &aArr, QValueVector <QT> &aVec) 238 232 { 233 Q_UNUSED (aArr); 234 Q_UNUSED (aVec); 239 235 AssertMsgFailedReturnVoid (("No conversion!\n")); 240 236 } … … 243 239 static void ToSafeArray (const QValueVector <QT *> &aVec, com::SafeArray <CT *> &aArr) 244 240 { 241 Q_UNUSED (aVec); 242 Q_UNUSED (aArr); 245 243 AssertMsgFailedReturnVoid (("No conversion!\n")); 246 244 } … … 249 247 static void FromSafeArray (const com::SafeArray <CT *> &aArr, QValueVector <QT *> &aVec) 250 248 { 249 Q_UNUSED (aArr); 250 Q_UNUSED (aVec); 251 251 AssertMsgFailedReturnVoid (("No conversion!\n")); 252 252 } … … 280 280 static void FromSafeArray (const com::SafeArray <BSTR> &aArr, 281 281 QValueVector <QString> &aVec); 282 283 /* Arrays of GUID */ 284 285 static void ToSafeArray (const QValueVector <QUuid> &aVec, 286 com::SafeGUIDArray &aArr); 287 static void FromSafeArray (const com::SafeGUIDArray &aArr, 288 QValueVector <QUuid> &aVec); 282 289 283 290 /* Arrays of interface pointers. Note: we need a separate pair of names … … 299 306 it != aVec.end(); ++ it, ++ i) 300 307 { 301 aArr [i] = (*it). iface();308 aArr [i] = (*it).raw(); 302 309 if (aArr [i]) 303 310 aArr [i]->AddRef(); … … 457 464 #endif /* !defined (VBOX_WITH_XPCOM) */ 458 465 459 void fetchErrorInfo (IUnknown * /*callee*/, const GUID * /*calleeIID*/) const {} 466 static void addref (IUnknown *aIface) { if (aIface) aIface->AddRef(); } 467 static void release (IUnknown *aIface) { if (aIface) aIface->Release(); } 468 469 protected: 460 470 461 471 mutable HRESULT mRC; … … 467 477 468 478 /** 469 * Alternative base class for the CInterface template that adds470 * the errorInfo() method for providing extended error info about471 * unsuccessful invocation of thelast called interface method.479 * Alternative base class for the CInterface template that adds the errorInfo() 480 * method for providing extended error info about unsuccessful invocation of the 481 * last called interface method. 472 482 */ 473 483 class COMBaseWithEI : public COMBase … … 476 486 477 487 /** 478 * 479 * 480 * 481 * 482 */ 483 COMErrorInfoerrorInfo() const { return mErrInfo; }488 * Returns error info set by the last unsuccessfully invoked interface 489 * method. Returned error info is useful only if CInterface::lastRC() 490 * represents a failure or a warning (i.e. CInterface::isReallyOk() is 491 * false). 492 */ 493 const COMErrorInfo &errorInfo() const { return mErrInfo; } 484 494 485 495 protected: 486 496 487 /* no arbitrary instance creation s*/497 /* no arbitrary instance creation */ 488 498 COMBaseWithEI() : COMBase () {}; 489 499 490 void fetchErrorInfo (IUnknown *callee, const GUID *calleeIID) const 491 { 492 mErrInfo.fetchFromCurrentThread (callee, calleeIID); 500 void setErrorInfo (const COMErrorInfo &aErrInfo) { mErrInfo = aErrInfo; } 501 502 void fetchErrorInfo (IUnknown *aCallee, const GUID *aCalleeIID) const 503 { 504 mErrInfo.fetchFromCurrentThread (aCallee, aCalleeIID); 493 505 } 494 506 … … 499 511 500 512 /** 501 * 513 * Simple class that encapsulates the result code and COMErrorInfo. 502 514 */ 503 515 class COMResult … … 507 519 COMResult() : mRC (S_OK) {} 508 520 509 /** Queries the current result code and error info from the given component */ 510 COMResult (const COMBase &aComponent) 511 { 512 mErrInfo = aComponent.errorInfo(); 513 mRC = aComponent.lastRC(); 514 } 515 516 /** Queries the current result code and error info from the given component */ 521 /** 522 * Queries the current result code from the given component. 523 */ 524 explicit COMResult (const COMBase &aComponent) 525 : mRC (aComponent.lastRC()) {} 526 527 /** 528 * Queries the current result code and error info from the given component. 529 */ 530 COMResult (const COMBaseWithEI &aComponent) 531 : mRC (aComponent.lastRC()) 532 , mErrInfo (aComponent.errorInfo()) {} 533 534 /** 535 * Queries the current result code from the given component. 536 */ 517 537 COMResult &operator= (const COMBase &aComponent) 518 538 { 519 mErrInfo = aComponent.errorInfo();520 539 mRC = aComponent.lastRC(); 521 540 return *this; 522 541 } 523 542 543 /** 544 * Queries the current result code and error info from the given component. 545 */ 546 COMResult &operator= (const COMBaseWithEI &aComponent) 547 { 548 mRC = aComponent.lastRC(); 549 mErrInfo = aComponent.errorInfo(); 550 return *this; 551 } 552 524 553 bool isNull() const { return mErrInfo.isNull(); } 525 554 … … 546 575 private: 547 576 577 HRESULT mRC; 548 578 COMErrorInfo mErrInfo; 549 HRESULT mRC;550 579 }; 551 580 552 581 ///////////////////////////////////////////////////////////////////////////// 553 582 554 class CUnknown;555 556 583 /** 557 * 558 * 559 * 560 * 561 * 562 * 563 * 564 * @param I interface class (i.e. IUnknown/nsISupports derivant)565 * @param B base class, either COMBase (by default) or COMBaseWithEI584 * Wrapper template class for all interfaces. 585 * 586 * All interface methods named as they are in the original, i.e. starting 587 * with the capital letter. All utility non-interface methods are named 588 * starting with the small letter. Utility methods should be not normally 589 * called by the end-user client application. 590 * 591 * @param I Interface class (i.e. IUnknown/nsISupports derivant). 592 * @param B Base class, either COMBase (by default) or COMBaseWithEI. 566 593 */ 567 594 template <class I, class B = COMBase> … … 573 600 typedef I Iface; 574 601 575 / * constructors & destructor */602 // constructors & destructor 576 603 577 604 CInterface() : mIface (NULL) {} … … 582 609 } 583 610 584 CInterface (const CUnknown &that); 585 586 CInterface (I *i) : mIface (i) { addref (mIface); } 611 CInterface (I *aIface) : mIface (aIface) { addref (mIface); } 587 612 588 613 virtual ~CInterface() { release (mIface); } 589 614 590 / * utility methods */591 592 void createInstance (const CLSID & clsid)615 // utility methods 616 617 void createInstance (const CLSID &aClsId) 593 618 { 594 619 AssertMsg (!mIface, ("Instance is already non-NULL\n")); … … 597 622 #if !defined (VBOX_WITH_XPCOM) 598 623 599 B::mRC = CoCreateInstance ( clsid, NULL, CLSCTX_ALL,624 B::mRC = CoCreateInstance (aClsId, NULL, CLSCTX_ALL, 600 625 _ATL_IIDOF (I), (void **) &mIface); 601 626 … … 605 630 B::mRC = NS_GetComponentManager (getter_AddRefs (manager)); 606 631 if (SUCCEEDED (B::mRC)) 607 B::mRC = manager->CreateInstance ( clsid, nsnull, NS_GET_IID (I),632 B::mRC = manager->CreateInstance (aClsId, nsnull, NS_GET_IID (I), 608 633 (void **) &mIface); 609 634 … … 617 642 } 618 643 619 void attach (I *i) 620 { 621 /* be aware of self (from COM point of view) assignment */ 622 I *old_iface = mIface; 623 mIface = i; 624 addref (mIface); 625 release (old_iface); 644 /** 645 * Attaches to the given foreign interface pointer by querying the own 646 * interface on it. The operation may fail. 647 */ 648 template <class OI> 649 void attach (OI *aIface) 650 { 651 /* be aware of self assignment */ 652 addref (aIface); 653 release (mIface); 654 if (aIface) 655 { 656 mIface = NULL; 657 #if !defined (VBOX_WITH_XPCOM) 658 B::mRC = aIface->QueryInterface (_ATL_IIDOF (I), (void **) &mIface); 659 #else /* !defined (VBOX_WITH_XPCOM) */ 660 B::mRC = aIface->QueryInterface (NS_GET_IID (I), (void **) &mIface); 661 #endif /* !defined (VBOX_WITH_XPCOM) */ 662 } 663 else 664 { 665 mIface = NULL; 666 B::mRC = S_OK; 667 } 668 }; 669 670 /** Specialization of attach() for our own interface I. Never fails. */ 671 void attach (I *aIface) 672 { 673 /* be aware of self assignment */ 674 addref (aIface); 675 release (mIface); 676 mIface = aIface; 626 677 B::mRC = S_OK; 627 678 }; 628 679 629 void attachUnknown (IUnknown *i) 630 { 631 /* be aware of self (from COM point of view) assignment */ 632 I *old_iface = mIface; 633 mIface = NULL; 634 B::mRC = S_OK; 635 if (i) 636 #if !defined (VBOX_WITH_XPCOM) 637 B::mRC = i->QueryInterface (_ATL_IIDOF (I), (void **) &mIface); 638 #else /* !defined (VBOX_WITH_XPCOM) */ 639 B::mRC = i->QueryInterface (NS_GET_IID (I), (void **) &mIface); 640 #endif /* !defined (VBOX_WITH_XPCOM) */ 641 release (old_iface); 642 }; 643 680 /** Detaches from the underlying interface pointer. */ 644 681 void detach() { release (mIface); mIface = NULL; } 645 682 683 /** Returns @c true if not attached to any interface pointer. */ 646 684 bool isNull() const { return mIface == NULL; } 647 685 … … 663 701 bool isReallyOk() const { return !isNull() && B::mRC == S_OK; } 664 702 665 / * utility operators */703 // utility operators 666 704 667 705 CInterface &operator= (const CInterface &that) … … 672 710 } 673 711 674 I *iface() const { return mIface; } 712 CInterface &operator= (I *aIface) 713 { 714 attach (aIface); 715 return *this; 716 } 717 718 /** 719 * Returns the raw interface pointer. Not intended to be used for anything 720 * else but in generated wrappers and for debugging. You've been warned. 721 */ 722 I *raw() const { return mIface; } 675 723 676 724 bool operator== (const CInterface &that) const { return mIface == that.mIface; } 677 725 bool operator!= (const CInterface &that) const { return mIface != that.mIface; } 678 726 679 CInterface &operator= (const CUnknown &that);680 681 727 protected: 682 683 static void addref (I *i) { if (i) i->AddRef(); }684 static void release (I *i) { if (i) i->Release(); }685 728 686 729 mutable I *mIface; … … 693 736 public: 694 737 695 CUnknown() : CInterface <IUnknown, COMBaseWithEI> () {} 696 697 template <class C> 698 explicit CUnknown (const C &that) 699 { 700 mIface = NULL; 701 if (that.mIface) 702 #if !defined (VBOX_WITH_XPCOM) 703 mRC = that.mIface->QueryInterface (_ATL_IIDOF (IUnknown), (void**) &mIface); 704 #else /* !defined (VBOX_WITH_XPCOM) */ 705 mRC = that.mIface->QueryInterface (NS_GET_IID (IUnknown), (void**) &mIface); 706 #endif /* !defined (VBOX_WITH_XPCOM) */ 738 typedef CInterface <IUnknown, COMBaseWithEI> Base; 739 740 CUnknown() {} 741 742 /** Creates an instance given another CInterface-based instance. */ 743 template <class OI, class OB> 744 explicit CUnknown (const CInterface <OI, OB> &that) 745 { 746 attach (that.mIface); 707 747 if (SUCCEEDED (mRC)) 708 748 { 749 /* preserve old error info if any */ 709 750 mRC = that.lastRC(); 710 mErrInfo = that.errorInfo(); 711 } 712 } 713 714 /* specialization for CUnknown */ 715 CUnknown (const CUnknown &that) : CInterface <IUnknown, COMBaseWithEI> () 716 { 717 mIface = that.mIface; 718 addref (mIface); 719 COMBaseWithEI::operator= (that); 720 } 721 722 template <class C> 723 CUnknown &operator= (const C &that) 724 { 725 /* be aware of self (from COM point of view) assignment */ 726 IUnknown *old_iface = mIface; 727 mIface = NULL; 728 mRC = S_OK; 729 #if !defined (VBOX_WITH_XPCOM) 730 if (that.mIface) 731 mRC = that.mIface->QueryInterface (_ATL_IIDOF (IUnknown), (void**) &mIface); 732 #else /* !defined (VBOX_WITH_XPCOM) */ 733 if (that.mIface) 734 mRC = that.mIface->QueryInterface (NS_GET_IID (IUnknown), (void**) &mIface); 735 #endif /* !defined (VBOX_WITH_XPCOM) */ 751 setErrorInfo (that.errorInfo()); 752 } 753 } 754 755 /** Constructor specialization for IUnknown. */ 756 CUnknown (const CUnknown &that) : Base (that) {} 757 758 /** Creates an instance given a foreign interface pointer. */ 759 template <class OI> 760 explicit CUnknown (OI *aIface) 761 { 762 attach (aIface); 763 } 764 765 /** Constructor specialization for IUnknown. */ 766 explicit CUnknown (IUnknown *aIface) : Base (aIface) {} 767 768 /** Assigns from another CInterface-based instance. */ 769 template <class OI, class OB> 770 CUnknown &operator= (const CInterface <OI, OB> &that) 771 { 772 attach (that.mIface); 736 773 if (SUCCEEDED (mRC)) 737 774 { 775 /* preserve old error info if any */ 738 776 mRC = that.lastRC(); 739 mErrInfo = that.errorInfo(); 740 } 741 release (old_iface); 777 setErrorInfo (that.errorInfo()); 778 } 742 779 return *this; 743 780 } 744 781 745 /* specialization for CUnknown*/782 /** Assignment specialization for CUnknown. */ 746 783 CUnknown &operator= (const CUnknown &that) 747 784 { 748 attach (that.mIface); 749 COMBaseWithEI::operator= (that); 785 Base::operator= (that); 750 786 return *this; 751 787 } 752 788 753 /* @internal Used in wrappers. */ 754 IUnknown *&ifaceRef() { return mIface; }; 789 /** Assigns from a foreign interface pointer. */ 790 template <class OI> 791 CUnknown &operator= (OI *aIface) 792 { 793 attach (aIface); 794 return *this; 795 } 796 797 /** Assignment specialization for IUnknown. */ 798 CUnknown &operator= (IUnknown *aIface) 799 { 800 Base::operator= (aIface); 801 return *this; 802 } 803 804 /* @internal Used in generated wrappers. Never use directly. */ 805 IUnknown *&rawRef() { return mIface; }; 755 806 }; 756 757 /* inlined CInterface methods that use CUnknown */758 759 template <class I, class B>760 inline CInterface <I, B>::CInterface (const CUnknown &that)761 : mIface (NULL)762 {763 attachUnknown (that.iface());764 if (SUCCEEDED (B::mRC))765 B::operator= ((B &) that);766 }767 768 template <class I, class B>769 inline CInterface <I, B> &CInterface <I, B>::operator =(const CUnknown &that)770 {771 attachUnknown (that.iface());772 if (SUCCEEDED (B::mRC))773 B::operator= ((B &) that);774 return *this;775 }776 807 777 808 ///////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
r11982 r13580 11 11 12 12 /* 13 Copyright (C) 2006-200 7Sun Microsystems, Inc.13 Copyright (C) 2006-2008 Sun Microsystems, Inc. 14 14 15 15 This file is part of VirtualBox Open Source Edition (OSE), as … … 352 352 </xsl:template> 353 353 354 <xsl:template name="declareAttributes"> 355 356 <xsl:param name="iface"/> 357 358 <xsl:apply-templates select="$iface//attribute[not(@internal='yes')]" mode="declare"/> 359 <xsl:if test="$iface//attribute[not(@internal='yes')]"> 360 <xsl:text>
</xsl:text> 361 </xsl:if> 362 <!-- go to the base interface --> 363 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'"> 364 <xsl:choose> 365 <!-- interfaces within library/if --> 366 <xsl:when test="name(..)='if'"> 367 <xsl:call-template name="declareAttributes"> 368 <xsl:with-param name="iface" select=" 369 preceding-sibling:: 370 *[(self::interface or self::collection) and @name=$iface/@extends] | 371 following-sibling:: 372 *[(self::interface or self::collection) and @name=$iface/@extends] | 373 ../preceding-sibling::if[@target=../@target]/ 374 *[(self::interface or self::collection) and @name=$iface/@extends] | 375 ../following-sibling::if[@target=../@target]/ 376 *[(self::interface or self::collection) and @name=$iface/@extends] 377 "/> 378 </xsl:call-template> 379 </xsl:when> 380 <!-- interfaces within library --> 381 <xsl:otherwise> 382 <xsl:call-template name="declareAttributes"> 383 <xsl:with-param name="iface" select=" 384 preceding-sibling:: 385 *[(self::interface or self::collection) and @name=$iface/@extends] | 386 following-sibling:: 387 *[(self::interface or self::collection) and @name=$iface/@extends] 388 "/> 389 </xsl:call-template> 390 </xsl:otherwise> 391 </xsl:choose> 392 </xsl:if> 393 394 </xsl:template> 395 396 <xsl:template name="declareMethods"> 397 398 <xsl:param name="iface"/> 399 400 <xsl:apply-templates select="$iface//method[not(@internal='yes')]" mode="declare"/> 401 <xsl:if test="$iface//method[not(@internal='yes')]"> 402 <xsl:text>
</xsl:text> 403 </xsl:if> 404 <!-- go to the base interface --> 405 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'"> 406 <xsl:choose> 407 <!-- interfaces within library/if --> 408 <xsl:when test="name(..)='if'"> 409 <xsl:call-template name="declareMethods"> 410 <xsl:with-param name="iface" select=" 411 preceding-sibling:: 412 *[(self::interface or self::collection) and @name=$iface/@extends] | 413 following-sibling:: 414 *[(self::interface or self::collection) and @name=$iface/@extends] | 415 ../preceding-sibling::if[@target=../@target]/ 416 *[(self::interface or self::collection) and @name=$iface/@extends] | 417 ../following-sibling::if[@target=../@target]/ 418 *[(self::interface or self::collection) and @name=$iface/@extends] 419 "/> 420 </xsl:call-template> 421 </xsl:when> 422 <!-- interfaces within library --> 423 <xsl:otherwise> 424 <xsl:call-template name="declareMethods"> 425 <xsl:with-param name="iface" select=" 426 preceding-sibling:: 427 *[(self::interface or self::collection) and @name=$iface/@extends] | 428 following-sibling:: 429 *[(self::interface or self::collection) and @name=$iface/@extends] 430 "/> 431 </xsl:call-template> 432 </xsl:otherwise> 433 </xsl:choose> 434 </xsl:if> 435 436 </xsl:template> 437 354 438 <xsl:template name="declareMembers"> 355 439 … … 359 443 <xsl:text> C</xsl:text> 360 444 <xsl:value-of select="substring(@name,2)"/> 361 <xsl:text> () : Base () {}
</xsl:text> 362 <!-- constructor taking CUnknown --> 445 <xsl:text> () {}

</xsl:text> 446 <!-- constructor taking CWhatever --> 447 <xsl:text> template <class OI, class OB> explicit C</xsl:text> 448 <xsl:value-of select="substring(@name,2)"/> 449 <xsl:text> (const CInterface <OI, OB> & that) 450 { 451 attach (that.raw()); 452 if (SUCCEEDED (mRC)) 453 { 454 mRC = that.lastRC(); 455 setErrorInfo (that.errorInfo()); 456 } 457 } 458 </xsl:text> 459 <xsl:text>
</xsl:text> 460 <!-- specialization for ourselves (copy constructor) --> 363 461 <xsl:text> C</xsl:text> 364 462 <xsl:value-of select="substring(@name,2)"/> 365 <xsl:text> (const CUnknown & that) : Base (that) {}
</xsl:text> 366 <!-- constructor taking raw iface pointer --> 367 <xsl:text> C</xsl:text> 463 <xsl:text> (const C</xsl:text> 464 <xsl:value-of select="substring(@name,2)"/> 465 <xsl:text> & that) : Base (that) {}

</xsl:text> 466 <!-- constructor taking a raw iface pointer --> 467 <xsl:text> template <class OI> explicit C</xsl:text> 468 <xsl:value-of select="substring(@name,2)"/> 469 <xsl:text> (OI * aIface) { attach (aIface); }

</xsl:text> 470 <!-- specialization for ourselves --> 471 <xsl:text> explicit C</xsl:text> 368 472 <xsl:value-of select="substring(@name,2)"/> 369 473 <xsl:text> (</xsl:text> 370 474 <xsl:value-of select="@name"/> 371 <xsl:text> *i) : Base (i) {}
</xsl:text> 372 <!-- assignment taking CUnknown --> 475 <xsl:text> * aIface) : Base (aIface) {}

</xsl:text> 476 <!-- assignment taking CWhatever --> 477 <xsl:text> template <class OI, class OB> C</xsl:text> 478 <xsl:value-of select="substring(@name,2)"/> 479 <xsl:text> & operator = (const CInterface <OI, OB> & that) 480 { 481 attach (that.raw()); 482 if (SUCCEEDED (mRC)) 483 { 484 mRC = that.lastRC(); 485 setErrorInfo (that.errorInfo()); 486 } 487 return *this; 488 } 489 </xsl:text> 490 <xsl:text>
</xsl:text> 491 <!-- specialization for ourselves --> 373 492 <xsl:text> C</xsl:text> 374 493 <xsl:value-of select="substring(@name,2)"/> 375 <xsl:text> & operator = (const C Unknown & that)
 {
 return (C</xsl:text>494 <xsl:text> & operator = (const C</xsl:text> 376 495 <xsl:value-of select="substring(@name,2)"/> 377 <xsl:text> &) Base::operator = (that);
 }

</xsl:text> 496 <xsl:text> & that) 497 { 498 Base::operator= (that); 499 return *this; 500 } 501 </xsl:text> 502 <xsl:text>
</xsl:text> 503 <!-- assignment taking a raw iface pointer --> 504 <xsl:text> template <class OI> C</xsl:text> 505 <xsl:value-of select="substring(@name,2)"/> 506 <xsl:text> & operator = (OI * aIface) 507 { 508 attach (aIface); 509 return *this; 510 } 511 </xsl:text> 512 <xsl:text>
</xsl:text> 513 <!-- specialization for ourselves --> 514 <xsl:text> C</xsl:text> 515 <xsl:value-of select="substring(@name,2)"/> 516 <xsl:text> & operator = (</xsl:text> 517 <xsl:value-of select="@name"/> 518 <xsl:text> * aIface) 519 { 520 Base::operator= (aIface); 521 return *this; 522 } 523 </xsl:text> 524 <xsl:text>
</xsl:text> 378 525 379 526 <xsl:text> // attributes (properties)

</xsl:text> 380 <xsl:apply-templates select=".//attribute[not(@internal='yes')]" mode="declare"/> 381 <xsl:if test=".//attribute[not(@internal='yes')]"> 382 <xsl:text>
</xsl:text> 383 </xsl:if> 527 <xsl:call-template name="declareAttributes"> 528 <xsl:with-param name="iface" select="."/> 529 </xsl:call-template> 384 530 385 531 <xsl:text> // methods

</xsl:text> 386 <xsl:apply-templates select=".//method[not(@internal='yes')]" mode="declare"/> 387 <xsl:if test=".//method[not(@internal='yes')]"> 388 <xsl:text>
</xsl:text> 389 </xsl:if> 532 <xsl:call-template name="declareMethods"> 533 <xsl:with-param name="iface" select="."/> 534 </xsl:call-template> 390 535 391 536 <xsl:text> // friend wrappers

</xsl:text> … … 561 706 </xsl:template> 562 707 708 <xsl:template name="defineAttributes"> 709 710 <xsl:param name="iface"/> 711 712 <xsl:apply-templates select="$iface//attribute[not(@internal='yes')]" mode="define"> 713 <xsl:with-param name="namespace" select="."/> 714 </xsl:apply-templates> 715 716 <!-- go to the base interface --> 717 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'"> 718 <xsl:choose> 719 <!-- interfaces within library/if --> 720 <xsl:when test="name(..)='if'"> 721 <xsl:call-template name="defineAttributes"> 722 <xsl:with-param name="iface" select=" 723 preceding-sibling:: 724 *[(self::interface or self::collection) and @name=$iface/@extends] | 725 following-sibling:: 726 *[(self::interface or self::collection) and @name=$iface/@extends] | 727 ../preceding-sibling::if[@target=../@target]/ 728 *[(self::interface or self::collection) and @name=$iface/@extends] | 729 ../following-sibling::if[@target=../@target]/ 730 *[(self::interface or self::collection) and @name=$iface/@extends] 731 "/> 732 </xsl:call-template> 733 </xsl:when> 734 <!-- interfaces within library --> 735 <xsl:otherwise> 736 <xsl:call-template name="defineAttributes"> 737 <xsl:with-param name="iface" select=" 738 preceding-sibling:: 739 *[(self::interface or self::collection) and @name=$iface/@extends] | 740 following-sibling:: 741 *[(self::interface or self::collection) and @name=$iface/@extends] 742 "/> 743 </xsl:call-template> 744 </xsl:otherwise> 745 </xsl:choose> 746 </xsl:if> 747 748 </xsl:template> 749 750 <xsl:template name="defineMethods"> 751 752 <xsl:param name="iface"/> 753 754 <xsl:apply-templates select="$iface//method[not(@internal='yes')]" mode="define"> 755 <xsl:with-param name="namespace" select="."/> 756 </xsl:apply-templates> 757 758 <!-- go to the base interface --> 759 <xsl:if test="$iface/@extends and $iface/@extends!='$unknown'"> 760 <xsl:choose> 761 <!-- interfaces within library/if --> 762 <xsl:when test="name(..)='if'"> 763 <xsl:call-template name="defineMethods"> 764 <xsl:with-param name="iface" select=" 765 preceding-sibling:: 766 *[(self::interface or self::collection) and @name=$iface/@extends] | 767 following-sibling:: 768 *[(self::interface or self::collection) and @name=$iface/@extends] | 769 ../preceding-sibling::if[@target=../@target]/ 770 *[(self::interface or self::collection) and @name=$iface/@extends] | 771 ../following-sibling::if[@target=../@target]/ 772 *[(self::interface or self::collection) and @name=$iface/@extends] 773 "/> 774 </xsl:call-template> 775 </xsl:when> 776 <!-- interfaces within library --> 777 <xsl:otherwise> 778 <xsl:call-template name="defineMethods"> 779 <xsl:with-param name="iface" select=" 780 preceding-sibling:: 781 *[(self::interface or self::collection) and @name=$iface/@extends] | 782 following-sibling:: 783 *[(self::interface or self::collection) and @name=$iface/@extends] 784 "/> 785 </xsl:call-template> 786 </xsl:otherwise> 787 </xsl:choose> 788 </xsl:if> 789 790 </xsl:template> 791 563 792 <xsl:template name="defineMembers"> 564 <xsl:apply-templates select=".//attribute[not(@internal='yes')]" mode="define"/> 565 <xsl:apply-templates select=".//method[not(@internal='yes')]" mode="define"/> 793 <xsl:call-template name="defineAttributes"> 794 <xsl:with-param name="iface" select="."/> 795 </xsl:call-template> 796 <xsl:call-template name="defineMethods"> 797 <xsl:with-param name="iface" select="."/> 798 </xsl:call-template> 566 799 </xsl:template> 567 800 568 801 <!-- attribute definitions --> 569 802 <xsl:template match="interface//attribute | collection//attribute" mode="define"> 803 804 <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/> 805 570 806 <xsl:apply-templates select="parent::node()" mode="begin"/> 571 807 <xsl:apply-templates select="@if" mode="begin"/> … … 573 809 <xsl:with-param name="return" select="."/> 574 810 <xsl:with-param name="define" select="'yes'"/> 811 <xsl:with-param name="namespace" select="$namespace"/> 575 812 </xsl:call-template> 576 813 <xsl:if test="not(@readonly='yes')"> … … 578 815 <xsl:with-param name="return" select="''"/> 579 816 <xsl:with-param name="define" select="'yes'"/> 817 <xsl:with-param name="namespace" select="$namespace"/> 580 818 </xsl:call-template> 581 819 </xsl:if> … … 583 821 <xsl:apply-templates select="parent::node()" mode="end"/> 584 822 <xsl:text>
</xsl:text> 823 585 824 </xsl:template> 586 825 587 826 <!-- method definitions --> 588 827 <xsl:template match="interface//method | collection//method" mode="define"> 828 829 <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/> 830 589 831 <xsl:apply-templates select="parent::node()" mode="begin"/> 590 832 <xsl:apply-templates select="@if" mode="begin"/> 591 833 <xsl:call-template name="composeMethod"> 592 834 <xsl:with-param name="define" select="'yes'"/> 835 <xsl:with-param name="namespace" select="$namespace"/> 593 836 </xsl:call-template> 594 837 <xsl:apply-templates select="@if" mode="end"/> 595 838 <xsl:apply-templates select="parent::node()" mode="end"/> 596 839 <xsl:text>
</xsl:text> 840 597 841 </xsl:template> 598 842 … … 622 866 * declaration, or 623 867 * empty string to produce method declaration only (w/o body) 868 * @param namespace 869 * actual interface node for which this method is being defined 870 * (necessary to properly set a class name for inherited methods). 871 * If not specified, will default to the parent interface/collection 872 * node of the method being defined. 624 873 --> 625 874 <xsl:template name="composeMethod"> 626 875 <xsl:param name="return" select="param[@dir='return']"/> 627 876 <xsl:param name="define" select="''"/> 628 <xsl: variablename="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>877 <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/> 629 878 <xsl:choose> 630 879 <!-- no return value --> … … 1024 1273 <xsl:choose> 1025 1274 <xsl:when test="@type='$unknown'"> 1026 <xsl:text>. iface()</xsl:text>1275 <xsl:text>.raw()</xsl:text> 1027 1276 </xsl:when> 1028 1277 <xsl:otherwise> … … 1038 1287 <xsl:choose> 1039 1288 <xsl:when test="@type='$unknown'"> 1040 <xsl:text>. ifaceRef()</xsl:text>1289 <xsl:text>.rawRef()</xsl:text> 1041 1290 </xsl:when> 1042 1291 <xsl:otherwise> … … 1545 1794 <xsl:text>> </xsl:text> 1546 1795 </xsl:when> 1796 <!-- GUID is special too --> 1797 <xsl:when test="@type='uuid'"> 1798 <xsl:text> com::SafeGUIDArray </xsl:text> 1799 </xsl:when> 1800 <!-- everything else is not --> 1547 1801 <xsl:otherwise> 1548 1802 <xsl:text> com::SafeArray <</xsl:text> -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r10395 r13580 112 112 void machineStateChanged (KMachineState state); 113 113 void additionsStateChanged (const QString &, bool, bool, bool); 114 void media Changed (VBoxDefs::DiskType aType);114 void mediaDriveChanged (VBoxDefs::MediaType aType); 115 115 void networkStateChange(); 116 116 void usbStateChange(); … … 241 241 bool mAutoresizeGuest : 1; 242 242 243 /** 243 /** 244 244 * This flag indicates whether the last console resize should trigger 245 245 * a size hint to the guest. This is important particularly when -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r9036 r13580 178 178 void updateNetworkAdarptersState(); 179 179 void updateUsbState(); 180 void updateMedia State (VBoxDefs::DiskType aType);180 void updateMediaDriveState (VBoxDefs::MediaType aType); 181 181 void updateSharedFoldersState(); 182 182 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r12627 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 106 106 struct VBoxDefs 107 107 { 108 /** Disk image type. */ 109 enum DiskType { InvalidType, HD = 0x01, CD = 0x02, FD = 0x04 }; 108 /** Media type. */ 109 enum MediaType 110 { 111 MediaType_Invalid, 112 MediaType_HardDisk, 113 MediaType_DVD, 114 MediaType_Floppy, 115 MediaType_All 116 }; 110 117 111 118 /** VM display rendering mode. */ … … 126 133 MachineStateChangeEventType, 127 134 AdditionsStateChangeEventType, 128 Media ChangeEventType,135 MediaDriveChangeEventType, 129 136 MachineDataChangeEventType, 130 137 MachineRegisteredEventType, … … 138 145 RuntimeErrorEventType, 139 146 ModifierKeyChangeEventType, 140 EnumerateMediaEventType,147 MediaEnumEventType, 141 148 #if defined (Q_WS_WIN) 142 149 ShellExecuteEventType, -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r8155 r13580 50 50 //////////////////////////////////////////////////////////////////////////////// 51 51 52 /** Simple media descriptor type. */ 53 struct VBoxMedia 52 /** 53 * Media descriptor for the GUI. 54 * 55 * Maintains the results of the last state (accessibility) check and precomposes 56 * string parameters such as location, size which can be used in various GUI 57 * controls. 58 * 59 * Many getter methods take the boolean @a aNoDiffs argument. Unless explicitly 60 * stated otherwise, this argument, when set to @c true, will cause the 61 * corresponding property of this object's root medium to be returned instead of 62 * its own one. This is useful when hard disk media is represented in the 63 * user-friendly "don't show diffs" mode. For non-hard disk media, the value of 64 * this argument is irrelevant because the root object for such medium is 65 * the medium itself. 66 * 67 * Note that this class "abuses" the KMediaState_NotCreated state value to 68 * indicate that the accessibility check of the given medium (see 69 * #blockAndQueryState()) has not been done yet and therefore some parameters 70 * such as #size() are meaningless because they can be read only from the 71 * accessible medium. The real KMediaState_NotCreated state is not necessary 72 * because this class is only used with created (existing) media. 73 */ 74 class VBoxMedium 54 75 { 55 enum Status { Unknown, Ok, Error, Inaccessible }; 56 57 VBoxMedia() : type (VBoxDefs::InvalidType), status (Ok) {} 58 59 VBoxMedia (const CUnknown &d, VBoxDefs::DiskType t, Status s) 60 : disk (d), type (t), status (s) {} 61 62 CUnknown disk; 63 VBoxDefs::DiskType type; 64 Status status; 76 public: 77 78 /** 79 * Creates a null medium descriptor which is not associated with any medium. 80 * The state field is set to KMediaState_NotCreated. 81 */ 82 VBoxMedium() 83 : mType (VBoxDefs::MediaType_Invalid) 84 , mState (KMediaState_NotCreated) 85 , mIsReadOnly (false), mIsUsedInSnapshots (false) 86 , mParent (NULL) {} 87 88 /** 89 * Creates a media descriptor associated with the given medium. 90 * 91 * The state field remain KMediaState_NotCreated until #blockAndQueryState() 92 * is called. All precomposed strings are filled up by implicitly calling 93 * #refresh(), see the #refresh() details for more info. 94 * 95 * One of the hardDisk, dvdImage, or floppyImage members is assigned from 96 * aMedium according to aType. @a aParent must be always NULL for non-hard 97 * disk media. 98 */ 99 VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType, 100 VBoxMedium *aParent = NULL) 101 : mMedium (aMedium), mType (aType) 102 , mState (KMediaState_NotCreated) 103 , mIsReadOnly (false), mIsUsedInSnapshots (false) 104 , mParent (aParent) { init(); } 105 106 /** 107 * Similar to the other non-null constructor but sets the media state to 108 * @a aState. Suitable when the media state is known such as right after 109 * creation. 110 */ 111 VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType, 112 KMediaState aState) 113 : mMedium (aMedium), mType (aType) 114 , mState (aState) 115 , mIsReadOnly (false), mIsUsedInSnapshots (false) 116 , mParent (NULL) { init(); } 117 118 void blockAndQueryState(); 119 void refresh(); 120 121 const CMedium &medium() const { return mMedium; }; 122 123 VBoxDefs::MediaType type() const { return mType; } 124 125 /** 126 * Media state. In "don't show diffs" mode, this is the worst state (in 127 * terms of inaccessibility) detected on the given hard disk chain. 128 * 129 * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode. 130 */ 131 KMediaState state (bool aNoDiffs = false) const 132 { 133 unconst (this)->checkNoDiffs (aNoDiffs); 134 return aNoDiffs ? mNoDiffs.state : mState; 135 } 136 137 QString lastAccessError() const { return mLastAccessError; } 138 139 /** 140 * Result of the last blockAndQueryState() call. Will indicate an error and 141 * contain a proper error info if the last state check fails. In "don't show 142 * diffs" mode, this is the worst result (in terms of inaccessibility) 143 * detected on the given hard disk chain. 144 * 145 * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode. 146 */ 147 const COMResult &result (bool aNoDiffs = false) const 148 { 149 unconst (this)->checkNoDiffs (aNoDiffs); 150 return aNoDiffs ? mNoDiffs.result : mResult; 151 } 152 153 const CHardDisk2 &hardDisk() const { return mHardDisk; } 154 const CDVDImage2 &dvdImage() const { return mDVDImage; } 155 const CFloppyImage2 &floppyImage() const { return mFloppyImage; } 156 157 QUuid id() const { return mId; } 158 159 QString location (bool aNoDiffs = false) const 160 { return aNoDiffs ? root().mLocation : mLocation; } 161 QString name (bool aNoDiffs = false) const 162 { return aNoDiffs ? root().mName : mName; } 163 164 QString size (bool aNoDiffs = false) const 165 { return aNoDiffs ? root().mSize : mSize; } 166 167 QString hardDiskFormat (bool aNoDiffs = false) const 168 { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; } 169 QString hardDiskType (bool aNoDiffs = false) const 170 { return aNoDiffs ? root().mHardDiskType : mHardDiskType; } 171 QString logicalSize (bool aNoDiffs = false) const 172 { return aNoDiffs ? root().mLogicalSize : mLogicalSize; } 173 174 QString usage (bool aNoDiffs = false) const 175 { return aNoDiffs ? root().mUsage : mUsage; } 176 177 /** 178 * Returns @c true if this medium is read-only (either because it is 179 * Immutable or because it has child hard disks). Read-only media can only 180 * be attached indirectly. 181 */ 182 bool isReadOnly() const { return mIsReadOnly; } 183 184 /** 185 * Returns @c true if this medium is attached to any VM (in the current 186 * state or in a snapshot) in which case #usage() will contain a string with 187 * comma-sparated VM names (with snapshot names, if any, in parenthesis). 188 */ 189 bool isUsed() const { return !mUsage.isNull(); } 190 191 /** 192 * Returns @c true if this medium is attached to any VM in any snapshot. 193 * which case #usage() will contain a string with comma-sparated VM names. 194 */ 195 bool isUsedInSnapshots() const { return mIsUsedInSnapshots; } 196 197 /** 198 * Returns @c true if this medium is attached to the given machine in the 199 * current state. 200 */ 201 bool isAttachedInCurStateTo (const QUuid &aMachineId) const 202 { return mCurStateMachineIds.findIndex (aMachineId) >= 0; } 203 204 /** 205 * Returns a vector of IDs of all machines this medium is attached 206 * to in their current state (i.e. excluding snapshots). 207 */ 208 const QValueList <QUuid> &curStateMachineIds() const 209 { return mCurStateMachineIds; } 210 211 /** 212 * Returns a parent medium. For non-hard disk media, this is always NULL. 213 */ 214 VBoxMedium *parent() const { return mParent; } 215 216 VBoxMedium &root() const; 217 218 QString toolTip(bool aNoDiffs = false, bool aCheckRO = false) const; 219 QPixmap icon (bool aNoDiffs = false, bool aCheckRO = false) const; 220 221 /** Shortcut to <tt>#toolTip (aNoDiffs, true)</tt>. */ 222 QString toolTipCheckRO (bool aNoDiffs = false) const 223 { return toolTip (aNoDiffs, true); } 224 225 /** Shortcut to <tt>#icon (aNoDiffs, true)</tt>. */ 226 QPixmap iconCheckRO (bool aNoDiffs = false) const 227 { return icon (aNoDiffs, true); } 228 229 QString details (bool aNoDiffs = false, bool aPredictDiff = false, 230 bool aUseHTML = false) const; 231 232 /** Shortcut to <tt>#details (aNoDiffs, aPredictDiff, true)</tt>. */ 233 QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const 234 { return details (aNoDiffs, aPredictDiff, true); } 235 236 /** Returns @c true if this media descriptor is a null object. */ 237 bool isNull() const { return mMedium.isNull(); } 238 239 private: 240 241 void init(); 242 243 void checkNoDiffs (bool aNoDiffs); 244 245 CMedium mMedium; 246 247 VBoxDefs::MediaType mType; 248 249 KMediaState mState; 250 QString mLastAccessError; 251 COMResult mResult; 252 253 CHardDisk2 mHardDisk; 254 CDVDImage2 mDVDImage; 255 CFloppyImage2 mFloppyImage; 256 257 QUuid mId; 258 QString mLocation; 259 QString mName; 260 QString mSize; 261 262 QString mHardDiskFormat; 263 QString mHardDiskType; 264 QString mLogicalSize; 265 266 QString mUsage; 267 QString mToolTip; 268 269 bool mIsReadOnly : 1; 270 bool mIsUsedInSnapshots : 1; 271 272 QValueList <QUuid> mCurStateMachineIds; 273 274 VBoxMedium *mParent; 275 276 /** 277 * Used to override some attributes in the user-friendly "don't show diffs" 278 * mode. 279 */ 280 struct NoDiffs 281 { 282 NoDiffs() : isSet (false), state (KMediaState_NotCreated) {} 283 284 bool isSet : 1; 285 286 KMediaState state; 287 COMResult result; 288 QString toolTip; 289 } 290 mNoDiffs; 65 291 }; 66 292 67 typedef QValueList <VBoxMedi a> VBoxMediaList;293 typedef QValueList <VBoxMedium> VBoxMediaList; 68 294 69 295 // VirtualBox callback events … … 255 481 } 256 482 257 QString toString (KHardDiskStorageType t) const 258 { 259 AssertMsg (!diskStorageTypes [t].isNull(), ("No text for %d", t)); 260 return diskStorageTypes [t]; 483 /** 484 * Similar to toString (KHardDiskType), but returns 'Differencing' for 485 * normal hard disks that have a parent. 486 */ 487 QString hardDiskTypeString (const CHardDisk2 &aHD) const 488 { 489 if (!aHD.GetParent().isNull()) 490 { 491 Assert (aHD.GetType() == KHardDiskType_Normal); 492 return diskTypes_Differencing; 493 } 494 return toString (aHD.GetType()); 261 495 } 262 496 … … 331 565 } 332 566 333 /**334 * Similar to toString (KHardDiskType), but returns 'Differencing'335 * for normal hard disks that have a parent hard disk.336 */337 QString hardDiskTypeString (const CHardDisk &aHD) const338 {339 if (!aHD.GetParent().isNull())340 {341 Assert (aHD.GetType() == KHardDiskType_Normal);342 return tr ("Differencing", "hard disk");343 }344 return toString (aHD.GetType());345 }346 347 567 QString toString (KDeviceType t) const 348 568 { … … 436 656 } 437 657 658 QPixmap warningIcon() const { return mWarningIcon; } 659 QPixmap errorIcon() const { return mErrorIcon; } 660 438 661 /* details generators */ 439 662 440 QString details (const CHardDisk &aHD, bool aPredict = false, 441 bool aDoRefresh = true); 663 QString details (const CHardDisk2 &aHD, bool aPredictDiff); 442 664 443 665 QString details (const CUSBDevice &aDevice) const; 444 666 QString toolTip (const CUSBDevice &aDevice) const; 445 667 446 QString prepareFileNameForHTML (const QString &fn) const; 447 448 QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks, 449 bool aDoRefresh = true); 668 QString detailsReport (const CMachine &aMachine, bool aIsNewVM, 669 bool aWithLinks); 450 670 451 671 /* VirtualBox helpers */ … … 467 687 468 688 /** 469 * Returns a list of all currently registered media. This list is used 470 * to globally track the accessiblity state of all media on a dedicated 471 * thread. This the list is initially empty (before the first enumeration 472 * process is started using #startEnumeratingMedia()). 473 */ 474 const VBoxMediaList ¤tMediaList() const { return media_list; } 689 * Returns a list of all currently registered media. This list is used to 690 * globally track the accessiblity state of all media on a dedicated thread. 691 * 692 * Note that the media list is initially empty (i.e. before the enumeration 693 * process is started for the first time using #startEnumeratingMedia()). 694 * See #startEnumeratingMedia() for more information about how meida are 695 * sorted in the returned list. 696 */ 697 const VBoxMediaList ¤tMediaList() const { return mMediaList; } 475 698 476 699 /** Returns true if the media enumeration is in progress. */ 477 bool isMediaEnumerationStarted() const { return media_enum_thread != NULL; } 478 479 void addMedia (const VBoxMedia &); 480 void updateMedia (const VBoxMedia &); 481 void removeMedia (VBoxDefs::DiskType, const QUuid &); 482 483 bool findMedia (const CUnknown &, VBoxMedia &) const; 700 bool isMediaEnumerationStarted() const { return mMediaEnumThread != NULL; } 701 702 void addMedium (const VBoxMedium &); 703 void updateMedium (const VBoxMedium &); 704 void removeMedium (VBoxDefs::MediaType, const QUuid &); 705 706 bool findMedium (const CMedium &, VBoxMedium &) const; 707 708 /** Compact version of #findMediumTo(). Asserts if not found. */ 709 VBoxMedium getMedium (const CMedium &aObj) const 710 { 711 VBoxMedium medium; 712 if (!findMedium (aObj, medium)) 713 AssertFailed(); 714 return medium; 715 } 484 716 485 717 /* various helpers */ … … 526 758 static QString formatSize (Q_UINT64, int aMode = 0); 527 759 760 static QString locationForHTML (const QString &aFileName); 761 528 762 static QString highlight (const QString &aStr, bool aToolTip = false); 529 763 … … 547 781 static QString removeAccelMark (const QString &aText); 548 782 783 static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2); 784 549 785 static QWidget *findWidget (QWidget *aParent, const char *aName, 550 786 const char *aClassName = NULL, … … 554 790 555 791 /** 556 * Emitted at the beginning of the enumeration process started557 * by#startEnumeratingMedia().792 * Emitted at the beginning of the enumeration process started by 793 * #startEnumeratingMedia(). 558 794 */ 559 795 void mediaEnumStarted(); 560 796 561 797 /** 562 * Emitted when a new media item from the list has updated563 * itsaccessibility state.564 */ 565 void medi aEnumerated (const VBoxMedia &aMedia, int aIndex);566 567 /** 568 * Emitted at the end of the enumeration process started569 * by#startEnumeratingMedia(). The @a aList argument is passed for570 * 798 * Emitted when a new medium item from the list has updated its 799 * accessibility state. 800 */ 801 void mediumEnumerated (const VBoxMedium &aMedum, int aIndex); 802 803 /** 804 * Emitted at the end of the enumeration process started by 805 * #startEnumeratingMedia(). The @a aList argument is passed for 806 * convenience, it is exactly the same as returned by #currentMediaList(). 571 807 */ 572 808 void mediaEnumFinished (const VBoxMediaList &aList); 573 809 574 810 /** Emitted when a new media is added using #addMedia(). */ 575 void medi aAdded (const VBoxMedia&);811 void mediumAdded (const VBoxMedium &); 576 812 577 813 /** Emitted when the media is updated using #updateMedia(). */ 578 void medi aUpdated (const VBoxMedia&);814 void mediumUpdated (const VBoxMedium &); 579 815 580 816 /** Emitted when the media is removed using #removeMedia(). */ 581 void medi aRemoved (VBoxDefs::DiskType, const QUuid &);817 void mediumRemoved (VBoxDefs::MediaType, const QUuid &); 582 818 583 819 /* signals emitted when the VirtualBox callback is called by the server … … 626 862 QUuid vmUuid; 627 863 628 QThread *m edia_enum_thread;629 VBoxMediaList m edia_list;864 QThread *mMediaEnumThread; 865 VBoxMediaList mMediaList; 630 866 631 867 VBoxDefs::RenderMode vm_render_mode; … … 657 893 QStringVector sessionStates; 658 894 QStringVector deviceTypes; 895 659 896 QStringVector storageBuses; 660 897 QStringVector storageBusDevices; 661 898 QStringVector storageBusChannels; 899 662 900 QStringVector diskTypes; 663 QStringVector diskStorageTypes; 901 QString diskTypes_Differencing; 902 664 903 QStringVector vrdpAuthTypes; 665 904 QStringVector portModeTypes; … … 674 913 675 914 QString mUserDefinedPortName; 915 916 QPixmap mWarningIcon, mErrorIcon; 676 917 677 918 mutable bool detailReportTemplatesReady; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMediaComboBox.h
r8418 r13580 27 27 28 28 #include <qcombobox.h> 29 #include <qvaluelist.h> 29 30 30 31 class QListBoxItem; … … 36 37 public: 37 38 38 VBoxMediaComboBox (QWidget *aParent = 0, const char *aName = 0, 39 int aType = 0, bool aUseEmptyItem = false); 39 typedef QMap <QUuid, QUuid> BaseToDiffMap; 40 41 VBoxMediaComboBox (QWidget *aParent, const char *aName, 42 VBoxDefs::MediaType aType, QUuid aMachineId = QUuid()); 40 43 ~VBoxMediaComboBox() {} 41 44 42 void refresh(); 43 void setUseEmptyItem (bool); 44 void setBelongsTo (const QUuid &); 45 QUuid getId (int aId = -1); 46 QUuid getBelongsTo(); 47 void setCurrentItem (const QUuid &); 48 void setType (int); 45 void refresh(); 46 void repopulate(); 47 48 QUuid id (int = -1); 49 QString location (int = -1); 50 51 void setCurrentItem (const QUuid &); 52 void setType (VBoxDefs::MediaType); 53 54 void setShowDiffs (bool aShowDiffs); 55 bool showDiffs() const { return mShowDiffs; } 49 56 50 57 protected slots: 51 58 52 59 void mediaEnumStarted(); 53 void medi aEnumerated (const VBoxMedia&, int);54 void medi aAdded (const VBoxMedia&);55 void medi aUpdated (const VBoxMedia&);56 void medi aRemoved (VBoxDefs::DiskType, const QUuid &);60 void mediumEnumerated (const VBoxMedium &, int); 61 void mediumAdded (const VBoxMedium &); 62 void mediumUpdated (const VBoxMedium &); 63 void mediumRemoved (VBoxDefs::MediaType, const QUuid &); 57 64 void processOnItem (QListBoxItem *); 58 65 void processActivated (int); … … 60 67 protected: 61 68 69 void addNoMediaItem(); 70 62 71 void updateToolTip (int); 63 void processMedia (const VBoxMedia &);64 void processHdMedia (const VBoxMedia &);65 void processCdMedia (const VBoxMedia &);66 void processFdMedia (const VBoxMedia &);67 void appendItem (const QString &, const QUuid &,68 const QString &, QPixmap *);69 void replaceItem (int, const QString &,70 const QString &, QPixmap *);71 void updateShortcut (const QString &, const QUuid &, const QString &,72 VBoxMedia::Status);73 72 74 int mType; 75 QStringList mUuidList; 76 QStringList mTipList; 77 QUuid mMachineId; 78 QUuid mRequiredId; 79 bool mUseEmptyItem; 80 QPixmap mPmInacc; 81 QPixmap mPmError; 73 void appendItem (const VBoxMedium &); 74 void replaceItem (int, const VBoxMedium &); 75 76 bool findMediaIndex (const QUuid &aId, size_t &aIndex); 77 78 VBoxDefs::MediaType mType; 79 80 /** Obtruncated VBoxMedium structure. */ 81 struct Medium 82 { 83 Medium() {} 84 Medium (const QUuid &aId, const QString &aLocation, 85 const QString aToolTip) 86 : id (aId), location (aLocation), toolTip (aToolTip) {} 87 88 QUuid id; 89 QString location; 90 QString toolTip; 91 }; 92 93 typedef QValueVector <Medium> Media; 94 Media mMedia; 95 96 QUuid mLastId; 97 98 bool mShowDiffs : 1; 99 100 QUuid mMachineId; 82 101 }; 83 102 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r13374 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 29 29 #include <qobject.h> 30 30 31 class VBoxMedium; 32 31 33 class QProcess; 32 34 … … 147 149 void cannotSaveGlobalConfig (const CVirtualBox &vbox); 148 150 void cannotSetSystemProperties (const CSystemProperties &props); 149 void cannotAccessUSB (const COMBase &obj);151 void cannotAccessUSB (const COMBaseWithEI &obj); 150 152 151 153 void cannotCreateMachine (const CVirtualBox &vbox, … … 175 177 176 178 void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath); 177 void cannotDiscardSnapshot (const CConsole &console, const CSnapshot &snapshot); 178 void cannotDiscardSnapshot (const CProgress &progress, const CSnapshot &snapshot); 179 void cannotDiscardSnapshot (const CConsole &aConsole, 180 const QString &aSnapshotName); 181 void cannotDiscardSnapshot (const CProgress &aProgress, 182 const QString &aSnapshotName); 179 183 void cannotDiscardCurrentState (const CConsole &console); 180 184 void cannotDiscardCurrentState (const CProgress &progress); … … 192 196 bool confirmDiscardSavedState (const CMachine &machine); 193 197 194 bool confirmReleaseImage (QWidget *parent, const QString &usage); 195 196 void sayCannotOverwriteHardDiskImage (QWidget *parent, const QString &src); 197 int confirmHardDiskImageDeletion (QWidget *parent, const QString &src); 198 void cannotDeleteHardDiskImage (QWidget *parent, const CVirtualDiskImage &vdi); 199 200 bool confirmHardDiskUnregister (QWidget *parent, const QString &src); 198 bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium, 199 const QString &aUsage); 200 201 bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium); 202 203 void sayCannotOverwriteHardDiskStorage (QWidget *aParent, 204 const QString &aLocation); 205 int confirmDeleteHardDiskStorage (QWidget *aParent, 206 const QString &aLocation); 207 void cannotDeleteHardDiskStorage (QWidget *aParent, const CHardDisk2 &aHD, 208 const CProgress &aProgress); 201 209 202 210 int confirmDetachSATASlots (QWidget *aParent); 203 211 int confirmRunNewHDWzdOrVDM (QWidget *aParent); 204 212 205 void cannotCreateHardDiskImage ( 206 QWidget *parent, const CVirtualBox &vbox, const QString &src, 207 const CVirtualDiskImage &vdi, const CProgress &progress); 208 void cannotAttachHardDisk (QWidget *parent, const CMachine &m, const QUuid &id, 209 KStorageBus bus, LONG channel, LONG dev); 210 void cannotDetachHardDisk (QWidget *parent, const CMachine &m, 211 KStorageBus bus, LONG channel, LONG dev); 212 void cannotRegisterMedia (QWidget *parent, const CVirtualBox &vbox, 213 VBoxDefs::DiskType type, const QString &src); 214 void cannotUnregisterMedia (QWidget *parent, const CVirtualBox &vbox, 215 VBoxDefs::DiskType type, const QString &src); 213 void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox, 214 const QString &aLocaiton, 215 const CHardDisk2 &aHD, 216 const CProgress &aProgress); 217 void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine, 218 const QString &aLocation, KStorageBus aBus, 219 LONG aChannel, LONG aDevice); 220 void cannotDetachHardDisk (QWidget *aParent, const CMachine &aMachine, 221 const QString &aLocation, KStorageBus aBus, 222 LONG aChannel, LONG aDevice); 223 224 void cannotMountMedium (QWidget *aParent, const CMachine &aMachine, 225 const VBoxMedium &aMedium, const COMResult &aResult); 226 void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine, 227 const VBoxMedium &aMedium, const COMResult &aResult); 228 229 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox, 230 VBoxDefs::MediaType aType, const QString &aLocation); 231 void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium, 232 const COMResult &aResult); 216 233 217 234 void cannotOpenSession (const CSession &session); … … 219 236 const CProgress &progress = CProgress()); 220 237 221 void cannotGetMediaAccessibility (const CUnknown &unk); 222 223 /// @todo (r=dmik) later 224 // void cannotMountMedia (const CUnknown &unk); 225 // void cannotUnmountMedia (const CUnknown &unk); 238 void cannotGetMediaAccessibility (const VBoxMedium &aMedium); 226 239 227 240 #if defined Q_WS_WIN … … 297 310 const QString &errorMsg); 298 311 312 static QString toAccusative (VBoxDefs::MediaType aType); 313 299 314 static QString formatRC (HRESULT aRC); 300 315 … … 307 322 } 308 323 309 static QString formatErrorInfo (const COMBase &aWrapper)324 static QString formatErrorInfo (const COMBaseWithEI &aWrapper) 310 325 { 311 326 Assert (aWrapper.lastRC() != S_OK); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxSelectorWnd.h
r8155 r13580 62 62 public slots: 63 63 64 void file DiskMgr();64 void fileMediaMgr(); 65 65 void fileSettings(); 66 66 void fileExit(); … … 117 117 118 118 /* actions */ 119 QAction *file DiskMgrAction;119 QAction *fileMediaMgrAction; 120 120 QAction *fileSettingsAction; 121 121 QAction *fileExitAction; -
trunk/src/VBox/Frontends/VirtualBox/src/COMDefs.cpp
r8155 r13580 208 208 } 209 209 210 /* static */ 211 void COMBase::ToSafeArray (const QValueVector <QUuid> &aVec, 212 com::SafeGUIDArray &aArr) 213 { 214 AssertCompileSize (GUID, sizeof (QUuid)); 215 aArr.reset (aVec.size()); 216 size_t i = 0; 217 for (QValueVector <QUuid>::const_iterator it = aVec.begin(); 218 it != aVec.end(); ++ it, ++ i) 219 aArr [i] = *(GUID *) &(*it); 220 } 221 222 /* static */ 223 void COMBase::FromSafeArray (const com::SafeGUIDArray &aArr, 224 QValueVector <QUuid> &aVec) 225 { 226 AssertCompileSize (GUID, sizeof (QUuid)); 227 aVec = QValueVector <QUuid> (aArr.size()); 228 size_t i = 0; 229 for (QValueVector <QUuid>::iterator it = aVec.begin(); 230 it != aVec.end(); ++ it, ++ i) 231 *it = *(QUuid *) &aArr [i]; 232 } 233 210 234 //////////////////////////////////////////////////////////////////////////////// 211 235 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r11667 r13580 269 269 }; 270 270 271 /** DVD/F Dchange event */272 class Media ChangeEvent : public QEvent271 /** DVD/Floppy drive change event */ 272 class MediaDriveChangeEvent : public QEvent 273 273 { 274 274 public: 275 Media ChangeEvent (VBoxDefs::DiskType aType)276 : QEvent ((QEvent::Type) VBoxDefs::Media ChangeEventType)275 MediaDriveChangeEvent (VBoxDefs::MediaType aType) 276 : QEvent ((QEvent::Type) VBoxDefs::MediaDriveChangeEventType) 277 277 , mType (aType) {} 278 VBoxDefs:: DiskType diskType() const { return mType; }278 VBoxDefs::MediaType type() const { return mType; } 279 279 private: 280 VBoxDefs:: DiskType mType;280 VBoxDefs::MediaType mType; 281 281 }; 282 282 … … 465 465 { 466 466 LogFlowFunc (("DVD Drive changed\n")); 467 QApplication::postEvent (mView, new MediaChangeEvent (VBoxDefs::CD)); 467 QApplication::postEvent (mView, 468 new MediaDriveChangeEvent (VBoxDefs::MediaType_DVD)); 468 469 return S_OK; 469 470 } … … 472 473 { 473 474 LogFlowFunc (("Floppy Drive changed\n")); 474 QApplication::postEvent (mView, new MediaChangeEvent (VBoxDefs::FD)); 475 QApplication::postEvent (mView, 476 new MediaDriveChangeEvent (VBoxDefs::MediaType_Floppy)); 475 477 return S_OK; 476 478 } … … 1217 1219 } 1218 1220 1219 case VBoxDefs::Media ChangeEventType:1220 { 1221 Media ChangeEvent *mce = (MediaChangeEvent *) e;1221 case VBoxDefs::MediaDriveChangeEventType: 1222 { 1223 MediaDriveChangeEvent *mce = (MediaDriveChangeEvent *) e; 1222 1224 LogFlowFunc (("MediaChangeEvent\n")); 1223 1225 1224 emit media Changed (mce->diskType());1226 emit mediaDriveChanged (mce->type()); 1225 1227 return true; 1226 1228 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r13374 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 25 25 #include "VBoxCloseVMDlg.h" 26 26 #include "VBoxTakeSnapshotDlg.h" 27 #include "VBox DiskImageManagerDlg.h"27 #include "VBoxMediaManagerDlg.h" 28 28 #include "VBoxVMFirstRunWzd.h" 29 29 #include "VBoxSharedFoldersSettings.h" … … 817 817 connect (console, SIGNAL (additionsStateChanged (const QString&, bool, bool, bool)), 818 818 this, SLOT (updateAdditionsState (const QString &, bool, bool, bool))); 819 connect (console, SIGNAL (media Changed (VBoxDefs::DiskType)),820 this, SLOT (updateMedia State (VBoxDefs::DiskType)));819 connect (console, SIGNAL (mediaDriveChanged (VBoxDefs::MediaType)), 820 this, SLOT (updateMediaDriveState (VBoxDefs::MediaType))); 821 821 connect (console, SIGNAL (usbStateChange()), 822 822 this, SLOT (updateUsbState())); … … 1678 1678 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1679 1679 "Floppy tooltip") 1680 .arg (QDir::convertSeparators (floppy.GetImage().Get FilePath()));1680 .arg (QDir::convertSeparators (floppy.GetImage().GetLocation())); 1681 1681 break; 1682 1682 } … … 1722 1722 name = tr ("<br><nobr><b>Image</b>: %1</nobr>", 1723 1723 "DVD-ROM tooltip") 1724 .arg (QDir::convertSeparators (dvd.GetImage().Get FilePath()));1724 .arg (QDir::convertSeparators (dvd.GetImage().GetLocation())); 1725 1725 break; 1726 1726 } … … 1743 1743 QString data; 1744 1744 bool hasDisks = false; 1745 CHardDisk AttachmentEnumerator aen = cmachine.GetHardDiskAttachments().Enumerate();1746 while (aen.HasMore())1747 {1748 CHardDiskAttachment hda = aen.GetNext();1749 CHardDisk hd = hda.GetHardDisk();1745 CHardDisk2AttachmentVector vec = cmachine.GetHardDisk2Attachments(); 1746 for (CHardDisk2AttachmentVector::ConstIterator hda = vec.begin(); 1747 hda != vec.end(); ++ hda) 1748 { 1749 CHardDisk2 hd = hda->GetHardDisk(); 1750 1750 data += QString ("<br><nobr><b>%1 %2</b>: %3</nobr>") 1751 .arg (vboxGlobal().toString (hda .GetBus(), hda.GetChannel()))1752 .arg (vboxGlobal().toString (hda .GetBus(), hda.GetChannel(),1753 hda .GetDevice()))1751 .arg (vboxGlobal().toString (hda->GetBus(), hda->GetChannel())) 1752 .arg (vboxGlobal().toString (hda->GetBus(), hda->GetChannel(), 1753 hda->GetDevice())) 1754 1754 .arg (QDir::convertSeparators (hd.GetLocation())); 1755 1755 hasDisks = true; … … 2500 2500 if (!console) return; 2501 2501 2502 VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", WType_Dialog | WShowModal); 2503 QUuid id = csession.GetMachine().GetId(); 2504 dlg.setup (VBoxDefs::FD, true, &id); 2505 2506 if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted) 2502 VBoxMediaManagerDlg dlg (this, "VBoxMediaManagerDlg", WType_Dialog | WShowModal); 2503 2504 dlg.setup (VBoxDefs::MediaType_Floppy, true /* aDoSelect */, 2505 true /* aRefresh */, csession.GetMachine()); 2506 2507 if (dlg.exec() == VBoxMediaManagerDlg::Accepted) 2507 2508 { 2508 2509 CFloppyDrive drv = csession.GetMachine().GetFloppyDrive(); 2509 drv.MountImage (dlg. getSelectedUuid());2510 drv.MountImage (dlg.selectedId()); 2510 2511 AssertWrapperOk (drv); 2511 2512 if (drv.isOk()) … … 2544 2545 if (!console) return; 2545 2546 2546 VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", WType_Dialog | WShowModal); 2547 QUuid id = csession.GetMachine().GetId(); 2548 dlg.setup (VBoxDefs::CD, true, &id); 2549 2550 if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted) 2547 VBoxMediaManagerDlg dlg (this, "VBoxMediaManagerDlg", WType_Dialog | WShowModal); 2548 2549 dlg.setup (VBoxDefs::MediaType_DVD, true /* aDoSelect */, 2550 true /* aRefresh */, csession.GetMachine()); 2551 2552 if (dlg.exec() == VBoxMediaManagerDlg::Accepted) 2551 2553 { 2552 2554 CDVDDrive drv = csession.GetMachine().GetDVDDrive(); 2553 drv.MountImage (dlg. getSelectedUuid());2555 drv.MountImage (dlg.selectedId()); 2554 2556 AssertWrapperOk (drv); 2555 2557 if (drv.isOk()) … … 2628 2630 else 2629 2631 { 2630 /* Check for the already registered required image :*/2632 /* Check for the already registered required image */ 2631 2633 CVirtualBox vbox = vboxGlobal().virtualBox(); 2632 2634 QString name = QString ("VBoxGuestAdditions_%1.iso") 2633 2635 .arg (vbox.GetVersion().remove ("_OSE")); 2634 CDVDImageEnumerator en = vbox.GetDVDImages().Enumerate(); 2635 while (en.HasMore()) 2636 { 2637 QString path = en.GetNext().GetFilePath(); 2638 /* compare the name part ignoring the file case*/ 2636 2637 CDVDImage2Vector vec = vbox.GetDVDImages(); 2638 for (CDVDImage2Vector::ConstIterator it = vec.begin(); 2639 it != vec.end(); ++ it) 2640 { 2641 QString path = it->GetLocation(); 2642 /* compare the name part ignoring the file case */ 2639 2643 QString fn = QFileInfo (path).fileName(); 2640 2644 if (RTPathCompare (name.utf8(), fn.utf8()) == 0) 2641 2645 return installGuestAdditionsFrom (path); 2642 2646 } 2643 /* Download required image: */ 2647 2648 /* Download the required image */ 2644 2649 int rc = vboxProblem().cannotFindGuestAdditions ( 2645 2650 QDir::convertSeparators (src1), QDir::convertSeparators (src2)); … … 2662 2667 QUuid uuid; 2663 2668 2664 CDVDImage image = vbox.FindDVDImage (aSource);2669 CDVDImage2 image = vbox.FindDVDImage (aSource); 2665 2670 if (image.isNull()) 2666 2671 { 2667 2672 image = vbox.OpenDVDImage (aSource, uuid); 2668 2673 if (vbox.isOk()) 2669 vbox.RegisterDVDImage (image);2670 if (vbox.isOk())2671 2674 uuid = image.GetId(); 2672 2675 } … … 2676 2679 if (!vbox.isOk()) 2677 2680 { 2678 vboxProblem().cannotRegisterMedia (this, vbox, VBoxDefs::CD, aSource); 2681 vboxProblem().cannotOpenMedium (this, vbox, 2682 VBoxDefs::MediaType_DVD, aSource); 2679 2683 return; 2680 2684 } … … 2683 2687 CDVDDrive drv = csession.GetMachine().GetDVDDrive(); 2684 2688 drv.MountImage (uuid); 2685 /// @todo (r=dmik) use VBoxProblemReporter::cannotMountMedia...2689 /// @todo NEWMEDIA use VBoxProblemReporter::cannotMountMedia 2686 2690 AssertWrapperOk (drv); 2687 2691 } … … 3304 3308 } 3305 3309 3306 void VBoxConsoleWnd::updateMediaState (VBoxDefs::DiskType aType) 3307 { 3308 Assert (aType == VBoxDefs::CD || aType == VBoxDefs::FD); 3309 updateAppearanceOf (aType == VBoxDefs::CD ? DVDStuff : 3310 aType == VBoxDefs::FD ? FloppyStuff : AllStuff); 3310 void VBoxConsoleWnd::updateMediaDriveState (VBoxDefs::MediaType aType) 3311 { 3312 Assert (aType == VBoxDefs::MediaType_DVD || aType == VBoxDefs::MediaType_Floppy); 3313 updateAppearanceOf (aType == VBoxDefs::MediaType_DVD ? DVDStuff : 3314 aType == VBoxDefs::MediaType_Floppy ? FloppyStuff : 3315 AllStuff); 3311 3316 } 3312 3317 … … 3452 3457 bool VBoxConsoleWnd::dbgCreated() 3453 3458 { 3459 #if 0 3460 /// @todo needs to be ported back from VirtualBox4 3454 3461 if (dbg_gui) 3455 3462 return true; 3456 int rc = DBGGuiCreate (csession. iface(), &dbg_gui, NULL);3463 int rc = DBGGuiCreate (csession.raw(), &dbg_gui); 3457 3464 if (VBOX_SUCCESS (rc)) 3458 3465 { … … 3460 3467 return true; 3461 3468 } 3469 #endif 3462 3470 return false; 3463 3471 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r12629 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 97 97 #endif 98 98 99 // VBox EnumerateMediaEvent99 // VBoxMedium 100 100 ///////////////////////////////////////////////////////////////////////////// 101 101 102 class VBoxEnumerateMediaEvent : public QEvent 102 void VBoxMedium::init() 103 { 104 AssertReturnVoid (!mMedium.isNull()); 105 106 switch (mType) 107 { 108 case VBoxDefs::MediaType_HardDisk: 109 { 110 mHardDisk = mMedium; 111 AssertReturnVoid (!mHardDisk.isNull()); 112 break; 113 } 114 case VBoxDefs::MediaType_DVD: 115 { 116 mDVDImage = mMedium; 117 AssertReturnVoid (!mDVDImage.isNull()); 118 Assert (mParent == NULL); 119 break; 120 } 121 case VBoxDefs::MediaType_Floppy: 122 { 123 mFloppyImage = mMedium; 124 AssertReturnVoid (!mFloppyImage.isNull()); 125 Assert (mParent == NULL); 126 break; 127 } 128 default: 129 AssertFailed(); 130 } 131 132 refresh(); 133 } 134 135 /** 136 * Queries the medium state. Call this and then read the state field instad 137 * of calling GetState() on medium directly as it will properly handle the 138 * situation when GetState() itself fails by setting state to Inaccessible 139 * and memorizing the error info describing why GetState() failed. 140 * 141 * As the last step, this method calls #refresh() to refresh all precomposed 142 * strings. 143 * 144 * @note This method blocks for the duration of the state check. Since this 145 * check may take quite a while (e.g. for a medium located on a 146 * network share), the calling thread must not be the UI thread. You 147 * have been warned. 148 */ 149 void VBoxMedium::blockAndQueryState() 150 { 151 mState = mMedium.GetState(); 152 153 /* save the result to distinguish between inaccessible and e.g. 154 * uninitialized objects */ 155 mResult = COMResult (mMedium); 156 157 if (!mResult.isOk()) 158 { 159 mState = KMediaState_Inaccessible; 160 mLastAccessError = QString::null; 161 } 162 else 163 mLastAccessError = mMedium.GetLastAccessError(); 164 165 refresh(); 166 } 167 168 /** 169 * Refreshes the precomposed strings containing such media parameters as 170 * location, size by querying the respective data from the associated 171 * media object. 172 * 173 * Note that some string such as #size() are meaningless if the media state is 174 * KMediaState_NotCreated (i.e. the medium has not yet been checked for 175 * accessibility). 176 */ 177 void VBoxMedium::refresh() 178 { 179 mId = mMedium.GetId(); 180 mLocation = mMedium.GetLocation(); 181 mName = mMedium.GetName(); 182 183 if (mType == VBoxDefs::MediaType_HardDisk) 184 { 185 /// @todo NEWMEDIA use CSystemProperties::GetHardDIskFormats to see if the 186 /// given hard disk format is a file 187 mLocation = QDir::convertSeparators (mLocation); 188 mHardDiskFormat = mHardDisk.GetFormat(); 189 mHardDiskType = vboxGlobal().hardDiskTypeString (mHardDisk); 190 191 mIsReadOnly = mHardDisk.GetReadOnly(); 192 193 /* adjust the parent if necessary (note that mParent must always point 194 * to an item from VBoxGlobal::currentMediaList()) */ 195 196 CHardDisk2 parent = mHardDisk.GetParent(); 197 Assert (!parent.isNull() || mParent == NULL); 198 199 if (!parent.isNull() && 200 (mParent == NULL || mParent->mHardDisk != parent)) 201 { 202 /* search for the parent (must be there) */ 203 const VBoxMediaList &list = vboxGlobal().currentMediaList(); 204 for (VBoxMediaList::const_iterator it = list.begin(); 205 it != list.end(); ++ it) 206 { 207 if ((*it).mType != VBoxDefs::MediaType_HardDisk) 208 break; 209 210 if ((*it).mHardDisk == parent) 211 { 212 /* we unconst here because by the const list we don't mean 213 * const items */ 214 mParent = unconst (&*it); 215 break; 216 } 217 } 218 219 Assert (mParent != NULL && mParent->mHardDisk == parent); 220 } 221 } 222 else 223 { 224 mLocation = QDir::convertSeparators (mLocation); 225 mHardDiskFormat = QString::null; 226 mHardDiskType = QString::null; 227 228 mIsReadOnly = false; 229 } 230 231 if (mState != KMediaState_Inaccessible && 232 mState != KMediaState_NotCreated) 233 { 234 mSize = vboxGlobal().formatSize (mMedium.GetSize()); 235 if (mType == VBoxDefs::MediaType_HardDisk) 236 mLogicalSize = vboxGlobal() 237 .formatSize (mHardDisk.GetLogicalSize() * _1M); 238 else 239 mLogicalSize = mSize; 240 } 241 else 242 { 243 mSize = mLogicalSize = QString ("--"); 244 } 245 246 /* detect usage */ 247 248 mUsage = QString::null; /* important: null means not used! */ 249 250 mCurStateMachineIds.clear(); 251 252 QValueVector <QUuid> machineIds = mMedium.GetMachineIds(); 253 if (machineIds.size() > 0) 254 { 255 QString usage; 256 257 CVirtualBox vbox = vboxGlobal().virtualBox(); 258 259 for (QValueVector <QUuid>::ConstIterator it = machineIds.begin(); 260 it != machineIds.end(); ++ it) 261 { 262 CMachine machine = vbox.GetMachine (*it); 263 264 QString name = machine.GetName(); 265 QString snapshots; 266 267 QValueVector <QUuid> snapIds = mMedium.GetSnapshotIds (*it); 268 for (QValueVector <QUuid>::ConstIterator jt = snapIds.begin(); 269 jt != snapIds.end(); ++ jt) 270 { 271 if (*jt == *it) 272 { 273 /* the medium is attached to the machine in the current 274 * state, we don't distinguish this for now by always 275 * giving the VM name in front of snapshot names. */ 276 277 mCurStateMachineIds.push_back (*jt); 278 continue; 279 } 280 281 CSnapshot snapshot = machine.GetSnapshot (*jt); 282 if (!snapshots.isNull()) 283 snapshots += ", "; 284 snapshots += snapshot.GetName(); 285 } 286 287 if (!usage.isNull()) 288 usage += ", "; 289 290 usage += name; 291 292 if (!snapshots.isNull()) 293 { 294 usage += QString (" (%2)").arg (snapshots); 295 mIsUsedInSnapshots = true; 296 } 297 else 298 mIsUsedInSnapshots = false; 299 } 300 301 Assert (!usage.isEmpty()); 302 mUsage = usage; 303 } 304 305 /* compose the tooltip (makes sense to keep the format in sync with 306 * VBoxMediaManagerDlg::languageChangeImp() and 307 * VBoxMediaManagerDlg::processCurrentChanged()) */ 308 309 mToolTip = QString ("<nobr><b>%1</b></nobr>").arg (mLocation); 310 311 if (mType == VBoxDefs::MediaType_HardDisk) 312 { 313 mToolTip += VBoxGlobal::tr ( 314 "<br><nobr>Type (Format): %2 (%3)</nobr>", 315 "hard disk") 316 .arg (mHardDiskType) 317 .arg (mHardDiskFormat); 318 } 319 320 mToolTip += VBoxGlobal::tr ( 321 "<br><nobr>Attached to: %1</nobr>", "medium") 322 .arg (mUsage.isNull() ? 323 VBoxGlobal::tr ("<i>Not Attached</i>", "medium") : 324 mUsage); 325 326 switch (mState) 327 { 328 case KMediaState_NotCreated: 329 { 330 mToolTip += VBoxGlobal::tr ("<br><i>Checking accessibility...</i>", 331 "medium"); 332 break; 333 } 334 case KMediaState_Inaccessible: 335 { 336 if (mResult.isOk()) 337 { 338 /* not accessibile */ 339 mToolTip += QString ("<hr>%1"). 340 arg (VBoxGlobal::highlight (mLastAccessError, 341 true /* aToolTip */)); 342 } 343 else 344 { 345 /* accessibility check (eg GetState()) itself failed */ 346 mToolTip = VBoxGlobal::tr ( 347 "<hr>Failed to check media accessibility.<br>%1.", 348 "medium"). 349 arg (VBoxProblemReporter::formatErrorInfo (mResult)); 350 } 351 break; 352 } 353 default: 354 break; 355 } 356 357 /* reset mNoDiffs */ 358 mNoDiffs.isSet = false; 359 } 360 361 /** 362 * Returns a root medium of this medium. For non-hard disk media, this is always 363 * this medium itself. 364 */ 365 VBoxMedium &VBoxMedium::root() const 366 { 367 VBoxMedium *root = unconst (this); 368 while (root->mParent != NULL) 369 root = root->mParent; 370 371 return *root; 372 } 373 374 /** 375 * Returns a tooltip for this medium. 376 * 377 * In "don't show diffs" mode (where the attributes of the base hard disk are 378 * shown instead of the attributes of the differencing hard disk), extra 379 * information will be added to the tooltip to give the user a hint that the 380 * medium is actually a differencing hard disk. 381 * 382 * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode. 383 * @param aCheckRO @c true to perform the #readOnly() check and add a notice 384 * accordingly. 385 */ 386 QString VBoxMedium::toolTip (bool aNoDiffs /*= false*/, 387 bool aCheckRO /*= false*/) const 388 { 389 unconst (this)->checkNoDiffs (aNoDiffs); 390 391 QString tip = aNoDiffs ? mNoDiffs.toolTip : mToolTip; 392 393 if (aCheckRO && mIsReadOnly) 394 tip += VBoxGlobal::tr ( 395 "<hr><img src=%1/> Attaching this hard disk will " 396 "be performed indirectly using a newly created " 397 "differencing hard disk.", 398 "medium"). 399 arg ("new_16px.png"); 400 401 return tip; 402 } 403 404 /** 405 * Returns an icon corresponding to the media state. Distinguishes between 406 * the Inaccessible state and the situation when querying the state itself 407 * failed. 408 * 409 * In "don't show diffs" mode (where the attributes of the base hard disk are 410 * shown instead of the attributes of the differencing hard disk), the most 411 * worst media state on the given hard disk chain will be used to select the 412 * media icon. 413 * 414 * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode. 415 * @param aCheckRO @c true to perform the #readOnly() check and change the icon 416 * accordingly. 417 */ 418 QPixmap VBoxMedium::icon (bool aNoDiffs /*= false*/, 419 bool aCheckRO /*= false*/) const 420 { 421 QPixmap icon; 422 423 if (state (aNoDiffs) == KMediaState_Inaccessible) 424 icon = result (aNoDiffs).isOk() ? 425 vboxGlobal().warningIcon() : vboxGlobal().errorIcon(); 426 427 if (aCheckRO && mIsReadOnly) 428 icon = VBoxGlobal:: 429 joinPixmaps (icon, QPixmap::fromMimeSource ("new_16px.png")); 430 431 return icon; 432 } 433 434 /** 435 * Returns the details of this medium as a single-line string 436 * 437 * For hard disks, the details include the location, type and the logical size 438 * of the hard disk. Note that if @a aNoDiffs is @c true, these properties are 439 * queried on the root hard disk of the given hard disk because the primary 440 * purpose of the returned string is to be human readabile (so that seeing a 441 * complex diff hard disk name is usually not desirable). 442 * 443 * For other media types, the location and the actual size are returned. 444 * Arguments @a aPredictDiff and @a aNoRoot are ignored in this case. 445 * 446 * @param aNoDiffs @c true to enable user-friendly "don't show diffs" mode. 447 * @param aPredictDiff @c true to mark the hard disk as differencing if 448 * attaching it would create a differencing hard disk (not 449 * used when @a aNoRoot is true). 450 * @param aUseHTML @c true to allow for emphasizing using bold and italics. 451 * 452 * @note Use #detailsHTML() instead of passing @c true for @a aUseHTML. 453 * 454 * @note The media object may become uninitialized by a third party while this 455 * method is reading its properties. In this case, the method will return 456 * an empty string. 457 */ 458 QString VBoxMedium::details (bool aNoDiffs /*= false*/, 459 bool aPredictDiff /*= false*/, 460 bool aUseHTML /*= false */) const 461 { 462 // @todo *** the below check is rough; if mMedium becomes uninitialized, any 463 // of getters called afterwards will also fail. The same relates to the 464 // root hard disk object (that will be the hard disk itself in case of 465 // non-differencing disks). However, this check was added to fix a 466 // particular use case: when the hard disk is a differencing hard disk and 467 // it happens to be discarded (and uninitialized) after this method is 468 // called but before we read all its properties (yes, it's possible!), the 469 // root object will be null and calling methods on it will assert in the 470 // debug builds. This check seems to be enough as a quick solution (fresh 471 // hard disk attachments will be re-read by a machine state change signal 472 // after the discard operation is finished, so the user will eventually see 473 // correct data), but in order to solve the problem properly we need to use 474 // exceptions everywhere (or check the result after every method call). See 475 // also Defect #2149. 476 if (!mMedium.isOk()) 477 return QString::null; 478 479 QString details, str; 480 481 VBoxMedium *root = unconst (this); 482 KMediaState state = mState; 483 484 if (mType == VBoxDefs::MediaType_HardDisk) 485 { 486 if (aNoDiffs) 487 { 488 root = &this->root(); 489 490 bool isDiff = 491 (!aPredictDiff && mParent != NULL) || 492 (aPredictDiff && mIsReadOnly); 493 494 details = isDiff && aUseHTML ? 495 QString ("<i>%1</i>, ").arg (root->mHardDiskType) : 496 QString ("%1, ").arg (root->mHardDiskType); 497 498 /* overall (worst) state */ 499 state = this->state (true /* aNoDiffs */); 500 501 /* we cannot get the logical size if the root is not checked yet */ 502 if (root->mState == KMediaState_NotCreated) 503 state = KMediaState_NotCreated; 504 } 505 else 506 { 507 details = QString ("%1, ").arg (root->mHardDiskType); 508 } 509 } 510 511 /// @todo prepend the details with the warning/error 512 // icon when not accessible 513 514 switch (state) 515 { 516 case KMediaState_NotCreated: 517 str = VBoxGlobal::tr ("Checking...", "medium"); 518 details += aUseHTML ? QString ("<i>%1</i>").arg (str) : str; 519 break; 520 case KMediaState_Inaccessible: 521 str = VBoxGlobal::tr ("Inaccessible", "medium"); 522 details += aUseHTML ? QString ("<b>%1</b>").arg (str) : str; 523 break; 524 default: 525 details += mType == VBoxDefs::MediaType_HardDisk ? 526 root->mLogicalSize : root->mSize; 527 break; 528 } 529 530 details = aUseHTML ? 531 QString ("%1 (<nobr>%2</nobr>)"). 532 arg (VBoxGlobal::locationForHTML (root->mName), details) : 533 QString ("%1 (%2)"). 534 arg (VBoxGlobal::locationForHTML (root->mName), details); 535 536 return details; 537 } 538 539 /** 540 * Checks if mNoDiffs is filled in and does it if not. 541 * 542 * @param aNoDiffs @if false, this method immediately returns. 543 */ 544 void VBoxMedium::checkNoDiffs (bool aNoDiffs) 545 { 546 if (!aNoDiffs || mNoDiffs.isSet) 547 return; 548 549 /* fill mNoDiffs */ 550 551 mNoDiffs.toolTip = QString::null; 552 553 /* detect the overall (worst) state of the given hard disk chain */ 554 mNoDiffs.state = mState; 555 for (VBoxMedium *cur = mParent; cur != NULL; 556 cur = cur->mParent) 557 { 558 if (cur->mState == KMediaState_Inaccessible) 559 { 560 mNoDiffs.state = cur->mState; 561 562 if (mNoDiffs.toolTip.isNull()) 563 mNoDiffs.toolTip = VBoxGlobal::tr ( 564 "<hr>Some of the media in this hard disk chain are " 565 "inaccessible. Please use the Virtual Media Manager " 566 "in <b>Show Differencing Hard Disks</b> mode to inspect " 567 "these media."); 568 569 if (!cur->mResult.isOk()) 570 { 571 mNoDiffs.result = cur->mResult; 572 break; 573 } 574 575 /* comtinue looking for another !cur->mResult.isOk() */ 576 } 577 } 578 579 if (mParent != NULL && !mIsReadOnly) 580 { 581 mNoDiffs.toolTip = VBoxGlobal::tr ( 582 "%1" 583 "<hr>This base hard disk is indirectly attached using the " 584 "following differencing hard disk:<br>" 585 "%2%3"). 586 arg (root().toolTip(), mToolTip, mNoDiffs.toolTip); 587 } 588 589 if (mNoDiffs.toolTip.isNull()) 590 mNoDiffs.toolTip = mToolTip; 591 592 mNoDiffs.isSet = true; 593 } 594 595 // VBoxMediaEnumEvent 596 ///////////////////////////////////////////////////////////////////////////// 597 598 class VBoxMediaEnumEvent : public QEvent 103 599 { 104 600 public: 105 601 106 602 /** Constructs a regular enum event */ 107 VBox EnumerateMediaEvent (const VBoxMedia &aMedia, int aIndex)108 : QEvent ((QEvent::Type) VBoxDefs:: EnumerateMediaEventType)109 , mMedi a (aMedia), mLast (false), mIndex (aIndex)603 VBoxMediaEnumEvent (const VBoxMedium &aMedium, int aIndex) 604 : QEvent ((QEvent::Type) VBoxDefs::MediaEnumEventType) 605 , mMedium (aMedium), mLast (false), mIndex (aIndex) 110 606 {} 111 607 /** Constructs the last enum event */ 112 VBox EnumerateMediaEvent()113 : QEvent ((QEvent::Type) VBoxDefs:: EnumerateMediaEventType)608 VBoxMediaEnumEvent() 609 : QEvent ((QEvent::Type) VBoxDefs::MediaEnumEventType) 114 610 , mLast (true), mIndex (-1) 115 611 {} 116 612 117 /** the last enumerated medi a(not valid when #last is true) */118 const VBoxMedi a mMedia;613 /** the last enumerated medium (not valid when #last is true) */ 614 const VBoxMedium mMedium; 119 615 /** whether this is the last event for the given enumeration or not */ 120 616 const bool mLast; … … 130 626 /** Constructs a regular enum event */ 131 627 VBoxShellExecuteEvent (QThread *aThread, const QString &aURL, 132 628 bool aOk) 133 629 : QEvent ((QEvent::Type) VBoxDefs::ShellExecuteEventType) 134 630 , mThread (aThread), mURL (aURL), mOk (aOk) … … 753 1249 , mRegDlg (NULL) 754 1250 #endif 755 , m edia_enum_thread (NULL)1251 , mMediaEnumThread (NULL) 756 1252 , verString ("1.0") 757 1253 , vm_state_color (KMachineState_COUNT) … … 763 1259 , storageBusChannels (3) 764 1260 , diskTypes (KHardDiskType_COUNT) 765 , diskStorageTypes (KHardDiskStorageType_COUNT)766 1261 , vrdpAuthTypes (KVRDPAuthType_COUNT) 767 1262 , portModeTypes (KPortMode_COUNT) … … 1296 1791 1297 1792 /** 1298 * Returns the details of the given hard disk as a single-line string 1299 * to be used in the VM details view. 1300 * 1301 * The details include the type and the virtual size of the hard disk. 1302 * Note that for differencing hard disks based on immutable hard disks, 1303 * the Immutable hard disk type is returned. 1304 * 1305 * @param aHD hard disk image (when predict = true, must be a top-level image) 1306 * @param aPredict when true, the function predicts the type of the resulting 1307 * image after attaching the given image to the machine. 1308 * Otherwise, a real type of the given image is returned 1309 * (with the exception mentioned above). 1310 * 1311 * @note The hard disk object may become uninitialized by a third party 1312 * while this method is reading its properties. In this case, the method will 1313 * return an empty string. 1314 */ 1315 QString VBoxGlobal::details (const CHardDisk &aHD, bool aPredict /* = false */, 1316 bool aDoRefresh) 1317 { 1318 Assert (!aPredict || aHD.GetParent().isNull()); 1319 1320 VBoxMedia media; 1321 if (!aDoRefresh) 1322 media = VBoxMedia (CUnknown (aHD), VBoxDefs::HD, VBoxMedia::Ok); 1323 else if (!findMedia (CUnknown (aHD), media)) 1793 * Searches for the given hard disk in the list of known media descriptors and 1794 * calls VBoxMedium::details() on the found desriptor. 1795 * 1796 * If the requeststed hard disk is not found (for example, it's a new hard disk 1797 * for a new VM created outside our UI), then media enumeration is requested and 1798 * the search is repeated. We assume that the secont attempt always succeeds and 1799 * assert otherwise. 1800 * 1801 * @note Technically, the second attempt may fail if, for example, the new hard 1802 * passed to this method disk gets removed before #startEnumeratingMedia() 1803 * succeeds. This (unexpected object uninitialization) is a generic 1804 * problem though and needs to be addressed using exceptions (see also the 1805 * @todo in VBoxMedium::details()). 1806 */ 1807 QString VBoxGlobal::details (const CHardDisk2 &aHD, 1808 bool aPredictDiff) 1809 { 1810 CMedium cmedium (aHD); 1811 VBoxMedium medium; 1812 1813 if (!findMedium (cmedium, medium)) 1324 1814 { 1325 1815 /* media may be new and not alredy in the media list, request refresh */ 1326 1816 startEnumeratingMedia(); 1327 if (!findMedia (CUnknown (aHD), media)) 1328 AssertFailed(); 1329 } 1330 1331 CHardDisk root = aHD.GetRoot(); 1332 1333 // @todo *** this check is rough; if aHD becomes uninitialized, any of aHD 1334 // getters called afterwards will also fail. The same relates to the root 1335 // object (that will be aHD itself in case of non-differencing 1336 // disks). However, this check was added to fix a particular use case: 1337 // when aHD is a differencing hard disk and it happens to be discarded 1338 // (and uninitialized) after this method is called but before we read all 1339 // its properties (yes, it's possible!), the root object will be null and 1340 // calling methods on it will assert in the debug builds. This check seems 1341 // to be enough as a quick solution (fresh hard disk attachments will be 1342 // re-read by a state change signal after the discard operation is 1343 // finished, so the user will eventually see correct data), but in order 1344 // to solve the problem properly we need to use exceptions everywhere (or 1345 // check the result after every method call). See also Comment #17 and 1346 // below in Defect #2126. 1347 if (!aHD.isOk()) 1348 return QString::null; 1349 1350 QString details; 1351 1352 KHardDiskType type = root.GetType(); 1353 1354 if (type == KHardDiskType_Normal && 1355 (aHD != root || (aPredict && root.GetChildren().GetCount() != 0))) 1356 details = tr ("Differencing", "hard disk"); 1357 else 1358 details = hardDiskTypeString (root); 1359 1360 details += ", "; 1361 1362 /// @todo prepend the details with the warning/error 1363 // icon when not accessible 1364 1365 switch (media.status) 1366 { 1367 case VBoxMedia::Unknown: 1368 details += tr ("<i>Checking...</i>", "hard disk"); 1369 break; 1370 case VBoxMedia::Ok: 1371 details += formatSize (root.GetSize() * _1M); 1372 break; 1373 case VBoxMedia::Error: 1374 case VBoxMedia::Inaccessible: 1375 details += tr ("<i>Inaccessible</i>", "hard disk"); 1376 break; 1377 } 1378 1379 return details; 1817 if (!findMedium (cmedium, medium)) 1818 AssertFailedReturn (QString::null); 1819 } 1820 1821 return medium.detailsHTML (true /* aNoDiffs */, aPredictDiff); 1380 1822 } 1381 1823 … … 1428 1870 1429 1871 /* add the state field if it's a host USB device */ 1430 CHostUSBDevice hostDev = CUnknown(aDevice);1872 CHostUSBDevice hostDev (aDevice); 1431 1873 if (!hostDev.isNull()) 1432 1874 { … … 1439 1881 1440 1882 /** 1441 * Puts soft hyphens after every path component in the given file name. 1442 * @param fn file name (must be a full path name) 1443 */ 1444 QString VBoxGlobal::prepareFileNameForHTML (const QString &fn) const 1445 { 1446 /// @todo (dmik) remove? 1447 // QString result = QDir::convertSeparators (fn); 1448 //#ifdef Q_OS_LINUX 1449 // result.replace ('/', "/<font color=red>­</font>"); 1450 //#else 1451 // result.replace ('\\', "\\<font color=red>­</font>"); 1452 //#endif 1453 // return result; 1454 QFileInfo fi (fn); 1455 return fi.fileName(); 1456 } 1457 1458 /** 1459 * Returns a details report on a given VM enclosed in a HTML table. 1460 * 1461 * @param m machine to create a report for 1462 * @param isNewVM true when called by the New VM Wizard 1463 * @param withLinks true if section titles should be hypertext links 1464 */ 1465 QString VBoxGlobal::detailsReport (const CMachine &m, bool isNewVM, 1466 bool withLinks, bool aDoRefresh) 1883 * Returns a details report on a given VM represented as a HTML table. 1884 * 1885 * @param aMachine Machine to create a report for. 1886 * @param aIsNewVM @c true when called by the New VM Wizard. 1887 * @param aWithLinks @c true if section titles should be hypertext links. 1888 */ 1889 QString VBoxGlobal::detailsReport (const CMachine &aMachine, bool aIsNewVM, 1890 bool aWithLinks) 1467 1891 { 1468 1892 static const char *sTableTpl = … … 1533 1957 /* common generated content */ 1534 1958 1535 const QString §ionTpl = withLinks1959 const QString §ionTpl = aWithLinks 1536 1960 ? sSectionHrefTpl 1537 1961 : sSectionBoldTpl; … … 1541 1965 int rows = 2; /* including section header and footer */ 1542 1966 1543 CHardDiskAttachmentEnumerator aen = m.GetHardDiskAttachments().Enumerate(); 1544 while (aen.HasMore()) 1545 { 1546 CHardDiskAttachment hda = aen.GetNext(); 1547 CHardDisk hd = hda.GetHardDisk(); 1548 /// @todo for the explaination of the below isOk() checks, see 1549 /// @todo *** in #details (const CHardDisk &, bool). 1967 CHardDisk2AttachmentVector vec = aMachine.GetHardDisk2Attachments(); 1968 for (size_t i = 0; i < vec.size(); ++ i) 1969 { 1970 CHardDisk2Attachment hda = vec [i]; 1971 CHardDisk2 hd = hda.GetHardDisk(); 1972 1973 /// @todo for the explaination of the below isOk() checks, see *** 1974 /// in #details (const CHardDisk &, bool). 1550 1975 if (hda.isOk()) 1551 1976 { 1552 CHardDisk root = hd.GetRoot(); 1553 if (hd.isOk()) 1554 { 1555 QString src = root.GetLocation(); 1556 KStorageBus bus = hda.GetBus(); 1557 LONG channel = hda.GetChannel(); 1558 LONG device = hda.GetDevice(); 1559 hardDisks += QString (sSectionItemTpl) 1560 .arg (toFullString (bus, channel, device)) 1561 .arg (QString ("%1 [<nobr>%2</nobr>]") 1562 .arg (prepareFileNameForHTML (src)) 1563 .arg (details (hd, isNewVM /* predict */, aDoRefresh))); 1564 ++ rows; 1565 } 1977 KStorageBus bus = hda.GetBus(); 1978 LONG channel = hda.GetChannel(); 1979 LONG device = hda.GetDevice(); 1980 hardDisks += QString (sSectionItemTpl) 1981 .arg (toFullString (bus, channel, device)) 1982 .arg (details (hd, aIsNewVM)); 1983 ++ rows; 1566 1984 } 1567 1985 } … … 1584 2002 /* compose details report */ 1585 2003 1586 const QString &generalBasicTpl = withLinks2004 const QString &generalBasicTpl = aWithLinks 1587 2005 ? sGeneralBasicHrefTpl 1588 2006 : sGeneralBasicBoldTpl; 1589 2007 1590 const QString &generalFullTpl = withLinks2008 const QString &generalFullTpl = aWithLinks 1591 2009 ? sGeneralFullHrefTpl 1592 2010 : sGeneralFullBoldTpl; … … 1594 2012 QString detailsReport; 1595 2013 1596 if ( isNewVM)2014 if (aIsNewVM) 1597 2015 { 1598 2016 detailsReport 1599 2017 = generalBasicTpl 1600 .arg ( m.GetName())1601 .arg (vmGuestOSTypeDescription ( m.GetOSTypeId()))1602 .arg ( m.GetMemorySize())2018 .arg (aMachine.GetName()) 2019 .arg (vmGuestOSTypeDescription (aMachine.GetOSTypeId())) 2020 .arg (aMachine.GetMemorySize()) 1603 2021 + hardDisks; 1604 2022 } … … 1609 2027 for (ulong i = 1; i <= mVBox.GetSystemProperties().GetMaxBootPosition(); i++) 1610 2028 { 1611 KDeviceType device = m.GetBootOrder (i);2029 KDeviceType device = aMachine.GetBootOrder (i); 1612 2030 if (device == KDeviceType_Null) 1613 2031 continue; … … 1619 2037 bootOrder = toString (KDeviceType_Null); 1620 2038 1621 CBIOSSettings biosSettings = m.GetBIOSSettings();2039 CBIOSSettings biosSettings = aMachine.GetBIOSSettings(); 1622 2040 1623 2041 /* ACPI */ … … 1633 2051 /* VT-x/AMD-V */ 1634 2052 CSystemProperties props = vboxGlobal().virtualBox().GetSystemProperties(); 1635 QString virt = m.GetHWVirtExEnabled() == KTSBool_True ?2053 QString virt = aMachine.GetHWVirtExEnabled() == KTSBool_True ? 1636 2054 tr ("Enabled", "details report (VT-x/AMD-V)") : 1637 m.GetHWVirtExEnabled() == KTSBool_False ?2055 aMachine.GetHWVirtExEnabled() == KTSBool_False ? 1638 2056 tr ("Disabled", "details report (VT-x/AMD-V)") : 1639 2057 props.GetHWVirtExEnabled() ? … … 1642 2060 1643 2061 /* PAE/NX */ 1644 QString pae = m.GetPAEEnabled()2062 QString pae = aMachine.GetPAEEnabled() 1645 2063 ? tr ("Enabled", "details report (PAE/NX)") 1646 2064 : tr ("Disabled", "details report (PAE/NX)"); … … 1649 2067 detailsReport 1650 2068 = generalFullTpl 1651 .arg ( m.GetName())1652 .arg (vmGuestOSTypeDescription ( m.GetOSTypeId()))1653 .arg ( m.GetMemorySize())1654 .arg ( m.GetVRAMSize())2069 .arg (aMachine.GetName()) 2070 .arg (vmGuestOSTypeDescription (aMachine.GetOSTypeId())) 2071 .arg (aMachine.GetMemorySize()) 2072 .arg (aMachine.GetVRAMSize()) 1655 2073 .arg (bootOrder) 1656 2074 .arg (acpi) … … 1663 2081 1664 2082 /* DVD */ 1665 CDVDDrive dvd = m.GetDVDDrive();2083 CDVDDrive dvd = aMachine.GetDVDDrive(); 1666 2084 item = QString (sSectionItemTpl); 1667 2085 switch (dvd.GetState()) … … 1672 2090 case KDriveState_ImageMounted: 1673 2091 { 1674 CDVDImage img = dvd.GetImage();2092 CDVDImage2 img = dvd.GetImage(); 1675 2093 item = item.arg (tr ("Image", "details report (DVD)"), 1676 prepareFileNameForHTML (img.GetFilePath()));2094 locationForHTML (img.GetName())); 1677 2095 break; 1678 2096 } … … 1700 2118 1701 2119 /* Floppy */ 1702 CFloppyDrive floppy = m.GetFloppyDrive();2120 CFloppyDrive floppy = aMachine.GetFloppyDrive(); 1703 2121 item = QString (sSectionItemTpl); 1704 2122 switch (floppy.GetState()) … … 1709 2127 case KDriveState_ImageMounted: 1710 2128 { 1711 CFloppyImage img = floppy.GetImage();2129 CFloppyImage2 img = floppy.GetImage(); 1712 2130 item = item.arg (tr ("Image", "details report (floppy)"), 1713 prepareFileNameForHTML (img.GetFilePath()));2131 locationForHTML (img.GetName())); 1714 2132 break; 1715 2133 } … … 1738 2156 /* audio */ 1739 2157 { 1740 CAudioAdapter audio = m.GetAudioAdapter();2158 CAudioAdapter audio = aMachine.GetAudioAdapter(); 1741 2159 int rows = audio.GetEnabled() ? 3 : 2; 1742 2160 if (audio.GetEnabled()) … … 1765 2183 for (ulong slot = 0; slot < count; slot ++) 1766 2184 { 1767 CNetworkAdapter adapter = m.GetNetworkAdapter (slot);2185 CNetworkAdapter adapter = aMachine.GetNetworkAdapter (slot); 1768 2186 if (adapter.GetEnabled()) 1769 2187 { … … 1811 2229 for (ulong slot = 0; slot < count; slot ++) 1812 2230 { 1813 CSerialPort port = m.GetSerialPort (slot);2231 CSerialPort port = aMachine.GetSerialPort (slot); 1814 2232 if (port.GetEnabled()) 1815 2233 { … … 1853 2271 for (ulong slot = 0; slot < count; slot ++) 1854 2272 { 1855 CParallelPort port = m.GetParallelPort (slot);2273 CParallelPort port = aMachine.GetParallelPort (slot); 1856 2274 if (port.GetEnabled()) 1857 2275 { … … 1885 2303 /* USB */ 1886 2304 { 1887 CUSBController ctl = m.GetUSBController();2305 CUSBController ctl = aMachine.GetUSBController(); 1888 2306 if (!ctl.isNull()) 1889 2307 { … … 1918 2336 /* Shared folders */ 1919 2337 { 1920 ulong count = m.GetSharedFolders().GetCount();2338 ulong count = aMachine.GetSharedFolders().GetCount(); 1921 2339 if (count > 0) 1922 2340 { … … 1939 2357 /* VRDP */ 1940 2358 { 1941 CVRDPServer srv = m.GetVRDPServer();2359 CVRDPServer srv = aMachine.GetVRDPServer(); 1942 2360 if (!srv.isNull()) 1943 2361 { … … 2146 2564 2147 2565 /** 2148 * Appends the disk object and all its children to the media list. 2566 * Appends the given list of hard disks and all their children to the media 2567 * list. To be called only from VBoxGlobal::startEnumeratingMedia(). 2149 2568 */ 2150 2569 static 2151 void addMediaToList (VBoxMediaList &aList, 2152 const CUnknown &aDisk, 2153 VBoxDefs::DiskType aType) 2154 { 2155 VBoxMedia media (aDisk, aType, VBoxMedia::Unknown); 2156 aList += media; 2157 /* append all vdi children */ 2158 if (aType == VBoxDefs::HD) 2159 { 2160 CHardDisk hd = aDisk; 2161 CHardDiskEnumerator enumerator = hd.GetChildren().Enumerate(); 2162 while (enumerator.HasMore()) 2163 { 2164 CHardDisk subHd = enumerator.GetNext(); 2165 addMediaToList (aList, CUnknown (subHd), VBoxDefs::HD); 2166 } 2167 } 2168 } 2169 2170 /** 2171 * Starts a thread that asynchronously enumerates all currently registered 2172 * media, checks for its accessibility and posts VBoxEnumerateMediaEvent 2173 * events to the VBoxGlobal object until all media is enumerated. 2174 * 2175 * If the enumeration is already in progress, no new thread is started. 2176 * 2177 * @sa #currentMediaList() 2178 * @sa #isMediaEnumerationStarted() 2570 void AddHardDisksToList (VBoxMediaList &aList, 2571 VBoxMediaList::iterator aWhere, 2572 const CHardDisk2Vector &aVector, 2573 VBoxMedium *aParent = NULL) 2574 { 2575 VBoxMediaList::iterator first = aWhere; 2576 2577 /* first pass: add siblings sorted */ 2578 for (CHardDisk2Vector::ConstIterator it = aVector.begin(); 2579 it != aVector.end(); ++ it) 2580 { 2581 VBoxMedium medium (CMedium (*it), VBoxDefs::MediaType_HardDisk, 2582 aParent); 2583 2584 /* search for a proper alphabetic position */ 2585 VBoxMediaList::iterator jt = first; 2586 for (; jt != aWhere; ++ jt) 2587 if ((*jt).name().localeAwareCompare (medium.name()) > 0) 2588 break; 2589 2590 aList.insert (jt, medium); 2591 2592 /* adjust the first item if inserted before it */ 2593 if (jt == first) 2594 -- first; 2595 } 2596 2597 /* second pass: add children */ 2598 for (VBoxMediaList::iterator it = first; it != aWhere;) 2599 { 2600 CHardDisk2Vector children = (*it).hardDisk().GetChildren(); 2601 VBoxMedium *parent = &(*it); 2602 2603 ++ it; /* go to the next sibling before inserting children */ 2604 AddHardDisksToList (aList, it, children, parent); 2605 } 2606 } 2607 2608 /** 2609 * Starts a thread that asynchronously enumerates all currently registered 2610 * media. 2611 * 2612 * Before the enumeration is started, the current media list (a list returned by 2613 * #currentMediaList()) is populated with all registered media and the 2614 * #mediaEnumStarted() signal is emitted. The enumeration thread then walks this 2615 * list, checks for media acessiblity and emits #mediumEnumerated() signals of 2616 * each checked medium. When all media are checked, the enumeration thread is 2617 * stopped and the #mediaEnumFinished() signal is emitted. 2618 * 2619 * If the enumeration is already in progress, no new thread is started. 2620 * 2621 * The media list returned by #currentMediaList() is always sorted 2622 * alphabetically by the location attribute and comes in the following order: 2623 * <ol> 2624 * <li>All hard disks. If a hard disk has children, these children 2625 * (alphabetically sorted) immediately follow their parent and terefore 2626 * appear before its next sibling hard disk.</li> 2627 * <li>All CD/DVD images.</li> 2628 * <li>All Floppy images.</li> 2629 * </ol> 2630 * 2631 * Note that #mediumEnumerated() signals are emitted in the same order as 2632 * described above. 2633 * 2634 * @sa #currentMediaList() 2635 * @sa #isMediaEnumerationStarted() 2179 2636 */ 2180 2637 void VBoxGlobal::startEnumeratingMedia() 2181 2638 { 2182 Assert (mValid);2639 AssertReturnVoid (mValid); 2183 2640 2184 2641 /* check if already started but not yet finished */ 2185 if (m edia_enum_thread)2642 if (mMediaEnumThread != NULL) 2186 2643 return; 2187 2644 … … 2191 2648 2192 2649 /* composes a list of all currently known media & their children */ 2193 media_list.clear(); 2194 { 2195 CHardDiskEnumerator enHD = mVBox.GetHardDisks().Enumerate(); 2196 while (enHD.HasMore()) 2197 addMediaToList (media_list, CUnknown (enHD.GetNext()), VBoxDefs::HD); 2198 2199 CDVDImageEnumerator enCD = mVBox.GetDVDImages().Enumerate(); 2200 while (enCD.HasMore()) 2201 addMediaToList (media_list, CUnknown (enCD.GetNext()), VBoxDefs::CD); 2202 2203 CFloppyImageEnumerator enFD = mVBox.GetFloppyImages().Enumerate(); 2204 while (enFD.HasMore()) 2205 addMediaToList (media_list, CUnknown (enFD.GetNext()), VBoxDefs::FD); 2650 mMediaList.clear(); 2651 { 2652 CHardDisk2Vector vec = mVBox.GetHardDisks2(); 2653 AddHardDisksToList (mMediaList, mMediaList.end(), vec); 2654 } 2655 { 2656 VBoxMediaList::iterator first = mMediaList.end(); 2657 2658 CDVDImage2Vector vec = mVBox.GetDVDImages(); 2659 for (CDVDImage2Vector::ConstIterator it = vec.begin(); 2660 it != vec.end(); ++ it) 2661 { 2662 VBoxMedium medium (CMedium (*it), VBoxDefs::MediaType_DVD); 2663 2664 /* search for a proper alphabetic position */ 2665 VBoxMediaList::iterator jt = first; 2666 for (; jt != mMediaList.end(); ++ jt) 2667 if ((*jt).name().localeAwareCompare (medium.name()) > 0) 2668 break; 2669 2670 mMediaList.insert (jt, medium); 2671 2672 /* adjust the first item if inserted before it */ 2673 if (jt == first) 2674 -- first; 2675 } 2676 } 2677 { 2678 VBoxMediaList::iterator first = mMediaList.end(); 2679 2680 CFloppyImage2Vector vec = mVBox.GetFloppyImages(); 2681 for (CFloppyImage2Vector::ConstIterator it = vec.begin(); 2682 it != vec.end(); ++ it) 2683 { 2684 VBoxMedium medium (CMedium (*it), VBoxDefs::MediaType_Floppy); 2685 2686 /* search for a proper alphabetic position */ 2687 VBoxMediaList::iterator jt = first; 2688 for (; jt != mMediaList.end(); ++ jt) 2689 if ((*jt).name().localeAwareCompare (medium.name()) > 0) 2690 break; 2691 2692 mMediaList.insert (jt, medium); 2693 2694 /* adjust the first item if inserted before it */ 2695 if (jt == first) 2696 -- first; 2697 } 2206 2698 } 2207 2699 2208 2700 /* enumeration thread class */ 2209 class Thread : public QThread2701 class MediaEnumThread : public QThread 2210 2702 { 2211 2703 public: 2212 2704 2213 Thread (const VBoxMediaList &aList) : mList (aList) {}2705 MediaEnumThread (const VBoxMediaList &aList) : mList (aList) {} 2214 2706 2215 2707 virtual void run() … … 2219 2711 2220 2712 CVirtualBox mVBox = vboxGlobal().virtualBox(); 2221 QObject * target= &vboxGlobal();2222 2223 /* enumerat inglist */2713 QObject *self = &vboxGlobal(); 2714 2715 /* enumerate the list */ 2224 2716 int index = 0; 2225 2717 VBoxMediaList::const_iterator it; … … 2228 2720 ++ it, ++ index) 2229 2721 { 2230 VBoxMedia media = *it; 2231 switch (media.type) 2232 { 2233 case VBoxDefs::HD: 2234 { 2235 CHardDisk hd = media.disk; 2236 media.status = 2237 hd.GetAccessible() == TRUE ? VBoxMedia::Ok : 2238 hd.isOk() ? VBoxMedia::Inaccessible : 2239 VBoxMedia::Error; 2240 /* assign back to store error info if any */ 2241 media.disk = hd; 2242 if (media.status == VBoxMedia::Inaccessible) 2243 { 2244 QUuid machineId = hd.GetMachineId(); 2245 if (!machineId.isNull()) 2246 { 2247 CMachine machine = mVBox.GetMachine (machineId); 2248 if (!machine.isNull() && (machine.GetState() >= KMachineState_Running)) 2249 media.status = VBoxMedia::Ok; 2250 } 2251 } 2252 QApplication::postEvent (target, 2253 new VBoxEnumerateMediaEvent (media, index)); 2254 break; 2255 } 2256 case VBoxDefs::CD: 2257 { 2258 CDVDImage cd = media.disk; 2259 media.status = 2260 cd.GetAccessible() == TRUE ? VBoxMedia::Ok : 2261 cd.isOk() ? VBoxMedia::Inaccessible : 2262 VBoxMedia::Error; 2263 /* assign back to store error info if any */ 2264 media.disk = cd; 2265 QApplication::postEvent (target, 2266 new VBoxEnumerateMediaEvent (media, index)); 2267 break; 2268 } 2269 case VBoxDefs::FD: 2270 { 2271 CFloppyImage fd = media.disk; 2272 media.status = 2273 fd.GetAccessible() == TRUE ? VBoxMedia::Ok : 2274 fd.isOk() ? VBoxMedia::Inaccessible : 2275 VBoxMedia::Error; 2276 /* assign back to store error info if any */ 2277 media.disk = fd; 2278 QApplication::postEvent (target, 2279 new VBoxEnumerateMediaEvent (media, index)); 2280 break; 2281 } 2282 default: 2283 { 2284 AssertMsgFailed (("Invalid aMedia type\n")); 2285 break; 2286 } 2287 } 2722 VBoxMedium medium = *it; 2723 medium.blockAndQueryState(); 2724 QApplication::postEvent (self, 2725 new VBoxMediaEnumEvent (medium, index)); 2288 2726 } 2289 2727 2290 /* post the last message to indicate the end of enumeration*/2728 /* post the end-of-enumeration event */ 2291 2729 if (!sVBoxGlobalInCleanup) 2292 QApplication::postEvent ( target, new VBoxEnumerateMediaEvent());2730 QApplication::postEvent (self, new VBoxMediaEnumEvent()); 2293 2731 2294 2732 COMBase::CleanupCOM(); … … 2301 2739 }; 2302 2740 2303 m edia_enum_thread = new Thread (media_list);2304 AssertReturnVoid (m edia_enum_thread);2305 2306 /* emit mediaEnumStarted() after we set m edia_enum_thread to != NULL2741 mMediaEnumThread = new MediaEnumThread (mMediaList); 2742 AssertReturnVoid (mMediaEnumThread); 2743 2744 /* emit mediaEnumStarted() after we set mMediaEnumThread to != NULL 2307 2745 * to cause isMediaEnumerationStarted() to return TRUE from slots */ 2308 2746 emit mediaEnumStarted(); 2309 2747 2310 media_enum_thread->start(); 2311 } 2312 2313 /** 2314 * Adds a new media to the current media list. 2315 * @note Currently, this method does nothing but emits the mediaAdded() signal. 2316 * Later, it will be used to synchronize the current media list with 2317 * the actial media list on the server after a single media opetartion 2318 * performed from within one of our UIs. 2319 * @sa #currentMediaList() 2320 */ 2321 void VBoxGlobal::addMedia (const VBoxMedia &aMedia) 2322 { 2323 emit mediaAdded (aMedia); 2324 } 2325 2326 /** 2327 * Updates the media in the current media list. 2328 * @note Currently, this method does nothing but emits the mediaUpdated() signal. 2329 * Later, it will be used to synchronize the current media list with 2330 * the actial media list on the server after a single media opetartion 2331 * performed from within one of our UIs. 2332 * @sa #currentMediaList() 2333 */ 2334 void VBoxGlobal::updateMedia (const VBoxMedia &aMedia) 2335 { 2336 emit mediaUpdated (aMedia); 2337 } 2338 2339 /** 2340 * Removes the media from the current media list. 2341 * @note Currently, this method does nothing but emits the mediaRemoved() signal. 2342 * Later, it will be used to synchronize the current media list with 2343 * the actial media list on the server after a single media opetartion 2344 * performed from within one of our UIs. 2345 * @sa #currentMediaList() 2346 */ 2347 void VBoxGlobal::removeMedia (VBoxDefs::DiskType aType, const QUuid &aId) 2348 { 2349 emit mediaRemoved (aType, aId); 2350 } 2351 2352 /** 2353 * Searches for a VBoxMedia object representing the given COM media object. 2748 mMediaEnumThread->start(); 2749 } 2750 2751 /** 2752 * Adds a new medium to the current media list and emits the #mediumAdded() 2753 * signal. 2754 * 2755 * @sa #currentMediaList() 2756 */ 2757 void VBoxGlobal::addMedium (const VBoxMedium &aMedium) 2758 { 2759 /* Note that we maitain the same order here as #startEnumeratingMedia() */ 2760 2761 VBoxMediaList::iterator it = mMediaList.begin(); 2762 2763 if (aMedium.type() == VBoxDefs::MediaType_HardDisk) 2764 { 2765 VBoxMediaList::iterator parent = mMediaList.end(); 2766 2767 for (; it != mMediaList.end(); ++ it) 2768 { 2769 if ((*it).type() != VBoxDefs::MediaType_HardDisk) 2770 break; 2771 2772 if (aMedium.parent() != NULL && parent == mMediaList.end()) 2773 { 2774 if (&*it == aMedium.parent()) 2775 parent = it; 2776 } 2777 else 2778 { 2779 /* break if met a parent's sibling (will insert before it) */ 2780 if (aMedium.parent() != NULL && 2781 (*it).parent() == (*parent).parent()) 2782 break; 2783 2784 /* compare to aMedium's siblings */ 2785 if ((*it).parent() == aMedium.parent() && 2786 (*it).name().localeAwareCompare (aMedium.name()) > 0) 2787 break; 2788 } 2789 } 2790 2791 AssertReturnVoid (aMedium.parent() == NULL || parent != mMediaList.end()); 2792 } 2793 else 2794 { 2795 for (; it != mMediaList.end(); ++ it) 2796 { 2797 /* skip HardDisks that come first */ 2798 if ((*it).type() == VBoxDefs::MediaType_HardDisk) 2799 continue; 2800 2801 /* skip DVD when inserting Floppy */ 2802 if (aMedium.type() == VBoxDefs::MediaType_Floppy && 2803 (*it).type() == VBoxDefs::MediaType_DVD) 2804 continue; 2805 2806 if ((*it).name().localeAwareCompare (aMedium.name()) > 0 || 2807 (aMedium.type() == VBoxDefs::MediaType_DVD && 2808 (*it).type() == VBoxDefs::MediaType_Floppy)) 2809 break; 2810 } 2811 } 2812 2813 it = mMediaList.insert (it, aMedium); 2814 2815 emit mediumAdded (*it); 2816 } 2817 2818 /** 2819 * Updates the medium in the current media list and emits the #mediumUpdated() 2820 * signal. 2821 * 2822 * @sa #currentMediaList() 2823 */ 2824 void VBoxGlobal::updateMedium (const VBoxMedium &aMedium) 2825 { 2826 VBoxMediaList::Iterator it; 2827 for (it = mMediaList.begin(); it != mMediaList.end(); ++ it) 2828 if ((*it).id() == aMedium.id()) 2829 break; 2830 2831 AssertReturnVoid (it != mMediaList.end()); 2832 2833 if (&*it != &aMedium) 2834 *it = aMedium; 2835 2836 emit mediumUpdated (*it); 2837 } 2838 2839 /** 2840 * Removes the medium from the current media list and emits the #mediumRemoved() 2841 * signal. 2842 * 2843 * @sa #currentMediaList() 2844 */ 2845 void VBoxGlobal::removeMedium (VBoxDefs::MediaType aType, const QUuid &aId) 2846 { 2847 VBoxMediaList::Iterator it; 2848 for (it = mMediaList.begin(); it != mMediaList.end(); ++ it) 2849 if ((*it).id() == aId) 2850 break; 2851 2852 AssertReturnVoid (it != mMediaList.end()); 2853 2854 #if DEBUG 2855 /* sanity: must be no children */ 2856 { 2857 VBoxMediaList::Iterator jt = it; 2858 ++ jt; 2859 AssertReturnVoid (jt == mMediaList.end() || (*jt).parent() != &*it); 2860 } 2861 #endif 2862 2863 VBoxMedium *parent = (*it).parent(); 2864 2865 /* remove the medium from the list to keep it in sync with the server "for 2866 * free" when the medium is deleted from one of our UIs */ 2867 mMediaList.erase (it); 2868 2869 emit mediumRemoved (aType, aId); 2870 2871 /* also emit the parent update signal because some attributes like 2872 * isReadOnly() may have been changed after child removal */ 2873 if (parent != NULL) 2874 { 2875 parent->refresh(); 2876 emit mediumUpdated (*parent); 2877 } 2878 } 2879 2880 /** 2881 * Searches for a VBoxMedum object representing the given COM medium object. 2354 2882 * 2355 2883 * @return true if found and false otherwise. 2356 2884 */ 2357 bool VBoxGlobal::findMedi a (const CUnknown &aObj, VBoxMedia &aMedia) const2358 { 2359 for (VBoxMediaList::ConstIterator it = m edia_list.begin();2360 it != m edia_list.end(); ++ it)2361 { 2362 if ((*it). disk== aObj)2363 { 2364 aMedi a= (*it);2885 bool VBoxGlobal::findMedium (const CMedium &aObj, VBoxMedium &aMedium) const 2886 { 2887 for (VBoxMediaList::ConstIterator it = mMediaList.begin(); 2888 it != mMediaList.end(); ++ it) 2889 { 2890 if ((*it).medium() == aObj) 2891 { 2892 aMedium = (*it); 2365 2893 return true; 2366 2894 } … … 2447 2975 machineStates [KMachineState_Restoring] = tr ("Restoring", "MachineState"); 2448 2976 machineStates [KMachineState_Discarding] = tr ("Discarding", "MachineState"); 2977 machineStates [KMachineState_SettingUp] = tr ("Setting Up", "MachineState"); 2449 2978 2450 2979 sessionStates [KSessionState_Closed] = tr ("Closed", "SessionState"); … … 2484 3013 diskTypes [KHardDiskType_Writethrough] = 2485 3014 tr ("Writethrough", "DiskType"); 2486 2487 diskStorageTypes [KHardDiskStorageType_VirtualDiskImage] = 2488 tr ("Virtual Disk Image", "DiskStorageType"); 2489 diskStorageTypes [KHardDiskStorageType_ISCSIHardDisk] = 2490 tr ("iSCSI", "DiskStorageType"); 2491 diskStorageTypes [KHardDiskStorageType_VMDKImage] = 2492 tr ("VMDK Image", "DiskStorageType"); 2493 diskStorageTypes [KHardDiskStorageType_CustomHardDisk] = 2494 tr ("Custom Hard Disk", "DiskStorageType"); 2495 diskStorageTypes [KHardDiskStorageType_VHDImage] = 2496 tr ("VHD Image", "DiskStorageType"); 3015 diskTypes_Differencing = 3016 tr ("Differencing", "DiskType"); 2497 3017 2498 3018 vrdpAuthTypes [KVRDPAuthType_Null] = … … 2583 3103 2584 3104 mUserDefinedPortName = tr ("User-defined", "serial port"); 3105 3106 { 3107 QImage img = 3108 QMessageBox::standardIcon (QMessageBox::Warning).convertToImage(); 3109 img = img.smoothScale (16, 16); 3110 mWarningIcon.convertFromImage (img); 3111 Assert (!mWarningIcon.isNull()); 3112 3113 img = 3114 QMessageBox::standardIcon (QMessageBox::Critical).convertToImage(); 3115 img = img.smoothScale (16, 16); 3116 mErrorIcon.convertFromImage (img); 3117 Assert (!mErrorIcon.isNull()); 3118 } 2585 3119 2586 3120 detailReportTemplatesReady = false; … … 3220 3754 3221 3755 /** 3756 * Puts soft hyphens after every path component in the given file name. 3757 * 3758 * @param aFileName File name (must be a full path name). 3759 */ 3760 /* static */ 3761 QString VBoxGlobal::locationForHTML (const QString &aFileName) 3762 { 3763 /// @todo (dmik) remove? 3764 // QString result = QDir::convertSeparators (fn); 3765 //#ifdef Q_OS_LINUX 3766 // result.replace ('/', "/<font color=red>­</font>"); 3767 //#else 3768 // result.replace ('\\', "\\<font color=red>­</font>"); 3769 //#endif 3770 // return result; 3771 QFileInfo fi (aFileName); 3772 return fi.fileName(); 3773 } 3774 3775 /** 3222 3776 * Reformats the input string @a aStr so that: 3223 3777 * - strings in single quotes will be put inside <nobr> and marked … … 3769 4323 3770 4324 /** 4325 * Joins two pixmaps horizontally with 2px space between them and returns the 4326 * result. 4327 * 4328 * @param aPM1 Left pixmap. 4329 * @param aPM2 Right pixmap. 4330 */ 4331 /* static */ 4332 QPixmap VBoxGlobal::joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2) 4333 { 4334 if (aPM1.isNull()) 4335 return aPM2; 4336 if (aPM2.isNull()) 4337 return aPM1; 4338 4339 QPixmap res; 4340 4341 { 4342 QImage img (aPM1.width() + aPM2.width() + 2, 4343 QMAX (aPM1.height(), aPM2.height()), 32); 4344 img.setAlphaBuffer (true); 4345 img.fill (0); 4346 res.convertFromImage (img); 4347 } 4348 4349 copyBlt (&res, 0, 0, &aPM1); 4350 copyBlt (&res, aPM1.width() + 2, res.height() - aPM2.height(), &aPM2); 4351 4352 return res; 4353 } 4354 4355 /** 3771 4356 * Searches for a widget that with @a aName (if it is not NULL) which inherits 3772 4357 * @a aClassName (if it is not NULL) and among children of @a aParent. If @a … … 3975 4560 } 3976 4561 3977 case VBoxDefs:: EnumerateMediaEventType:3978 { 3979 VBox EnumerateMediaEvent *ev = (VBoxEnumerateMediaEvent *) e;4562 case VBoxDefs::MediaEnumEventType: 4563 { 4564 VBoxMediaEnumEvent *ev = (VBoxMediaEnumEvent *) e; 3980 4565 3981 4566 if (!ev->mLast) 3982 4567 { 3983 if (ev->mMedia.status == VBoxMedia::Error) 3984 vboxProblem().cannotGetMediaAccessibility (ev->mMedia.disk); 3985 media_list [ev->mIndex] = ev->mMedia; 3986 emit mediaEnumerated (media_list [ev->mIndex], ev->mIndex); 4568 if (ev->mMedium.state() == KMediaState_Inaccessible && 4569 !ev->mMedium.result().isOk()) 4570 vboxProblem().cannotGetMediaAccessibility (ev->mMedium); 4571 mMediaList [ev->mIndex] = ev->mMedium; 4572 emit mediumEnumerated (mMediaList [ev->mIndex], ev->mIndex); 3987 4573 } 3988 4574 else 3989 4575 { 3990 4576 /* the thread has posted the last message, wait for termination */ 3991 m edia_enum_thread->wait();3992 delete m edia_enum_thread;3993 m edia_enum_thread = 0;3994 3995 emit mediaEnumFinished (m edia_list);4577 mMediaEnumThread->wait(); 4578 delete mMediaEnumThread; 4579 mMediaEnumThread = 0; 4580 4581 emit mediaEnumFinished (mMediaList); 3996 4582 } 3997 4583 … … 4167 4753 {KMachineState_Restoring, "state_restoring_16px.png"}, 4168 4754 {KMachineState_Discarding, "state_discarding_16px.png"}, 4755 {KMachineState_SettingUp, "settings_16px.png"}, 4169 4756 }; 4170 4757 mStateIcons.setAutoDelete (true); // takes ownership of elements … … 4193 4780 vm_state_color.insert (KMachineState_Restoring, &Qt::green); 4194 4781 vm_state_color.insert (KMachineState_Discarding, &Qt::green); 4782 vm_state_color.insert (KMachineState_SettingUp, &Qt::green); 4195 4783 4196 4784 /* Redefine default large and small icon sizes. In particular, it is … … 4324 4912 } 4325 4913 4326 if (m edia_enum_thread)4914 if (mMediaEnumThread) 4327 4915 { 4328 4916 /* sVBoxGlobalInCleanup is true here, so just wait for the thread */ 4329 m edia_enum_thread->wait();4330 delete m edia_enum_thread;4331 m edia_enum_thread = 0;4917 mMediaEnumThread->wait(); 4918 delete mMediaEnumThread; 4919 mMediaEnumThread = NULL; 4332 4920 } 4333 4921 … … 4345 4933 vm_os_types.clear(); 4346 4934 /* media list contains a lot of CUUnknown, release them */ 4347 m edia_list.clear();4935 mMediaList.clear(); 4348 4936 /* the last step to ensure we don't use COM any more */ 4349 4937 mVBox.detach(); 4350 4938 4351 /* There may be VBox EnumerateMediaEvent instances still in the message4939 /* There may be VBoxMediaEnumEvent instances still in the message 4352 4940 * queue which reference COM objects. Remove them to release those objects 4353 4941 * before uninitializing the COM subsystem. */ … … 4411 4999 while (en.HasMore()) 4412 5000 { 4413 CHostUSBDevice iterator= en.GetNext();4414 CUSBDevice usb = CUnknown (iterator);5001 CHostUSBDevice dev = en.GetNext(); 5002 CUSBDevice usb (dev); 4415 5003 int id = insertItem (vboxGlobal().details (usb)); 4416 5004 mUSBDevicesMap [id] = usb; … … 4421 5009 mConsole.GetUSBDevices().FindById (usb.GetId()); 4422 5010 setItemChecked (id, !attachedUSB.isNull()); 4423 setItemEnabled (id, iterator.GetState() !=5011 setItemEnabled (id, dev.GetState() != 4424 5012 KUSBDeviceState_Unavailable); 4425 5013 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaComboBox.cpp
r9487 r13580 22 22 23 23 #include "VBoxMediaComboBox.h" 24 #include "VBox DiskImageManagerDlg.h"24 #include "VBoxMediaManagerDlg.h" 25 25 26 26 #include <qfileinfo.h> … … 31 31 #include <qlistbox.h> 32 32 33 VBoxMediaComboBox::VBoxMediaComboBox (QWidget *aParent, const char *aName, 34 int aType, bool aUseEmptyItem) 35 : QComboBox (aParent , aName), 36 mType (aType), mRequiredId (QUuid()), mUseEmptyItem (aUseEmptyItem) 33 VBoxMediaComboBox:: 34 VBoxMediaComboBox (QWidget *aParent, const char *aName, 35 VBoxDefs::MediaType aType, QUuid aMachineId /*= QUuid()*/) 36 : QComboBox (aParent , aName) 37 , mType (aType), mLastId (QUuid()) 38 , mShowDiffs (false) 39 , mMachineId (aMachineId) 37 40 { 38 41 setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed); 42 39 43 /* setup enumeration handlers */ 40 44 connect (&vboxGlobal(), SIGNAL (mediaEnumStarted()), 41 45 this, SLOT (mediaEnumStarted())); 42 connect (&vboxGlobal(), SIGNAL (medi aEnumerated (const VBoxMedia&, int)),43 this, SLOT (medi aEnumerated (const VBoxMedia&, int)));46 connect (&vboxGlobal(), SIGNAL (mediumEnumerated (const VBoxMedium &, int)), 47 this, SLOT (mediumEnumerated (const VBoxMedium &, int))); 44 48 45 49 /* setup update handlers */ 46 connect (&vboxGlobal(), SIGNAL (medi aAdded (const VBoxMedia&)),47 this, SLOT (medi aAdded (const VBoxMedia&)));48 connect (&vboxGlobal(), SIGNAL (medi aUpdated (const VBoxMedia&)),49 this, SLOT (medi aUpdated (const VBoxMedia&)));50 connect (&vboxGlobal(), SIGNAL (medi aRemoved (VBoxDefs::DiskType, const QUuid &)),51 this, SLOT (medi aRemoved (VBoxDefs::DiskType, const QUuid &)));50 connect (&vboxGlobal(), SIGNAL (mediumAdded (const VBoxMedium &)), 51 this, SLOT (mediumAdded (const VBoxMedium &))); 52 connect (&vboxGlobal(), SIGNAL (mediumUpdated (const VBoxMedium &)), 53 this, SLOT (mediumUpdated (const VBoxMedium &))); 54 connect (&vboxGlobal(), SIGNAL (mediumRemoved (VBoxDefs::MediaType, const QUuid &)), 55 this, SLOT (mediumRemoved (VBoxDefs::MediaType, const QUuid &))); 52 56 53 57 connect (this, SIGNAL (activated (int)), 54 58 this, SLOT (processActivated (int))); 55 59 56 /* in some qt themes embeddedlist-box is not used by default, so create it */60 /* in some qt themes the list-box is not used by default, so create it */ 57 61 if (!listBox()) 58 62 setListBox (new QListBox (this)); 59 if (listBox()) 60 connect (listBox(), SIGNAL (onItem (QListBoxItem*)), 61 this, SLOT (processOnItem (QListBoxItem*))); 62 63 /* cache pixmaps as class members */ 64 QImage img; 65 img = QMessageBox::standardIcon (QMessageBox::Warning).convertToImage(); 66 if (!img.isNull()) 67 { 68 img = img.smoothScale (14, 14); 69 mPmInacc.convertFromImage (img); 70 } 71 img = QMessageBox::standardIcon (QMessageBox::Critical).convertToImage(); 72 if (!img.isNull()) 73 { 74 img = img.smoothScale (14, 14); 75 mPmError.convertFromImage (img); 76 } 77 } 78 63 64 AssertReturnVoid (listBox()); 65 66 connect (listBox(), SIGNAL (onItem (QListBoxItem*)), 67 this, SLOT (processOnItem (QListBoxItem*))); 68 } 69 70 /** 71 * Fills this combobox with the current media list. 72 */ 79 73 void VBoxMediaComboBox::refresh() 80 74 { 81 /* clearing lists */ 82 clear(), mUuidList.clear(), mTipList.clear(); 83 /* prepend empty item if used */ 84 if (mUseEmptyItem) 85 appendItem (tr ("<no hard disk>"), QUuid(), tr ("No hard disk"), 0); 86 /* load current media list */ 75 /* clear lists */ 76 clear(), mMedia.clear(); 77 78 /* load the current media list */ 87 79 VBoxMediaList list = vboxGlobal().currentMediaList(); 88 80 VBoxMediaList::const_iterator it; 89 81 for (it = list.begin(); it != list.end(); ++ it) 90 mediaEnumerated (*it, 0); 91 /* activate item selected during current list loading */ 92 processActivated (currentItem()); 93 } 94 82 mediumAdded (*it); 83 84 if (count() == 0) 85 { 86 /* no media of the desired type, add the "no media" pseudo-item */ 87 addNoMediaItem(); 88 } 89 90 /* inform the interested parties about the possibly changed active item's 91 * icon, text, tooltip etc. */ 92 emit activated (currentItem()); 93 } 94 95 /** 96 * Requests the global media list enumeration and repopulates the list with its 97 * results. 98 */ 99 void VBoxMediaComboBox::repopulate() 100 { 101 if (!vboxGlobal().isMediaEnumerationStarted()) 102 vboxGlobal().startEnumeratingMedia(); 103 else 104 refresh(); 105 } 106 107 QUuid VBoxMediaComboBox::id (int aIndex /*= -1*/) 108 { 109 AssertReturn (aIndex == -1 || 110 (aIndex >= 0 && (size_t) aIndex < mMedia.size()), 111 QUuid()); 112 113 return mMedia [aIndex == -1 ? currentItem() : aIndex].id; 114 } 115 116 QString VBoxMediaComboBox::location (int aIndex /*= -1*/) 117 { 118 AssertReturn (aIndex == -1 || 119 (aIndex >= 0 && (size_t) aIndex < mMedia.size()), 120 QString::null); 121 122 return mMedia [aIndex == -1 ? currentItem() : aIndex].location; 123 } 124 125 /** 126 * Selects a media item with the given ID or does nothing if there is no such 127 * item. Note that this method, as opposed to QComboBox::setCurrentItem(int), 128 * does emit the activated() signal on success. 129 */ 130 void VBoxMediaComboBox::setCurrentItem (const QUuid &aId) 131 { 132 mLastId = aId; 133 134 size_t index; 135 if (findMediaIndex (aId, index)) 136 { 137 /* Note that the media combobox may be not populated here yet, so we 138 * don't assert */ 139 QComboBox::setCurrentItem (index); 140 emit activated (index); 141 } 142 } 143 144 void VBoxMediaComboBox::setType (VBoxDefs::MediaType aType) 145 { 146 mType = aType; 147 } 148 149 /** 150 * Enables or disables the "show diffs" mode. 151 * 152 * In disabled "show diffs" mode, this combobox will only include base hard 153 * disks plus differencing hard disks that are attached to the associated 154 * machine passed to the constructor in the current state (if any). Note 155 * that for these differencing hard disks, the details of their base hard disks 156 * are shown instead of their own details (human-friendly mode). 157 * 158 * In enabled "show diffs" mode, all hard disks, base and differencing, are 159 * shown. 160 * 161 * Note that you must call #refresh() in order for this change to take effect. 162 * 163 * @param aShowDiffs @c true to enable "show diffs" mode. 164 */ 165 void VBoxMediaComboBox::setShowDiffs (bool aShowDiffs) 166 { 167 AssertReturnVoid (aShowDiffs == true || !mMachineId.isNull()); 168 169 mShowDiffs = aShowDiffs; 170 } 95 171 96 172 void VBoxMediaComboBox::mediaEnumStarted() … … 99 175 } 100 176 101 void VBoxMediaComboBox::mediaEnumerated (const VBoxMedia &aMedia, int /*aIndex*/) 102 { 103 processMedia (aMedia); 104 } 105 106 107 void VBoxMediaComboBox::mediaAdded (const VBoxMedia &aMedia) 108 { 109 processMedia (aMedia); 110 } 111 112 void VBoxMediaComboBox::mediaUpdated (const VBoxMedia &aMedia) 113 { 114 processMedia (aMedia); 115 } 116 117 void VBoxMediaComboBox::mediaRemoved (VBoxDefs::DiskType aType, 118 const QUuid &aId) 119 { 120 if (!(aType & mType)) 121 return; 122 123 /* search & remove media */ 124 int index = mUuidList.findIndex (aId); 125 if (index != -1) 126 { 127 removeItem (index); 128 mUuidList.remove (mUuidList.at (index)); 129 mTipList.remove (mTipList.at (index)); 130 /* emit signal to ensure parent dialog process selection changes */ 131 emit activated (currentItem()); 132 } 133 } 134 135 136 void VBoxMediaComboBox::processMedia (const VBoxMedia &aMedia) 137 { 138 if (!(aMedia.type & mType)) 139 return; 140 141 switch (aMedia.type) 142 { 143 case VBoxDefs::HD: 177 void VBoxMediaComboBox::mediumEnumerated (const VBoxMedium &aMedium, int /*aIndex*/) 178 { 179 mediumUpdated (aMedium); 180 } 181 182 void VBoxMediaComboBox::mediumAdded (const VBoxMedium &aMedium) 183 { 184 if (mType != aMedium.type()) 185 return; 186 187 if (!mShowDiffs && aMedium.type() == VBoxDefs::MediaType_HardDisk) 188 { 189 if (aMedium.parent() != NULL) 144 190 { 145 /* ignoring non-root disks */ 146 CHardDisk hd = aMedia.disk; 147 if (hd.GetParent().isNull()) 148 processHdMedia (aMedia); 149 break; 191 /* in !mShowDiffs mode, we ignore all diffs except ones that are 192 * directly attached to the related VM in the current state */ 193 if (!aMedium.isAttachedInCurStateTo (mMachineId)) 194 return; 150 195 } 151 case VBoxDefs::CD: 152 processCdMedia (aMedia); 153 break; 154 case VBoxDefs::FD: 155 processFdMedia (aMedia); 156 break; 157 default: 158 AssertFailed(); 159 } 160 } 161 162 void VBoxMediaComboBox::processHdMedia (const VBoxMedia &aMedia) 163 { 164 QUuid mediaId; 165 QString toolTip; 166 CHardDisk hd = aMedia.disk; 167 QString src = hd.GetLocation(); 168 QUuid machineId = hd.GetMachineId(); 169 /* append list only with free hd */ 170 if (machineId.isNull() || machineId == mMachineId) 171 { 172 mediaId = hd.GetId(); 173 toolTip = VBoxDiskImageManagerDlg::composeHdToolTip (hd, aMedia.status); 174 } 175 if (!mediaId.isNull()) 176 updateShortcut (src, mediaId, toolTip, aMedia.status); 177 } 178 179 void VBoxMediaComboBox::processCdMedia (const VBoxMedia &aMedia) 180 { 181 CDVDImage dvd = aMedia.disk; 182 QString src = dvd.GetFilePath(); 183 QUuid mediaId = dvd.GetId(); 184 QString toolTip = VBoxDiskImageManagerDlg::composeCdToolTip (dvd, aMedia.status); 185 updateShortcut (src, mediaId, toolTip, aMedia.status); 186 } 187 188 void VBoxMediaComboBox::processFdMedia (const VBoxMedia &aMedia) 189 { 190 CFloppyImage floppy = aMedia.disk; 191 QString src = floppy.GetFilePath(); 192 QUuid mediaId = floppy.GetId(); 193 QString toolTip = VBoxDiskImageManagerDlg::composeFdToolTip (floppy, aMedia.status); 194 updateShortcut (src, mediaId, toolTip, aMedia.status); 195 } 196 197 void VBoxMediaComboBox::updateShortcut (const QString &aSrc, 198 const QUuid &aId, 199 const QString &aTip, 200 VBoxMedia::Status aStatus) 201 { 202 /* compose item's name */ 203 QFileInfo fi (aSrc); 204 QString name = QString ("%1 (%2)").arg (fi.fileName()) 205 .arg (QDir::convertSeparators (fi.dirPath())); 206 /* update warning/error icons */ 207 QPixmap *pixmap = 0; 208 if (aStatus == VBoxMedia::Inaccessible) 209 pixmap = &mPmInacc; 210 else if (aStatus == VBoxMedia::Error) 211 pixmap = &mPmError; 212 213 /* search media */ 214 int index = mUuidList.findIndex (aId); 215 /* create or update media */ 216 if (index == -1) 217 appendItem (name, aId, aTip, pixmap); 218 else 219 replaceItem (index, name, aTip, pixmap); 220 221 /* activate required item if it was updated */ 222 if (aId == mRequiredId) 223 setCurrentItem (aId); 224 /* select last added item if there is no item selected */ 196 } 197 198 appendItem (aMedium); 199 200 if (aMedium.id() == mLastId) 201 { 202 /* activate the required item if there is any */ 203 setCurrentItem (aMedium.id()); 204 } 225 205 else if (currentText().isEmpty()) 226 QComboBox::setCurrentItem (index == -1 ? count() - 1 : index); 227 } 228 229 void VBoxMediaComboBox::processActivated (int aItem) 230 { 231 mRequiredId = mUuidList.isEmpty() || aItem < 0 ? QUuid() : QUuid (mUuidList [aItem]); 232 updateToolTip (aItem); 233 } 234 235 void VBoxMediaComboBox::updateToolTip (int aItem) 236 { 237 /* combobox tooltip attaching */ 206 { 207 /* select last added item if there is no item selected */ 208 QComboBox::setCurrentItem (count() - 1); 209 } 210 } 211 212 void VBoxMediaComboBox::mediumUpdated (const VBoxMedium &aMedium) 213 { 214 if (mType != aMedium.type()) 215 return; 216 217 size_t index; 218 if (!findMediaIndex (aMedium.id(), index)) 219 return; 220 221 replaceItem (index, aMedium); 222 223 /* emit the signal to ensure the parent dialog handles the change of 224 * the selected item's data */ 225 emit activated (currentItem()); 226 } 227 228 void VBoxMediaComboBox::mediumRemoved (VBoxDefs::MediaType aType, 229 const QUuid &aId) 230 { 231 if (mType != aType) 232 return; 233 234 size_t index; 235 if (!findMediaIndex (aId, index)) 236 return; 237 238 removeItem (index); 239 240 mMedia.erase (mMedia.begin() + index); 241 242 if (count() == 0) 243 { 244 /* no media left, add the "no media" pseudo-item */ 245 addNoMediaItem(); 246 } 247 248 /* emit the signal to ensure the parent dialog handles the change of 249 * the selected item */ 250 emit activated (currentItem()); 251 } 252 253 void VBoxMediaComboBox::processActivated (int aIndex) 254 { 255 AssertReturnVoid (aIndex >= 0 && (size_t) aIndex < mMedia.size()); 256 257 mLastId = mMedia [aIndex].id; 258 259 updateToolTip (aIndex); 260 } 261 262 void VBoxMediaComboBox::addNoMediaItem() 263 { 264 AssertReturnVoid (count() == 0); 265 AssertReturnVoid (mMedia.size() == 0); 266 267 mMedia.append ( 268 Medium (QUuid(), QString::null, 269 tr ("No media available. Use the Virtual Media " 270 "Manager to add media of the corresponding type."))); 271 insertItem (tr ("<no media>")); 272 273 setCurrentItem (0); 274 } 275 276 void VBoxMediaComboBox::updateToolTip (int aIndex) 277 { 278 /* set the combobox tooltip */ 238 279 QToolTip::remove (this); 239 if ( !mTipList.isEmpty() && aItem >= 0)240 QToolTip::add (this, m TipList [aItem]);241 } 242 243 void VBoxMediaComboBox::processOnItem (QListBoxItem *aItem)244 { 245 /* combobox item's tooltip attaching*/280 if (aIndex >= 0 && (size_t) aIndex < mMedia.size()) 281 QToolTip::add (this, mMedia [aIndex].toolTip); 282 } 283 284 void VBoxMediaComboBox::processOnItem (QListBoxItem *aItem) 285 { 286 /* set the combobox item's tooltip */ 246 287 int index = listBox()->index (aItem); 247 288 QToolTip::remove (listBox()->viewport()); 248 QToolTip::add (listBox()->viewport(), mTipList [index]); 249 } 250 251 QUuid VBoxMediaComboBox::getId (int aId) 252 { 253 return mUuidList.isEmpty() ? QUuid() : 254 aId == -1 ? QUuid (mUuidList [currentItem()]) : 255 QUuid (mUuidList [aId]); 256 } 257 258 void VBoxMediaComboBox::appendItem (const QString &aName, 259 const QUuid &aId, 260 const QString &aTip, 261 QPixmap *aPixmap) 262 { 263 int currentIndex = currentItem(); 264 265 int insertPosition = -1; 266 for (int i = 0; i < count(); ++ i) 267 /* Searching for the first real (non-null) vdi item 268 which have name greater than the item to be inserted. 269 This is necessary for sorting items alphabetically. */ 270 if (text (i).localeAwareCompare (aName) > 0 && 271 !getId (i).isNull()) 289 QToolTip::add (listBox()->viewport(), mMedia [index].toolTip); 290 } 291 292 void VBoxMediaComboBox::appendItem (const VBoxMedium &aMedium) 293 { 294 if (!mShowDiffs && aMedium.parent() != NULL) 295 { 296 /* We are adding the direct machine diff in !mShowDiffs mode. Since its 297 * base hard disk has been already appended (enumerated before), we want 298 * to replace the base with the diff to avoid shownig both (both would 299 * be labeled using the base filename and therefore look like 300 * duplicates). Note though that these visual duplicates are still 301 * possible in !mShowDiffs mode if the same base hard disk is attached* 302 * to the VM through different diffs (this is why we don't assert 303 * below on findMediaIndex() == true). However, this situation is 304 * unavoidable so we accept it assuming that the user will switch to 305 mShowDiffs mode if he needs clarity. */ 306 size_t index; 307 if (findMediaIndex (aMedium.root().id(), index)) 272 308 { 273 insertPosition = i; 309 replaceItem (index, aMedium); 310 return; 311 } 312 } 313 314 if (count() == 1 && mMedia [0].id.isNull()) 315 { 316 /* there is a "no media" pseudo-item, remove it */ 317 clear(), mMedia.clear(); 318 } 319 320 mMedia.append (Medium (aMedium.id(), aMedium.location(), 321 aMedium.toolTipCheckRO (!mShowDiffs))); 322 323 insertItem (aMedium.iconCheckRO (!mShowDiffs), 324 aMedium.details (!mShowDiffs), -1); 325 } 326 327 void VBoxMediaComboBox::replaceItem (int aIndex, const VBoxMedium &aMedium) 328 { 329 AssertReturnVoid (aIndex >= 0 && (size_t) aIndex < mMedia.size()); 330 331 mMedia [aIndex].id = aMedium.id(); 332 mMedia [aIndex].location = aMedium.location(); 333 mMedia [aIndex].toolTip = aMedium.toolTipCheckRO (!mShowDiffs); 334 335 changeItem (aMedium.iconCheckRO (!mShowDiffs), 336 aMedium.details (!mShowDiffs), aIndex); 337 338 if (aIndex == currentItem()) 339 updateToolTip (aIndex); 340 } 341 342 /** 343 * Searches for a medium with the given ID in mMedia and stores its index in @a 344 * aIndex. Returns @c true if the media was found and @c false otherwise (@a 345 * aIndex will be set to a value >= mMedia.size() in this case). 346 * 347 * @param aId Media ID to search for. 348 * @param aIndex Where to store the found media index. 349 */ 350 bool VBoxMediaComboBox::findMediaIndex (const QUuid &aId, size_t &aIndex) 351 { 352 aIndex = 0; 353 354 for (; aIndex < mMedia.size(); ++ aIndex ) 355 if (mMedia [aIndex ].id == aId) 274 356 break; 275 } 276 277 insertPosition == -1 ? mUuidList.append (aId) : 278 mUuidList.insert (mUuidList.at (insertPosition), aId); 279 280 insertPosition == -1 ? mTipList.append (aTip) : 281 mTipList.insert (mTipList.at (insertPosition), aTip); 282 283 aPixmap ? insertItem (*aPixmap, aName, insertPosition) : 284 insertItem (aName, insertPosition); 285 286 if (insertPosition != -1 && currentIndex >= insertPosition) 287 QComboBox::setCurrentItem (currentIndex + 1); 288 } 289 290 void VBoxMediaComboBox::replaceItem (int aNumber, 291 const QString &aName, 292 const QString &aTip, 293 QPixmap *aPixmap) 294 { 295 aPixmap ? changeItem (*aPixmap, aName, aNumber) : changeItem (aName, aNumber); 296 mTipList [aNumber] = aTip; 297 } 298 299 void VBoxMediaComboBox::setUseEmptyItem (bool aUseEmptyItem) 300 { 301 mUseEmptyItem = aUseEmptyItem; 302 } 303 304 void VBoxMediaComboBox::setBelongsTo (const QUuid &aMachineId) 305 { 306 mMachineId = aMachineId; 307 } 308 309 QUuid VBoxMediaComboBox::getBelongsTo() 310 { 311 return mMachineId; 312 } 313 314 void VBoxMediaComboBox::setCurrentItem (const QUuid &aId) 315 { 316 mRequiredId = aId; 317 int index = mUuidList.findIndex (mRequiredId); 318 if (index != -1) 319 { 320 QComboBox::setCurrentItem (index); 321 emit activated (index); 322 } 323 } 324 325 void VBoxMediaComboBox::setType (int aType) 326 { 327 mType = aType; 328 } 357 358 return aIndex < mMedia.size(); 359 } 360 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r13374 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 602 602 } 603 603 604 void VBoxProblemReporter::cannotAccessUSB (const COMBase &obj)604 void VBoxProblemReporter::cannotAccessUSB (const COMBaseWithEI &obj) 605 605 { 606 606 /* If IMachine::GetUSBController(), IHost::GetUSBDevices() etc. return … … 702 702 { 703 703 AssertWrapperOk (progress); 704 CConsole console = CProgress (progress).GetInitiator();704 CConsole console (CProgress (progress).GetInitiator()); 705 705 AssertWrapperOk (console); 706 706 … … 762 762 { 763 763 AssertWrapperOk (progress); 764 CConsole console = CProgress (progress).GetInitiator();764 CConsole console (CProgress (progress).GetInitiator()); 765 765 AssertWrapperOk (console); 766 766 … … 788 788 { 789 789 AssertWrapperOk (progress); 790 CConsole console = CProgress (progress).GetInitiator();790 CConsole console (CProgress (progress).GetInitiator()); 791 791 AssertWrapperOk (console); 792 792 … … 814 814 { 815 815 AssertWrapperOk (progress); 816 CConsole console = CProgress (progress).GetInitiator();816 CConsole console (CProgress (progress).GetInitiator()); 817 817 AssertWrapperOk (console); 818 818 … … 859 859 } 860 860 861 void VBoxProblemReporter::cannotDiscardSnapshot (const CConsole &console, 862 const CSnapshot &snapshot) 863 { 864 message ( 865 mainWindowShown(), 866 Error, 861 void VBoxProblemReporter::cannotDiscardSnapshot (const CConsole &aConsole, 862 const QString &aSnapshotName) 863 { 864 message (mainWindowShown(), Error, 867 865 tr ("Failed to discard the snapshot <b>%1</b> of the virtual " 868 866 "machine <b>%2</b>.") 869 .arg (snapshot.GetName()) 870 .arg (CConsole (console).GetMachine().GetName()), 871 formatErrorInfo (console)); 872 } 873 874 void VBoxProblemReporter::cannotDiscardSnapshot (const CProgress &progress, 875 const CSnapshot &snapshot) 876 { 877 CConsole console = CProgress (progress).GetInitiator(); 878 879 message ( 880 mainWindowShown(), 881 Error, 867 .arg (aSnapshotName) 868 .arg (CConsole (aConsole).GetMachine().GetName()), 869 formatErrorInfo (aConsole)); 870 } 871 872 void VBoxProblemReporter::cannotDiscardSnapshot (const CProgress &aProgress, 873 const QString &aSnapshotName) 874 { 875 CConsole console (CProgress (aProgress).GetInitiator()); 876 877 message (mainWindowShown(), Error, 882 878 tr ("Failed to discard the snapshot <b>%1</b> of the virtual " 883 879 "machine <b>%2</b>.") 884 .arg ( snapshot.GetName())880 .arg (aSnapshotName) 885 881 .arg (console.GetMachine().GetName()), 886 formatErrorInfo ( progress.GetErrorInfo()));882 formatErrorInfo (aProgress.GetErrorInfo())); 887 883 } 888 884 … … 900 896 void VBoxProblemReporter::cannotDiscardCurrentState (const CProgress &progress) 901 897 { 902 CConsole console = CProgress (progress).GetInitiator();898 CConsole console (CProgress (progress).GetInitiator()); 903 899 904 900 message ( … … 924 920 void VBoxProblemReporter::cannotDiscardCurrentSnapshotAndState (const CProgress &progress) 925 921 { 926 CConsole console = CProgress (progress).GetInitiator();922 CConsole console (CProgress (progress).GetInitiator()); 927 923 928 924 message ( … … 1024 1020 } 1025 1021 1026 bool VBoxProblemReporter::confirmReleaseImage (QWidget *parent, 1027 const QString &usage) 1028 { 1029 return messageOkCancel (parent, Question, 1030 tr ("<p>Releasing this media image will detach it from the " 1031 "following virtual machine(s): <b>%1</b>.</p>" 1032 "<p>Continue?</p>") 1033 .arg (usage), 1034 "confirmReleaseImage", 1035 tr ("Continue", "detach image")); 1036 } 1037 1038 void VBoxProblemReporter::sayCannotOverwriteHardDiskImage (QWidget *parent, 1039 const QString &src) 1040 { 1041 message (parent, Info, 1042 tr ("<p>The image file <b>%1</b> already exists. " 1043 "You cannot create a new virtual hard disk that uses this file, " 1044 "because it can be already used by another virtual hard disk.</p>" 1045 "<p>Please specify a different image file name.</p>") 1046 .arg (src)); 1047 } 1048 1049 int VBoxProblemReporter::confirmHardDiskImageDeletion (QWidget *parent, 1050 const QString &src) 1051 { 1052 return message (parent, Question, 1053 tr ("<p>Do you want to delete this hard disk's image file " 1054 "<nobr><b>%1</b>?</nobr></p>" 1055 "<p>If you select <b>Delete</b> then the image file will be permanently " 1056 "deleted after unregistering the hard disk. This operation " 1057 "cannot be undone.</p>" 1058 "<p>If you select <b>Unregister</b> then the virtual hard disk will be " 1059 "unregistered and removed from the collection, but the image file " 1060 "will be left on your physical disk.</p>") 1061 .arg (src), 1022 bool VBoxProblemReporter::confirmReleaseMedium (QWidget *aParent, 1023 const VBoxMedium &aMedium, 1024 const QString &aUsage) 1025 { 1026 return messageOkCancel (aParent, Question, 1027 tr ("<p>Are you sure you want to release the %1 " 1028 "<nobr><b>%2</b></nobr>?</p>" 1029 "<p>This will detach it from the " 1030 "following virtual machine(s): <b>%3</b>.</p>") 1031 .arg (toAccusative (aMedium.type())) 1032 .arg (aMedium.location()) 1033 .arg (aUsage), 1034 0 /* aAutoConfirmId */, 1035 tr ("Release", "detach medium")); 1036 } 1037 1038 bool VBoxProblemReporter::confirmRemoveMedium (QWidget *aParent, 1039 const VBoxMedium &aMedium) 1040 { 1041 QString msg = 1042 tr ("<p>Are you sure you want to remove the %1 " 1043 "<nobr><b>%2</b></nobr> from the list of known media?</p>") 1044 .arg (toAccusative (aMedium.type())) 1045 .arg (aMedium.location()); 1046 1047 if (aMedium.type() == VBoxDefs::MediaType_HardDisk) 1048 { 1049 if (aMedium.state() == KMediaState_Inaccessible) 1050 msg += 1051 tr ("Note that this hard disk is inaccessible so that its " 1052 "storage unit cannot be deleted right now."); 1053 else 1054 msg += 1055 tr ("The next dialog will let you choose whether you also " 1056 "want to delete the storage unit of this hard disk or " 1057 "keep it for later usage."); 1058 } 1059 else 1060 msg += 1061 tr ("<p>Note that the storage unit of this medium will not be " 1062 "deleted and therefore it will be possible to add it to " 1063 "the list later again.</p>"); 1064 1065 return messageOkCancel (aParent, Question, msg, 1066 "confirmRemoveMedium", /* aAutoConfirmId */ 1067 tr ("Remove", "medium")); 1068 } 1069 1070 void VBoxProblemReporter::sayCannotOverwriteHardDiskStorage ( 1071 QWidget *aParent, const QString &aLocation) 1072 { 1073 message (aParent, Info, 1074 tr ("<p>The hard disk storage unit at location <b>%1</b> already " 1075 "exists. You cannot create a new virtual hard disk that uses this " 1076 "location because it can be already used by another virtual hard " 1077 "disk.</p>" 1078 "<p>Please specify a different location.</p>") 1079 .arg (aLocation)); 1080 } 1081 1082 int VBoxProblemReporter::confirmDeleteHardDiskStorage ( 1083 QWidget *aParent, const QString &aLocation) 1084 { 1085 return message (aParent, Question, 1086 tr ("<p>Do you want to delete the storage unit of the hard disk " 1087 "<nobr><b>%1</b></nobr>?</p>" 1088 "<p>If you select <b>Delete</b> then the specified storage unit " 1089 "will be permanently deleted. This operation <b>cannot be " 1090 "undone</b>.</p>" 1091 "<p>If you select <b>Keep</b> then the hard disk will be only " 1092 "removed from the list of known hard disks, but the storage unit " 1093 "will be left untouched which makes it possible to add this hard " 1094 "disk to the list later again.</p>") 1095 .arg (aLocation), 1062 1096 0, /* aAutoConfirmId */ 1063 1097 QIMessageBox::Yes, 1064 1098 QIMessageBox::No | QIMessageBox::Default, 1065 1099 QIMessageBox::Cancel | QIMessageBox::Escape, 1066 tr ("Delete", "hard disk"), 1067 tr ("Unregister", "hard disk")); 1068 } 1069 1070 void VBoxProblemReporter::cannotDeleteHardDiskImage (QWidget *parent, 1071 const CVirtualDiskImage &vdi) 1072 { 1073 /* below, we use CHardDisk (hd) to preserve current error info 1100 tr ("Delete", "hard disk storage"), 1101 tr ("Keep", "hard disk storage")); 1102 } 1103 1104 void VBoxProblemReporter::cannotDeleteHardDiskStorage (QWidget *aParent, 1105 const CHardDisk2 &aHD, 1106 const CProgress &aProgress) 1107 { 1108 /* below, we use CHardDisk2 (aHD) to preserve current error info 1074 1109 * for formatErrorInfo() */ 1075 1110 1076 message (parent, Error, 1077 tr ("Failed to delete the virtual hard disk image <b>%1</b>.") 1078 .arg (CVirtualDiskImage (vdi).GetFilePath()), 1079 formatErrorInfo (vdi)); 1080 } 1081 1082 bool VBoxProblemReporter::confirmHardDiskUnregister (QWidget *parent, 1083 const QString &src) 1084 { 1085 return messageOkCancel (parent, Question, 1086 tr ("<p>Do you want to remove (unregister) the virtual hard disk " 1087 "<nobr><b>%1</b>?</nobr></p>") 1088 .arg (src), 1089 0 /* aAutoConfirmId */, 1090 tr ("Unregister", "hard disk")); 1111 message (aParent, Error, 1112 tr ("Failed to delete the storage unit of the hard disk <b>%1</b>.") 1113 .arg (CHardDisk2 (aHD).GetLocation()), 1114 !aHD.isOk() ? formatErrorInfo (aHD) : 1115 !aProgress.isOk() ? formatErrorInfo (aProgress) : 1116 formatErrorInfo (aProgress.GetErrorInfo())); 1091 1117 } 1092 1118 … … 1110 1136 "<p>Press the <b>Create</b> button to start the <i>New Virtual " 1111 1137 "Disk</i> wizard and create a new hard disk, or press the " 1112 "<b>Select</b> button to open the <i>Virtual DiskManager</i> "1138 "<b>Select</b> button to open the <i>Virtual Media Manager</i> " 1113 1139 "and select what to do.</p>"), 1114 1140 0, /* aAutoConfirmId */ … … 1120 1146 } 1121 1147 1122 void VBoxProblemReporter::cannotCreateHardDiskImage ( 1123 QWidget *parent, const CVirtualBox &vbox, const QString &src, 1124 const CVirtualDiskImage &vdi, const CProgress &progress) 1125 { 1126 message (parent, Error, 1127 tr ("Failed to create the virtual hard disk image <nobr><b>%1</b>.</nobr>") 1128 .arg (src), 1129 !vbox.isOk() ? formatErrorInfo (vbox) : 1130 !vdi.isOk() ? formatErrorInfo (vdi) : 1131 formatErrorInfo (progress.GetErrorInfo())); 1148 void VBoxProblemReporter::cannotCreateHardDiskStorage ( 1149 QWidget *aParent, const CVirtualBox &aVBox, const QString &aLocation, 1150 const CHardDisk2 &aHD, const CProgress &aProgress) 1151 { 1152 message (aParent, Error, 1153 tr ("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>") 1154 .arg (aLocation), 1155 !aVBox.isOk() ? formatErrorInfo (aVBox) : 1156 !aHD.isOk() ? formatErrorInfo (aHD) : 1157 !aProgress.isOk() ? formatErrorInfo (aProgress) : 1158 formatErrorInfo (aProgress.GetErrorInfo())); 1132 1159 } 1133 1160 1134 1161 void VBoxProblemReporter::cannotAttachHardDisk ( 1135 QWidget *parent, const CMachine &m, const QUuid &id, 1136 KStorageBus bus, LONG channel, LONG dev) 1137 { 1138 message (parent, Error, 1139 tr ("Failed to attach a hard disk image with UUID %1 " 1140 "to device slot %2 on channel %3 of the %4 bus of the machine <b>%5</b>.") 1141 .arg (id) 1142 .arg (vboxGlobal().toString (bus, channel, dev)) 1143 .arg (vboxGlobal().toString (bus, channel)) 1144 .arg (vboxGlobal().toString (bus)) 1145 .arg (CMachine (m).GetName()), 1146 formatErrorInfo (m)); 1162 QWidget *aParent, const CMachine &aMachine, const QString &aLocation, 1163 KStorageBus aBus, LONG aChannel, LONG aDevice) 1164 { 1165 message (aParent, Error, 1166 tr ("Failed to attach the hard disk <nobr><b>%1</b></nobr> " 1167 "to the slot <i>%2</i> of the machine <b>%3</b>.") 1168 .arg (aLocation) 1169 .arg (vboxGlobal().toFullString (aBus, aChannel, aDevice)) 1170 .arg (CMachine (aMachine).GetName()), 1171 formatErrorInfo (aMachine)); 1147 1172 } 1148 1173 1149 1174 void VBoxProblemReporter::cannotDetachHardDisk ( 1150 QWidget *parent, const CMachine &m, 1151 KStorageBus bus, LONG channel, LONG dev) 1152 { 1153 message (parent, Error, 1154 tr ("Failed to detach a hard disk image " 1155 "from device slot %1 on channel %2 of the %3 bus of the machine <b>%4</b>.") 1156 .arg (vboxGlobal().toString (bus, channel, dev)) 1157 .arg (vboxGlobal().toString (bus, channel)) 1158 .arg (vboxGlobal().toString (bus)) 1159 .arg (CMachine (m).GetName()), 1160 formatErrorInfo (m)); 1161 } 1162 1163 void VBoxProblemReporter::cannotRegisterMedia ( 1164 QWidget *parent, const CVirtualBox &vbox, 1165 VBoxDefs::DiskType type, const QString &src) 1166 { 1167 QString media = type == VBoxDefs::HD ? tr ("hard disk") : 1168 type == VBoxDefs::CD ? tr ("CD/DVD image") : 1169 type == VBoxDefs::FD ? tr ("floppy image") : 1170 QString::null; 1171 1172 Assert (!media.isNull()); 1173 1174 message (parent, Error, 1175 tr ("Failed to register the %1 <nobr><b>%2</b></nobr>.") 1176 .arg (media) 1177 .arg (src), 1178 formatErrorInfo (vbox)); 1179 } 1180 1181 void VBoxProblemReporter::cannotUnregisterMedia ( 1182 QWidget *parent, const CVirtualBox &vbox, 1183 VBoxDefs::DiskType type, const QString &src) 1184 { 1185 QString media = type == VBoxDefs::HD ? tr ("hard disk") : 1186 type == VBoxDefs::CD ? tr ("CD/DVD image") : 1187 type == VBoxDefs::FD ? tr ("floppy image") : 1188 QString::null; 1189 1190 Assert (!media.isNull()); 1191 1192 message (parent, Error, 1193 tr ("Failed to unregister the %1 <nobr><b>%2</b></nobr>.") 1194 .arg (media) 1195 .arg (src), 1196 formatErrorInfo (vbox)); 1175 QWidget *aParent, const CMachine &aMachine, const QString &aLocation, 1176 KStorageBus aBus, LONG aChannel, LONG aDevice) 1177 { 1178 message (aParent, Error, 1179 tr ("Failed to detach the hard disk <nobr><b>%1</b></nobr> " 1180 "from the slot <i>%2</i> of the machine <b>%3</b>.") 1181 .arg (aLocation) 1182 .arg (vboxGlobal().toFullString (aBus, aChannel, aDevice)) 1183 .arg (CMachine (aMachine).GetName()), 1184 formatErrorInfo (aMachine)); 1185 } 1186 1187 void VBoxProblemReporter:: 1188 cannotMountMedium (QWidget *aParent, const CMachine &aMachine, 1189 const VBoxMedium &aMedium, const COMResult &aResult) 1190 { 1191 message (aParent, Error, 1192 tr ("Failed to mount the %1 <nobr><b>%2</b></nobr> " 1193 "to the machine <b>%3</b>.") 1194 .arg (toAccusative (aMedium.type())) 1195 .arg (aMedium.location()) 1196 .arg (CMachine (aMachine).GetName()), 1197 formatErrorInfo (aResult)); 1198 } 1199 1200 void VBoxProblemReporter:: 1201 cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine, 1202 const VBoxMedium &aMedium, const COMResult &aResult) 1203 { 1204 message (aParent, Error, 1205 tr ("Failed to unmount the %1 <nobr><b>%2</b></nobr> " 1206 "from the machine <b>%3</b>.") 1207 .arg (toAccusative (aMedium.type())) 1208 .arg (aMedium.location()) 1209 .arg (CMachine (aMachine).GetName()), 1210 formatErrorInfo (aResult)); 1211 } 1212 1213 void VBoxProblemReporter::cannotOpenMedium ( 1214 QWidget *aParent, const CVirtualBox &aVBox, 1215 VBoxDefs::MediaType aType, const QString &aLocation) 1216 { 1217 message (aParent, Error, 1218 tr ("Failed to open the %1 <nobr><b>%2</b></nobr>.") 1219 .arg (toAccusative (aType)) 1220 .arg (aLocation), 1221 formatErrorInfo (aVBox)); 1222 } 1223 1224 void VBoxProblemReporter::cannotCloseMedium ( 1225 QWidget *aParent, const VBoxMedium &aMedium, const COMResult &aResult) 1226 { 1227 message (aParent, Error, 1228 tr ("Failed to close the %1 <nobr><b>%2</b></nobr>.") 1229 .arg (toAccusative (aMedium.type())) 1230 .arg (aMedium.location()), 1231 formatErrorInfo (aResult)); 1197 1232 } 1198 1233 … … 1229 1264 } 1230 1265 1231 void VBoxProblemReporter::cannotGetMediaAccessibility (const CUnknown &unk) 1232 { 1233 QString src; 1234 CHardDisk hd; 1235 CDVDImage dvd; 1236 CFloppyImage floppy; 1237 1238 if (!(hd = unk).isNull()) 1239 src = hd.GetLocation(); 1240 else 1241 if (!(dvd = unk).isNull()) 1242 src = dvd.GetFilePath(); 1243 else 1244 if (!(floppy = unk).isNull()) 1245 src = floppy.GetFilePath(); 1246 else 1247 AssertMsgFailed (("Not a valid CUnknown\n")); 1248 1266 void VBoxProblemReporter::cannotGetMediaAccessibility (const VBoxMedium &aMedium) 1267 { 1249 1268 message (qApp->activeWindow(), Error, 1250 tr ("Failed to get the accessibility state of the media " 1251 "<nobr><b>%1</b></nobr>. Some of the registered media may " 1252 "become inaccessible.") 1253 .arg (src), 1254 formatErrorInfo (unk)); 1269 tr ("Failed to get the accessibility state of the medium " 1270 "<nobr><b>%1</b></nobr>.") 1271 .arg (aMedium.location()), 1272 formatErrorInfo (aMedium.result())); 1255 1273 } 1256 1274 … … 1688 1706 { 1689 1707 int rc = message (&vboxGlobal().selectorWnd(), Warning, 1690 tr ("<p>One or more of the registeredvirtual hard disks, CD/DVD or "1708 tr ("<p>One or more virtual hard disks, CD/DVD or " 1691 1709 "floppy media are not currently accessible. As a result, you will " 1692 1710 "not be able to operate virtual machines that use these media until " 1693 1711 "they become accessible later.</p>" 1694 "<p>Press <b>Check</b> to open the Virtual DiskManager window and "1712 "<p>Press <b>Check</b> to open the Virtual Media Manager window and " 1695 1713 "see what media are inaccessible, or press <b>Ignore</b> to " 1696 1714 "ignore this message.</p>"), … … 2002 2020 } 2003 2021 2022 /* static */ 2023 QString VBoxProblemReporter::toAccusative (VBoxDefs::MediaType aType) 2024 { 2025 QString type = 2026 aType == VBoxDefs::MediaType_HardDisk ? 2027 tr ("hard disk", "failed to close ...") : 2028 aType == VBoxDefs::MediaType_DVD ? 2029 tr ("CD/DVD image", "failed to close ...") : 2030 aType == VBoxDefs::MediaType_Floppy ? 2031 tr ("floppy image", "failed to close ...") : 2032 QString::null; 2033 2034 Assert (!type.isNull()); 2035 return type; 2036 } 2037 2004 2038 /** 2005 2039 * Formats the given COM result code as a human-readable string. -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r10148 r13580 29 29 #include "VBoxSnapshotsWgt.h" 30 30 #include "VBoxNewVMWzd.h" 31 #include "VBox DiskImageManagerDlg.h"31 #include "VBoxMediaManagerDlg.h" 32 32 #include "VBoxVMSettingsDlg.h" 33 33 #include "VBoxGlobalSettingsDlg.h" … … 400 400 /* actions */ 401 401 402 file DiskMgrAction = new QAction( this, "fileDiskMgrAction" );403 file DiskMgrAction->setIconSet (VBoxGlobal::iconSet ("diskim_16px.png"));402 fileMediaMgrAction = new QAction( this, "fileMediaMgrAction" ); 403 fileMediaMgrAction->setIconSet (VBoxGlobal::iconSet ("diskim_16px.png")); 404 404 fileSettingsAction = new QAction(this, "fileSettingsAction"); 405 405 fileSettingsAction->setIconSet (VBoxGlobal::iconSet ("global_settings_16px.png")); … … 519 519 520 520 QPopupMenu *fileMenu = new QPopupMenu(this, "fileMenu"); 521 file DiskMgrAction->addTo( fileMenu );521 fileMediaMgrAction->addTo( fileMenu ); 522 522 fileMenu->insertSeparator(); 523 523 fileSettingsAction->addTo(fileMenu); … … 626 626 627 627 /* signals and slots connections */ 628 connect (file DiskMgrAction, SIGNAL (activated()), this, SLOT(fileDiskMgr()));628 connect (fileMediaMgrAction, SIGNAL (activated()), this, SLOT(fileMediaMgr())); 629 629 connect (fileSettingsAction, SIGNAL (activated()), this, SLOT(fileSettings())); 630 630 connect (fileExitAction, SIGNAL (activated()), this, SLOT (fileExit())); … … 712 712 ///////////////////////////////////////////////////////////////////////////// 713 713 714 void VBoxSelectorWnd::file DiskMgr()715 { 716 VBox DiskImageManagerDlg::showModeless();714 void VBoxSelectorWnd::fileMediaMgr() 715 { 716 VBoxMediaManagerDlg::showModeless(); 717 717 } 718 718 … … 838 838 VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem(); 839 839 840 AssertMsgReturn (item, ("Item must be always selected here"), (void) 0);840 AssertMsgReturnVoid (item, ("Item must be always selected here")); 841 841 842 842 if (vboxProblem().confirmMachineDeletion (item->machine())) … … 847 847 if (item->accessible()) 848 848 { 849 /* open a direct session to modify VM settings */849 /* Open a direct session to modify VM settings */ 850 850 CSession session = vboxGlobal().openSession (id); 851 851 if (session.isNull()) 852 852 return; 853 853 CMachine machine = session.GetMachine(); 854 /* detach all hard disks before unregistering */ 854 /* Detach all attached Hard Disks */ 855 CHardDisk2AttachmentVector vec = machine.GetHardDisk2Attachments(); 856 for (uint i = 0; i < vec.size(); ++ i) 855 857 { 856 CHardDiskAttachmentEnumerator hen 857 = machine.GetHardDiskAttachments().Enumerate(); 858 while (hen.HasMore()) 859 { 860 CHardDiskAttachment att = hen.GetNext(); 861 machine.DetachHardDisk (att.GetBus(), att.GetChannel(), att.GetDevice()); 862 } 858 CHardDisk2Attachment hda = vec [i]; 859 machine.DetachHardDisk2 (hda.GetBus(), hda.GetChannel(), hda.GetDevice()); 860 if (!machine.isOk()) 861 vboxProblem().cannotDetachHardDisk (this, machine, 862 vboxGlobal().getMedium (CMedium (hda.GetHardDisk())).location(), 863 hda.GetBus(), hda.GetChannel(), hda.GetDevice()); 863 864 } 864 /* commit changes */865 /* Commit changes */ 865 866 machine.SaveSettings(); 866 867 if (!machine.isOk()) … … 1140 1141 vmListBoxCurrentChanged(); 1141 1142 1142 file DiskMgrAction->setMenuText (tr ("Virtual &DiskManager..."));1143 file DiskMgrAction->setAccel (tr ("Ctrl+D"));1144 file DiskMgrAction->setStatusTip (tr ("Display the Virtual DiskManager dialog"));1143 fileMediaMgrAction->setMenuText (tr ("&Virtual Media Manager...")); 1144 fileMediaMgrAction->setAccel (tr ("Ctrl+D")); 1145 fileMediaMgrAction->setStatusTip (tr ("Display the Virtual Media Manager dialog")); 1145 1146 1146 1147 #ifdef Q_WS_MAC … … 1435 1436 break; 1436 1437 1437 /* ignore the signal if a VBox DiskImageManagerDlg window is active */1438 /* ignore the signal if a VBoxMediaManagerDlg window is active */ 1438 1439 if (qApp->activeWindow() && 1439 !strcmp (qApp->activeWindow()->className(), "VBox DiskImageManagerDlg"))1440 !strcmp (qApp->activeWindow()->className(), "VBoxMediaManagerDlg")) 1440 1441 break; 1441 1442 … … 1443 1444 VBoxMediaList::const_iterator it; 1444 1445 for (it = list.begin(); it != list.end(); ++ it) 1445 if ((*it).stat us == VBoxMedia::Inaccessible)1446 if ((*it).state() == KMediaState_Inaccessible) 1446 1447 break; 1447 1448 … … 1450 1451 /* Show the VDM dialog but don't refresh once more after a 1451 1452 * just-finished refresh */ 1452 VBox DiskImageManagerDlg::showModeless (false /* aRefresh */);1453 VBoxMediaManagerDlg::showModeless (false /* aRefresh */); 1453 1454 } 1454 1455 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListBox.cpp
r8155 r13580 453 453 const VBoxVMListBox *lb = vmListBox(); 454 454 455 QFontMetrics fmName = QFontMetrics(lb->nameFont());456 QFontMetrics fmShot = QFontMetrics(lb->shotFont());457 QFontMetrics fmState = QFontMetrics(lb->stateFont (mSessionState));455 QFontMetrics fmName (lb->nameFont()); 456 QFontMetrics fmShot (lb->shotFont()); 457 QFontMetrics fmState (lb->stateFont (mSessionState)); 458 458 const int marg = lb->margin(); 459 459 … … 492 492 const VBoxVMListBox *lb = vmListBox(); 493 493 494 QFontMetrics fmName = QFontMetrics(lb->nameFont());495 QFontMetrics fmState = QFontMetrics(lb->stateFont (mSessionState));494 QFontMetrics fmName (lb->nameFont()); 495 QFontMetrics fmState (lb->stateFont (mSessionState)); 496 496 const int marg = lb->margin(); 497 497 … … 671 671 const VBoxVMListBox *lb = vmListBox(); 672 672 673 QFontMetrics fmName = QFontMetrics(lb->nameFont());674 QFontMetrics fmShot = QFontMetrics(lb->shotFont());675 QFontMetrics fmState = QFontMetrics(lb->stateFont (mSessionState));673 QFontMetrics fmName (lb->nameFont()); 674 QFontMetrics fmShot (lb->shotFont()); 675 QFontMetrics fmState (lb->stateFont (mSessionState)); 676 676 const int marg = lb->margin(); 677 677 -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r11822 r13580 244 244 else 245 245 { 246 /* pre-populate the media list before showing the main widget */ 247 vboxGlobal().startEnumeratingMedia(); 248 246 249 a.setMainWidget (&vboxGlobal().selectorWnd()); 247 250 vboxGlobal().selectorWnd().show(); … … 249 252 vboxGlobal().showRegistrationDialog (false /* aForce */); 250 253 #endif 251 vboxGlobal().startEnumeratingMedia();252 254 rc = a.exec(); 253 255 } -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui
r8183 r13580 275 275 <widget class="QLineEdit" row="0" column="1"> 276 276 <property name="name"> 277 <cstring>le VDIFolder</cstring>277 <cstring>leHardDiskFolder</cstring> 278 278 </property> 279 279 <property name="frameShape"> … … 284 284 </property> 285 285 <property name="whatsThis" stdset="0"> 286 <string>Displays the path to the default VDIfolder. This folder is used, if not explicitly specified otherwise, when adding existing or creating new virtual hard disks.</string>286 <string>Displays the path to the default hard disk folder. This folder is used, if not explicitly specified otherwise, when adding existing or creating new virtual hard disks.</string> 287 287 </property> 288 288 </widget> … … 300 300 </property> 301 301 <property name="text"> 302 <string> VDI files</string>302 <string>Hard Disks</string> 303 303 </property> 304 304 </widget> … … 325 325 <widget class="QToolButton" row="0" column="3"> 326 326 <property name="name"> 327 <cstring>tbReset VDIFolder</cstring>327 <cstring>tbResetHardDiskFolder</cstring> 328 328 </property> 329 329 <property name="focusPolicy"> … … 340 340 </property> 341 341 <property name="whatsThis" stdset="0"> 342 <string>Resets the VDIfolder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.</string>342 <string>Resets the hard disk folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.</string> 343 343 </property> 344 344 </widget> … … 353 353 <widget class="QToolButton" row="0" column="2"> 354 354 <property name="name"> 355 <cstring>tbSelect VDIFolder</cstring>355 <cstring>tbSelectHardDiskFolder</cstring> 356 356 </property> 357 357 <property name="focusPolicy"> … … 371 371 </property> 372 372 <property name="whatsThis" stdset="0"> 373 <string>Opens a dialog to select the default VDIfolder.</string>373 <string>Opens a dialog to select the default hard disk folder.</string> 374 374 </property> 375 375 </widget> … … 1163 1163 </connection> 1164 1164 <connection> 1165 <sender>tbReset VDIFolder</sender>1165 <sender>tbResetHardDiskFolder</sender> 1166 1166 <signal>clicked()</signal> 1167 1167 <receiver>VBoxGlobalSettingsDlg</receiver> … … 1169 1169 </connection> 1170 1170 <connection> 1171 <sender>tbSelect VDIFolder</sender>1171 <sender>tbSelectHardDiskFolder</sender> 1172 1172 <signal>clicked()</signal> 1173 1173 <receiver>VBoxGlobalSettingsDlg</receiver> … … 1256 1256 <tabstop>listView</tabstop> 1257 1257 <tabstop>chbAutoCapture</tabstop> 1258 <tabstop>le VDIFolder</tabstop>1259 <tabstop>tbSelect VDIFolder</tabstop>1260 <tabstop>tbReset VDIFolder</tabstop>1258 <tabstop>leHardDiskFolder</tabstop> 1259 <tabstop>tbSelectHardDiskFolder</tabstop> 1260 <tabstop>tbResetHardDiskFolder</tabstop> 1261 1261 <tabstop>leMachineFolder</tabstop> 1262 1262 <tabstop>tbSelectMachineFolder</tabstop> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxGlobalSettingsDlg.ui.h
r8724 r13580 645 645 /* default folders */ 646 646 647 le VDIFolder->setText (props.GetDefaultVDIFolder());647 leHardDiskFolder->setText (props.GetDefaultHardDiskFolder()); 648 648 leMachineFolder->setText (props.GetDefaultMachineFolder()); 649 649 … … 691 691 { 692 692 CHostUSBDeviceFilter hostFilter = en.GetNext(); 693 CUSBDeviceFilter filter = CUnknown(hostFilter);693 CUSBDeviceFilter filter (hostFilter); 694 694 addUSBFilter (filter, false); 695 695 } … … 726 726 /* default folders */ 727 727 728 if (le VDIFolder->isModified())729 props.SetDefault VDIFolder (leVDIFolder->text());728 if (leHardDiskFolder->isModified()) 729 props.SetDefaultHardDiskFolder (leHardDiskFolder->text()); 730 730 if (props.isOk() && leMachineFolder->isModified()) 731 731 props.SetDefaultMachineFolder (leMachineFolder->text()); … … 774 774 filter.SetActive (uli->isOn()); 775 775 776 CHostUSBDeviceFilter insertedFilter = CUnknown(filter);776 CHostUSBDeviceFilter insertedFilter (filter); 777 777 if (mUSBFilterListModified) 778 778 host.InsertUSBDeviceFilter (host.GetUSBDeviceFilters().GetCount(), … … 841 841 842 842 QLineEdit *le = 0; 843 if (tb == tbReset VDIFolder) le = leVDIFolder;843 if (tb == tbResetHardDiskFolder) le = leHardDiskFolder; 844 844 else if (tb == tbResetMachineFolder) le = leMachineFolder; 845 845 else if (tb == tbResetVRDPLib) le = leVRDPLib; … … 860 860 861 861 QLineEdit *le = 0; 862 if (tb == tbSelect VDIFolder) le = leVDIFolder;862 if (tb == tbSelectHardDiskFolder) le = leHardDiskFolder; 863 863 else if (tb == tbSelectMachineFolder) le = leMachineFolder; 864 864 else if (tb == tbSelectVRDPLib) le = leVRDPLib; … … 992 992 hostFilter.SetAction (KUSBDeviceFilterAction_Hold); 993 993 994 CUSBDeviceFilter filter = CUnknown(hostFilter);994 CUSBDeviceFilter filter (hostFilter); 995 995 filter.SetActive (true); 996 996 addUSBFilter (filter, true); … … 1025 1025 hostFilter.SetAction (KUSBDeviceFilterAction_Hold); 1026 1026 1027 CUSBDeviceFilter filter = CUnknown(hostFilter);1027 CUSBDeviceFilter filter (hostFilter); 1028 1028 filter.SetVendorId (QString().sprintf ("%04hX", usb.GetVendorId())); 1029 1029 filter.SetProductId (QString().sprintf ("%04hX", usb.GetProductId())); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxHardDiskSettings.ui
r8395 r13580 56 56 <widget class="QCheckBox"> 57 57 <property name="name"> 58 <cstring>m CbSATA</cstring>58 <cstring>mSATACheck</cstring> 59 59 </property> 60 60 <property name="text"> … … 81 81 <cstring>unnamed</cstring> 82 82 </property> 83 <widget class="QListView"> 84 <column> 83 <vbox> 84 <property name="name"> 85 <cstring>unnamed</cstring> 86 </property> 87 <widget class="QListView"> 88 <column> 89 <property name="text"> 90 <string>Slot</string> 91 </property> 92 <property name="clickable"> 93 <bool>true</bool> 94 </property> 95 <property name="resizable"> 96 <bool>true</bool> 97 </property> 98 </column> 99 <column> 100 <property name="text"> 101 <string>Hard Disk</string> 102 </property> 103 <property name="clickable"> 104 <bool>true</bool> 105 </property> 106 <property name="resizable"> 107 <bool>true</bool> 108 </property> 109 </column> 110 <property name="name"> 111 <cstring>mLvHD</cstring> 112 </property> 113 <property name="allColumnsShowFocus"> 114 <bool>true</bool> 115 </property> 116 <property name="resizeMode"> 117 <enum>LastColumn</enum> 118 </property> 119 <property name="whatsThis" stdset="0"> 120 <string> 121 <qt>Lists all hard disks attached to 122 this machine. Use a mouse double-click or the 123 <tt>F2</tt>/<tt>Space</tt> 124 key on the highlighted item to activate the 125 drop-down list and choose the desired value. 126 Use the context menu or buttons to the right 127 to add or remove hard disk 128 attachments.</qt> 129 </string> 130 </property> 131 </widget> 132 <widget class="QCheckBox"> 133 <property name="name"> 134 <cstring>mShowDiffsCheck</cstring> 135 </property> 85 136 <property name="text"> 86 <string>Slot</string> 87 </property> 88 <property name="clickable"> 89 <bool>true</bool> 90 </property> 91 <property name="resizable"> 92 <bool>true</bool> 93 </property> 94 </column> 95 <column> 96 <property name="text"> 97 <string>Hard Disk</string> 98 </property> 99 <property name="clickable"> 100 <bool>true</bool> 101 </property> 102 <property name="resizable"> 103 <bool>true</bool> 104 </property> 105 </column> 106 <property name="name"> 107 <cstring>mLvHD</cstring> 108 </property> 109 <property name="allColumnsShowFocus"> 110 <bool>true</bool> 111 </property> 112 <property name="resizeMode"> 113 <enum>LastColumn</enum> 114 </property> 115 <property name="whatsThis" stdset="0"> 116 <string> 117 <qt>Lists all hard disks attached to 118 this machine. Use a mouse double-click or the 119 <tt>F2</tt>/<tt>Space</tt> 120 key on the highlighted item to activate the 121 drop-down list and choose the desired value. 122 Use the context menu or buttons to the right 123 to add or remove hard disk 124 attachments.</qt> 125 </string> 126 </property> 127 </widget> 137 <string>&Show Differencing Hard Disks</string> 138 </property> 139 <property name="whatsThis" stdset="0"> 140 <string> 141 <qt>If checked, it will show 142 differencing hard disks actually attached 143 to the slots instead of their base hard 144 disks (shown in case of indirect 145 attachments) and will also let attach 146 other differencing hard disks explicitly. 147 Check this only if you need a complex hard 148 disk setup.</qt> 149 </string> 150 </property> 151 </widget> 152 </vbox> 128 153 <widget class="QLayoutWidget"> 129 154 <property name="name"> … … 218 243 <property name="whatsThis" stdset="0"> 219 244 <string> 220 <qt>Invokes the Virtual DiskManager to select a hard disk245 <qt>Invokes the Virtual Media Manager to select a hard disk 221 246 to attach to the currently highlighted slot.</qt> 222 247 </string> … … 241 266 <signal>activated()</signal> 242 267 <receiver>VBoxHardDiskSettings</receiver> 243 <slot>showVDM()</slot> 268 <slot>showMediaManager()</slot> 269 </connection> 270 <connection> 271 <sender>mSATACheck</sender> 272 <signal>toggled(bool)</signal> 273 <receiver>VBoxHardDiskSettings</receiver> 274 <slot>onSATACheckToggled(bool)</slot> 275 </connection> 276 <connection> 277 <sender>mLvHD</sender> 278 <signal>pressed(QListViewItem*,const QPoint&,int)</signal> 279 <receiver>VBoxHardDiskSettings</receiver> 280 <slot>moveFocus(QListViewItem*, const QPoint&,int)</slot> 281 </connection> 282 <connection> 283 <sender>mLvHD</sender> 284 <signal>currentChanged(QListViewItem*)</signal> 285 <receiver>VBoxHardDiskSettings</receiver> 286 <slot>onCurrentChanged(QListViewItem*)</slot> 287 </connection> 288 <connection> 289 <sender>mLvHD</sender> 290 <signal>contextMenuRequested(QListViewItem*,const QPoint&,int)</signal> 291 <receiver>VBoxHardDiskSettings</receiver> 292 <slot>onContextMenuRequested(QListViewItem*,const QPoint&,int)</slot> 293 </connection> 294 <connection> 295 <sender>mShowDiffsCheck</sender> 296 <signal>toggled(bool)</signal> 297 <receiver>VBoxHardDiskSettings</receiver> 298 <slot>onShowDiffsCheckToggled(bool)</slot> 244 299 </connection> 245 300 </connections> … … 259 314 <include location="local" impldecl="in implementation">VBoxProblemReporter.h</include> 260 315 <include location="local" impldecl="in implementation">VBoxMediaComboBox.h</include> 261 <include location="local" impldecl="in implementation">VBox DiskImageManagerDlg.h</include>316 <include location="local" impldecl="in implementation">VBoxMediaManagerDlg.h</include> 262 317 <include location="local" impldecl="in implementation">VBoxNewHDWzd.h</include> 263 318 <include location="local" impldecl="in implementation">VBoxHardDiskSettings.ui.h</include> … … 275 330 <signals> 276 331 <signal>afterCurrentChanged()</signal> 277 <signal>h ddListChanged()</signal>332 <signal>hardDiskListChanged()</signal> 278 333 </signals> 279 334 <slots> 280 335 <slot>addHDItem()</slot> 281 336 <slot>delHDItem()</slot> 282 <slot>show VDM()</slot>337 <slot>showMediaManager()</slot> 283 338 <slot>moveFocus( QListViewItem *, const QPoint &, int )</slot> 284 339 <slot>onCurrentChanged( QListViewItem * )</slot> 285 <slot>onToggleSATAController( bool aOn )</slot> 340 <slot>onSATACheckToggled( bool aOn )</slot> 341 <slot>onShowDiffsCheckToggled( bool aOn )</slot> 286 342 <slot>onAfterCurrentChanged( QListViewItem * )</slot> 287 343 <slot>onContextMenuRequested( QListViewItem *, const QPoint &, int )</slot> … … 293 349 <function>putBackToMachine()</function> 294 350 <function returnType="QString">checkValidity()</function> 295 <function access="private" returnType="HDListItem*">createItem( HDSlotUniquizer *, const CMachine &)</function>351 <function access="private" returnType="HDListItem*">createItem()</function> 296 352 <function access="private" returnType="bool">event( QEvent * )</function> 297 353 <function access="private">showEvent( QShowEvent * )</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxHardDiskSettings.ui.h
r8576 r13580 148 148 149 149 /** 150 * QComboBox class reimplementation to use as selector for IDE & SATA151 * slots.150 * QComboBox class reimplementation to use as an editor for the device slot 151 * column. 152 152 */ 153 153 class HDSlotItem : public QComboBox … … 258 258 }; 259 259 260 /** 261 * VBoxMediaComboBox class reimplementation to use as selector for VDI 262 * image. 263 */ 264 class HDVdiItem : public VBoxMediaComboBox 265 { 266 Q_OBJECT 267 268 public: 269 270 HDVdiItem (QWidget *aParent, int aType, QListViewItem *aItem) 271 : VBoxMediaComboBox (aParent, "HDVdiItem", aType) 272 , mItem (aItem) 273 { 274 setFocusPolicy (QWidget::NoFocus); 275 connect (&vboxGlobal(), 276 SIGNAL (mediaRemoved (VBoxDefs::DiskType, const QUuid &)), 277 this, SLOT (repaintHandler())); 278 } 279 280 private slots: 281 282 void repaintHandler() 283 { 284 mItem->repaint(); 285 } 286 287 private: 288 289 QListViewItem *mItem; 290 }; 291 292 QValueList<HDSlot> HDSlotUniquizer::list (HDSlotItem *aSubscriber, bool aFilter) 260 QValueList <HDSlot> HDSlotUniquizer::list (HDSlotItem *aSubscriber, bool aFilter) 293 261 { 294 262 QValueList<HDSlot> list = mIDEList + mSATAList; … … 316 284 } 317 285 286 /** 287 * VBoxMediaComboBox class reimplementation to use as an editor for the hard 288 * disk column. 289 */ 290 class HDItem : public VBoxMediaComboBox 291 { 292 Q_OBJECT 293 294 public: 295 296 HDItem (QWidget *aParent, const char *aName, QUuid aMachineID, 297 QListViewItem *aItem) 298 : VBoxMediaComboBox (aParent, aName, VBoxDefs::MediaType_HardDisk, 299 aMachineID) 300 , mItem (aItem) 301 { 302 setFocusPolicy (QWidget::NoFocus); 303 304 connect (this, SIGNAL (activated (int)), 305 this, SLOT (onThisActivated (int))); 306 } 307 308 private slots: 309 310 void onThisActivated (int) 311 { 312 mItem->repaint(); 313 } 314 315 private: 316 317 QListViewItem *mItem; 318 }; 319 318 320 class HDSpaceItem : public QListViewItem 319 321 { … … 337 339 enum { HDListItemType = 1010 }; 338 340 339 HDListItem ( VBoxHardDiskSettings *aWidget, QListView *aParent,340 QListViewItem *aAfter,341 HDSlotUniquizer *aUniq, const CMachine &aMachine)341 HDListItem (QListView *aParent, QListViewItem *aAfter, 342 VBoxHardDiskSettings *aSettings, HDSlotUniquizer *aUniq, 343 const QUuid &aMachineId) 342 344 : QListViewItem (aParent, aAfter) 343 , mWidget (aWidget)344 , mUniq (aUniq)345 , mMachine (aMachine)346 345 , mFocusColumn (-1) 347 346 , mAutoFocus (false) 348 347 { 349 init(); 350 } 351 352 HDListItem (VBoxHardDiskSettings *aWidget, QListView *aParent, 353 HDSlotUniquizer *aUniq, const CMachine &aMachine) 348 init (aSettings, aUniq, aMachineId); 349 } 350 351 HDListItem (QListView *aParent, 352 VBoxHardDiskSettings *aSettings, HDSlotUniquizer *aUniq, 353 const QUuid &aMachineId) 354 354 : QListViewItem (aParent) 355 , mWidget (aWidget)356 , mUniq (aUniq)357 , mMachine (aMachine)358 355 , mFocusColumn (-1) 359 { 360 init(); 356 , mAutoFocus (false) 357 { 358 init (aSettings, aUniq, aMachineId); 359 } 360 361 virtual ~HDListItem() 362 { 363 mHDCombo->deleteLater(); 364 mSlotCombo->deleteLater(); 361 365 } 362 366 363 367 int rtti() const { return HDListItemType; } 364 368 365 QString toolTip() 366 { 367 return QToolTip::textFor (mVector [1]); 368 } 369 370 HDListItem* nextSibling() const 371 { 372 QListViewItem *item = QListViewItem::nextSibling(); 373 return item && item->rtti() == HDListItemType ? 374 static_cast<HDListItem*> (item) : 0; 375 } 376 377 void setId (const QUuid &aId) const 378 { 379 static_cast<VBoxMediaComboBox*> (mVector [1])->setCurrentItem (aId); 380 } 381 382 QUuid getId() const 383 { 384 return static_cast<VBoxMediaComboBox*> (mVector [1])->getId(); 385 } 386 387 KStorageBus bus() const 388 { 389 return static_cast<HDSlotItem*> (mVector [0])->currentBus(); 390 } 391 392 LONG channel() const 393 { 394 return static_cast<HDSlotItem*> (mVector [0])->currentChannel(); 395 } 396 397 LONG device() const 398 { 399 return static_cast<HDSlotItem*> (mVector [0])->currentDevice(); 400 } 369 QString toolTip() { return QToolTip::textFor (mHDCombo); } 370 371 void setId (const QUuid &aId) { mHDCombo->setCurrentItem (aId); } 372 373 QUuid id() const { return mHDCombo->id(); } 374 QString location() const { return mHDCombo->location(); } 375 376 KStorageBus bus() { return mSlotCombo->currentBus(); } 377 378 LONG channel() const { return mSlotCombo->currentChannel(); } 379 380 LONG device() const { return mSlotCombo->currentDevice(); } 401 381 402 382 QString text (int aColumn) const 403 383 { 404 return mVector [aColumn]->currentText(); 384 AssertReturn (aColumn >= 0 && (size_t) aColumn < ELEMENTS (mCombos), 385 QString::null); 386 387 return mCombos [aColumn]->currentText(); 388 } 389 390 const QPixmap *pixmap (int aColumn) const 391 { 392 AssertReturn (aColumn >= 0 && (size_t) aColumn < ELEMENTS (mCombos), 393 NULL); 394 395 return mCombos [aColumn]->pixmap (mCombos [aColumn]->currentItem()); 405 396 } 406 397 … … 420 411 { 421 412 if (mFocusColumn >= 0) 422 if (mVector [mFocusColumn]->count()) 423 mVector [mFocusColumn]->popup(); 413 { 414 AssertReturnVoid ((size_t) mFocusColumn < ELEMENTS (mCombos)); 415 416 if (mCombos [mFocusColumn]->count()) 417 mCombos [mFocusColumn]->popup(); 418 } 424 419 } 425 420 … … 429 424 } 430 425 431 void setAttachment (const CHardDisk Attachment &aHda)426 void setAttachment (const CHardDisk2Attachment &aHda) 432 427 { 433 428 QString device = vboxGlobal() 434 429 .toFullString (aHda.GetBus(), aHda.GetChannel(), aHda.GetDevice()); 435 430 436 if (mVector [0]->listBox()->findItem (device, Qt::ExactMatch)) 437 static_cast<HDSlotItem*> (mVector [0])->setText (device); 438 439 static_cast<VBoxMediaComboBox*> (mVector [1])-> 440 setCurrentItem (aHda.GetHardDisk().GetRoot().GetId()); 441 442 mVector [0]->setHidden (true); 443 mVector [1]->setHidden (true); 444 } 445 446 int vdiCount() 447 { 448 return mVector [1]->count(); 449 } 450 451 void tryToChooseExcluding (const QStringList &aUsedList) 452 { 453 for (int i = 0; i < mVector [1]->count(); ++ i) 454 { 455 if (!aUsedList.contains (mVector [1]->text (i))) 456 { 457 setId (static_cast<HDVdiItem*> (mVector [1])->getId (i)); 431 if (mSlotCombo->listBox()->findItem (device, Qt::ExactMatch)) 432 mSlotCombo->setText (device); 433 434 mHDCombo->setCurrentItem (aHda.GetHardDisk().GetId()); 435 } 436 437 int hardDiskCount() 438 { 439 int count = mHDCombo->count(); 440 if (count == 1 && mHDCombo-> id (0).isNull()) 441 return 0; /* ignore the "no media" item */ 442 return count; 443 } 444 445 void tryToSelectNotOneOf (const QValueList <QUuid> &aUsedList) 446 { 447 for (int i = 0; i < mHDCombo->count(); ++ i) 448 { 449 if (!aUsedList.contains (mHDCombo->id (i))) 450 { 451 mHDCombo->setCurrentItem (mHDCombo->id (i)); 458 452 break; 459 453 } … … 461 455 } 462 456 457 void setShowDiffs (bool aOn) 458 { 459 if (mHDCombo->showDiffs() != aOn) 460 { 461 mHDCombo->setShowDiffs (aOn); 462 mHDCombo->refresh(); 463 } 464 } 465 463 466 private: 464 467 465 void init() 466 { 468 void init (VBoxHardDiskSettings *aSettings, HDSlotUniquizer *aUniq, 469 const QUuid &aMachineId) 470 { 471 AssertReturnVoid (listView()->columns() == ELEMENTS (mCombos)); 472 467 473 setSelectable (false); 468 mVector.setAutoDelete (true); 469 m Vector.resize (listView()->columns());470 471 QComboBox *cbslot = new HDSlotItem (listView()->viewport(), mUniq);472 QObject::connect (cbslot, SIGNAL (activated (int)),473 mWidget, SIGNAL (hddListChanged())); 474 m Vector.insert (0, cbslot);475 476 VBoxMediaComboBox *cbvdi = new HDVdiItem (listView()->viewport(),477 VBoxDefs::HD, this);478 QObject::connect (cbvdi, SIGNAL (activated (int)),479 mWidget, SIGNAL (hddListChanged())); 480 mVector.insert (1, cbvdi);481 cbvdi->setBelongsTo (mMachine.GetId());482 cbvdi->refresh(); 474 475 mSlotCombo = new HDSlotItem (listView()->viewport(), aUniq); 476 QObject::connect (mSlotCombo, SIGNAL (activated (int)), 477 aSettings, SIGNAL (hardDiskListChanged())); 478 mCombos [0] = mSlotCombo; 479 480 mHDCombo = new HDItem (listView()->viewport(), "mHDCombo", 481 aMachineId, this); 482 QObject::connect (mHDCombo, SIGNAL (activated (int)), 483 aSettings, SIGNAL (hardDiskListChanged())); 484 mCombos [1] = mHDCombo; 485 486 /* populate the media combobox */ 487 mHDCombo->refresh(); 488 483 489 #ifdef Q_WS_MAC 484 490 /* White background on Mac OS X */ 485 cbslot->setPaletteBackgroundColor (cbslot->parentWidget()->paletteBackgroundColor()); 486 cbvdi->setPaletteBackgroundColor (cbvdi->parentWidget()->paletteBackgroundColor()); 491 mSlotCombo->setPaletteBackgroundColor (mSlotCombo->parentWidget()-> 492 paletteBackgroundColor()); 493 mHDCombo->setPaletteBackgroundColor (mHDCombo->parentWidget()-> 494 paletteBackgroundColor()); 487 495 #endif /* Q_WS_MAC */ 496 497 mSlotCombo->setHidden (true); 498 mHDCombo->setHidden (true); 488 499 } 489 500 … … 491 502 int aColumn, int aWidth, int aAlign) 492 503 { 493 QComboBox *cb = mVector [aColumn]; 494 495 int indent = 0; 496 for (int i = 0; i < aColumn; ++ i) 497 indent = listView()->columnWidth (i); 498 499 QRect rect = listView()->itemRect (this); 500 501 int xc = rect.x() + indent; 502 int yc = rect.y(); 503 int wc = listView()->columnWidth (aColumn); 504 int hc = rect.height(); 505 506 cb->move (xc, yc); 507 cb->resize (wc, hc); 504 AssertReturnVoid (aColumn >= 0 && (size_t) aColumn < ELEMENTS (mCombos)); 505 506 QComboBox *cb = mCombos [aColumn]; 507 508 /// @todo (r=dmik) show/hide functionality should be removed from here 509 /// to the appropriate places like focus handling routines 508 510 509 511 if (aColumn == mFocusColumn) 510 512 { 513 int indent = 0; 514 for (int i = 0; i < aColumn; ++ i) 515 indent = listView()->columnWidth (i); 516 517 QRect rect = listView()->itemRect (this); 518 519 int xc = rect.x() + indent; 520 int yc = rect.y(); 521 int wc = listView()->columnWidth (aColumn); 522 int hc = rect.height(); 523 524 cb->move (xc, yc); 525 cb->resize (wc, hc); 526 511 527 if (cb->isHidden()) 512 528 cb->show(); 513 529 if (mAutoFocus && !cb->hasFocus()) 514 530 QTimer::singleShot (0, cb, SLOT (setFocus())); 515 } 516 else if (aColumn != mFocusColumn && !cb->isHidden()) 531 532 return; 533 534 } 535 536 if (aColumn != mFocusColumn && !cb->isHidden()) 517 537 cb->hide(); 518 538 … … 532 552 } 533 553 534 VBoxHardDiskSettings *mWidget; 535 HDSlotUniquizer *mUniq; 536 CMachine mMachine; 537 QPtrVector<QComboBox> mVector; 554 HDSlotItem *mSlotCombo; 555 VBoxMediaComboBox *mHDCombo; 556 QComboBox *mCombos [2]; 538 557 int mFocusColumn; 539 558 bool mAutoFocus; … … 585 604 (VBoxGlobal::iconSet ("select_file_16px.png", "select_file_dis_16px.png")); 586 605 587 /* connections */588 connect (mCbSATA, SIGNAL (toggled (bool)),589 this, SLOT (onToggleSATAController (bool)));590 connect (mLvHD, SIGNAL (pressed (QListViewItem*, const QPoint&, int)),591 this, SLOT (moveFocus (QListViewItem*, const QPoint&, int)));592 connect (mLvHD, SIGNAL (currentChanged (QListViewItem*)),593 this, SLOT (onCurrentChanged (QListViewItem*)));594 connect (mLvHD, SIGNAL (contextMenuRequested (QListViewItem*, const QPoint&, int)),595 this, SLOT (onContextMenuRequested (QListViewItem*, const QPoint&, int)));596 597 606 /* rest */ 598 607 … … 606 615 void VBoxHardDiskSettings::getFromMachine (const CMachine &aMachine) 607 616 { 617 AssertReturnVoid (mMachine.isNull()); 618 AssertReturnVoid (!aMachine.isNull()); 619 608 620 mMachine = aMachine; 609 621 … … 614 626 /* hide the SATA check box if the SATA controller is not available 615 627 * (i.e. in VirtualBox OSE) */ 616 m CbSATA->setHidden (true);628 mSATACheck->setHidden (true); 617 629 } 618 630 else 619 631 { 620 mCbSATA->setChecked (ctl.GetEnabled()); 621 } 622 } 623 624 CHardDiskAttachmentEnumerator en = 625 mMachine.GetHardDiskAttachments().Enumerate(); 626 while (en.HasMore()) 627 { 628 CHardDiskAttachment hda = en.GetNext(); 629 HDListItem *item = createItem (mSlotUniquizer, mMachine); 632 mSATACheck->setChecked (ctl.GetEnabled()); 633 } 634 } 635 636 CHardDisk2AttachmentVector vec = mMachine.GetHardDisk2Attachments(); 637 for (size_t i = 0; i < vec.size(); ++ i) 638 { 639 CHardDisk2Attachment hda = vec [i]; 640 HDListItem *item = createItem(); 630 641 item->setAttachment (hda); 631 642 } 643 632 644 mLvHD->setSortColumn (0); 633 645 mLvHD->sort(); … … 642 654 if (!ctl.isNull()) 643 655 { 644 ctl.SetEnabled (m CbSATA->isChecked());656 ctl.SetEnabled (mSATACheck->isChecked()); 645 657 } 646 658 647 659 /* Detach all attached Hard Disks */ 648 CHardDiskAttachmentEnumerator en = 649 mMachine.GetHardDiskAttachments().Enumerate(); 650 while (en.HasMore()) 651 { 652 CHardDiskAttachment hda = en.GetNext(); 653 mMachine.DetachHardDisk (hda.GetBus(), hda.GetChannel(), hda.GetDevice()); 660 CHardDisk2AttachmentVector vec = mMachine.GetHardDisk2Attachments(); 661 for (size_t i = 0; i < vec.size(); ++ i) 662 { 663 CHardDisk2Attachment hda = vec [i]; 664 mMachine.DetachHardDisk2 (hda.GetBus(), hda.GetChannel(), hda.GetDevice()); 654 665 if (!mMachine.isOk()) 655 666 vboxProblem().cannotDetachHardDisk (this, mMachine, 667 vboxGlobal().getMedium (CMedium (hda.GetHardDisk())).location(), 656 668 hda.GetBus(), hda.GetChannel(), hda.GetDevice()); 657 669 } 658 670 659 /* Sort&Attach all listed Hard Disks */ 671 /* Sort & attach all listed Hard Disks */ 672 660 673 mLvHD->setSortColumn (0); 661 674 mLvHD->sort(); 662 675 LONG maxSATAPort = 1; 663 HDListItem *item = mLvHD->firstChild() && 664 mLvHD->firstChild()->rtti() == HDListItem::HDListItemType ? 665 static_cast<HDListItem*> (mLvHD->firstChild()) : 0; 666 while (item) 667 { 668 if (item->bus() == KStorageBus_SATA) 669 maxSATAPort = maxSATAPort < (item->channel()+1) ? 670 (item->channel()+1) : maxSATAPort; 671 mMachine.AttachHardDisk (item->getId(), 672 item->bus(), item->channel(), item->device()); 676 677 for (QListViewItem *item = mLvHD->firstChild(); item; 678 item = item->nextSibling()) 679 { 680 if (item->rtti() != HDListItem::HDListItemType) 681 continue; 682 683 HDListItem *hdi = static_cast <HDListItem *> (item); 684 685 if (hdi->bus() == KStorageBus_SATA) 686 maxSATAPort = QMAX (hdi->channel() + 1, maxSATAPort); 687 mMachine.AttachHardDisk2 (hdi->id(), 688 hdi->bus(), hdi->channel(), hdi->device()); 673 689 if (!mMachine.isOk()) 674 vboxProblem().cannotAttachHardDisk (this, mMachine, item->getId(), 675 item->bus(), item->channel(), item->device()); 676 item = item->nextSibling(); 690 vboxProblem().cannotAttachHardDisk (this, mMachine, 691 hdi->location(), hdi->bus(), hdi->channel(), hdi->device()); 677 692 } 678 693 679 694 if (!ctl.isNull()) 680 695 { 681 mMachine.GetSATAController().SetPortCount (maxSATAPort);696 ctl.SetPortCount (maxSATAPort); 682 697 } 683 698 } … … 687 702 QString result; 688 703 QStringList slList; 689 Q StringListidList;704 QValueList <QUuid> idList; 690 705 691 706 /* Search for coincidences through all the media-id */ 692 HDListItem *item = mLvHD->firstChild() && 693 mLvHD->firstChild()->rtti() == HDListItem::HDListItemType ? 694 static_cast<HDListItem*> (mLvHD->firstChild()) : 0; 695 while (item) 696 { 697 QString id = item->getId().toString(); 698 if (item->getId().isNull()) 707 for (QListViewItem *item = mLvHD->firstChild(); item; 708 item = item->nextSibling()) 709 { 710 if (item->rtti() != HDListItem::HDListItemType) 711 continue; 712 713 HDListItem *hdi = static_cast <HDListItem *> (item); 714 715 QUuid id = hdi->id(); 716 if (id.isNull()) 699 717 { 700 718 result = tr ("No hard disk is selected for <i>%1</i>") 701 .arg ( item->text (0));719 .arg (hdi->text (0)); 702 720 break; 703 721 } … … 714 732 idList << id; 715 733 } 716 item = item->nextSibling();717 734 } 718 735 … … 722 739 void VBoxHardDiskSettings::addHDItem() 723 740 { 724 /* Create new item */725 HDListItem *item = createItem (mSlotUniquizer, mMachine);741 /* Create a new item */ 742 HDListItem *item = createItem(); 726 743 item->moveFocusToColumn (1); 727 744 mLvHD->setCurrentItem (item); 728 745 if (!mLvHD->hasFocus()) 729 746 mLvHD->setFocus(); 730 /* Qt3 isn't emits currentChanged() signal if first list-view item added */ 747 748 /* Qt3 doesn't emit currentChanged() signal when the first item is added */ 731 749 if (mLvHD->childCount() == 1) 732 750 onCurrentChanged (item); 733 751 734 /* Search through the attachments for the used VDIs */ 735 QStringList usedList; 736 HDListItem *it = mLvHD->firstChild()->rtti() == HDListItem::HDListItemType ? 737 static_cast<HDListItem*> (mLvHD->firstChild()) : 0; 738 while (it && it != item) 739 { 740 usedList << it->text (1); 741 it = it->nextSibling(); 742 } 743 item->tryToChooseExcluding (usedList); 744 745 /* Ask the user for method to add new vdi */ 746 int result = mLvHD->childCount() - 1 > item->vdiCount() ? 752 /* Search through the attachments for the used hard disks */ 753 QValueList <QUuid> usedList; 754 for (QListViewItem *it = mLvHD->firstChild(); it; 755 it = it->nextSibling()) 756 { 757 if (it->rtti() != HDListItem::HDListItemType) 758 continue; 759 760 HDListItem *hdi = static_cast <HDListItem *> (it); 761 762 usedList << hdi->id(); 763 } 764 765 item->tryToSelectNotOneOf (usedList); 766 767 /* Ask the user for a method to add a new hard disk */ 768 int result = mLvHD->childCount() - 1 > item->hardDiskCount() ? 747 769 vboxProblem().confirmRunNewHDWzdOrVDM (this) : 748 770 QIMessageBox::Cancel; … … 752 774 if (dlg.exec() == QDialog::Accepted) 753 775 { 754 CHardDisk hd = dlg.hardDisk(); 755 VBoxMedia::Status status = 756 hd.GetAccessible() ? VBoxMedia::Ok : 757 hd.isOk() ? VBoxMedia::Inaccessible : 758 VBoxMedia::Error; 759 vboxGlobal().addMedia (VBoxMedia (CUnknown (hd), VBoxDefs::HD, status)); 776 CHardDisk2 hd = dlg.hardDisk(); 760 777 item->setId (dlg.hardDisk().GetId()); 761 778 } 762 779 } 763 780 else if (result == QIMessageBox::No) 764 show VDM();765 766 emit h ddListChanged();781 showMediaManager(); 782 783 emit hardDiskListChanged(); 767 784 } 768 785 … … 786 803 } 787 804 788 emit h ddListChanged();789 } 790 791 void VBoxHardDiskSettings::show VDM()805 emit hardDiskListChanged(); 806 } 807 808 void VBoxHardDiskSettings::showMediaManager() 792 809 { 793 810 HDListItem *item = mLvHD->currentItem() && 794 811 mLvHD->currentItem()->rtti() == HDListItem::HDListItemType ? 795 static_cast<HDListItem*> (mLvHD->currentItem()) : 0; 796 797 VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", 798 WType_Dialog | WShowModal); 799 800 QUuid machineId = mMachine.GetId(); 801 QUuid hdId = item->getId(); 802 803 dlg.setup (VBoxDefs::HD, true, &machineId, true /* aRefresh */, 804 mMachine, hdId, QUuid(), QUuid()); 805 806 if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted) 807 item->setId (dlg.getSelectedUuid()); 812 static_cast <HDListItem *> (mLvHD->currentItem()) : 0; 813 814 VBoxMediaManagerDlg dlg (this, "VBoxMediaManagerDlg", 815 WType_Dialog | WShowModal); 816 817 dlg.setup (VBoxDefs::MediaType_HardDisk, true /* aDoSelect */, 818 true /* aRefresh */, mMachine, item->id(), 819 mShowDiffsCheck->isOn()); 820 821 if (dlg.exec() == VBoxMediaManagerDlg::Accepted) 822 item->setId (dlg.selectedId()); 808 823 } 809 824 … … 812 827 if (aItem && aItem->rtti() == HDListItem::HDListItemType) 813 828 { 814 static_cast <HDListItem*> (aItem)->moveFocusToColumn (aCol);829 static_cast <HDListItem *> (aItem)->moveFocusToColumn (aCol); 815 830 onAfterCurrentChanged (aItem); 816 831 } … … 823 838 } 824 839 825 void VBoxHardDiskSettings::on ToggleSATAController(bool aOn)840 void VBoxHardDiskSettings::onSATACheckToggled (bool aOn) 826 841 { 827 842 if (!aOn) 828 843 { 829 HDListItem *firstItem = mLvHD->firstChild() && 830 mLvHD->firstChild()->rtti() == HDListItem::HDListItemType ? 831 static_cast<HDListItem*> (mLvHD->firstChild()) : 0; 832 833 /* Search the list for the SATA ports in */ 834 HDListItem *sataItem = firstItem; 835 while (sataItem) 836 { 837 if (sataItem->bus() == KStorageBus_SATA) 844 /* Search the list for the SATA ports */ 845 HDListItem *sataItem = NULL; 846 for (QListViewItem *item = mLvHD->firstChild(); item; 847 item = item->nextSibling()) 848 { 849 if (item->rtti() != HDListItem::HDListItemType) 850 continue; 851 852 HDListItem *hdi = static_cast <HDListItem *> (item); 853 854 if (hdi->bus() == KStorageBus_SATA) 855 { 856 sataItem = hdi; 838 857 break; 839 sataItem = sataItem->nextSibling();858 } 840 859 } 841 860 … … 847 866 { 848 867 /* Switch check-box back to "on" */ 849 m CbSATA->blockSignals (true);850 m CbSATA->setChecked (true);851 m CbSATA->blockSignals (false);868 mSATACheck->blockSignals (true); 869 mSATACheck->setChecked (true); 870 mSATACheck->blockSignals (false); 852 871 return; 853 872 } … … 855 874 { 856 875 /* Delete SATA items */ 857 HDListItem *it = firstItem;858 876 mLvHD->blockSignals (true); 859 while (it)877 for (QListViewItem *item = mLvHD->firstChild(); item;) 860 878 { 861 HDListItem *curIt = it; 862 it = it->nextSibling(); 863 if (curIt->bus() == KStorageBus_SATA) 879 if (item->rtti() == HDListItem::HDListItemType) 864 880 { 865 if (curIt == mLvHD->currentItem()) 866 mPrevItem = 0; 867 delete curIt; 881 HDListItem *hdi = static_cast <HDListItem *> (item); 882 if (hdi->bus() == KStorageBus_SATA) 883 { 884 if (hdi == mLvHD->currentItem()) 885 mPrevItem = NULL; 886 887 item = hdi->nextSibling(); 888 delete hdi; 889 continue; 890 } 868 891 } 892 893 item = item->nextSibling(); 869 894 } 895 870 896 mLvHD->blockSignals (false); 871 emit h ddListChanged();897 emit hardDiskListChanged(); 872 898 } 873 899 } … … 879 905 mSlotUniquizer->setSATAPortsCount (newSATAPortsCount); 880 906 onAfterCurrentChanged (mPrevItem); 907 } 908 } 909 910 void VBoxHardDiskSettings::onShowDiffsCheckToggled (bool aOn) 911 { 912 for (QListViewItem *item = mLvHD->firstChild(); item; 913 item = item->nextSibling()) 914 { 915 if (item->rtti() != HDListItem::HDListItemType) 916 continue; 917 918 HDListItem *hdi = static_cast <HDListItem *> (item); 919 920 hdi->setShowDiffs (aOn); 881 921 } 882 922 } … … 916 956 } 917 957 918 HDListItem* VBoxHardDiskSettings::createItem (HDSlotUniquizer *aUniq, 919 const CMachine &aMachine) 958 HDListItem *VBoxHardDiskSettings::createItem() 920 959 { 921 960 QListViewItem *item = mLvHD->lastItem(); … … 923 962 HDListItem *last = item->itemAbove() && 924 963 item->itemAbove()->rtti() == HDListItem::HDListItemType ? 925 static_cast<HDListItem*> (item->itemAbove()) : 0; 926 927 return last ? 928 new HDListItem (this, mLvHD, last, aUniq, aMachine) : 929 new HDListItem (this, mLvHD, aUniq, aMachine); 964 static_cast <HDListItem *> (item->itemAbove()) : 0; 965 966 QUuid machineId = mMachine.GetId(); 967 968 HDListItem *newItem = last ? 969 new HDListItem (mLvHD, last, this, mSlotUniquizer, machineId) : 970 new HDListItem (mLvHD, this, mSlotUniquizer, machineId); 971 972 AssertReturn (newItem != NULL, NULL); 973 974 newItem->setShowDiffs (mShowDiffsCheck->isOn()); 975 976 return newItem; 930 977 } 931 978 … … 937 984 case OnItemChangedEvent::Type: 938 985 { 939 OnItemChangedEvent *e = static_cast <OnItemChangedEvent*> (aEvent);986 OnItemChangedEvent *e = static_cast <OnItemChangedEvent *> (aEvent); 940 987 onAfterCurrentChanged (e->mItem); 941 988 break; … … 974 1021 HDListItem *item = clickedItem && 975 1022 clickedItem->rtti() == HDListItem::HDListItemType ? 976 static_cast <HDListItem*> (clickedItem) : 0;1023 static_cast <HDListItem *> (clickedItem) : 0; 977 1024 978 1025 if (!item && mAddAttachmentAct->isEnabled()) … … 990 1037 } 991 1038 992 QMouseEvent *e = static_cast <QMouseEvent*> (aEvent);1039 QMouseEvent *e = static_cast <QMouseEvent *> (aEvent); 993 1040 QListViewItem *hoveredItem = mLvHD->itemAt (e->pos()); 994 1041 HDListItem *item = hoveredItem && 995 1042 hoveredItem->rtti() == HDListItem::HDListItemType ? 996 static_cast <HDListItem*> (hoveredItem) : 0;1043 static_cast <HDListItem *> (hoveredItem) : 0; 997 1044 998 1045 QString oldTip = QToolTip::textFor (mLvHD->viewport()); … … 1014 1061 HDListItem *item = mLvHD->currentItem() && 1015 1062 mLvHD->currentItem()->rtti() == HDListItem::HDListItemType ? 1016 static_cast <HDListItem*> (mLvHD->currentItem()) : 0;1063 static_cast <HDListItem *> (mLvHD->currentItem()) : 0; 1017 1064 1018 1065 QKeyEvent *e = static_cast<QKeyEvent*> (aEvent); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewHDWzd.ui
r11982 r13580 5 5 :folding=explicit:collapseFolds=1: 6 6 7 Copyright (C) 2006-200 7Sun Microsystems, Inc.7 Copyright (C) 2006-2008 Sun Microsystems, Inc. 8 8 9 9 This file is part of VirtualBox Open Source Edition (OSE), as … … 98 98 </property> 99 99 <property name="text"> 100 <string><p>This wizard will help you to create a new virtual hard disk imagefor your virtual machine.</p>100 <string><p>This wizard will help you to create a new virtual hard disk for your virtual machine.</p> 101 101 <p>Use the <b>Next</b> button to go to the next page of the wizard 102 102 and the <b>Back</b> button to return to the previous page.</p></string> … … 149 149 </property> 150 150 <attribute name="title"> 151 <string> Virtual Disk Image Type</string>151 <string>Hard Disk Storage Type</string> 152 152 </attribute> 153 153 <hbox> … … 204 204 </property> 205 205 <property name="text"> 206 <string><p>Select the type of virtual hard disk imageyou want to create.</p>207 <p>A <b>dynamically expanding image</b> initially occupies a very small amount206 <string><p>Select the type of virtual hard disk you want to create.</p> 207 <p>A <b>dynamically expanding storage</b> initially occupies a very small amount 208 208 of space on your physical hard disk. It will grow dynamically (up to 209 209 the size specified) as the Guest OS claims disk space.</p> 210 <p>A <b>fixed-size image</b> does not grow. It is stored in a file of approximately211 the same size as the size of the virtual hard disk. The creation of a fixed-size image may take a long212 time depending on the image size and the write performance of your harddisk.</p></string>210 <p>A <b>fixed-size storage</b> does not grow. It is stored in a file of approximately 211 the same size as the size of the virtual hard disk. The creation of a fixed-size storage may take a long 212 time depending on the storage size and the write performance of your harddisk.</p></string> 213 213 </property> 214 214 <property name="alignment"> … … 221 221 </property> 222 222 <property name="title"> 223 <string> Image Type</string>223 <string>Storage Type</string> 224 224 </property> 225 225 <property name="exclusive"> … … 235 235 </property> 236 236 <property name="text"> 237 <string>&Dynamically expanding image</string>237 <string>&Dynamically expanding storage</string> 238 238 </property> 239 239 <property name="checked"> … … 246 246 </property> 247 247 <property name="text"> 248 <string>&Fixed-size image</string>248 <string>&Fixed-size storage</string> 249 249 </property> 250 250 </widget> … … 329 329 </property> 330 330 <property name="text"> 331 <string><p>Press the <b>Select</b> button to select the location and name of thefile332 to store the virtual hard disk imageor type a file name in the entry field.</p></string>331 <string><p>Press the <b>Select</b> button to select the location of a file 332 to store the hard disk data or type a file name in the entry field.</p></string> 333 333 </property> 334 334 <property name="alignment"> … … 341 341 </property> 342 342 <property name="title"> 343 <string>& Image File Name</string>343 <string>&Location</string> 344 344 </property> 345 345 <hbox> … … 393 393 </property> 394 394 <property name="text"> 395 <string><p>Select the size of the virtual hard disk i mage in megabytes. This size will be reported to the Guest OS396 as the size of the virtualhard disk.</p></string>395 <string><p>Select the size of the virtual hard disk in megabytes. This size will be reported to the Guest OS 396 as the maximum size of this hard disk.</p></string> 397 397 </property> 398 398 <property name="alignment"> … … 405 405 </property> 406 406 <property name="title"> 407 <string> Image&Size</string>407 <string>&Size</string> 408 408 </property> 409 409 <hbox> … … 624 624 </property> 625 625 <property name="text"> 626 <string>You are going to create a new virtual hard disk imagewith the following parameters:</string>626 <string>You are going to create a new virtual hard disk with the following parameters:</string> 627 627 </property> 628 628 <property name="alignment"> … … 644 644 <property name="text"> 645 645 <string>If the above settings are correct, press the <b>Finish</b> button. 646 Once you press it, a new hard disk imagewill be created.646 Once you press it, a new hard disk will be created. 647 647 </string> 648 648 </property> … … 708 708 <include location="global" impldecl="in implementation">qvalidator.h</include> 709 709 <include location="global" impldecl="in implementation">qlocale.h</include> 710 <include location="global" impldecl="in implementation">iprt/path.h</include> 710 711 </includes> 711 712 <forwards> … … 713 714 </forwards> 714 715 <variables> 715 <variable access="private">QIWidgetValidator * wvalNameAndSize;</variable>716 <variable access="private">CHardDisk chd;</variable>717 <variable access="private">int sliderScale;</variable>718 <variable access="private">Q_UINT64 m axVDISize;</variable>719 <variable access="private">Q_UINT64 currentSize;</variable>720 <variable access="private">QITextEdit * teSummary;</variable>716 <variable access="private">QIWidgetValidator *mWValNameAndSize;</variable> 717 <variable access="private">CHardDisk2 mHD;</variable> 718 <variable access="private">int mSliderScale;</variable> 719 <variable access="private">Q_UINT64 mMaxVDISize;</variable> 720 <variable access="private">Q_UINT64 mCurrentSize;</variable> 721 <variable access="private">QITextEdit *mSummaryText;</variable> 721 722 </variables> 722 723 <slots> 723 <slot>enableNext( const QIWidgetValidator * wval)</slot>724 <slot>enableNext( const QIWidgetValidator * )</slot> 724 725 <slot>revalidate( QIWidgetValidator * )</slot> 725 <slot>slSize_valueChanged( int val)</slot>726 <slot>leSize_textChanged( const QString & text)</slot>726 <slot>slSize_valueChanged( int )</slot> 727 <slot>leSize_textChanged( const QString & )</slot> 727 728 <slot>tbNameSelect_clicked()</slot> 728 729 </slots> … … 732 733 <function>setRecommendedFileName( const QString & aName )</function> 733 734 <function>setRecommendedSize( Q_UINT64 aSize )</function> 734 <function returnType="QString">imageFileName()</function> 735 <function returnType="Q_UINT64">imageSize()</function> 736 <function returnType="bool">isDynamicImage()</function> 737 <function returnType="CHardDisk">hardDisk() { return chd; }</function> 738 <function>showPage( QWidget * page )</function> 739 <function>updateSizeToolTip (Q_UINT64)</function> 735 <function returnType="QString">location()</function> 736 <function returnType="bool">isDynamicStorage()</function> 737 <function returnType="CHardDisk2">hardDisk() { return mHD; }</function> 738 <function>showPage( QWidget * )</function> 739 <function>updateSizeToolTip( Q_UINT64 )</function> 740 740 <function>accept()</function> 741 741 <function access="private" returnType="bool">createHardDisk()</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewHDWzd.ui.h
r8155 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 40 40 41 41 /** 42 * Composes a file name from the given relative or full file name 43 * based on the home directory and the default VDI directory. 42 * Composes a file name from the given relative or full file name based on the 43 * home directory and the default VDI directory. See IMedum::location for 44 * details. 44 45 */ 45 static QString composeFullFileName (const QString file)46 static QString composeFullFileName (const QString &aName) 46 47 { 47 48 CVirtualBox vbox = vboxGlobal().virtualBox(); 48 49 QString homeFolder = vbox.GetHomeFolder(); 49 QString defaultFolder = vbox.GetSystemProperties().GetDefaultVDIFolder(); 50 51 QFileInfo fi = QFileInfo (file); 52 if (fi.fileName() == file) 50 QString defaultFolder = vbox.GetSystemProperties().GetDefaultHardDiskFolder(); 51 52 /* Note: the logic below must match the logic of the IMedum::location 53 * setter, otherwise the returned path may differ from the path actually 54 * set for the hard disk by the VirtualBox API */ 55 56 QFileInfo fi (aName); 57 if (fi.fileName() == aName) 53 58 { 54 59 /* no path info at all, use defaultFolder */ 55 fi = QFileInfo (defaultFolder, file);60 fi = QFileInfo (defaultFolder, aName); 56 61 } 57 62 else if (fi.isRelative()) 58 63 { 59 64 /* resolve relatively to homeFolder */ 60 fi = QFileInfo (homeFolder, file);65 fi = QFileInfo (homeFolder, aName); 61 66 } 62 67 63 68 return QDir::convertSeparators (fi.absFilePath()); 64 69 } 65 66 /// @todo (r=dmik) not currently used67 #if 068 class QISizeValidator : public QValidator69 {70 public:71 72 QISizeValidator (QObject * aParent,73 Q_UINT64 aMinSize, Q_UINT64 aMaxSize,74 const char * aName = 0) :75 QValidator (aParent, aName), mMinSize (aMinSize), mMaxSize (aMaxSize) {}76 77 ~QISizeValidator() {}78 79 State validate (QString &input, int &/*pos*/) const80 {81 QRegExp regexp ("^([^M^G^T^P^\\d\\s]*)(\\d+(([^\\s^\\d^M^G^T^P]+)(\\d*))?)?(\\s*)([MGTP]B?)?$");82 int position = regexp.search (input);83 if (position == -1)84 return Invalid;85 else86 {87 if (!regexp.cap (1).isEmpty() ||88 regexp.cap (4).length() > 1 ||89 regexp.cap (5).length() > 2 ||90 regexp.cap (6).length() > 1)91 return Invalid;92 93 if (regexp.cap (7).length() == 1)94 return Intermediate;95 96 QString size = regexp.cap (2);97 if (size.isEmpty())98 return Intermediate;99 100 bool result = false;101 bool warning = false;102 if (!regexp.cap (4).isEmpty() && regexp.cap (5).isEmpty())103 {104 size += "0";105 warning = true;106 }107 QLocale::system().toDouble (size, &result);108 109 Q_UINT64 sizeB = vboxGlobal().parseSize (input);110 if (sizeB > mMaxSize || sizeB < mMinSize)111 warning = true;112 113 if (result)114 return warning ? Intermediate : Acceptable;115 else116 return Invalid;117 }118 }119 120 protected:121 122 Q_UINT64 mMinSize;123 Q_UINT64 mMaxSize;124 };125 #endif126 70 127 71 static inline int log2i (Q_UINT64 val) … … 155 99 } 156 100 101 102 //////////////////////////////////////////////////////////////////////////////// 103 104 157 105 void VBoxNewHDWzd::init() 158 106 { … … 175 123 VBoxGlobal::adoptLabelPixmap (pmSummary); 176 124 177 /* Image type page */125 /* Storage type page */ 178 126 179 127 /* Name and Size page */ … … 181 129 CSystemProperties sysProps = vboxGlobal().virtualBox().GetSystemProperties(); 182 130 183 m axVDISize = sysProps.GetMaxVDISize();131 mMaxVDISize = sysProps.GetMaxVDISize(); 184 132 185 133 /* Detect how many steps to recognize between adjacent powers of 2 186 * to ensure that the last slider step is exactly m axVDISize */187 sliderScale = 0;188 { 189 int pow = log2i (m axVDISize);134 * to ensure that the last slider step is exactly mMaxVDISize */ 135 mSliderScale = 0; 136 { 137 int pow = log2i (mMaxVDISize); 190 138 Q_UINT64 tickMB = Q_UINT64 (1) << pow; 191 if (tickMB < m axVDISize)139 if (tickMB < mMaxVDISize) 192 140 { 193 141 Q_UINT64 tickMBNext = Q_UINT64 (1) << (pow + 1); 194 Q_UINT64 gap = tickMBNext - m axVDISize;195 /// @todo (r=dmik) overflow may happen if m axVDISize is TOO big196 sliderScale = (int) ((tickMBNext - tickMB) / gap);142 Q_UINT64 gap = tickMBNext - mMaxVDISize; 143 /// @todo (r=dmik) overflow may happen if mMaxVDISize is TOO big 144 mSliderScale = (int) ((tickMBNext - tickMB) / gap); 197 145 } 198 146 } 199 sliderScale = QMAX (sliderScale, 8);147 mSliderScale = QMAX (mSliderScale, 8); 200 148 201 149 leName->setValidator (new QRegExpValidator (QRegExp( ".+" ), this)); … … 204 152 leSize->setAlignment (Qt::AlignRight); 205 153 206 wvalNameAndSize = new QIWidgetValidator (pageNameAndSize, this);207 connect ( wvalNameAndSize, SIGNAL (validityChanged (const QIWidgetValidator *)),154 mWValNameAndSize = new QIWidgetValidator (pageNameAndSize, this); 155 connect (mWValNameAndSize, SIGNAL (validityChanged (const QIWidgetValidator *)), 208 156 this, SLOT (enableNext (const QIWidgetValidator *))); 209 connect ( wvalNameAndSize, SIGNAL (isValidRequested (QIWidgetValidator *)),157 connect (mWValNameAndSize, SIGNAL (isValidRequested (QIWidgetValidator *)), 210 158 this, SLOT (revalidate (QIWidgetValidator *))); 211 /* we ask revalidate only when currentSize is changed after manually159 /* we ask revalidate only when mCurrentSize is changed after manually 212 160 * editing the line edit field; the slider cannot produce invalid values */ 213 161 connect (leSize, SIGNAL (textChanged (const QString &)), 214 wvalNameAndSize, SLOT (revalidate()));162 mWValNameAndSize, SLOT (revalidate())); 215 163 216 164 /* Summary page */ 217 165 218 teSummary= new QITextEdit (pageSummary);219 teSummary->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);220 teSummary->setFrameShape (QTextEdit::NoFrame);221 teSummary->setReadOnly (TRUE);222 summaryLayout->insertWidget (1, teSummary);166 mSummaryText = new QITextEdit (pageSummary); 167 mSummaryText->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum); 168 mSummaryText->setFrameShape (QTextEdit::NoFrame); 169 mSummaryText->setReadOnly (TRUE); 170 summaryLayout->insertWidget (1, mSummaryText); 223 171 224 172 /* filter out Enter keys in order to direct them to the default dlg button */ 225 173 QIKeyFilter *ef = new QIKeyFilter (this, Key_Enter); 226 ef->watchOn ( teSummary);174 ef->watchOn (mSummaryText); 227 175 228 176 /* set initial values 229 177 * ---------------------------------------------------------------------- */ 230 178 231 /* Image type page */179 /* Storage type page */ 232 180 233 181 /* Name and Size page */ 182 183 /// @todo NEWMEDIA use extension as reported by CHardDiskFormat 234 184 235 185 static ulong HDNumber = 0; … … 237 187 238 188 slSize->setFocusPolicy (QWidget::StrongFocus); 239 slSize->setPageStep ( sliderScale);240 slSize->setLineStep ( sliderScale / 8);189 slSize->setPageStep (mSliderScale); 190 slSize->setLineStep (mSliderScale / 8); 241 191 slSize->setTickInterval (0); 242 slSize->setMinValue (sizeMBToSlider (MinVDISize, sliderScale));243 slSize->setMaxValue (sizeMBToSlider (m axVDISize, sliderScale));192 slSize->setMinValue (sizeMBToSlider (MinVDISize, mSliderScale)); 193 slSize->setMaxValue (sizeMBToSlider (mMaxVDISize, mSliderScale)); 244 194 245 195 txSizeMin->setText (vboxGlobal().formatSize (MinVDISize * _1M)); 246 txSizeMax->setText (vboxGlobal().formatSize (m axVDISize * _1M));196 txSizeMax->setText (vboxGlobal().formatSize (mMaxVDISize * _1M)); 247 197 248 198 /* limit the max. size of QLineEdit (STUPID Qt has NO correct means for that) */ … … 255 205 /* Summary page */ 256 206 257 teSummary->setPaper (pageSummary->backgroundBrush());207 mSummaryText->setPaper (pageSummary->backgroundBrush()); 258 208 259 209 /* update the next button state for pages with validation 260 210 * (validityChanged() connected to enableNext() will do the job) */ 261 wvalNameAndSize->revalidate();211 mWValNameAndSize->revalidate(); 262 212 263 213 /* the finish button on the Summary page is always enabled */ … … 302 252 void VBoxNewHDWzd::setRecommendedSize (Q_UINT64 aSize) 303 253 { 304 AssertReturnVoid (aSize >= MinVDISize && aSize <= m axVDISize);305 currentSize = aSize;306 slSize->setValue (sizeMBToSlider ( currentSize, sliderScale));307 leSize->setText (vboxGlobal().formatSize ( currentSize * _1M));308 updateSizeToolTip ( currentSize * _1M);309 } 310 311 312 QString VBoxNewHDWzd:: imageFileName()254 AssertReturnVoid (aSize >= MinVDISize && aSize <= mMaxVDISize); 255 mCurrentSize = aSize; 256 slSize->setValue (sizeMBToSlider (mCurrentSize, mSliderScale)); 257 leSize->setText (vboxGlobal().formatSize (mCurrentSize * _1M)); 258 updateSizeToolTip (mCurrentSize * _1M); 259 } 260 261 262 QString VBoxNewHDWzd::location() 313 263 { 314 264 QString name = QDir::convertSeparators (leName->text()); … … 320 270 321 271 QString ext = QFileInfo (name).extension(); 322 /* compare against the proper case */ 323 #if defined (Q_OS_FREEBSD) || defined (Q_OS_LINUX) || defined (Q_OS_NETBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_SOLARIS) 324 #elif defined (Q_OS_WIN) || defined (Q_OS_OS2) || defined (Q_OS_MACX) 325 ext = ext.lower(); 326 #else 327 #error Port me! 328 #endif 329 330 if (ext != "vdi") 272 273 if (RTPathCompare (ext.utf8(), "vdi") != 0) 331 274 name += ".vdi"; 332 275 … … 335 278 336 279 337 Q_UINT64 VBoxNewHDWzd::imageSize() 338 { 339 return currentSize; 340 } 341 342 343 bool VBoxNewHDWzd::isDynamicImage() 280 bool VBoxNewHDWzd::isDynamicStorage() 344 281 { 345 282 return rbDynamicType->isOn(); … … 362 299 if (pg == pageNameAndSize) 363 300 { 364 valid = currentSize >= MinVDISize && currentSize <= maxVDISize;301 valid = mCurrentSize >= MinVDISize && mCurrentSize <= mMaxVDISize; 365 302 } 366 303 … … 380 317 if (currentPage() == pageNameAndSize) 381 318 { 382 if (QFileInfo ( imageFileName()).exists())319 if (QFileInfo (location()).exists()) 383 320 { 384 vboxProblem().sayCannotOverwriteHardDisk Image (this, imageFileName());321 vboxProblem().sayCannotOverwriteHardDiskStorage (this, location()); 385 322 return; 386 323 } … … 393 330 type = VBoxGlobal::removeAccelMark (type); 394 331 395 Q_UINT64 sizeB = imageSize()* _1M;332 Q_UINT64 sizeB = mCurrentSize * _1M; 396 333 397 334 // compose summary … … 404 341 )) 405 342 .arg (type) 406 .arg (composeFullFileName ( imageFileName()))343 .arg (composeFullFileName (location())) 407 344 .arg (VBoxGlobal::formatSize (sizeB)) 408 345 .arg (sizeB); 409 teSummary->setText (summary);346 mSummaryText->setText (summary); 410 347 /* set Finish to default */ 411 348 finishButton()->setDefault (true); … … 436 373 else if (page == pageSummary) 437 374 { 438 teSummary->setFocus();375 mSummaryText->setFocus(); 439 376 } 440 377 … … 454 391 455 392 /** 456 * 457 * 393 * Performs steps necessary to create a hard disk. This method handles all 394 * errors and shows the corresponding messages when appropriate. 458 395 * 459 * @return wheter the creation was successful or not396 * @return Wheter the creation was successful or not. 460 397 */ 461 398 bool VBoxNewHDWzd::createHardDisk() 462 399 { 463 QString src = imageFileName(); 464 Q_UINT64 size = imageSize(); 465 466 AssertReturn (!src.isEmpty(), false); 467 AssertReturn (size > 0, false); 400 QString loc = location(); 401 402 AssertReturn (!loc.isEmpty(), false); 403 AssertReturn (mCurrentSize > 0, false); 468 404 469 405 CVirtualBox vbox = vboxGlobal().virtualBox(); 470 406 471 407 CProgress progress; 472 CHardDisk hd = vbox.CreateHardDisk (KHardDiskStorageType_VirtualDiskImage); 473 474 /// @todo (dmik) later, change wrappers so that converting 475 // to CUnknown is not necessary for cross-assignments 476 CVirtualDiskImage vdi = CUnknown (hd); 408 409 CHardDisk2 hd = vbox.CreateHardDisk2 (QString ("VDI"), loc); 477 410 478 411 if (!vbox.isOk()) 479 412 { 480 vboxProblem().cannotCreateHardDisk Image (this,481 vbox, src, vdi,progress);413 vboxProblem().cannotCreateHardDiskStorage (this, vbox, loc, hd, 414 progress); 482 415 return false; 483 416 } 484 417 485 vdi.SetFilePath (src); 486 487 if (isDynamicImage()) 488 progress = vdi.CreateDynamicImage (size); 418 if (isDynamicStorage()) 419 progress = hd.CreateDynamicStorage (mCurrentSize); 489 420 else 490 progress = vdi.CreateFixedImage (size);491 492 if (! vdi.isOk())493 { 494 vboxProblem().cannotCreateHardDisk Image (this,495 vbox, src, vdi,progress);421 progress = hd.CreateFixedStorage (mCurrentSize); 422 423 if (!hd.isOk()) 424 { 425 vboxProblem().cannotCreateHardDiskStorage (this, vbox, loc, hd, 426 progress); 496 427 return false; 497 428 } … … 499 430 vboxProblem().showModalProgressDialog (progress, caption(), parentWidget()); 500 431 501 if ( progress.GetResultCode() != 0)502 { 503 vboxProblem().cannotCreateHardDisk Image (this,504 vbox, src, vdi,progress);432 if (!progress.isOk() || progress.GetResultCode() != 0) 433 { 434 vboxProblem().cannotCreateHardDiskStorage (this, vbox, loc, hd, 435 progress); 505 436 return false; 506 437 } 507 438 508 vbox.RegisterHardDisk (hd); 509 if (!vbox.isOk()) 510 { 511 vboxProblem().cannotRegisterMedia (this, vbox, VBoxDefs::HD, 512 vdi.GetFilePath()); 513 /* delete the image file on failure */ 514 vdi.DeleteImage(); 515 return false; 516 } 517 518 chd = hd; 439 /* inform everybody there is a new medium */ 440 vboxGlobal().addMedium (VBoxMedium (CMedium (hd), 441 VBoxDefs::MediaType_HardDisk, 442 KMediaState_Created)); 443 444 mHD = hd; 519 445 return true; 520 446 } … … 525 451 if (focusWidget() == slSize) 526 452 { 527 currentSize = sliderToSizeMB (val, sliderScale);528 leSize->setText (vboxGlobal().formatSize ( currentSize * _1M));529 updateSizeToolTip ( currentSize * _1M);453 mCurrentSize = sliderToSizeMB (val, mSliderScale); 454 leSize->setText (vboxGlobal().formatSize (mCurrentSize * _1M)); 455 updateSizeToolTip (mCurrentSize * _1M); 530 456 } 531 457 } … … 536 462 if (focusWidget() == leSize) 537 463 { 538 currentSize = vboxGlobal().parseSize (text);539 updateSizeToolTip ( currentSize);540 currentSize /= _1M;541 slSize->setValue (sizeMBToSlider ( currentSize, sliderScale));464 mCurrentSize = vboxGlobal().parseSize (text); 465 updateSizeToolTip (mCurrentSize); 466 mCurrentSize /= _1M; 467 slSize->setValue (sizeMBToSlider (mCurrentSize, mSliderScale)); 542 468 } 543 469 } … … 558 484 { 559 485 CVirtualBox vbox = vboxGlobal().virtualBox(); 560 fld = QFileInfo (vbox.GetSystemProperties().GetDefault VDIFolder());486 fld = QFileInfo (vbox.GetSystemProperties().GetDefaultHardDiskFolder()); 561 487 if (!fld.exists()) 562 488 fld = vbox.GetHomeFolder(); 563 489 } 564 490 565 // QFileDialog fd (this, "New DiskImageDialog", TRUE);491 // QFileDialog fd (this, "NewMediaDialog", TRUE); 566 492 // fd.setMode (QFileDialog::AnyFile); 567 493 // fd.setViewMode (QFileDialog::List); … … 574 500 tr ("Hard disk images (*.vdi)"), 575 501 this, 576 "New DiskImageDialog",502 "NewMediaDialog", 577 503 tr ("Select a file for the new hard disk image file")); 578 504 -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewVMWzd.ui
r11982 r13580 6 6 :folding=explicit:collapseFolds=1: 7 7 8 Copyright (C) 2006-200 7Sun Microsystems, Inc.8 Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 10 10 This file is part of VirtualBox Open Source Edition (OSE), as … … 757 757 disk using the <b>New</b> button or select an existing hard disk 758 758 image from the drop-down list or by pressing the <b>Existing</b> 759 button (to invoke the Virtual DiskManager dialog).</p>759 button (to invoke the Virtual Media Manager dialog).</p> 760 760 <p>If you need a more complicated hard disk setup, you can also skip this 761 761 step and attach hard disks later using the VM Settings dialog.</p></string> … … 789 789 </property> 790 790 <property name="title"> 791 <string>B&oot Hard Disk (Primary Master)</string> 791 <string>Boot Hard &Disk (Primary Master)</string> 792 </property> 793 <property name="checkable"> 794 <bool>true</bool> 792 795 </property> 793 796 <grid> … … 991 994 <signal>clicked()</signal> 992 995 <receiver>VBoxNewVMWzd</receiver> 993 <slot>showNew VDIWizard()</slot>996 <slot>showNewHardDiskWizard()</slot> 994 997 </connection> 995 998 <connection> … … 997 1000 <signal>clicked()</signal> 998 1001 <receiver>VBoxNewVMWzd</receiver> 999 <slot>show VDIManager()</slot>1002 <slot>showHardDiskManager()</slot> 1000 1003 </connection> 1001 1004 <connection> … … 1033 1036 <include location="local" impldecl="in implementation">VBoxUtils.h</include> 1034 1037 <include location="local" impldecl="in implementation">VBoxGlobal.h</include> 1035 <include location="local" impldecl="in implementation">VBox DiskImageManagerDlg.h</include>1038 <include location="local" impldecl="in implementation">VBoxMediaManagerDlg.h</include> 1036 1039 <include location="local" impldecl="in implementation">VBoxNewHDWzd.h</include> 1037 1040 <include location="local" impldecl="in implementation">VBoxMediaComboBox.h</include> … … 1045 1048 <variable access="private">QIWidgetValidator *wvalMemory;</variable> 1046 1049 <variable access="private">QIWidgetValidator *wvalHDD;</variable> 1047 <variable access="private">QUuid uuidHD;</variable> 1048 <variable access="private">CHardDisk chd;</variable> 1049 <variable access="private">CMachine cmachine;</variable> 1050 <variable access="private">VBoxMediaComboBox *mediaCombo;</variable> 1050 <variable access="private">CHardDisk2 mHardDisk;</variable> 1051 <variable access="private">CMachine mMachine;</variable> 1052 <variable access="private">VBoxMediaComboBox *mHDCombo;</variable> 1051 1053 <variable access="private">QITextEdit *teSummary;</variable> 1052 1054 </variables> … … 1054 1056 <slot>enableNext( const QIWidgetValidator * wval )</slot> 1055 1057 <slot>revalidate( QIWidgetValidator * wval )</slot> 1056 <slot>show VDIManager()</slot>1057 <slot>showNew VDIWizard()</slot>1058 <slot>showHardDiskManager()</slot> 1059 <slot>showNewHardDiskWizard()</slot> 1058 1060 <slot>slRAM_valueChanged( int val )</slot> 1059 1061 <slot>leRAM_textChanged( const QString & text )</slot> 1060 1062 <slot>cbOS_activated( int item )</slot> 1061 <slot>currentMediaChanged( int item )</slot>1062 1063 </slots> 1063 1064 <functions> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewVMWzd.ui.h
r10351 r13580 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 103 103 104 104 /* HDD Images page */ 105 mediaCombo = new VBoxMediaComboBox (grbHDA, "mediaCombo", VBoxDefs::HD, true); 106 grbHDALayout->addMultiCellWidget (mediaCombo, 0, 0, 0, 2); 107 setTabOrder (mediaCombo, pbNewHD); 105 mHDCombo = new VBoxMediaComboBox (grbHDA, "mHDCombo", 106 VBoxDefs::MediaType_HardDisk); 107 grbHDALayout->addMultiCellWidget (mHDCombo, 0, 0, 0, 2); 108 setTabOrder (mHDCombo, pbNewHD); 108 109 setTabOrder (pbNewHD, pbExistingHD); 109 connect (mediaCombo, SIGNAL (activated (int)), 110 this, SLOT (currentMediaChanged (int))); 111 if (!vboxGlobal().isMediaEnumerationStarted()) 112 vboxGlobal().startEnumeratingMedia(); 113 else 114 mediaCombo->refresh(); 115 116 /// @todo (dmik) remove? 117 wvalHDD = new QIWidgetValidator (pageHDD, this); 118 connect (wvalHDD, SIGNAL (validityChanged (const QIWidgetValidator *)), 119 this, SLOT (enableNext (const QIWidgetValidator *))); 120 connect (wvalHDD, SIGNAL (isValidRequested (QIWidgetValidator *)), 121 this, SLOT (revalidate (QIWidgetValidator *))); 110 111 /* request to check media accessibility */ 112 mHDCombo->repopulate(); 122 113 123 114 /* Summary page */ … … 176 167 wvalNameAndOS->revalidate(); 177 168 wvalMemory->revalidate(); 178 wvalHDD->revalidate();179 169 180 170 /* the finish button on the Summary page is always enabled */ … … 222 212 } 223 213 224 225 214 void VBoxNewVMWzd::revalidate (QIWidgetValidator *wval) 226 215 { … … 229 218 bool valid = wval->isOtherValid(); 230 219 231 if (wval == wvalHDD) 232 { 233 if (!chd.isNull() && mediaCombo->getId() != chd.GetId()) 234 ensureNewHardDiskDeleted(); 235 } 236 237 wval->setOtherValid( valid ); 238 } 239 220 wval->setOtherValid (valid); 221 } 240 222 241 223 void VBoxNewVMWzd::showPage (QWidget *page) … … 243 225 if (page == pageSummary) 244 226 { 245 if (!mediaCombo->currentItem()) 227 bool haveHardDisk = grbHDA->isChecked() && !mHDCombo->id().isNull(); 228 229 if (!haveHardDisk) 246 230 { 247 231 if (!vboxProblem().confirmHardDisklessMachine (this)) … … 258 242 .arg (slRAM->value()); 259 243 260 if ( mediaCombo->currentItem())244 if (haveHardDisk) 261 245 summary += QString (tr ( 262 246 "<tr><td>Boot Hard Disk:</td><td>%4</td></tr>")) 263 .arg (m ediaCombo->currentText());247 .arg (mHDCombo->currentText()); 264 248 265 249 teSummary->setText ("<table>" + summary + "</table>"); … … 276 260 QWizard::showPage (page); 277 261 278 /* 279 * fix focus on the last page. when we go to the last page 280 * having the Next in focus the focus goes to the Cancel 281 * button because when the Next hides Finish is not yet shown. 282 */ 262 /* fix focus on the last page. when we go to the last page having the Next 263 * in focus the focus goes to the Cancel button because when the Next hides 264 Finish is not yet shown. */ 283 265 if (page == pageSummary && focusWidget() == cancelButton()) 284 266 finishButton()->setFocus(); … … 290 272 slRAM->setFocus(); 291 273 else if (page == pageHDD) 292 m ediaCombo->setFocus();274 mHDCombo->setFocus(); 293 275 else if (page == pageSummary) 294 276 teSummary->setFocus(); … … 299 281 void VBoxNewVMWzd::accept() 300 282 { 301 /* 302 * Try to create the machine when the Finish button is pressed. 303 * On failure, the wisard will remain open to give it another try. 304 */ 283 /* Try to create the machine when the Finish button is pressed. On 284 * failure, the wizard will remain open to give it another try. */ 305 285 if (constructMachine()) 306 286 QWizard::accept(); … … 312 292 313 293 /* create a machine with the default settings file location */ 314 if ( cmachine.isNull())315 { 316 cmachine = vbox.CreateMachine (QString(), leName->text(), QUuid());294 if (mMachine.isNull()) 295 { 296 mMachine = vbox.CreateMachine (QString(), leName->text(), QUuid()); 317 297 if (!vbox.isOk()) 318 298 { … … 320 300 return false; 321 301 } 322 if (uuidHD.isNull() || !chd.isNull()) 323 cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, "yes"); 302 303 /* The FirstRun wizard is to be shown only when we don't attach any hard 304 * disk or attach a new (empty) one. Selecting an existing hard disk 305 * will cancel the wizard. */ 306 if (mHDCombo->id().isNull() || !mHardDisk.isNull()) 307 mMachine.SetExtraData (VBoxDefs::GUI_FirstRun, "yes"); 324 308 } 325 309 … … 330 314 AssertMsg (!type.isNull(), ("vmGuestOSType() must return non-null type")); 331 315 QString typeId = type.GetId(); 332 cmachine.SetOSTypeId (typeId);316 mMachine.SetOSTypeId (typeId); 333 317 334 318 if (typeId == "os2warp3" || … … 336 320 typeId == "os2warp45" || 337 321 typeId == "ecs") 338 cmachine.SetHWVirtExEnabled (KTSBool_True);322 mMachine.SetHWVirtExEnabled (KTSBool_True); 339 323 340 324 /* RAM size */ 341 cmachine.SetMemorySize (slRAM->value());325 mMachine.SetMemorySize (slRAM->value()); 342 326 343 327 /* add one network adapter (NAT) by default */ 344 328 { 345 CNetworkAdapter cadapter = cmachine.GetNetworkAdapter (0);329 CNetworkAdapter cadapter = mMachine.GetNetworkAdapter (0); 346 330 #ifdef VBOX_WITH_E1000 347 331 /* Default to e1k on solaris */ … … 358 342 359 343 /* register the VM prior to attaching hard disks */ 360 vbox.RegisterMachine ( cmachine);344 vbox.RegisterMachine (mMachine); 361 345 if (!vbox.isOk()) 362 346 { 363 vboxProblem().cannotCreateMachine (vbox, cmachine, this);347 vboxProblem().cannotCreateMachine (vbox, mMachine, this); 364 348 return false; 365 349 } 366 350 367 /* Boot hard disk (Primary Master) */ 368 if (!uuidHD.isNull()) 351 /* Boot hard disk (IDE Primary Master) */ 352 QUuid hardDiskId = mHDCombo->id(); 353 if (!hardDiskId.isNull()) 369 354 { 370 355 bool ok = false; 371 QUuid id = cmachine.GetId();356 QUuid id = mMachine.GetId(); 372 357 CSession session = vboxGlobal().openSession (id); 373 358 if (!session.isNull()) 374 359 { 375 360 CMachine m = session.GetMachine(); 376 m.AttachHardDisk (uuidHD, KStorageBus_IDE, 0, 0);361 m.AttachHardDisk2 (hardDiskId, KStorageBus_IDE, 0, 0); 377 362 if (m.isOk()) 378 363 { … … 384 369 } 385 370 else 386 vboxProblem().cannotAttachHardDisk (this, m, uuidHD, 371 vboxProblem().cannotAttachHardDisk (this, m, 372 mHDCombo->location(), 387 373 KStorageBus_IDE, 0, 0); 388 374 session.Close(); … … 393 379 vbox.UnregisterMachine (id); 394 380 if (vbox.isOk()) 395 cmachine.DeleteSettings();381 mMachine.DeleteSettings(); 396 382 return false; 397 383 } 398 384 } 399 385 400 /* ensure we don't delete a newly created hard disk on success */401 chd.detach();386 /* ensure we don't try to delete a newly created hard disk on success */ 387 mHardDisk.detach(); 402 388 403 389 return true; … … 406 392 void VBoxNewVMWzd::ensureNewHardDiskDeleted() 407 393 { 408 if (!chd.isNull()) 409 { 410 QUuid hdId = chd.GetId(); 411 CVirtualBox vbox = vboxGlobal().virtualBox(); 412 vbox.UnregisterHardDisk (chd.GetId()); 413 if (!vbox.isOk()) 414 vboxProblem().cannotUnregisterMedia (this, vbox, VBoxDefs::HD, 415 chd.GetLocation()); 394 if (!mHardDisk.isNull()) 395 { 396 /* remember ID as it may be lost after the deletion */ 397 QUuid id = mHardDisk.GetId(); 398 399 bool success = false; 400 401 CProgress progress = mHardDisk.DeleteStorage(); 402 if (mHardDisk.isOk()) 403 { 404 vboxProblem().showModalProgressDialog (progress, caption(), 405 parentWidget()); 406 if (progress.isOk() && progress.GetResultCode() == S_OK) 407 success = true; 408 } 409 410 if (success) 411 vboxGlobal().removeMedium (VBoxDefs::MediaType_HardDisk, id); 416 412 else 417 { 418 CVirtualDiskImage vdi = CUnknown (chd); 419 if (!vdi.isNull()) 420 { 421 vdi.DeleteImage(); 422 if (!vdi.isOk()) 423 vboxProblem().cannotDeleteHardDiskImage (this, vdi); 424 } 425 } 426 chd.detach(); 427 vboxGlobal().removeMedia (VBoxDefs::HD, hdId); 413 vboxProblem().cannotDeleteHardDiskStorage (this, mHardDisk, 414 progress); 415 mHardDisk.detach(); 428 416 } 429 417 } … … 431 419 CMachine VBoxNewVMWzd::machine() 432 420 { 433 return cmachine;434 } 435 436 void VBoxNewVMWzd::show VDIManager()437 { 438 VBox DiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", WType_Dialog | WShowModal);439 dlg.setup (VBoxDefs:: HD, true);440 QUuid newId = dlg.exec() == VBoxDiskImageManagerDlg::Accepted ? 441 dlg.getSelectedUuid() : mediaCombo->getId();442 443 if (uuidHD != newId)444 {445 ensureNewHardDiskDeleted();446 uuidHD = newId;447 mediaCombo->setCurrentItem (uuidHD);448 }449 mediaCombo->setFocus();450 /* revailidate */ 451 wvalHDD->revalidate();452 } 453 454 void VBoxNewVMWzd::showNew VDIWizard()421 return mMachine; 422 } 423 424 void VBoxNewVMWzd::showHardDiskManager() 425 { 426 VBoxMediaManagerDlg dlg (this, "VBoxMediaManagerDlg", WType_Dialog | WShowModal); 427 dlg.setup (VBoxDefs::MediaType_HardDisk, true); 428 429 if (dlg.exec() == VBoxMediaManagerDlg::Accepted) 430 { 431 QUuid newId = dlg.selectedId(); 432 if (mHDCombo->id() != newId) 433 { 434 ensureNewHardDiskDeleted(); 435 mHDCombo->setCurrentItem (newId); 436 } 437 } 438 439 mHDCombo->setFocus(); 440 } 441 442 void VBoxNewVMWzd::showNewHardDiskWizard() 455 443 { 456 444 VBoxNewHDWzd dlg (this, "VBoxNewHDWzd"); … … 464 452 { 465 453 ensureNewHardDiskDeleted(); 466 chd = dlg.hardDisk(); 467 /* fetch uuid and name/path */ 468 uuidHD = chd.GetId(); 469 /* update media combobox */ 470 VBoxMedia::Status status = 471 chd.GetAccessible() == TRUE ? VBoxMedia::Ok : 472 chd.isOk() ? VBoxMedia::Inaccessible : 473 VBoxMedia::Error; 474 vboxGlobal().addMedia (VBoxMedia (CUnknown (chd), VBoxDefs::HD, status)); 475 mediaCombo->setCurrentItem (uuidHD); 476 mediaCombo->setFocus(); 477 /* revailidate */ 478 wvalHDD->revalidate(); 454 mHardDisk = dlg.hardDisk(); 455 456 mHDCombo->setCurrentItem (mHardDisk.GetId()); 457 mHDCombo->setFocus(); 479 458 } 480 459 } … … 484 463 leRAM->setText (QString().setNum (val)); 485 464 } 486 487 465 488 466 void VBoxNewVMWzd::leRAM_textChanged (const QString &text) … … 505 483 } 506 484 507 void VBoxNewVMWzd::currentMediaChanged (int)508 {509 uuidHD = mediaCombo->getId();510 /* revailidate */511 wvalHDD->revalidate();512 } -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSnapshotsWgt.ui.h
r8155 r13580 556 556 return; 557 557 558 QString snapName = mMachine.GetSnapshot (snapId).GetName(); 559 558 560 CConsole console = session.GetConsole(); 559 561 CProgress progress = console.DiscardSnapshot (snapId); … … 565 567 566 568 if (progress.GetResultCode() != 0) 567 vboxProblem().cannotDiscardSnapshot (progress, mMachine.GetSnapshot (snapId));569 vboxProblem().cannotDiscardSnapshot (progress, snapName); 568 570 } 569 571 else 570 vboxProblem().cannotDiscardSnapshot (console, mMachine.GetSnapshot (snapId));572 vboxProblem().cannotDiscardSnapshot (console, snapName); 571 573 572 574 session.Close(); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxUSBFilterSettings.ui.h
r8155 r13580 80 80 case VBoxUSBFilterSettings::HostType: 81 81 { 82 const CHostUSBDeviceFilter filter = CUnknown(aFilter);82 const CHostUSBDeviceFilter filter (aFilter); 83 83 KUSBDeviceFilterAction action = filter.GetAction(); 84 84 if (action == KUSBDeviceFilterAction_Ignore) … … 150 150 case VBoxUSBFilterSettings::HostType: 151 151 { 152 CHostUSBDeviceFilter filter = CUnknown(mFilter);152 CHostUSBDeviceFilter filter (mFilter); 153 153 filter.SetAction (vboxGlobal().toUSBDevFilterAction ( 154 154 cbAction->currentText())); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMFirstRunWzd.ui
r11982 r13580 6 6 :folding=explicit:collapseFolds=1: 7 7 8 Copyright (C) 2007 Sun Microsystems, Inc.8 Copyright (C) 2007-2008 Sun Microsystems, Inc. 9 9 10 10 This file is part of VirtualBox Open Source Edition (OSE), as … … 647 647 <signal>clicked()</signal> 648 648 <receiver>VBoxVMFirstRunWzd</receiver> 649 <slot>open Vdm()</slot>649 <slot>openMediaManager()</slot> 650 650 </connection> 651 651 </connections> … … 657 657 <include location="local" impldecl="in implementation">VBoxGlobal.h</include> 658 658 <include location="local" impldecl="in implementation">VBoxMediaComboBox.h</include> 659 <include location="local" impldecl="in implementation">VBox DiskImageManagerDlg.h</include>659 <include location="local" impldecl="in implementation">VBoxMediaManagerDlg.h</include> 660 660 </includes> 661 661 <forwards> … … 676 676 <slot>mediaTypeChanged()</slot> 677 677 <slot>mediaSourceChanged()</slot> 678 <slot>open Vdm()</slot>678 <slot>openMediaManager()</slot> 679 679 </slots> 680 680 <functions> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMFirstRunWzd.ui.h
r8155 r13580 53 53 54 54 /* media page */ 55 cbImage = new VBoxMediaComboBox (bgSource, "cbImage", VBoxDefs:: CD);55 cbImage = new VBoxMediaComboBox (bgSource, "cbImage", VBoxDefs::MediaType_DVD); 56 56 ltVdm->insertWidget (0, cbImage); 57 57 tbVdm->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png", … … 110 110 machine = aMachine; 111 111 112 CHardDisk AttachmentEnumerator en = machine.GetHardDiskAttachments().Enumerate();113 if ( en.HasMore())112 CHardDisk2AttachmentVector vec = machine.GetHardDisk2Attachments(); 113 if (vec.size() != 0) 114 114 { 115 115 txWelcomeHD->setHidden (true); … … 209 209 { 210 210 CDVDDrive virtualDrive = machine.GetDVDDrive(); 211 virtualDrive.MountImage (cbImage-> getId());211 virtualDrive.MountImage (cbImage->id()); 212 212 } 213 213 } … … 227 227 { 228 228 CFloppyDrive virtualDrive = machine.GetFloppyDrive(); 229 virtualDrive.MountImage (cbImage-> getId());229 virtualDrive.MountImage (cbImage->id()); 230 230 } 231 231 } … … 283 283 284 284 /* Switch media images type to CD */ 285 cbImage->setType (VBoxDefs:: CD);285 cbImage->setType (VBoxDefs::MediaType_DVD); 286 286 } 287 287 /* Floppy Media type selected */ … … 308 308 309 309 /* Switch media images type to FD */ 310 cbImage->setType (VBoxDefs::FD); 311 } 312 /* Update media images list */ 313 if (!vboxGlobal().isMediaEnumerationStarted()) 314 vboxGlobal().startEnumeratingMedia(); 315 else 316 cbImage->refresh(); 310 cbImage->setType (VBoxDefs::MediaType_Floppy); 311 } 312 313 /* Repopulate the media list */ 314 cbImage->repopulate(); 317 315 318 316 /* Revalidate updated page */ … … 332 330 333 331 334 void VBoxVMFirstRunWzd::openVdm() 335 { 336 VBoxDiskImageManagerDlg vdm (this, "VBoxDiskImageManagerDlg", 337 WType_Dialog | WShowModal); 338 QUuid machineId = machine.GetId(); 339 VBoxDefs::DiskType type = rbCdType->isChecked() ? VBoxDefs::CD : 340 rbFdType->isChecked() ? VBoxDefs::FD : VBoxDefs::InvalidType; 341 vdm.setup (type, true, &machineId); 342 if (vdm.exec() == VBoxDiskImageManagerDlg::Accepted) 343 { 344 cbImage->setCurrentItem (vdm.getSelectedUuid()); 332 void VBoxVMFirstRunWzd::openMediaManager() 333 { 334 VBoxDefs::MediaType type = 335 rbCdType->isChecked() ? VBoxDefs::MediaType_DVD : 336 rbFdType->isChecked() ? VBoxDefs::MediaType_Floppy : 337 VBoxDefs::MediaType_Invalid; 338 339 AssertReturnVoid (type != VBoxDefs::MediaType_Invalid); 340 341 VBoxMediaManagerDlg dlg (this, "VBoxMediaManagerDlg", 342 WType_Dialog | WShowModal); 343 344 dlg.setup (type, true /* aDoSelect */); 345 if (dlg.exec() == VBoxMediaManagerDlg::Accepted) 346 { 347 cbImage->setCurrentItem (dlg.selectedId()); 345 348 346 349 /* Revalidate updated page */ -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMInformationDlg.ui.h
r9364 r13580 143 143 connect (&vboxGlobal(), SIGNAL (mediaEnumFinished (const VBoxMediaList &)), 144 144 this, SLOT (updateDetails())); 145 connect (mConsole, SIGNAL (medi aChanged (VBoxDefs::DiskType)),145 connect (mConsole, SIGNAL (mediumChanged (VBoxDefs::MediaType)), 146 146 this, SLOT (updateDetails())); 147 147 connect (mConsole, SIGNAL (sharedFoldersChanged()), … … 435 435 /* details page update */ 436 436 mDetailsText->setText ( 437 vboxGlobal().detailsReport (mSession.GetMachine(), false /* isNewVM */,438 false /* withLinks */, false /* refresh*/));437 vboxGlobal().detailsReport (mSession.GetMachine(), false /* aIsNewVM */, 438 false /* aWithLinks */)); 439 439 } 440 440 … … 561 561 562 562 /* IDE Hard Disk (Primary Master) */ 563 if (!m.GetHardDisk (KStorageBus_IDE, 0, 0).isNull())563 if (!m.GetHardDisk2 (KStorageBus_IDE, 0, 0).isNull()) 564 564 { 565 565 hdStat += formatHardDisk (KStorageBus_IDE, 0, 0, "IDE00"); … … 568 568 569 569 /* IDE Hard Disk (Primary Slave) */ 570 if (!m.GetHardDisk (KStorageBus_IDE, 0, 1).isNull())570 if (!m.GetHardDisk2 (KStorageBus_IDE, 0, 1).isNull()) 571 571 { 572 572 hdStat += formatHardDisk (KStorageBus_IDE, 0, 1, "IDE01"); … … 575 575 576 576 /* IDE Hard Disk (Secondary Slave) */ 577 if (!m.GetHardDisk (KStorageBus_IDE, 1, 1).isNull())577 if (!m.GetHardDisk2 (KStorageBus_IDE, 1, 1).isNull()) 578 578 { 579 579 hdStat += formatHardDisk (KStorageBus_IDE, 1, 1, "IDE11"); … … 584 584 for (int i = 0; i < 30; ++ i) 585 585 { 586 if (!m.GetHardDisk (KStorageBus_SATA, i, 0).isNull())586 if (!m.GetHardDisk2 (KStorageBus_SATA, i, 0).isNull()) 587 587 { 588 588 hdStat += formatHardDisk (KStorageBus_SATA, i, 0, … … 649 649 return QString::null; 650 650 651 CHardDisk hd = mSession.GetMachine().GetHardDisk(aBus, aChannel, aDevice);651 CHardDisk2 hd = mSession.GetMachine().GetHardDisk2 (aBus, aChannel, aDevice); 652 652 QString header = "<tr><td></td><td colspan=3><nobr><u>%1</u></nobr></td></tr>"; 653 653 QString name = vboxGlobal().toFullString (aBus, aChannel, aDevice); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r8497 r13580 1643 1643 </property> 1644 1644 <property name="whatsThis" stdset="0"> 1645 <string>Invokes the Virtual DiskManager to select a CD/DVD image to mount.</string>1645 <string>Invokes the Virtual Media Manager to select a CD/DVD image to mount.</string> 1646 1646 </property> 1647 1647 </widget> … … 1842 1842 </property> 1843 1843 <property name="whatsThis" stdset="0"> 1844 <string>Invokes the Virtual DiskManager to select a Floppy image to mount.</string>1844 <string>Invokes the Virtual Media Manager to select a Floppy image to mount.</string> 1845 1845 </property> 1846 1846 </widget> … … 3032 3032 <include location="local" impldecl="in implementation">VBoxUSBFilterSettings.h</include> 3033 3033 <include location="local" impldecl="in implementation">VBoxSharedFoldersSettings.h</include> 3034 <include location="local" impldecl="in implementation">VBox DiskImageManagerDlg.h</include>3034 <include location="local" impldecl="in implementation">VBoxMediaManagerDlg.h</include> 3035 3035 <include location="local" impldecl="in implementation">VBoxMediaComboBox.h</include> 3036 3036 <include location="local" impldecl="in implementation">QIRichLabel.h</include> … … 3039 3039 <forwards> 3040 3040 <forward>class VBoxMediaComboBox</forward> 3041 <forward>class VBox DiskImageManagerDlg</forward>3041 <forward>class VBoxMediaManagerDlg</forward> 3042 3042 <forward>class VBoxUSBMenu</forward> 3043 3043 <forward>class VBoxSharedFoldersSettings</forward> … … 3084 3084 <slot>revalidate( QIWidgetValidator * wval )</slot> 3085 3085 <slot>updateWhatsThis( bool gotFocus = false )</slot> 3086 <slot>show ImageManagerISODVD()</slot>3087 <slot>show ImageManagerISOFloppy()</slot>3088 <slot>show VDImageManager( QUuid *id, VBoxMediaComboBox *le, QLabel *tx = NULL)</slot>3086 <slot>showDVDManager()</slot> 3087 <slot>showFloppyManager()</slot> 3088 <slot>showMediaManager( QUuid *, VBoxMediaComboBox * )</slot> 3089 3089 <slot>addNetworkAdapter( const CNetworkAdapter & )</slot> 3090 3090 <slot>updateNetworksList()</slot> … … 3127 3127 <function access="private">showEvent( QShowEvent * )</function> 3128 3128 <function access="private">updateShortcuts()</function> 3129 <function access="private" returnType="QString">getHdInfo( QGroupBox*, QUuid )</function>3130 3129 <function access="private">loadInterfacesList()</function> 3131 3130 <function access="private">loadNetworksList()</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r11955 r13580 598 598 this, SLOT (revalidate (QIWidgetValidator *))); 599 599 600 connect (mHDSettings, SIGNAL (h ddListChanged()), wvalHDD, SLOT (revalidate()));601 connect (mHDSettings, SIGNAL (h ddListChanged()), this, SLOT (resetFirstRunFlag()));600 connect (mHDSettings, SIGNAL (hardDiskListChanged()), wvalHDD, SLOT (revalidate())); 601 connect (mHDSettings, SIGNAL (hardDiskListChanged()), this, SLOT (resetFirstRunFlag())); 602 602 603 603 /* CD/DVD-ROM Drive Page */ … … 607 607 "virtual machine. Note that the CD/DVD drive is always connected to the " 608 608 "Secondary Master IDE controller of the machine.")); 609 cbISODVD = new VBoxMediaComboBox (bgDVD, "cbISODVD", VBoxDefs:: CD);609 cbISODVD = new VBoxMediaComboBox (bgDVD, "cbISODVD", VBoxDefs::MediaType_DVD); 610 610 cdLayout->insertWidget(0, cbISODVD); 611 611 QWhatsThis::add (cbISODVD, tr ("Displays the image file to mount to the virtual CD/DVD " … … 622 622 connect (rbISODVD, SIGNAL (stateChanged (int)), wvalDVD, SLOT (revalidate())); 623 623 connect (cbISODVD, SIGNAL (activated (int)), this, SLOT (cdMediaChanged())); 624 connect (tbISODVD, SIGNAL (clicked()), this, SLOT (show ImageManagerISODVD()));624 connect (tbISODVD, SIGNAL (clicked()), this, SLOT (showDVDManager())); 625 625 626 626 /* setup iconsets -- qdesigner is not capable... */ … … 633 633 tr ("When checked, mounts the specified media to the Floppy drive of the " 634 634 "virtual machine.")); 635 cbISOFloppy = new VBoxMediaComboBox (bgFloppy, "cbISOFloppy", VBoxDefs:: FD);635 cbISOFloppy = new VBoxMediaComboBox (bgFloppy, "cbISOFloppy", VBoxDefs::MediaType_Floppy); 636 636 fdLayout->insertWidget(0, cbISOFloppy); 637 637 QWhatsThis::add (cbISOFloppy, tr ("Displays the image file to mount to the virtual Floppy " … … 648 648 connect (rbISOFloppy, SIGNAL (stateChanged (int)), wvalFloppy, SLOT (revalidate())); 649 649 connect (cbISOFloppy, SIGNAL (activated (int)), this, SLOT (fdMediaChanged())); 650 connect (tbISOFloppy, SIGNAL (clicked()), this, SLOT (show ImageManagerISOFloppy()));650 connect (tbISOFloppy, SIGNAL (clicked()), this, SLOT (showFloppyManager())); 651 651 652 652 /* setup iconsets -- qdesigner is not capable... */ … … 1178 1178 { 1179 1179 resetFirstRunFlag(); 1180 uuidISODVD = bgDVD->isChecked() ? cbISODVD-> getId() : QUuid();1180 uuidISODVD = bgDVD->isChecked() ? cbISODVD->id() : QUuid(); 1181 1181 /* revailidate */ 1182 1182 wvalDVD->revalidate(); … … 1187 1187 { 1188 1188 resetFirstRunFlag(); 1189 uuidISOFloppy = bgFloppy->isChecked() ? cbISOFloppy-> getId() : QUuid();1189 uuidISOFloppy = bgFloppy->isChecked() ? cbISOFloppy->id() : QUuid(); 1190 1190 /* revailidate */ 1191 1191 wvalFloppy->revalidate(); 1192 1192 } 1193 1193 1194 1195 QString VBoxVMSettingsDlg::getHdInfo (QGroupBox *aGroupBox, QUuid aId)1196 {1197 QString notAttached = tr ("<not attached>", "hard disk");1198 if (aId.isNull())1199 return notAttached;1200 return aGroupBox->isChecked() ?1201 vboxGlobal().details (vboxGlobal().virtualBox().GetHardDisk (aId), true) :1202 notAttached;1203 }1204 1194 1205 1195 void VBoxVMSettingsDlg::updateWhatsThis (bool gotFocus /* = false */) … … 1234 1224 } 1235 1225 1226 1236 1227 void VBoxVMSettingsDlg::setWarning (const QString &warning) 1237 1228 { … … 1246 1237 } 1247 1238 1239 1248 1240 /** 1249 * 1241 * Sets up this dialog. 1250 1242 * 1251 * 1252 * '[cat]' column of #listView (see VBoxVMSettingsDlg.ui in qdesigner)1253 * prepended with the '#' sign. In this case, the specified category page1254 * will beactivated when the dialog is open.1243 * If @a aCategory is non-null, it should be one of values from the hidden 1244 * '[cat]' column of #listView (see VBoxVMSettingsDlg.ui in qdesigner) prepended 1245 * with the '#' sign. In this case, the specified category page will be 1246 * activated when the dialog is open. 1255 1247 * 1256 * If @a aWidget is non-null, it should be a name of one of widgets1257 * from the given category page. In this case, the specified widget1258 * will get focus whenthe dialog is open.1248 * If @a aWidget is non-null, it should be a name of one of widgets from the 1249 * given category page. In this case, the specified widget will get focus when 1250 * the dialog is open. 1259 1251 * 1260 * 1252 * @note Calling this method after the dialog is open has no sense. 1261 1253 * 1262 * @param aCategoryCategory to select when the dialog is open or null.1263 * @param aWidgetCategory to select when the dialog is open or null.1254 * @param aCategory Category to select when the dialog is open or null. 1255 * @param aWidget Category to select when the dialog is open or null. 1264 1256 */ 1265 1257 void VBoxVMSettingsDlg::setup (const QString &aCategory, const QString &aControl) … … 1303 1295 } 1304 1296 } 1297 1305 1298 1306 1299 void VBoxVMSettingsDlg::listView_currentChanged (QListViewItem *item) … … 1652 1645 case KDriveState_ImageMounted: 1653 1646 { 1654 CFloppyImage img = floppy.GetImage();1655 QString src = img.Get FilePath();1647 CFloppyImage2 img = floppy.GetImage(); 1648 QString src = img.GetLocation(); 1656 1649 AssertMsg (!src.isNull(), ("Image file must not be null")); 1657 1650 QFileInfo fi (src); … … 1724 1717 case KDriveState_ImageMounted: 1725 1718 { 1726 CDVDImage img = dvd.GetImage();1727 QString src = img.Get FilePath();1719 CDVDImage2 img = dvd.GetImage(); 1720 QString src = img.GetLocation(); 1728 1721 AssertMsg (!src.isNull(), ("Image file must not be null")); 1729 1722 QFileInfo fi (src); … … 2103 2096 2104 2097 2105 void VBoxVMSettingsDlg::showImageManagerISODVD() { showVDImageManager (&uuidISODVD, cbISODVD); } 2106 void VBoxVMSettingsDlg::showImageManagerISOFloppy() { showVDImageManager(&uuidISOFloppy, cbISOFloppy); } 2107 2108 void VBoxVMSettingsDlg::showVDImageManager (QUuid *id, VBoxMediaComboBox *cbb, QLabel*) 2109 { 2110 VBoxDefs::DiskType type = VBoxDefs::InvalidType; 2111 if (cbb == cbISODVD) 2112 type = VBoxDefs::CD; 2113 else if (cbb == cbISOFloppy) 2114 type = VBoxDefs::FD; 2098 void VBoxVMSettingsDlg::showDVDManager() 2099 { 2100 showMediaManager (&uuidISODVD, cbISODVD); 2101 } 2102 2103 2104 void VBoxVMSettingsDlg::showFloppyManager() 2105 { 2106 showMediaManager (&uuidISOFloppy, cbISOFloppy); 2107 } 2108 2109 2110 void VBoxVMSettingsDlg::showMediaManager (QUuid *aId, VBoxMediaComboBox *aCombo) 2111 { 2112 VBoxDefs::MediaType type = VBoxDefs::MediaType_Invalid; 2113 2114 if (aCombo == cbISODVD) 2115 type = VBoxDefs::MediaType_DVD; 2116 else if (aCombo == cbISOFloppy) 2117 type = VBoxDefs::MediaType_Floppy; 2118 2119 AssertReturnVoid (type != VBoxDefs::MediaType_Invalid); 2120 2121 VBoxMediaManagerDlg dlg (this, "VBoxMediaManagerDlg", 2122 WType_Dialog | WShowModal); 2123 2124 dlg.setup (type, true /* aDoSelect */, true /* aRefresh */, cmachine, 2125 aCombo->id()); 2126 2127 if (dlg.exec() == VBoxMediaManagerDlg::Accepted) 2128 { 2129 *aId = dlg.selectedId(); 2130 resetFirstRunFlag(); 2131 } 2115 2132 else 2116 type = VBoxDefs::HD; 2117 2118 VBoxDiskImageManagerDlg dlg (this, "VBoxDiskImageManagerDlg", 2119 WType_Dialog | WShowModal); 2120 QUuid machineId = cmachine.GetId(); 2121 QUuid hdId = type == VBoxDefs::HD ? cbb->getId() : QUuid(); 2122 QUuid cdId = type == VBoxDefs::CD ? cbb->getId() : QUuid(); 2123 QUuid fdId = type == VBoxDefs::FD ? cbb->getId() : QUuid(); 2124 dlg.setup (type, true, &machineId, true /* aRefresh */, cmachine, 2125 hdId, cdId, fdId); 2126 if (dlg.exec() == VBoxDiskImageManagerDlg::Accepted) 2127 { 2128 *id = dlg.getSelectedUuid(); 2129 resetFirstRunFlag(); 2130 } 2131 else 2132 { 2133 *id = cbb->getId(); 2134 } 2135 2136 cbb->setCurrentItem (*id); 2137 cbb->setFocus(); 2133 { 2134 *aId = aCombo->id(); 2135 } 2136 2137 aCombo->setCurrentItem (*aId); 2138 aCombo->setFocus(); 2138 2139 2139 2140 /* revalidate pages with custom validation */ 2140 wvalHDD->revalidate();2141 2141 wvalDVD->revalidate(); 2142 2142 wvalFloppy->revalidate(); 2143 2143 } 2144 2144 2145 2145 2146 void VBoxVMSettingsDlg::addNetworkAdapter (const CNetworkAdapter &aAdapter) … … 2194 2195 } 2195 2196 2197 2196 2198 void VBoxVMSettingsDlg::updateNetworksList() 2197 2199 { … … 2222 2224 mLockNetworkListUpdate = false; 2223 2225 } 2226 2224 2227 2225 2228 void VBoxVMSettingsDlg::addSerialPort (const CSerialPort &aPort) … … 2257 2260 } 2258 2261 2262 2259 2263 void VBoxVMSettingsDlg::addParallelPort (const CParallelPort &aPort) 2260 2264 { … … 2289 2293 } 2290 2294 2295 2291 2296 void VBoxVMSettingsDlg::slRAM_valueChanged( int val ) 2292 2297 { … … 2294 2299 } 2295 2300 2301 2296 2302 void VBoxVMSettingsDlg::leRAM_textChanged( const QString &text ) 2297 2303 { … … 2299 2305 } 2300 2306 2307 2301 2308 void VBoxVMSettingsDlg::slVRAM_valueChanged( int val ) 2302 2309 { … … 2304 2311 } 2305 2312 2313 2306 2314 void VBoxVMSettingsDlg::leVRAM_textChanged( const QString &text ) 2307 2315 { 2308 2316 slVRAM->setValue( text.toInt() ); 2309 2317 } 2318 2310 2319 2311 2320 void VBoxVMSettingsDlg::cbOS_activated (int item) … … 2322 2331 } 2323 2332 2333 2324 2334 void VBoxVMSettingsDlg::tbResetSavedStateFolder_clicked() 2325 2335 { … … 2332 2342 } 2333 2343 2344 2334 2345 void VBoxVMSettingsDlg::tbSelectSavedStateFolder_clicked() 2335 2346 { … … 2354 2365 } 2355 2366 2367 2356 2368 // USB Filter stuff 2357 2369 //////////////////////////////////////////////////////////////////////////////// 2370 2358 2371 2359 2372 void VBoxVMSettingsDlg::usbAdapterToggled (bool aOn) … … 2363 2376 grbUSBFilters->setEnabled (aOn); 2364 2377 } 2378 2365 2379 2366 2380 void VBoxVMSettingsDlg::addUSBFilter (const CUSBDeviceFilter &aFilter, bool isNew) … … 2405 2419 } 2406 2420 2421 2407 2422 void VBoxVMSettingsDlg::lvUSBFilters_currentChanged (QListViewItem *item) 2408 2423 { … … 2427 2442 } 2428 2443 2444 2429 2445 void VBoxVMSettingsDlg::lvUSBFilters_contextMenuRequested (QListViewItem *, 2430 2446 const QPoint &aPoint, int) … … 2433 2449 } 2434 2450 2451 2435 2452 void VBoxVMSettingsDlg::lvUSBFilters_setCurrentText (const QString &aText) 2436 2453 { … … 2440 2457 item->setText (lvUSBFilters_Name, aText); 2441 2458 } 2459 2442 2460 2443 2461 void VBoxVMSettingsDlg::addUSBFilterAct_activated() … … 2468 2486 } 2469 2487 2488 2470 2489 void VBoxVMSettingsDlg::addUSBFilterFromAct_activated() 2471 2490 { … … 2480 2499 usbDevicesMenu->exec (pos); 2481 2500 } 2501 2482 2502 2483 2503 void VBoxVMSettingsDlg::menuAddUSBFilterFrom_activated (int aIndex) … … 2513 2533 } 2514 2534 2535 2515 2536 void VBoxVMSettingsDlg::removeUSBFilterAct_activated() 2516 2537 { … … 2530 2551 } 2531 2552 2553 2532 2554 void VBoxVMSettingsDlg::USBFilterUpAct_activated() 2533 2555 { … … 2551 2573 } 2552 2574 2575 2553 2576 void VBoxVMSettingsDlg::USBFilterDownAct_activated() 2554 2577 { … … 2565 2588 } 2566 2589 2590 2567 2591 #include "VBoxVMSettingsDlg.ui.moc" 2568 2592
Note:
See TracChangeset
for help on using the changeset viewer.