VirtualBox

Ignore:
Timestamp:
Sep 22, 2009 3:50:03 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
52692
Message:

API: big medium handling change and lots of assorted other cleanups and fixes

Location:
trunk/src/VBox/Frontends/VirtualBox/include
Files:
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl

    r17808 r23223  
    224224  <!-- forward declarations -->
    225225  <xsl:text>// forward declarations&#x0A;&#x0A;</xsl:text>
    226   <xsl:for-each select="interface | collection | enumerator">
     226  <xsl:for-each select="interface">
    227227    <xsl:text>class C</xsl:text>
    228228    <xsl:value-of select="substring(@name,2)"/>
     
    250250  <xsl:apply-templates select="
    251251      if |
    252       interface[not(@internal='yes')] |
    253       collection[not(@internal='yes')] |
    254       enumerator[not(@internal='yes')]
     252      interface[not(@internal='yes')]
    255253    "
    256254    mode="declare"
     
    260258  <xsl:apply-templates select="
    261259      if |
    262       interface[not(@internal='yes')] |
    263       collection[not(@internal='yes')] |
    264       enumerator[not(@internal='yes')]
     260      interface[not(@internal='yes')]
    265261    "
    266262    mode="define"
     
    272268 *  interface declarations
    273269-->
    274 <xsl:template match="interface | collection | enumerator" mode="declare">
     270<xsl:template match="interface" mode="declare">
    275271
    276272  <xsl:text>// </xsl:text>
     
    295291  <xsl:text>&gt; Base;&#x0A;&#x0A;</xsl:text>
    296292
    297   <xsl:if test="name()='collection'">
    298     <xsl:text>    // collection stuff&#x0A;&#x0A;</xsl:text>
    299     <xsl:text>    ULONG GetCount () const;&#x0A;</xsl:text>
    300     <xsl:text>    </xsl:text>
    301     <xsl:apply-templates select="@type"/>
    302     <xsl:text> GetItemAt (ULONG index) const;&#x0A;</xsl:text>
    303     <xsl:text>    </xsl:text>
    304     <xsl:apply-templates select="@enumerator"/>
    305     <xsl:text> Enumerate () const;&#x0A;&#x0A;</xsl:text>
    306   </xsl:if>
    307 
    308   <xsl:if test="name()='enumerator'">
    309     <xsl:text>    // enumerator stuff&#x0A;&#x0A;</xsl:text>
    310     <xsl:text>    BOOL HasMore () const;&#x0A;</xsl:text>
    311     <xsl:text>    </xsl:text>
    312     <xsl:apply-templates select="@type"/>
    313     <xsl:text> GetNext () const;&#x0A;&#x0A;</xsl:text>
    314     <xsl:text>    // friend wrappers&#x0A;&#x0A;</xsl:text>
    315     <xsl:text>    friend class CUnknown;&#x0A;</xsl:text>
    316     <xsl:variable name="name" select="@name"/>
    317     <xsl:variable name="parent" select=".."/>
    318     <!-- for definitions inside <if> -->
    319     <xsl:if test="name(..)='if'">
    320       <xsl:for-each select="
    321         preceding-sibling::collection | following-sibling::collection |
    322         ../preceding-sibling::if[@target=$parent/@target]/collection |
    323         ../following-sibling::if[@target=$parent/@target]/collection
    324       ">
    325         <xsl:if test="@enumerator=$name">
    326           <xsl:text>    friend class C</xsl:text>
    327           <xsl:value-of select="substring(@name,2)"/>
    328           <xsl:text>;&#x0A;</xsl:text>
    329         </xsl:if>
    330       </xsl:for-each>
    331     </xsl:if>
    332     <!-- for definitions outside <if> (i.e. inside <library>) -->
    333     <xsl:if test="name(..)!='if'">
    334       <xsl:for-each select="
    335         preceding-sibling::collection | following-sibling::collection
    336       ">
    337         <xsl:if test="@enumerator=$name">
    338           <xsl:text>    friend class C</xsl:text>
    339           <xsl:value-of select="substring(@name,2)"/>
    340           <xsl:text>;&#x0A;</xsl:text>
    341         </xsl:if>
    342       </xsl:for-each>
    343     </xsl:if>
    344   </xsl:if>
    345 
    346   <xsl:if test="name()='interface' or name()='collection'">
     293  <xsl:if test="name()='interface'">
    347294    <xsl:call-template name="declareMembers"/>
    348295  </xsl:if>
     
    368315          <xsl:with-param name="iface" select="
    369316            preceding-sibling::
    370               *[(self::interface or self::collection) and @name=$iface/@extends] |
     317              *[self::interface and @name=$iface/@extends] |
    371318            following-sibling::
    372               *[(self::interface or self::collection) and @name=$iface/@extends] |
     319              *[self::interface and @name=$iface/@extends] |
    373320            ../preceding-sibling::if[@target=../@target]/
    374               *[(self::interface or self::collection) and @name=$iface/@extends] |
     321              *[self::interface and @name=$iface/@extends] |
    375322            ../following-sibling::if[@target=../@target]/
    376               *[(self::interface or self::collection) and @name=$iface/@extends]
     323              *[self::interface and @name=$iface/@extends]
    377324          "/>
    378325        </xsl:call-template>
     
    383330          <xsl:with-param name="iface" select="
    384331            preceding-sibling::
    385               *[(self::interface or self::collection) and @name=$iface/@extends] |
     332              *[self::interface and @name=$iface/@extends] |
    386333            following-sibling::
    387               *[(self::interface or self::collection) and @name=$iface/@extends]
     334              *[self::interface and @name=$iface/@extends]
    388335          "/>
    389336        </xsl:call-template>
     
    410357          <xsl:with-param name="iface" select="
    411358            preceding-sibling::
    412               *[(self::interface or self::collection) and @name=$iface/@extends] |
     359              *[self::interface and @name=$iface/@extends] |
    413360            following-sibling::
    414               *[(self::interface or self::collection) and @name=$iface/@extends] |
     361              *[self::interface and @name=$iface/@extends] |
    415362            ../preceding-sibling::if[@target=../@target]/
    416               *[(self::interface or self::collection) and @name=$iface/@extends] |
     363              *[self::interface and @name=$iface/@extends] |
    417364            ../following-sibling::if[@target=../@target]/
    418               *[(self::interface or self::collection) and @name=$iface/@extends]
     365              *[self::interface and @name=$iface/@extends]
    419366          "/>
    420367        </xsl:call-template>
     
    425372          <xsl:with-param name="iface" select="
    426373            preceding-sibling::
    427               *[(self::interface or self::collection) and @name=$iface/@extends] |
     374              *[self::interface and @name=$iface/@extends] |
    428375            following-sibling::
    429               *[(self::interface or self::collection) and @name=$iface/@extends]
     376              *[self::interface and @name=$iface/@extends]
    430377          "/>
    431378        </xsl:call-template>
     
    541488  <xsl:if test="name(..)='if'">
    542489    <xsl:for-each select="
    543       preceding-sibling::*[self::interface or self::collection or self::enumerator] |
    544       following-sibling::*[self::interface or self::collection or self::enumerator] |
    545       ../preceding-sibling::*[self::interface or self::collection or self::enumerator] |
    546       ../following-sibling::*[self::interface or self::collection or self::enumerator] |
    547       ../preceding-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator] |
    548       ../following-sibling::if[@target=$parent/@target]/*[self::interface or self::collection or self::enumerator]
     490      preceding-sibling::*[self::interface] |
     491      following-sibling::*[self::interface] |
     492      ../preceding-sibling::*[self::interface] |
     493      ../following-sibling::*[self::interface] |
     494      ../preceding-sibling::if[@target=$parent/@target]/*[self::interface] |
     495      ../following-sibling::if[@target=$parent/@target]/*[self::interface]
    549496    ">
    550497      <xsl:if test="
    551         ((name()='interface' or name()='collection')
     498        ((name()='interface')
    552499         and
    553500         ((name(..)!='if' and (if[@target=$parent/@target]/method/param[@type=$name]
     
    556503          or
    557504          (.//method/param[@type=$name] or attribute[@type=$name])))
    558         or
    559         (name(..)='if' and (name()='collection' or name()='enumerator') and @type=$name)
    560505      ">
    561506        <xsl:text>    friend class C</xsl:text>
     
    568513  <xsl:if test="name(..)!='if'">
    569514    <xsl:for-each select="
    570       preceding-sibling::*[self::interface or self::collection or self::enumerator] |
    571       following-sibling::*[self::interface or self::collection or self::enumerator] |
    572       preceding-sibling::if/*[self::interface or self::collection or self::enumerator] |
    573       following-sibling::if/*[self::interface or self::collection or self::enumerator]
     515      preceding-sibling::*[self::interface] |
     516      following-sibling::*[self::interface] |
     517      preceding-sibling::if/*[self::interface] |
     518      following-sibling::if/*[self::interface]
    574519    ">
    575520      <xsl:if test="
    576         ((name()='interface' or name()='collection')
    577          and
    578          (.//method/param[@type=$name] or attribute[@type=$name]))
    579         or
    580         ((name()='collection' or name()='enumerator') and @type=$name)
     521        name()='interface' and (.//method/param[@type=$name] or attribute[@type=$name])
    581522      ">
    582523        <xsl:text>    friend class C</xsl:text>
     
    590531
    591532<!-- attribute declarations -->
    592 <xsl:template match="interface//attribute | collection//attribute" mode="declare">
    593   <xsl:if test="@array">
    594     <xsl:message terminate="yes">
    595       <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    596       <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
    597     </xsl:message>
    598   </xsl:if>
     533<xsl:template match="interface//attribute" mode="declare">
    599534  <xsl:apply-templates select="parent::node()" mode="begin"/>
    600535  <xsl:apply-templates select="@if" mode="begin"/>
     
    612547
    613548<!-- method declarations -->
    614 <xsl:template match="interface//method | collection//method" mode="declare">
     549<xsl:template match="interface//method" mode="declare">
    615550  <xsl:apply-templates select="parent::node()" mode="begin"/>
    616551  <xsl:apply-templates select="@if" mode="begin"/>
     
    624559 *  interface definitions
    625560-->
    626 <xsl:template match="interface | collection | enumerator" mode="define">
     561<xsl:template match="interface" mode="define">
    627562
    628563  <xsl:text>// </xsl:text>
     
    630565  <xsl:text> wrapper&#x0A;&#x0A;</xsl:text>
    631566
    632   <xsl:if test="name()='collection'">
    633     <!-- GetCount -->
    634     <xsl:text>inline ULONG C</xsl:text>
    635     <xsl:value-of select="substring(@name,2)"/>
    636     <xsl:text>::GetCount () const&#x0A;{&#x0A;</xsl:text>
    637     <xsl:text>    ULONG count = 0;&#x0A;</xsl:text>
    638     <xsl:text>    Assert (mIface);&#x0A;</xsl:text>
    639     <xsl:text>    if (!mIface)&#x0A;        return count;&#x0A;</xsl:text>
    640     <xsl:text>    mRC = mIface->COMGETTER(Count) (&amp;count);&#x0A;</xsl:text>
    641     <xsl:call-template name="tryComposeFetchErrorInfo"/>
    642     <xsl:text>    return count;&#x0A;</xsl:text>
    643     <xsl:text>}&#x0A;&#x0A;</xsl:text>
    644     <!-- GetItemAt -->
    645     <xsl:text>inline </xsl:text>
    646     <xsl:apply-templates select="@type"/>
    647     <xsl:text> C</xsl:text>
    648     <xsl:value-of select="substring(@name,2)"/>
    649     <xsl:text>::GetItemAt (ULONG index) const&#x0A;{&#x0A;</xsl:text>
    650     <xsl:text>    </xsl:text><xsl:apply-templates select="@type"/>
    651     <xsl:text> item;&#x0A;</xsl:text>
    652     <xsl:text>    Assert (mIface);&#x0A;</xsl:text>
    653     <xsl:text>    if (!mIface)&#x0A;        return item;&#x0A;</xsl:text>
    654     <xsl:text>    mRC = mIface->GetItemAt (index, &amp;item.mIface);&#x0A;</xsl:text>
    655     <xsl:call-template name="tryComposeFetchErrorInfo"/>
    656     <xsl:text>    return item;&#x0A;</xsl:text>
    657     <xsl:text>}&#x0A;&#x0A;</xsl:text>
    658     <!-- Enumerate -->
    659     <xsl:text>inline </xsl:text>
    660     <xsl:apply-templates select="@enumerator"/>
    661     <xsl:text> C</xsl:text>
    662     <xsl:value-of select="substring(@name,2)"/>
    663     <xsl:text>::Enumerate () const&#x0A;{&#x0A;</xsl:text>
    664     <xsl:text>    </xsl:text><xsl:apply-templates select="@enumerator"/>
    665     <xsl:text> enumerator;&#x0A;</xsl:text>
    666     <xsl:text>    Assert (mIface);&#x0A;</xsl:text>
    667     <xsl:text>    if (!mIface)&#x0A;        return enumerator;&#x0A;</xsl:text>
    668     <xsl:text>    mRC = mIface->Enumerate (&amp;enumerator.mIface);&#x0A;</xsl:text>
    669     <xsl:call-template name="tryComposeFetchErrorInfo"/>
    670     <xsl:text>    return enumerator;&#x0A;</xsl:text>
    671     <xsl:text>}&#x0A;&#x0A;</xsl:text>
    672   </xsl:if>
    673 
    674   <xsl:if test="name()='enumerator'">
    675     <!-- HasMore -->
    676     <xsl:text>inline BOOL C</xsl:text>
    677     <xsl:value-of select="substring(@name,2)"/>
    678     <xsl:text>::HasMore () const&#x0A;{&#x0A;</xsl:text>
    679     <xsl:text>    BOOL more = FALSE;&#x0A;</xsl:text>
    680     <xsl:text>    Assert (mIface);&#x0A;</xsl:text>
    681     <xsl:text>    if (!mIface)&#x0A;        return more;&#x0A;</xsl:text>
    682     <xsl:text>    mRC = mIface->HasMore (&amp;more);&#x0A;</xsl:text>
    683     <xsl:call-template name="tryComposeFetchErrorInfo"/>
    684     <xsl:text>    return more;&#x0A;</xsl:text>
    685     <xsl:text>}&#x0A;&#x0A;</xsl:text>
    686     <!-- GetNext -->
    687     <xsl:text>inline </xsl:text>
    688     <xsl:apply-templates select="@type"/>
    689     <xsl:text> C</xsl:text>
    690     <xsl:value-of select="substring(@name,2)"/>
    691     <xsl:text>::GetNext () const&#x0A;{&#x0A;</xsl:text>
    692     <xsl:text>    </xsl:text><xsl:apply-templates select="@type"/>
    693     <xsl:text> next;&#x0A;</xsl:text>
    694     <xsl:text>    Assert (mIface);&#x0A;</xsl:text>
    695     <xsl:text>    if (!mIface)&#x0A;        return next;&#x0A;</xsl:text>
    696     <xsl:text>    mRC = mIface->GetNext (&amp;next.mIface);&#x0A;</xsl:text>
    697     <xsl:call-template name="tryComposeFetchErrorInfo"/>
    698     <xsl:text>    return next;&#x0A;</xsl:text>
    699     <xsl:text>}&#x0A;&#x0A;</xsl:text>
    700   </xsl:if>
    701 
    702   <xsl:if test="name()='interface' or name()='collection'">
     567  <xsl:if test="name()='interface'">
    703568    <xsl:call-template name="defineMembers"/>
    704569  </xsl:if>
     
    722587          <xsl:with-param name="iface" select="
    723588            preceding-sibling::
    724               *[(self::interface or self::collection) and @name=$iface/@extends] |
     589              *[self::interface and @name=$iface/@extends] |
    725590            following-sibling::
    726               *[(self::interface or self::collection) and @name=$iface/@extends] |
     591              *[self::interface and @name=$iface/@extends] |
    727592            ../preceding-sibling::if[@target=../@target]/
    728               *[(self::interface or self::collection) and @name=$iface/@extends] |
     593              *[self::interface and @name=$iface/@extends] |
    729594            ../following-sibling::if[@target=../@target]/
    730               *[(self::interface or self::collection) and @name=$iface/@extends]
     595              *[self::interface and @name=$iface/@extends]
    731596          "/>
    732597        </xsl:call-template>
     
    737602          <xsl:with-param name="iface" select="
    738603            preceding-sibling::
    739               *[(self::interface or self::collection) and @name=$iface/@extends] |
     604              *[self::interface and @name=$iface/@extends] |
    740605            following-sibling::
    741               *[(self::interface or self::collection) and @name=$iface/@extends]
     606              *[self::interface and @name=$iface/@extends]
    742607          "/>
    743608        </xsl:call-template>
     
    764629          <xsl:with-param name="iface" select="
    765630            preceding-sibling::
    766               *[(self::interface or self::collection) and @name=$iface/@extends] |
     631              *[self::interface and @name=$iface/@extends] |
    767632            following-sibling::
    768               *[(self::interface or self::collection) and @name=$iface/@extends] |
     633              *[self::interface and @name=$iface/@extends] |
    769634            ../preceding-sibling::if[@target=../@target]/
    770               *[(self::interface or self::collection) and @name=$iface/@extends] |
     635              *[self::interface and @name=$iface/@extends] |
    771636            ../following-sibling::if[@target=../@target]/
    772               *[(self::interface or self::collection) and @name=$iface/@extends]
     637              *[self::interface and @name=$iface/@extends]
    773638          "/>
    774639        </xsl:call-template>
     
    779644          <xsl:with-param name="iface" select="
    780645            preceding-sibling::
    781               *[(self::interface or self::collection) and @name=$iface/@extends] |
     646              *[self::interface and @name=$iface/@extends] |
    782647            following-sibling::
    783               *[(self::interface or self::collection) and @name=$iface/@extends]
     648              *[self::interface and @name=$iface/@extends]
    784649          "/>
    785650        </xsl:call-template>
     
    800665
    801666<!-- attribute definitions -->
    802 <xsl:template match="interface//attribute | collection//attribute" mode="define">
    803 
    804   <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
     667<xsl:template match="interface//attribute" mode="define">
     668
     669  <xsl:param name="namespace" select="ancestor::interface[1]"/>
    805670
    806671  <xsl:apply-templates select="parent::node()" mode="begin"/>
     
    825690
    826691<!-- method definitions -->
    827 <xsl:template match="interface//method | collection//method" mode="define">
    828 
    829   <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
     692<xsl:template match="interface//method" mode="define">
     693
     694  <xsl:param name="namespace" select="ancestor::interface[1]"/>
    830695
    831696  <xsl:apply-templates select="parent::node()" mode="begin"/>
     
    869734 *      actual interface node for which this method is being defined
    870735 *      (necessary to properly set a class name for inherited methods).
    871  *      If not specified, will default to the parent interface/collection
     736 *      If not specified, will default to the parent interface
    872737 *      node of the method being defined.
    873738-->
     
    875740  <xsl:param name="return" select="param[@dir='return']"/>
    876741  <xsl:param name="define" select="''"/>
    877   <xsl:param name="namespace" select="(ancestor::interface | ancestor::collection)[1]"/>
     742  <xsl:param name="namespace" select="ancestor::interface[1]"/>
    878743  <xsl:choose>
    879744    <!-- no return value -->
     
    1111976 *  appropriate base class name that provides error info functionality
    1112977 *  (depending on the mode parameter). Does nothing if the current
    1113  *  entity (interface, collection or enumerator) does not support error info.
     978 *  interface does not support error info.
    1114979 *
    1115980 *  @param mode
     
    1120985  <xsl:param name="mode" select="''"/>
    1121986  <xsl:variable name="ifaceSupportsErrorInfo" select="
    1122     (ancestor-or-self::interface |
    1123      ancestor-or-self::collection |
    1124      ancestor-or-self::enumerator)[1]/@supportsErrorInfo
     987    ancestor-or-self::interface[1]/@supportsErrorInfo
    1125988  "/>
    1126989  <xsl:variable name="librarySupportsErrorInfo" select="ancestor::library/@supportsErrorInfo"/>
     
    11881051    </xsl:when>
    11891052    <!-- string types -->
    1190     <xsl:when test="@type = 'wstring'">
     1053    <xsl:when test="@type = 'wstring' or @type = 'uuid'">
    11911054      <xsl:choose>
    11921055        <xsl:when test="$isIn">
     
    11991062        <xsl:when test="$isOut">
    12001063          <xsl:text>BSTROut (a</xsl:text>
    1201           <xsl:call-template name="capitalize">
    1202             <xsl:with-param name="str" select="@name"/>
    1203           </xsl:call-template>
    1204           <xsl:text>)</xsl:text>
    1205         </xsl:when>
    1206       </xsl:choose>
    1207     </xsl:when>
    1208     <!-- uuid type -->
    1209     <xsl:when test="@type = 'uuid'">
    1210       <xsl:choose>
    1211         <xsl:when test="$isIn">
    1212           <xsl:text>GUIDIn (a</xsl:text>
    1213           <xsl:call-template name="capitalize">
    1214             <xsl:with-param name="str" select="@name"/>
    1215           </xsl:call-template>
    1216           <xsl:text>)</xsl:text>
    1217         </xsl:when>
    1218         <xsl:when test="$isOut">
    1219           <xsl:text>GUIDOut (a</xsl:text>
    12201064          <xsl:call-template name="capitalize">
    12211065            <xsl:with-param name="str" select="@name"/>
     
    12551099    <xsl:when test="
    12561100      @type='$unknown' or
    1257       ((ancestor::library/enumerator[@name=current()/@type]) or
    1258        (ancestor::library/if[@target=$self_target]/enumerator[@name=current()/@type])
    1259       ) or
    12601101      ((ancestor::library/interface[@name=current()/@type]) or
    12611102       (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
    1262       ) or
    1263       ((ancestor::library/collection[@name=current()/@type]) or
    1264        (ancestor::library/if[@target=$self_target]/collection[@name=current()/@type])
    12651103      )
    12661104    ">
     
    13281166 *  attribute/parameter type conversion (returns plain Qt type name)
    13291167-->
    1330 <xsl:template match="
    1331   attribute/@type | param/@type |
    1332   enumerator/@type | collection/@type | collection/@enumerator
    1333 ">
     1168<xsl:template match="attribute/@type | param/@type">
    13341169  <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    13351170
    1336   <xsl:if test="../@array and ../@safearray='yes'">
    1337     <xsl:message terminate="yes">
    1338       <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    1339       <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
    1340     </xsl:message>
    1341   </xsl:if>
    1342 
    1343   <xsl:if test="../@array and ((name(..)='param' and ../@dir='return') or (name(..)='attribute'))">
    1344     <xsl:message terminate="yes">
    1345       <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    1346       <xsl:text>return 'array' parameters and 'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
    1347     </xsl:message>
    1348   </xsl:if>
    1349 
    13501171  <xsl:choose>
    1351     <!-- modifiers (ignored for 'enumeration' attributes)-->
     1172    <!-- modifiers -->
    13521173    <xsl:when test="name(current())='type' and ../@mod">
    1353       <xsl:if test="../@safearray">
     1174      <xsl:if test="../@safearray and ../@mod='ptr'">
    13541175        <xsl:message terminate="yes">
    13551176          <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    13561177          <xsl:text>either 'safearray' or 'mod' attribute is allowed, but not both!</xsl:text>
    1357         </xsl:message>
    1358       </xsl:if>
    1359       <xsl:if test="../@array">
    1360         <xsl:message terminate="yes">
    1361           <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    1362           <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
    13631178        </xsl:message>
    13641179      </xsl:if>
     
    13761191            <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
    13771192            <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
    1378             <xsl:when test=".='char'">CHAR *</xsl:when>
    1379             <!--<xsl:when test=".='string'">??</xsl:when-->
    1380             <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
    1381             <!--<xsl:when test=".='wstring'">??</xsl:when-->
    13821193            <xsl:otherwise>
    13831194              <xsl:message terminate="yes">
     
    13901201            </xsl:otherwise>
    13911202          </xsl:choose>
     1203        </xsl:when>
     1204        <xsl:when test="../@mod='string'">
     1205          <xsl:if test="../@safearray">
     1206            <xsl:text>QVector &lt;</xsl:text>
     1207          </xsl:if>
     1208          <xsl:choose>
     1209            <!-- standard types -->
     1210            <!--xsl:when test=".='result'">??</xsl:when-->
     1211            <xsl:when test=".='uuid'">QString</xsl:when>
     1212            <xsl:otherwise>
     1213              <xsl:message terminate="yes">
     1214                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1215                <xsl:text>attribute 'mod=</xsl:text>
     1216                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     1217                <xsl:text>' cannot be used with type </xsl:text>
     1218                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     1219              </xsl:message>
     1220            </xsl:otherwise>
     1221          </xsl:choose>
     1222          <xsl:if test="../@safearray">
     1223            <xsl:text>&gt;</xsl:text>
     1224          </xsl:if>
    13921225        </xsl:when>
    13931226        <xsl:otherwise>
     
    14351268            <!-- custom interface types -->
    14361269            <xsl:when test="
    1437               (name(current())='enumerator' and
    1438                ((ancestor::library/enumerator[@name=current()]) or
    1439                 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
    1440               ) or
    14411270              ((ancestor::library/interface[@name=current()]) or
    14421271               (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    1443               ) or
    1444               ((ancestor::library/collection[@name=current()]) or
    1445                (ancestor::library/if[@target=$self_target]/collection[@name=current()])
    14461272              )
    14471273            ">
     
    14711297 *  types.
    14721298-->
    1473 <xsl:template match="
    1474   attribute/@type | param/@type |
    1475   enumerator/@type | collection/@type | collection/@enumerator
    1476 " mode="initializer">
     1299<xsl:template match="attribute/@type | param/@type" mode="initializer">
    14771300
    14781301  <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
     
    14821305    <xsl:when test="../@safearray">
    14831306    </xsl:when>
    1484     <!-- modifiers (ignored for 'enumeration' attributes)-->
     1307    <!-- modifiers -->
    14851308    <xsl:when test="name(current())='type' and ../@mod">
    14861309      <xsl:choose>
     
    14971320            <xsl:when test=".='unsigned long'"> = NULL</xsl:when>
    14981321            <xsl:when test=".='unsigned long long'"> = NULL</xsl:when>
    1499             <xsl:when test=".='char'"> = NULL</xsl:when>
    1500             <!--<xsl:when test=".='string'">??</xsl:when-->
    1501             <xsl:when test=".='wchar'"> = NULL</xsl:when>
    1502             <!--<xsl:when test=".='wstring'">??</xsl:when-->
     1322            <xsl:otherwise>
     1323              <xsl:message terminate="yes">
     1324                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1325                <xsl:text>attribute 'mod=</xsl:text>
     1326                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     1327                <xsl:text>' cannot be used with type </xsl:text>
     1328                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     1329              </xsl:message>
     1330            </xsl:otherwise>
     1331          </xsl:choose>
     1332        </xsl:when>
     1333        <xsl:when test="../@mod='string'">
     1334          <xsl:choose>
     1335            <!-- standard types -->
     1336            <!--xsl:when test=".='result'">??</xsl:when-->
     1337            <xsl:when test=".='uuid'"></xsl:when>
    15031338            <xsl:otherwise>
    15041339              <xsl:message terminate="yes">
     
    15711406      ) or
    15721407      .='$unknown' or
    1573       ((ancestor::library/enumerator[@name=current()]) or
    1574        (ancestor::library/if[@target=$self_target]/enumerator[@name=current()])
    1575       ) or
    15761408      ((ancestor::library/interface[@name=current()]) or
    15771409       (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    1578       ) or
    1579       ((ancestor::library/collection[@name=current()]) or
    1580        (ancestor::library/if[@target=$self_target]/collection[@name=current()])
    15811410      )
    15821411    ">
     
    16161445        <!-- <param> context -->
    16171446        <xsl:when test="name(..)='param'">
    1618           <xsl:choose>
    1619             <xsl:when test="../@array">
    1620               <xsl:apply-templates select="."/>
    1621               <xsl:text> *</xsl:text>
    1622               <xsl:if test="../@dir='out'">
    1623                 <xsl:text> &amp;</xsl:text>
    1624               </xsl:if>
    1625             </xsl:when>
    1626             <xsl:otherwise>
    1627               <xsl:apply-templates select="."/>
    1628               <xsl:if test="../@dir='out'">
    1629                 <xsl:text> &amp;</xsl:text>
    1630               </xsl:if>
    1631             </xsl:otherwise>
    1632           </xsl:choose>
     1447          <xsl:apply-templates select="."/>
     1448          <xsl:if test="../@dir='out'">
     1449            <xsl:text> &amp;</xsl:text>
     1450          </xsl:if>
    16331451        </xsl:when>
    16341452      </xsl:choose>
     
    16421460 *  (basically, copied from midl.xsl)
    16431461-->
    1644 <xsl:template match="
    1645   attribute/@type | param/@type |
    1646   enumerator/@type | collection/@type | collection/@enumerator
    1647 " mode="com">
     1462<xsl:template match="attribute/@type | param/@type" mode="com">
    16481463
    16491464  <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    16501465
    16511466  <xsl:choose>
    1652     <!-- modifiers (ignored for 'enumeration' attributes)-->
     1467    <!-- modifiers -->
    16531468    <xsl:when test="name(current())='type' and ../@mod">
    16541469      <xsl:choose>
     
    16651480            <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
    16661481            <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
    1667             <xsl:when test=".='char'">CHAR *</xsl:when>
    1668             <!--xsl:when test=".='string'">??</xsl:when-->
    1669             <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
    1670             <!--xsl:when test=".='wstring'">??</xsl:when-->
     1482            <xsl:otherwise>
     1483              <xsl:message terminate="yes">
     1484                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1485                <xsl:text>attribute 'mod=</xsl:text>
     1486                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     1487                <xsl:text>' cannot be used with type </xsl:text>
     1488                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     1489              </xsl:message>
     1490            </xsl:otherwise>
     1491          </xsl:choose>
     1492        </xsl:when>
     1493        <xsl:when test="../@mod='string'">
     1494          <xsl:choose>
     1495            <!-- standard types -->
     1496            <!--xsl:when test=".='result'">??</xsl:when-->
     1497            <xsl:when test=".='uuid'">BSTR</xsl:when>
    16711498            <xsl:otherwise>
    16721499              <xsl:message terminate="yes">
     
    17211548            <!-- custom interface types -->
    17221549            <xsl:when test="
    1723               (name(current())='enumerator' and
    1724                ((ancestor::library/enumerator[@name=current()]) or
    1725                 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
    1726               ) or
    17271550              ((ancestor::library/interface[@name=current()]) or
    17281551               (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    1729               ) or
    1730               ((ancestor::library/collection[@name=current()]) or
    1731                (ancestor::library/if[@target=$self_target]/collection[@name=current()])
    17321552              )
    17331553            ">
     
    17681588
    17691589  <xsl:variable name="is_iface" select="(
    1770     ((ancestor::library/enumerator[@name=current()/@type]) or
    1771      (ancestor::library/if[@target=$self_target]/enumerator[@name=current()/@type])
    1772     ) or
    17731590    ((ancestor::library/interface[@name=current()/@type]) or
    17741591     (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
    1775     ) or
    1776     ((ancestor::library/collection[@name=current()/@type]) or
    1777      (ancestor::library/if[@target=$self_target]/collection[@name=current()/@type])
    17781592    )
    17791593  )"/>
     
    18061620            </xsl:when>
    18071621            <!-- GUID is special too -->
    1808             <xsl:when test="@type='uuid'">
     1622            <xsl:when test="@type='uuid' and @mod!='string'">
    18091623              <xsl:text>    com::SafeGUIDArray </xsl:text>
    18101624            </xsl:when>
  • trunk/src/VBox/Frontends/VirtualBox/include/QILabelSeparator.h

    r14398 r23223  
    2424#define __QILabelSeparator_h__
    2525
    26 /* Qt includes */
     26/* Global includes */
    2727#include <QWidget>
    2828
     29/* Global forwards */
    2930class QLabel;
    3031
     
    3536public:
    3637
    37     QILabelSeparator (QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0);
    38     QILabelSeparator (const QString &aText, QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0);
     38    QILabelSeparator (QWidget *aParent = 0, Qt::WindowFlags aFlags = 0);
     39    QILabelSeparator (const QString &aText, QWidget *aParent = 0, Qt::WindowFlags aFlags = 0);
    3940
     41    QString text() const;
    4042    void setBuddy (QWidget *aBuddy);
    4143
     
    4446    void clear();
    4547    void setText (const QString &aText);
    46     QString text() const;
    4748
    4849protected:
     
    5051    virtual void init();
    5152
    52     /* Protected member vars */
    5353    QLabel *mLabel;
    5454};
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r22834 r23223  
    155155    void machineStateChanged (KMachineState state);
    156156    void additionsStateChanged (const QString &, bool, bool, bool);
    157     void mediaDriveChanged (VBoxDefs::MediaType aType);
     157    void mediaDriveChanged (VBoxDefs::MediumType aType);
    158158    void networkStateChange();
    159159    void usbStateChange();
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r23142 r23223  
    240240    void updateNetworkAdaptersState();
    241241    void updateUsbState();
    242     void updateMediaDriveState (VBoxDefs::MediaType aType);
     242    void updateMediaDriveState (VBoxDefs::MediumType aType);
    243243    void updateSharedFoldersState();
    244244
     
    358358    bool no_auto_close : 1;
    359359
    360     QMap <QAction *, CHostDVDDrive> hostDVDMap;
    361     QMap <QAction *, CHostFloppyDrive> hostFloppyMap;
     360    QMap <QAction *, CMedium> hostDVDMap;
     361    QMap <QAction *, CMedium> hostFloppyMap;
    362362
    363363    QRect mNormalGeo;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r22816 r23223  
    6969struct VBoxDefs
    7070{
    71     /** Media type. */
    72     enum MediaType
     71    /** Medium type. */
     72    enum MediumType
    7373    {
    74         MediaType_Invalid,
    75         MediaType_HardDisk,
    76         MediaType_DVD,
    77         MediaType_Floppy,
    78         MediaType_All
     74        MediumType_Invalid,
     75        MediumType_HardDisk,
     76        MediumType_DVD,
     77        MediumType_Floppy,
     78        MediumType_All
    7979    };
    8080
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r22816 r23223  
    245245};
    246246
     247struct StorageSlot
     248{
     249    StorageSlot() : bus (KStorageBus_Null), port (0), device (0) {}
     250    StorageSlot (const StorageSlot &aOther) : bus (aOther.bus), port (aOther.port), device (aOther.device) {}
     251    StorageSlot (KStorageBus aBus, LONG aPort, LONG aDevice) : bus (aBus), port (aPort), device (aDevice) {}
     252    StorageSlot& operator= (const StorageSlot &aOther) { bus = aOther.bus; port = aOther.port; device = aOther.device; return *this; }
     253    bool operator== (const StorageSlot &aOther) const { return bus == aOther.bus && port == aOther.port && device == aOther.device; }
     254    bool operator!= (const StorageSlot &aOther) const { return bus != aOther.bus || port != aOther.port || device != aOther.device; }
     255    bool isNull() { return bus == KStorageBus_Null; }
     256    KStorageBus bus; LONG port; LONG device;
     257};
     258Q_DECLARE_METATYPE (StorageSlot);
     259
    247260// VBoxGlobal class
    248261////////////////////////////////////////////////////////////////////////////////
     
    383396            case KStorageControllerType_LsiLogic:
    384397            case KStorageControllerType_BusLogic: sb = KStorageBus_SCSI; break;
     398            case KStorageControllerType_I82078: sb = KStorageBus_Floppy; break;
    385399            default:
    386400              AssertMsgFailed (("toStorageBusType: %d not handled\n", aControllerType)); break;
     
    395409    LONG toStorageDevice (KStorageBus aBus, LONG aChannel, const QString &aDevice) const;
    396410
    397     QString toFullString (KStorageBus aBus, LONG aChannel, LONG aDevice) const;
    398 
    399     QString toString (KHardDiskType t) const
     411    QString toFullString (StorageSlot aSlot) const;
     412    StorageSlot toStorageSlot (const QString &aSlot) const;
     413
     414    QString toString (KMediumType t) const
    400415    {
    401416        AssertMsg (!mDiskTypes.value (t).isNull(), ("No text for %d", t));
     
    404419
    405420    /**
    406      * Similar to toString (KHardDiskType), but returns 'Differencing' for
     421     * Similar to toString (KMediumType), but returns 'Differencing' for
    407422     * normal hard disks that have a parent.
    408423     */
    409     QString hardDiskTypeString (const CHardDisk &aHD) const
     424    QString mediumTypeString (const CMedium &aHD) const
    410425    {
    411426        if (!aHD.GetParent().isNull())
    412427        {
    413             Assert (aHD.GetType() == KHardDiskType_Normal);
     428            Assert (aHD.GetType() == KMediumType_Normal);
    414429            return mDiskTypes_Differencing;
    415430        }
     
    456471    }
    457472
    458     KStorageControllerType toIDEControllerType (const QString &s) const
     473    KStorageControllerType toControllerType (const QString &s) const
    459474    {
    460475        QULongStringHash::const_iterator it =
     
    593608    /* details generators */
    594609
    595     QString details (const CHardDisk &aHD, bool aPredictDiff);
     610    QString details (const CMedium &aHD, bool aPredictDiff);
    596611
    597612    QString details (const CUSBDevice &aDevice) const;
     
    635650    void addMedium (const VBoxMedium &);
    636651    void updateMedium (const VBoxMedium &);
    637     void removeMedium (VBoxDefs::MediaType, const QString &);
     652    void removeMedium (VBoxDefs::MediumType, const QString &);
    638653
    639654    bool findMedium (const CMedium &, VBoxMedium &) const;
     655    VBoxMedium findMedium (const QString &aMediumId) const;
    640656
    641657    /** Compact version of #findMediumTo(). Asserts if not found. */
     
    674690    QString helpFile() const;
    675691
     692    static QIcon iconSet (const QPixmap &aNormal,
     693                          const QPixmap &aDisabled = QPixmap(),
     694                          const QPixmap &aActive = QPixmap());
    676695    static QIcon iconSet (const char *aNormal,
    677696                          const char *aDisabled = NULL,
     
    787806
    788807    /** Emitted when the media is removed using #removeMedia(). */
    789     void mediumRemoved (VBoxDefs::MediaType, const QString &);
     808    void mediumRemoved (VBoxDefs::MediumType, const QString &);
    790809
    791810    /* signals emitted when the VirtualBox callback is called by the server
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxMediaComboBox.h

    r19239 r23223  
    4646
    4747    void setCurrentItem (const QString &aItemId);
    48     void setType (VBoxDefs::MediaType aMediaType);
     48    void setType (VBoxDefs::MediumType aMediumType);
    4949    void setMachineId (const QString &aMachineId = QString::null);
     50    void setNullItemPresent (bool aNullItemPresent);
    5051
    5152    void setShowDiffs (bool aShowDiffs);
     
    5960    void mediumAdded (const VBoxMedium &);
    6061    void mediumUpdated (const VBoxMedium &);
    61     void mediumRemoved (VBoxDefs::MediaType, const QString &);
     62    void mediumRemoved (VBoxDefs::MediumType, const QString &);
    6263
    6364    void processActivated (int aIndex);
     
    7778    bool findMediaIndex (const QString &aId, int &aIndex);
    7879
    79     VBoxDefs::MediaType mType;
     80    VBoxDefs::MediumType mType;
    8081
    8182    /** Obtruncated VBoxMedium structure. */
     
    9899
    99100    bool mShowDiffs : 1;
     101    bool mNullItemPresent : 1;
    100102
    101103    QString mMachineId;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxMediaManagerDlg.h

    r22999 r23223  
    5050    ~VBoxMediaManagerDlg();
    5151
    52     void setup (VBoxDefs::MediaType aType, bool aDoSelect,
     52    void setup (VBoxDefs::MediumType aType, bool aDoSelect,
    5353                bool aRefresh = true,
    5454                const CMachine &aSessionMachine = CMachine(),
     
    7878    void mediumAdded (const VBoxMedium &aMedium);
    7979    void mediumUpdated (const VBoxMedium &aMedium);
    80     void mediumRemoved (VBoxDefs::MediaType aType, const QString &aId);
     80    void mediumRemoved (VBoxDefs::MediumType aType, const QString &aId);
    8181
    8282    void mediumEnumStarted();
     
    103103private:
    104104
    105     QTreeWidget* treeWidget (VBoxDefs::MediaType aType) const;
    106     VBoxDefs::MediaType currentTreeWidgetType() const;
     105    QTreeWidget* treeWidget (VBoxDefs::MediumType aType) const;
     106    VBoxDefs::MediumType currentTreeWidgetType() const;
    107107    QTreeWidget* currentTreeWidget() const;
    108108
     
    112112    void setCurrentItem (QTreeWidget *aTree, QTreeWidgetItem *aItem);
    113113
    114     void addMediumToList (const QString &aLocation, VBoxDefs::MediaType aType);
     114    void addMediumToList (const QString &aLocation, VBoxDefs::MediumType aType);
    115115
    116116    MediaItem* createHardDiskItem (QTreeWidget *aTree, const VBoxMedium &aMedium) const;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxMedium.h

    r19239 r23223  
    2424#define __VBoxMedium_h__
    2525
    26 #include "COMDefs.h"
    27 
    28 /* Qt includes */
     26/* Global includes */
    2927#include <QPixmap>
    3028#include <QLinkedList>
     29
     30/* Local includes */
     31#include "COMDefs.h"
    3132
    3233/**
     
    4546 * the medium itself.
    4647 *
    47  * Note that this class "abuses" the KMediaState_NotCreated state value to
     48 * Note that this class "abuses" the KMediumState_NotCreated state value to
    4849 * indicate that the accessibility check of the given medium (see
    4950 * #blockAndQueryState()) has not been done yet and therefore some parameters
    5051 * such as #size() are meaningless because they can be read only from the
    51  * accessible medium. The real KMediaState_NotCreated state is not necessary
     52 * accessible medium. The real KMediumState_NotCreated state is not necessary
    5253 * because this class is only used with created (existing) media.
    5354 */
     
    5859    /**
    5960     * Creates a null medium descriptor which is not associated with any medium.
    60      * The state field is set to KMediaState_NotCreated.
     61     * The state field is set to KMediumState_NotCreated.
    6162     */
    6263    VBoxMedium()
    63         : mType (VBoxDefs::MediaType_Invalid)
    64         , mState (KMediaState_NotCreated)
    65         , mIsReadOnly (false), mIsUsedInSnapshots (false)
    66         , mParent (NULL) {}
     64        : mType (VBoxDefs::MediumType_Invalid)
     65        , mState (KMediumState_NotCreated)
     66        , mIsReadOnly (false)
     67        , mIsUsedInSnapshots (false)
     68        , mParent (0) { refresh(); }
    6769
    6870    /**
    6971     * Creates a media descriptor associated with the given medium.
    7072     *
    71      * The state field remain KMediaState_NotCreated until #blockAndQueryState()
     73     * The state field remain KMediumState_NotCreated until #blockAndQueryState()
    7274     * is called. All precomposed strings are filled up by implicitly calling
    7375     * #refresh(), see the #refresh() details for more info.
     
    7779     * disk media.
    7880     */
    79     VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType,
    80                 VBoxMedium *aParent = NULL)
    81         : mMedium (aMedium), mType (aType)
    82         , mState (KMediaState_NotCreated)
    83         , mIsReadOnly (false), mIsUsedInSnapshots (false)
    84         , mParent (aParent) { init(); }
     81    VBoxMedium (const CMedium &aMedium, VBoxDefs::MediumType aType, VBoxMedium *aParent = 0)
     82        : mMedium (aMedium)
     83        , mType (aType)
     84        , mState (KMediumState_NotCreated)
     85        , mIsReadOnly (false)
     86        , mIsUsedInSnapshots (false)
     87        , mParent (aParent) { refresh(); }
    8588
    8689    /**
     
    8992     * creation.
    9093     */
    91     VBoxMedium (const CMedium &aMedium, VBoxDefs::MediaType aType,
    92                 KMediaState aState)
    93         : mMedium (aMedium), mType (aType)
     94    VBoxMedium (const CMedium &aMedium, VBoxDefs::MediumType aType, KMediumState aState)
     95        : mMedium (aMedium)
     96        , mType (aType)
    9497        , mState (aState)
    95         , mIsReadOnly (false), mIsUsedInSnapshots (false)
    96         , mParent (NULL) { init(); }
     98        , mIsReadOnly (false)
     99        , mIsUsedInSnapshots (false)
     100        , mParent (0) { refresh(); }
    97101
    98102    void blockAndQueryState();
    99103    void refresh();
    100104
    101     const CMedium &medium() const { return mMedium; };
    102 
    103     VBoxDefs::MediaType type() const { return mType; }
     105    const CMedium &medium() const { return mMedium; }
     106
     107    VBoxDefs::MediumType type() const { return mType; }
    104108
    105109    /**
     
    109113     * @param aNoDiffs  @c true to enable user-friendly "don't show diffs" mode.
    110114     */
    111     KMediaState state (bool aNoDiffs = false) const
     115    KMediumState state (bool aNoDiffs = false) const
    112116    {
    113117        unconst (this)->checkNoDiffs (aNoDiffs);
     
    131135    }
    132136
    133     const CHardDisk &hardDisk() const { return mHardDisk; }
    134     const CDVDImage &dvdImage() const { return mDVDImage; }
    135     const CFloppyImage &floppyImage() const { return mFloppyImage; }
    136 
    137137    QString id() const { return mId; }
    138 
    139     QString location (bool aNoDiffs = false) const
    140         { return aNoDiffs ? root().mLocation : mLocation; }
    141     QString name (bool aNoDiffs = false) const
    142         { return aNoDiffs ? root().mName : mName; }
    143 
    144     QString size (bool aNoDiffs = false) const
    145         { return aNoDiffs ? root().mSize : mSize; }
    146 
    147     QString hardDiskFormat (bool aNoDiffs = false) const
    148         { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; }
    149     QString hardDiskType (bool aNoDiffs = false) const
    150         { return aNoDiffs ? root().mHardDiskType : mHardDiskType; }
    151     QString logicalSize (bool aNoDiffs = false) const
    152         { return aNoDiffs ? root().mLogicalSize : mLogicalSize; }
    153 
    154     QString usage (bool aNoDiffs = false) const
    155     { return aNoDiffs ? root().mUsage : mUsage; }
     138    QString name (bool aNoDiffs = false) const { return aNoDiffs ? root().mName : mName; }
     139    QString location (bool aNoDiffs = false) const { return aNoDiffs ? root().mLocation : mLocation; }
     140    QString size (bool aNoDiffs = false) const { return aNoDiffs ? root().mSize : mSize; }
     141    QString logicalSize (bool aNoDiffs = false) const { return aNoDiffs ? root().mLogicalSize : mLogicalSize; }
     142    QString hardDiskFormat (bool aNoDiffs = false) const { return aNoDiffs ? root().mHardDiskFormat : mHardDiskFormat; }
     143    QString hardDiskType (bool aNoDiffs = false) const { return aNoDiffs ? root().mHardDiskType : mHardDiskType; }
     144    QString usage (bool aNoDiffs = false) const { return aNoDiffs ? root().mUsage : mUsage; }
    156145
    157146    /**
     
    171160    /**
    172161     * Returns @c true if this medium is attached to any VM in any snapshot.
    173      * which case #usage() will contain a string with comma-sparated VM names.
    174162     */
    175163    bool isUsedInSnapshots() const { return mIsUsedInSnapshots; }
    176164
    177165    /**
    178      * Returns @c true if this medium is attached to the given machine in the
    179      * current state.
    180      */
    181     bool isAttachedInCurStateTo (const QString &aMachineId) const
    182         { return mCurStateMachineIds.indexOf (aMachineId) >= 0; }
     166     * Returns @c true if this medium corresponds to real host drive.
     167     */
     168    bool isHostDrive() const { return mIsHostDrive; }
     169
     170    /**
     171     * Returns @c true if this medium is attached to the given machine in the current state.
     172     */
     173    bool isAttachedInCurStateTo (const QString &aMachineId) const { return mCurStateMachineIds.indexOf (aMachineId) >= 0; }
    183174
    184175    /**
     
    186177     * to in their current state (i.e. excluding snapshots).
    187178     */
    188     const QList <QString> &curStateMachineIds() const
    189         { return mCurStateMachineIds; }
     179    const QList <QString> &curStateMachineIds() const { return mCurStateMachineIds; }
    190180
    191181    /**
     
    196186    VBoxMedium &root() const;
    197187
    198     QString toolTip(bool aNoDiffs = false, bool aCheckRO = false) const;
     188    QString toolTip (bool aNoDiffs = false, bool aCheckRO = false) const;
    199189    QPixmap icon (bool aNoDiffs = false, bool aCheckRO = false) const;
    200190
    201191    /** Shortcut to <tt>#toolTip (aNoDiffs, true)</tt>. */
    202     QString toolTipCheckRO (bool aNoDiffs = false) const
    203         { return toolTip (aNoDiffs, true); }
     192    QString toolTipCheckRO (bool aNoDiffs = false) const { return toolTip (aNoDiffs, true); }
    204193
    205194    /** Shortcut to <tt>#icon (aNoDiffs, true)</tt>. */
    206     QPixmap iconCheckRO (bool aNoDiffs = false) const
    207         { return icon (aNoDiffs, true); }
    208 
    209     QString details (bool aNoDiffs = false, bool aPredictDiff = false,
    210                      bool aUseHTML = false) const;
     195    QPixmap iconCheckRO (bool aNoDiffs = false) const { return icon (aNoDiffs, true); }
     196
     197    QString details (bool aNoDiffs = false, bool aPredictDiff = false, bool aUseHTML = false) const;
    211198
    212199    /** Shortcut to <tt>#details (aNoDiffs, aPredictDiff, true)</tt>. */
    213     QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const
    214         { return details (aNoDiffs, aPredictDiff, true); }
     200    QString detailsHTML (bool aNoDiffs = false, bool aPredictDiff = false) const { return details (aNoDiffs, aPredictDiff, true); }
    215201
    216202    /** Returns @c true if this media descriptor is a null object. */
     
    219205private:
    220206
    221     void init();
    222 
    223207    void checkNoDiffs (bool aNoDiffs);
    224208
    225209    CMedium mMedium;
    226210
    227     VBoxDefs::MediaType mType;
    228 
    229     KMediaState mState;
     211    VBoxDefs::MediumType mType;
     212
     213    KMediumState mState;
    230214    QString mLastAccessError;
    231215    COMResult mResult;
    232 
    233     CHardDisk mHardDisk;
    234     CDVDImage mDVDImage;
    235     CFloppyImage mFloppyImage;
    236216
    237217    QString mId;
     
    249229    bool mIsReadOnly        : 1;
    250230    bool mIsUsedInSnapshots : 1;
     231    bool mIsHostDrive       : 1;
    251232
    252233    QList <QString> mCurStateMachineIds;
     
    260241    struct NoDiffs
    261242    {
    262         NoDiffs() : isSet (false), state (KMediaState_NotCreated) {}
     243        NoDiffs() : isSet (false), state (KMediumState_NotCreated) {}
    263244
    264245        bool isSet : 1;
    265246
    266         KMediaState state;
     247        KMediumState state;
    267248        COMResult result;
    268249        QString toolTip;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxNewHDWzd.h

    r16867 r23223  
    3939    VBoxNewHDWzd (QWidget *aParent = 0);
    4040
    41     CHardDisk hardDisk() { return mHD; }
     41    CMedium hardDisk() { return mHD; }
    4242    void setRecommendedFileName (const QString &aName);
    4343    void setRecommendedSize (quint64 aSize);
     
    6666
    6767    QIWidgetValidator *mWValNameAndSize;
    68     CHardDisk          mHD;
     68    CMedium            mHD;
    6969    int                mSliderScale;
    7070    quint64            mMaxVDISize;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxNewVMWzd.h

    r18080 r23223  
    6969    QIWidgetValidator *mWvalMemory;
    7070    QIWidgetValidator *mWvalHDD;
    71     CHardDisk mHardDisk;
     71    CMedium mHardDisk;
    7272    CMachine mMachine;
    7373};
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r22434 r23223  
    239239    int confirmDeleteHardDiskStorage (QWidget *aParent,
    240240                                      const QString &aLocation);
    241     void cannotDeleteHardDiskStorage (QWidget *aParent, const CHardDisk &aHD,
     241    void cannotDeleteHardDiskStorage (QWidget *aParent, const CMedium &aHD,
    242242                                      const CProgress &aProgress);
    243243
    244244    int confirmDetachAddControllerSlots (QWidget *aParent) const;
    245245    int confirmChangeAddControllerSlots (QWidget *aParent) const;
    246     int confirmRunNewHDWzdOrVDM (QWidget* aParent);
     246    int confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType);
    247247
    248248    void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
    249249                                      const QString &aLocaiton,
    250                                       const CHardDisk &aHD,
     250                                      const CMedium &aHD,
    251251                                      const CProgress &aProgress);
    252252    void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine,
     
    262262                            const VBoxMedium &aMedium, const COMResult &aResult);
    263263    void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
    264                            VBoxDefs::MediaType aType, const QString &aLocation);
     264                           VBoxDefs::MediumType aType, const QString &aLocation);
    265265    void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
    266266                            const COMResult &aResult);
     
    358358                           const QString &errorMsg) const;
    359359
    360     static QString toAccusative (VBoxDefs::MediaType aType);
     360    static QString toAccusative (VBoxDefs::MediumType aType);
    361361
    362362    static QString formatRC (HRESULT aRC);
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxToolBar.h

    r20052 r23223  
    2626#include <QGlobalStatic> /* for Q_WS_MAC */
    2727#ifdef Q_WS_MAC
    28 # include "VBoxUtils.h"
     28#include "VBoxUtils.h"
    2929#endif
    3030
     
    4949    VBoxToolBar (QWidget *aParent)
    5050        : QToolBar (aParent)
    51         , mMainWindow (qobject_cast<QMainWindow*> (aParent))
     51        , mMainWindow (qobject_cast <QMainWindow*> (aParent))
    5252    {
    5353        setFloatable (false);
    5454        setMovable (false);
     55
     56        /* Remove that ugly frame panel around the toolbar.
     57         * Doing that currently for Cleanlooks & Windows styles. */
     58        if (qobject_cast <QCleanlooksStyle*> (QToolBar::style()) ||
     59            qobject_cast <QWindowsStyle*> (QToolBar::style()))
     60            setStyleSheet ("QToolBar { border: 0px none black; }");
     61
    5562        if (layout())
    5663            layout()->setContentsMargins (0, 0, 0, 0);;
    5764
    5865        setContextMenuPolicy (Qt::NoContextMenu);
    59 
    60         /* Remove that ugly frame panel around the toolbar. */
    61         /* I'm not sure if we should do this generally on linux for that mass
    62          * of KDE styles. But maybe some of them are based on CleanLooks so
    63          * they are looking ok also. */
    64         QStyle *style = NULL;
    65         if (!style)
    66             /* Check for cleanlooks style */
    67             style = qobject_cast<QCleanlooksStyle*> (QToolBar::style());
    68         if (!style)
    69             /* Check for windows style */
    70             style = qobject_cast<QWindowsStyle*> (QToolBar::style());
    71         if (style)
    72             setStyleSheet ("QToolBar { border: 0px none black; }");
    7366    }
    7467
    75     void setMacToolbar ()
     68#ifdef Q_WS_MAC
     69    void setMacToolbar()
    7670    {
    77 #ifdef Q_WS_MAC
    7871        if (mMainWindow)
    7972        {
    8073            mMainWindow->setUnifiedTitleAndToolBarOnMac (true);
    81 # ifndef QT_MAC_USE_COCOA
     74#ifndef QT_MAC_USE_COCOA
    8275            WindowRef window = ::darwinToNativeWindow (this);
    8376            EventHandlerUPP eventHandler = ::NewEventHandlerUPP (VBoxToolBar::macEventFilter);
     
    9083                                       RT_ELEMENTS (eventTypes), eventTypes,
    9184                                       NULL, NULL);
    92 # endif /* !QT_MAC_USE_COCOA */
     85#endif /* !QT_MAC_USE_COCOA */
    9386        }
    94 #endif /* Q_WS_MAC */
    9587    }
    9688
    97 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
     89#ifndef QT_MAC_USE_COCOA
    9890    static pascal OSStatus macEventFilter (EventHandlerCallRef aNextHandler,
    9991                                           EventRef aEvent, void * /* aUserData */)
     
    117109        return CallNextEventHandler (aNextHandler, aEvent);
    118110    }
    119 #endif /* Q_WS_MAC && !QT_MAC_USE_COCOA */
     111#endif /* !QT_MAC_USE_COCOA */
    120112
    121113    void setShowToolBarButton (bool aShow)
    122114    {
    123 #ifdef Q_WS_MAC
    124115        ::darwinSetShowsToolbarButton (this, aShow);
    125 #else  /* Q_WS_MAC */
    126         Q_UNUSED (aShow);
    127 #endif /* !Q_WS_MAC */
    128116    }
     117#endif /* Q_WS_MAC */
    129118
    130     void setUsesTextLabel (bool enable)
     119    void setUsesTextLabel (bool aEnable)
    131120    {
    132121        Qt::ToolButtonStyle tbs = Qt::ToolButtonTextUnderIcon;
    133         if (!enable)
     122        if (!aEnable)
    134123            tbs = Qt::ToolButtonIconOnly;
    135124
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMFirstRunWzd.h

    r13580 r23223  
    5757    QIWidgetValidator         *mWvalType;
    5858    CMachine                   mMachine;
    59     QVector <CHostDVDDrive>    mHostDVDs;
    60     QVector <CHostFloppyDrive> mHostFloppys;
     59    QVector <CMedium>          mHostDVDs;
     60    QVector <CMedium>          mHostFloppys;
    6161};
    6262
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMSettingsHD.h

    r19837 r23223  
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#define __VBoxVMSettingsHD_h__
    2525
     26/* Global includes */
     27#include <QItemDelegate>
     28#include <QPointer>
     29
     30/* Local includes */
    2631#include "VBoxSettingsPage.h"
    2732#include "VBoxVMSettingsHD.gen.h"
    2833#include "COMDefs.h"
    29 #include "VBoxMediaComboBox.h"
    30 
    31 /* Qt includes */
    32 #include <QComboBox>
    33 
    34 /** Register type to store slot data */
    35 class SlotValue
    36 {
    37 public:
    38     SlotValue()
    39         : bus (KStorageBus_Null), channel (0), device (0)
    40         , name (QString::null) {}
    41     SlotValue (KStorageBus aBus, LONG aChannel, LONG aDevice)
    42         : bus (aBus), channel (aChannel), device (aDevice)
    43         , name (vboxGlobal().toFullString (aBus, aChannel, aDevice)) {}
    44     SlotValue (const SlotValue &aOther)
    45         : bus (aOther.bus), channel (aOther.channel), device (aOther.device)
    46         , name (aOther.name) {}
    47 
    48     SlotValue& operator= (const SlotValue &aOther)
     34
     35/* Local forwardes */
     36class AttachmentItem;
     37class ControllerItem;
     38
     39/* Internal Types */
     40typedef QList <StorageSlot> SlotsList;
     41typedef QList <KDeviceType> DeviceTypeList;
     42typedef QList <KStorageControllerType> ControllerTypeList;
     43Q_DECLARE_METATYPE (SlotsList);
     44Q_DECLARE_METATYPE (DeviceTypeList);
     45Q_DECLARE_METATYPE (ControllerTypeList);
     46
     47/* Pixmap Storage Pool */
     48class PixmapPool : public QObject
     49{
     50    Q_OBJECT;
     51
     52public:
     53
     54    enum PixmapType
    4955    {
    50         bus     = aOther.bus;
    51         channel = aOther.channel;
    52         device  = aOther.device;
    53         name    = aOther.name;
    54         return *this;
    55     }
    56 
    57     bool operator== (const SlotValue &aOther)
     56        InvalidPixmap     = -1,
     57
     58        AddControllerEn   =  0,
     59        AddControllerDis  =  1,
     60        DelControllerEn   =  2,
     61        DelControllerDis  =  3,
     62
     63        AddAttachmentEn   =  4,
     64        AddAttachmentDis  =  5,
     65        DelAttachmentEn   =  6,
     66        DelAttachmentDis  =  7,
     67
     68        IDEController     =  8,
     69        SATAController    =  9,
     70        SCSIController    = 10,
     71        FloppyController  = 11,
     72
     73        HDAttachmentEn    = 12,
     74        HDAttachmentDis   = 13,
     75        CDAttachmentEn    = 14,
     76        CDAttachmentDis   = 15,
     77        FDAttachmentEn    = 16,
     78        FDAttachmentDis   = 17,
     79
     80        PlusEn            = 18,
     81        PlusDis           = 19,
     82        MinusEn           = 20,
     83        MinusDis          = 21,
     84
     85        UnknownEn         = 22,
     86
     87        VMMEn             = 23,
     88        VMMDis            = 24,
     89
     90        MaxIndex
     91    };
     92
     93    static PixmapPool* pool (QObject *aParent = 0);
     94
     95    QPixmap pixmap (PixmapType aType) const;
     96
     97protected:
     98
     99    PixmapPool (QObject *aParent);
     100
     101    static QPointer <PixmapPool> mThis;
     102
     103private:
     104
     105    QVector <QPixmap> mPool;
     106};
     107
     108/* Abstract Controller Type */
     109class AbstractControllerType
     110{
     111public:
     112
     113    AbstractControllerType (KStorageBus aBusType, KStorageControllerType aCtrType);
     114    virtual ~AbstractControllerType() {}
     115
     116    KStorageBus busType() const;
     117    KStorageControllerType ctrType() const;
     118    ControllerTypeList ctrTypes() const;
     119    PixmapPool::PixmapType pixmap() const;
     120
     121    void setCtrType (KStorageControllerType aCtrType);
     122
     123    virtual DeviceTypeList deviceTypeList() const = 0;
     124
     125protected:
     126
     127    virtual KStorageControllerType first() const = 0;
     128    virtual uint size() const = 0;
     129
     130    KStorageBus mBusType;
     131    KStorageControllerType mCtrType;
     132    PixmapPool::PixmapType mPixmap;
     133};
     134
     135/* IDE Controller Type */
     136class IDEControllerType : public AbstractControllerType
     137{
     138public:
     139
     140    IDEControllerType (KStorageControllerType aSubType);
     141
     142private:
     143
     144    DeviceTypeList deviceTypeList() const;
     145
     146    KStorageControllerType first() const;
     147    uint size() const;
     148};
     149
     150/* SATA Controller Type */
     151class SATAControllerType : public AbstractControllerType
     152{
     153public:
     154
     155    SATAControllerType (KStorageControllerType aSubType);
     156
     157private:
     158
     159    DeviceTypeList deviceTypeList() const;
     160
     161    KStorageControllerType first() const;
     162    uint size() const;
     163};
     164
     165/* SCSI Controller Type */
     166class SCSIControllerType : public AbstractControllerType
     167{
     168public:
     169
     170    SCSIControllerType (KStorageControllerType aSubType);
     171
     172private:
     173
     174    DeviceTypeList deviceTypeList() const;
     175
     176    KStorageControllerType first() const;
     177    uint size() const;
     178};
     179
     180/* Floppy Controller Type */
     181class FloppyControllerType : public AbstractControllerType
     182{
     183public:
     184
     185    FloppyControllerType (KStorageControllerType aSubType);
     186
     187private:
     188
     189    DeviceTypeList deviceTypeList() const;
     190
     191    KStorageControllerType first() const;
     192    uint size() const;
     193};
     194
     195/* Abstract Item */
     196class AbstractItem
     197{
     198public:
     199
     200    enum ItemType
    58201    {
    59         return bus     == aOther.bus &&
    60                channel == aOther.channel &&
    61                device  == aOther.device;
    62     }
    63 
    64     bool operator!= (const SlotValue &aOther)
     202        Type_InvalidItem    = 0,
     203        Type_RootItem       = 1,
     204        Type_ControllerItem = 2,
     205        Type_AttachmentItem = 3
     206    };
     207
     208    AbstractItem (AbstractItem *aParent = 0);
     209    virtual ~AbstractItem();
     210
     211    AbstractItem* parent();
     212    QUuid id();
     213
     214    virtual ItemType rtti() const = 0;
     215    virtual AbstractItem* childByPos (int aIndex) = 0;
     216    virtual AbstractItem* childById (const QUuid &aId) = 0;
     217    virtual int posOfChild (AbstractItem *aItem) const = 0;
     218    virtual int childCount() const = 0;
     219    virtual QString text() const = 0;
     220    virtual QString tip() const = 0;
     221    virtual QPixmap pixmap() = 0;
     222
     223protected:
     224
     225    virtual void addChild (AbstractItem *aItem) = 0;
     226    virtual void delChild (AbstractItem *aItem) = 0;
     227
     228    AbstractItem *mParent;
     229    QUuid         mId;
     230};
     231Q_DECLARE_METATYPE (AbstractItem::ItemType);
     232
     233/* Root Item */
     234class RootItem : public AbstractItem
     235{
     236public:
     237
     238    RootItem();
     239   ~RootItem();
     240
     241    ItemType rtti() const;
     242    AbstractItem* childByPos (int aIndex);
     243    AbstractItem* childById (const QUuid &aId);
     244    int posOfChild (AbstractItem *aItem) const;
     245    int childCount() const;
     246    QString text() const;
     247    QString tip() const;
     248    QPixmap pixmap();
     249
     250private:
     251
     252    void addChild (AbstractItem *aItem);
     253    void delChild (AbstractItem *aItem);
     254
     255    QList <AbstractItem*> mControllers;
     256};
     257
     258/* Controller Item */
     259class ControllerItem : public AbstractItem
     260{
     261public:
     262
     263    ControllerItem (AbstractItem *aParent, const QString &aName, KStorageBus aBusType,
     264                    KStorageControllerType aControllerType);
     265   ~ControllerItem();
     266
     267    ItemType rtti() const;
     268    AbstractItem* childByPos (int aIndex);
     269    AbstractItem* childById (const QUuid &aId);
     270    int posOfChild (AbstractItem *aItem) const;
     271    int childCount() const;
     272    QString text() const;
     273    QString tip() const;
     274    QPixmap pixmap();
     275
     276    KStorageBus ctrBusType() const;
     277    QString ctrName() const;
     278    KStorageControllerType ctrType() const;
     279    ControllerTypeList ctrTypes() const;
     280
     281    void setCtrName (const QString &aCtrName);
     282    void setCtrType (KStorageControllerType aCtrType);
     283
     284    SlotsList ctrAllSlots() const;
     285    SlotsList ctrUsedSlots() const;
     286    DeviceTypeList ctrDeviceTypeList() const;
     287    QStringList ctrAllMediumIds() const;
     288    QStringList ctrUsedMediumIds() const;
     289
     290private:
     291
     292    void addChild (AbstractItem *aItem);
     293    void delChild (AbstractItem *aItem);
     294
     295    QString mCtrName;
     296    AbstractControllerType *mCtrType;
     297    QList <AbstractItem*> mAttachments;
     298};
     299
     300/* Attachment Item */
     301class AttachmentItem : public AbstractItem
     302{
     303public:
     304
     305    AttachmentItem (AbstractItem *aParent, KDeviceType aDeviceType);
     306
     307    ItemType rtti() const;
     308    AbstractItem* childByPos (int aIndex);
     309    AbstractItem* childById (const QUuid &aId);
     310    int posOfChild (AbstractItem *aItem) const;
     311    int childCount() const;
     312    QString text() const;
     313    QString tip() const;
     314    QPixmap pixmap();
     315
     316    StorageSlot attSlot() const;
     317    SlotsList attSlots() const;
     318    KDeviceType attDeviceType() const;
     319    DeviceTypeList attDeviceTypes() const;
     320    QString attMediumId() const;
     321    QStringList attMediumIds (bool aFilter = true) const;
     322    bool attIsHostDrive() const;
     323    bool attIsPassthrough() const;
     324
     325    void setAttSlot (const StorageSlot &aAttSlot);
     326    void setAttDevice (KDeviceType aAttDeviceType);
     327    void setAttMediumId (const QString &aAttMediumId);
     328    void setAttIsPassthrough (bool aPassthrough);
     329
     330    QString attSize() const;
     331    QString attLogicalSize() const;
     332    QString attLocation() const;
     333    QString attFormat() const;
     334    QString attUsage() const;
     335
     336private:
     337
     338    void cache (const VBoxMedium &aMedium);
     339
     340    void addChild (AbstractItem *aItem);
     341    void delChild (AbstractItem *aItem);
     342
     343    KDeviceType mAttDeviceType;
     344
     345    StorageSlot mAttSlot;
     346    QString mAttMediumId;
     347    bool mAttIsHostDrive;
     348    bool mAttIsPassthrough;
     349
     350    QString mAttName;
     351    QString mAttTip;
     352    QPixmap mAttPixmap;
     353
     354    QString mAttSize;
     355    QString mAttLogicalSize;
     356    QString mAttLocation;
     357    QString mAttFormat;
     358    QString mAttUsage;
     359};
     360
     361/* Storage Model */
     362class StorageModel : public QAbstractItemModel
     363{
     364    Q_OBJECT;
     365
     366public:
     367
     368    enum DataRole
    65369    {
    66         return ! (*this == aOther);
    67     }
    68 
    69     KStorageBus bus;
    70     LONG        channel;
    71     LONG        device;
    72     QString     name;
    73 };
    74 Q_DECLARE_METATYPE (SlotValue);
    75 
    76 /** Register type to store disk data */
    77 class DiskValue
    78 {
    79 public:
    80     DiskValue()
    81         : id (QString::null)
    82         , name (QString::null), tip (QString::null), pix (QPixmap()) {}
    83     DiskValue (const QString &aId);
    84     DiskValue (const DiskValue &aOther)
    85         : id (aOther.id)
    86         , name (aOther.name), tip (aOther.tip), pix (aOther.pix) {}
    87 
    88     DiskValue& operator= (const DiskValue &aOther)
    89     {
    90         id   = aOther.id;
    91         name = aOther.name;
    92         tip  = aOther.tip;
    93         pix  = aOther.pix;
    94         return *this;
    95     }
    96 
    97     bool operator== (const DiskValue &aOther)
    98     {
    99         return id == aOther.id;
    100     }
    101 
    102     bool operator!= (const DiskValue &aOther)
    103     {
    104         return ! (*this == aOther);
    105     }
    106 
    107     QString id;
    108     QString name;
    109     QString tip;
    110     QPixmap pix;
    111 };
    112 Q_DECLARE_METATYPE (DiskValue);
    113 
    114 /** Declare type to store both slot&disk data */
    115 class Attachment
    116 {
    117 public:
    118     Attachment (SlotValue aSlot, DiskValue aDisk)
    119         : slot (aSlot), disk (aDisk) {}
    120 
    121     /* Define sorting rules */
    122     bool operator< (const Attachment &aOther) const
    123     {
    124         return (slot.bus <  aOther.slot.bus) ||
    125                (slot.bus == aOther.slot.bus && slot.channel <  aOther.slot.channel) ||
    126                (slot.bus == aOther.slot.bus && slot.channel == aOther.slot.channel && slot.device <  aOther.slot.device);
    127     }
    128 
    129     SlotValue slot;
    130     DiskValue disk;
    131 };
    132 
    133 /**
    134  * QAbstractTableModel class reimplementation.
    135  * Used to feat slot/disk selection mechanism.
    136  */
    137 class AttachmentsModel : public QAbstractTableModel
     370        R_ItemId = Qt::UserRole + 1,
     371        R_ItemPixmap,
     372        R_ItemPixmapRect,
     373        R_ItemName,
     374        R_ItemNamePoint,
     375        R_ItemType,
     376        R_IsController,
     377        R_IsAttachment,
     378
     379        R_IsMoreControllersPossible,
     380        R_IsMoreAttachmentsPossible,
     381
     382        R_CtrName,
     383        R_CtrType,
     384        R_CtrTypes,
     385        R_CtrDevices,
     386        R_CtrBusType,
     387
     388        R_AttSlot,
     389        R_AttSlots,
     390        R_AttDevice,
     391        R_AttDevices,
     392        R_AttMediumId,
     393        R_AttIsHostDrive,
     394        R_AttIsPassthrough,
     395        R_AttSize,
     396        R_AttLogicalSize,
     397        R_AttLocation,
     398        R_AttFormat,
     399        R_AttUsage,
     400
     401        R_Margin,
     402        R_Spacing,
     403        R_IconSize,
     404
     405        R_HDPixmapEn,
     406        R_HDPixmapDis,
     407        R_CDPixmapEn,
     408        R_CDPixmapDis,
     409        R_FDPixmapEn,
     410        R_FDPixmapDis,
     411        R_HDPixmapRect,
     412        R_CDPixmapRect,
     413        R_FDPixmapRect,
     414
     415        R_PlusPixmapEn,
     416        R_PlusPixmapDis,
     417        R_MinusPixmapEn,
     418        R_MinusPixmapDis,
     419        R_AdderPoint
     420    };
     421
     422    StorageModel (QObject *aParent);
     423   ~StorageModel();
     424
     425    int rowCount (const QModelIndex &aParent = QModelIndex()) const;
     426    int columnCount (const QModelIndex &aParent = QModelIndex()) const;
     427
     428    QModelIndex root() const;
     429    QModelIndex index (int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const;
     430    QModelIndex parent (const QModelIndex &aIndex) const;
     431
     432    QVariant data (const QModelIndex &aIndex, int aRole) const;
     433    bool setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole);
     434
     435    QModelIndex addController (const QString &aCtrName, KStorageBus aBusType, KStorageControllerType aCtrType);
     436    void delController (const QUuid &aCtrId);
     437
     438    QModelIndex addAttachment (const QUuid &aCtrId, KDeviceType aDeviceType);
     439    void delAttachment (const QUuid &aCtrId, const QUuid &aAttId);
     440
     441private:
     442
     443    Qt::ItemFlags flags (const QModelIndex &aIndex) const;
     444
     445    AbstractItem *mRootItem;
     446
     447    QPixmap mPlusPixmapEn;
     448    QPixmap mPlusPixmapDis;
     449
     450    QPixmap mMinusPixmapEn;
     451    QPixmap mMinusPixmapDis;
     452};
     453
     454/* Storage Delegate */
     455class StorageDelegate : public QItemDelegate
    138456{
    139457    Q_OBJECT;
     
    141459public:
    142460
    143     AttachmentsModel (QITableView *aParent, int aSlotId, int aDiskId)
    144         : QAbstractTableModel (aParent), mParent (aParent)
    145         , mSlotId (aSlotId), mDiskId (aDiskId) {}
    146 
    147     Qt::ItemFlags flags (const QModelIndex &aIndex) const;
    148 
    149     int columnCount (const QModelIndex &aParent = QModelIndex()) const
    150         { NOREF (aParent); return 2; }
    151     int rowCount (const QModelIndex &aParent = QModelIndex()) const
    152         { NOREF (aParent); return mUsedSlotsList.count() + 1; }
    153 
    154     QVariant data (const QModelIndex &aIndex,
    155                    int aRole = Qt::DisplayRole) const;
    156     bool setData (const QModelIndex &aIndex,
    157                   const QVariant &aValue,
    158                   int aRole = Qt::EditRole);
    159     QVariant headerData (int aSection,
    160                          Qt::Orientation aOrientation,
    161                          int aRole = Qt::DisplayRole) const;
    162 
    163     void addItem (const SlotValue &aSlot = SlotValue(),
    164                   const DiskValue &aDisk = DiskValue());
    165     void delItem (int aIndex);
    166 
    167     const QList<SlotValue>& usedSlotsList() { return mUsedSlotsList; }
    168     const QList<DiskValue>& usedDisksList() { return mUsedDisksList; }
    169     QList<Attachment> fullUsedList();
    170 
    171     void removeAddController();
    172     void updateDisks();
    173 
    174 private:
    175 
    176     QITableView *mParent;
    177     QList<SlotValue> mUsedSlotsList;
    178     QList<DiskValue> mUsedDisksList;
    179     int mSlotId;
    180     int mDiskId;
    181 };
    182 
    183 /**
    184  * QComboBox class reimplementation.
    185  * Used as editor for HD Attachment SLOT field.
    186  */
    187 class SlotEditor : public QComboBox
    188 {
    189     Q_OBJECT;
    190     Q_PROPERTY (QVariant slot READ slot WRITE setSlot USER true);
    191 
    192 public:
    193 
    194     SlotEditor (QWidget *aParent);
    195 
    196     QVariant slot() const;
    197     void setSlot (QVariant aSlot);
    198 
    199 signals:
    200 
    201     void readyToCommit (QWidget *aThis);
    202 
    203 private slots:
    204 
    205     void onActivate();
    206 
    207 private:
    208 
    209 #if 0 /* F2 key binding left for future releases... */
    210     void keyPressEvent (QKeyEvent *aEvent);
    211 #endif
    212 
    213     void populate (const SlotValue &aIncluding);
    214 
    215     QList<SlotValue> mList;
    216 };
    217 
    218 /**
    219  * VBoxMediaComboBox class reimplementation.
    220  * Used as editor for HD Attachment DISK field.
    221  */
    222 class DiskEditor : public VBoxMediaComboBox
    223 {
    224     Q_OBJECT;
    225     Q_PROPERTY (QVariant disk READ disk WRITE setDisk USER true);
    226 
    227 public:
    228 
    229     static DiskEditor* activeEditor();
    230 
    231     DiskEditor (QWidget *aParent);
    232    ~DiskEditor();
    233 
    234     QVariant disk() const;
    235     void setDisk (QVariant aDisk);
    236 
    237 signals:
    238 
    239     void readyToCommit (QWidget *aThis);
    240 
    241 protected:
    242 
    243     void paintEvent (QPaintEvent *aEvent);
    244     void initStyleOption (QStyleOptionComboBox *aOption) const;
    245 
    246 private slots:
    247 
    248     void onActivate();
    249 
    250 private:
    251 
    252 #if 0 /* F2 key binding left for future releases... */
    253     void keyPressEvent (QKeyEvent *aEvent);
    254 #endif
    255 
    256     static DiskEditor *mInstance;
    257 };
    258 
    259 /**
    260  * Singleton QObject class reimplementation.
    261  * Used to make selected HD Attachments slots unique &
    262  * stores some specific data used for HD Settings.
    263  */
    264 class HDSettings : public QObject
    265 {
    266     Q_OBJECT;
    267 
    268 public:
    269 
    270     static HDSettings* instance (QWidget *aParent = 0,
    271                                  AttachmentsModel *aWatched = 0);
    272 
    273     QList<SlotValue> slotsList (const SlotValue &aIncluding = SlotValue(),
    274                                 bool aFilter = false) const;
    275     QList<DiskValue> disksList() const;
    276 
    277     bool tryToChooseUniqueDisk (DiskValue &aResult) const;
    278 
    279     const CMachine& machine() const { return mMachine; }
    280     void setMachine (const CMachine &aMachine) { mMachine = aMachine; }
    281 
    282     int addCount() const { return mAddCount; }
    283     void setAddCount (int aAddCount, KStorageBus aAddBus)
    284     {
    285         if (mAddCount != aAddCount ||
    286             aAddBus != mAddBus)
    287         {
    288             mAddCount = aAddCount;
    289             mAddBus = aAddBus;
    290             makeAddControllerList();
    291         }
    292     }
    293 
    294     bool showDiffs() const { return mShowDiffs; }
    295     void setShowDiffs (bool aShowDiffs)
    296     {
    297         mShowDiffs = aShowDiffs;
    298         update();
    299     }
    300 
    301 protected:
    302 
    303     HDSettings (QWidget *aParent, AttachmentsModel *aWatched);
    304     virtual ~HDSettings();
    305 
    306 private slots:
    307 
    308     void update()
    309     {
    310         makeMediumList();
    311         mModel->updateDisks();
    312     }
    313 
    314 private:
    315 
    316     void makeIDEList();
    317     void makeAddControllerList();
    318     void makeMediumList();
    319 
    320 
    321     static HDSettings *mInstance;
    322 
    323     AttachmentsModel *mModel;
    324     CMachine mMachine;
    325 
    326     QList<SlotValue> mIDEList;
    327     QList<SlotValue> mAddControllerList;
    328     QList<DiskValue> mDisksList;
    329 
    330     int mAddCount;
    331     KStorageBus mAddBus;
    332     bool mShowDiffs;
     461    StorageDelegate (QObject *aParent);
     462
     463private:
     464
     465    void paint (QPainter *aPainter, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const;
    333466};
    334467
     
    348481signals:
    349482
    350     void hdChanged();
     483    void mediumChanged();
    351484
    352485protected:
     
    358491    bool revalidate (QString &aWarning, QString &aTitle);
    359492
    360     void setOrderAfter (QWidget *aWidget);
    361 
    362493    void retranslateUi();
    363494
     495    void showEvent (QShowEvent *aEvent);
     496
    364497private slots:
    365498
    366     void addAttachment();
     499    void addController();
     500    void addIDEController();
     501    void addSATAController();
     502    void addSCSIController();
     503    void addFloppyController();
     504    void delController();
     505
     506    void addAttachment (KDeviceType aDeviceType = KDeviceType_Null);
    367507    void delAttachment();
    368     void showMediaManager();
    369 
    370     void onAddControllerCheckToggled (int);
    371     void onAddControllerTypeChanged (int aIndex);
    372     bool checkAddControllers (int aWhat);
    373     void onShowDiffsCheckToggled (int);
    374 
    375     void updateActions (const QModelIndex &aIndex);
    376 
    377 private:
    378 
    379     /* events */
    380     bool eventFilter (QObject *aObj, QEvent *aEvent);
    381     void showEvent (QShowEvent *aEvent);
    382 
    383     /* private functions */
    384     QString getWithMediaManager (const QString &aInitialId = QString::null);
     508
     509    void getInformation();
     510    void setInformation();
     511
     512    void onVmmInvoked();
     513
     514    void updateActionsState();
     515
     516    void onRowInserted (const QModelIndex &aParent, int aIndex);
     517    void onRowRemoved();
     518
     519    void onCurrentItemChanged();
     520
     521    void onContextMenuRequested (const QPoint &aPosition);
     522
     523    void onDrawItemBranches (QPainter *aPainter, const QRect &aRect, const QModelIndex &aIndex);
     524
     525    void onMouseClicked (QMouseEvent *aEvent);
     526
     527private:
     528
    385529    QString getWithNewHDWizard();
    386     int maxNameLength() const;
    387     void removeFocus();
    388     KStorageControllerType currentControllerType() const
    389     {
    390         return static_cast<KStorageControllerType> (mCbControllerType->itemData (mCbControllerType->currentIndex()).toInt());
    391     }
    392     KStorageBus currentBusType() const
    393     {
    394         return vboxGlobal().toStorageBusType (currentControllerType());
    395     }
    396     int currentMaxPortCount() const
    397     {
    398         int c = 0;
    399         switch (currentBusType())
    400         {
    401             case KStorageBus_IDE: c = 2; break;
    402             case KStorageBus_SATA: c = 30; break;
    403             case KStorageBus_SCSI: c = 16; break;
    404             default: break;
    405         }
    406         return c;
    407     }
    408 
    409     /* variables */
     530    QString getWithMediaManager (VBoxDefs::MediumType aMediumType);
     531
     532    void updateAdditionalObjects (KDeviceType aType);
     533
    410534    CMachine mMachine;
    411     AttachmentsModel *mModel;
    412535    QIWidgetValidator *mValidator;
    413536
    414     QAction *mNewAction;
    415     QAction *mDelAction;
    416     QAction *mVdmAction;
    417 
    418     bool mWasTableSelected;
    419     bool mPolished;
    420 
    421     int mLastSelAddControllerIndex;
     537    StorageModel *mStorageModel;
     538
     539    QAction *mAddCtrAction;
     540    QAction *mAddIDECtrAction;
     541    QAction *mAddSATACtrAction;
     542    QAction *mAddSCSICtrAction;
     543    QAction *mAddFloppyCtrAction;
     544    QAction *mDelCtrAction;
     545    QAction *mAddAttAction;
     546    QAction *mDelAttAction;
     547
     548    bool mIsLoadingInProgress;
     549    bool mIsPolished;
    422550};
    423551
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette