VirtualBox

Changeset 63833 in vbox


Ignore:
Timestamp:
Sep 14, 2016 1:11:01 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 28): Selector UI: Extending UISnapshotPane API with item casting stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r63832 r63833  
    583583void UISnapshotPane::sltCurrentItemChanged(QTreeWidgetItem *pItem)
    584584{
     585    /* Acquire corresponding snapshot item: */
     586    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
     587
    585588    /* Make the selected item visible: */
    586     const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
    587589    if (pSnapshotItem)
    588590    {
     
    644646void UISnapshotPane::sltContextMenuRequested(const QPoint &point)
    645647{
    646     /* Search for corresponding snapshot item: */
     648    /* Search for corresponding item: */
    647649    const QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(point);
    648     const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
    649     if (!pSnapshotItem)
     650    if (!pItem)
    650651        return;
     652
     653    /* Acquire corresponding snapshot item: */
     654    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
     655    AssertReturnVoid(pSnapshotItem);
    651656
    652657    /* Prepare menu: */
     
    679684        return;
    680685
    681     /* Make sure snapshot item was changed: */
    682     const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
    683     if (!pSnapshotItem)
    684         return;
     686    /* Acquire corresponding snapshot item: */
     687    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
     688    AssertReturnVoid(pSnapshotItem);
    685689
    686690    /* Rename corresponding snapshot: */
     
    696700        return;
    697701
    698     /* Make sure snapshot item was double-clicked: */
    699     const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;
    700     if (!pSnapshotItem)
    701         return;
     702    /* Acquire corresponding snapshot item: */
     703    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
     704    AssertReturnVoid(pSnapshotItem);
    702705
    703706    /* Handle Ctrl+DoubleClick: */
     
    711714void UISnapshotPane::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false */)
    712715{
    713     /* Get currently chosen item: */
    714     const SnapshotWgtItem *pSnapshotItem = m_pTreeWidget->currentItem() ? static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()) : 0;
     716    /* Acquire currently chosen snapshot item: */
     717    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
    715718    AssertReturnVoid(pSnapshotItem);
    716719
     
    760763void UISnapshotPane::sltDeleteSnapshot()
    761764{
    762     /* Get currently chosen item: */
    763     const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
    764         static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     765    /* Acquire currently chosen snapshot item: */
     766    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
    765767    AssertReturnVoid(pSnapshotItem);
    766768
     
    810812void UISnapshotPane::sltShowSnapshotDetails()
    811813{
    812     /* Get currently chosen item: */
    813     const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
    814         static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     814    /* Acquire currently chosen snapshot item: */
     815    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
    815816    AssertReturnVoid(pSnapshotItem);
    816817
     
    830831void UISnapshotPane::sltCloneSnapshot()
    831832{
    832     /* Get currently chosen item: */
    833     const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
    834         static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     833    /* Acquire currently chosen snapshot item: */
     834    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
    835835    AssertReturnVoid(pSnapshotItem);
    836836
     
    10141014    /* Remember the selected item and it's first child: */
    10151015    QString strSelectedItem, strFirstChildOfSelectedItem;
    1016     const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 :
    1017         static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem());
     1016    const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem());
    10181017    if (pSnapshotItem)
    10191018    {
    10201019        strSelectedItem = pSnapshotItem->snapshotID();
    10211020        if (pSnapshotItem->child(0))
    1022             strFirstChildOfSelectedItem = static_cast<const SnapshotWgtItem*>(pSnapshotItem->child(0))->snapshotID();
     1021            strFirstChildOfSelectedItem = toSnapshotItem(pSnapshotItem->child(0))->snapshotID();
    10231022    }
    10241023
     
    10831082    while (*it)
    10841083    {
    1085         SnapshotWgtItem *pSnapshotItem = static_cast<SnapshotWgtItem*>(*it);
     1084        SnapshotWgtItem *pSnapshotItem = toSnapshotItem(*it);
    10861085        if (pSnapshotItem->snapshotID() == strSnapshotID)
    10871086            return pSnapshotItem;
     
    11301129SnapshotAgeFormat UISnapshotPane::traverseSnapshotAge(QTreeWidgetItem *pItem) const
    11311130{
    1132     /* Make sure passed root is of valid type: */
    1133     SnapshotWgtItem *pSnapshotItem = pItem->type() == SnapshotWgtItem::ItemType ?
    1134                                      static_cast<SnapshotWgtItem*>(pItem) : 0;
     1131    /* Acquire corresponding snapshot item: */
     1132    SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem);
    11351133
    11361134    /* Fetch the snapshot age of the root if it's valid: */
     
    11501148}
    11511149
     1150/* static  */
     1151SnapshotWgtItem *UISnapshotPane::toSnapshotItem(QTreeWidgetItem *pItem)
     1152{
     1153    /* Make sure alive SnapshotWgtItem passed: */
     1154    if (!pItem || pItem->type() != SnapshotWgtItem::ItemType)
     1155        return 0;
     1156
     1157    /* Return casted SnapshotWgtItem then: */
     1158    return static_cast<SnapshotWgtItem*>(pItem);
     1159}
     1160
     1161/* static */
     1162const SnapshotWgtItem *UISnapshotPane::toSnapshotItem(const QTreeWidgetItem *pItem)
     1163{
     1164    /* Make sure alive SnapshotWgtItem passed: */
     1165    if (!pItem || pItem->type() != SnapshotWgtItem::ItemType)
     1166        return 0;
     1167
     1168    /* Return casted SnapshotWgtItem then: */
     1169    return static_cast<const SnapshotWgtItem*>(pItem);
     1170}
     1171
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r63832 r63833  
    141141    SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const;
    142142
     143    /** Casts QTreeWidgetItem to SnapshotWgtItem if possible. */
     144    static SnapshotWgtItem *toSnapshotItem(QTreeWidgetItem *pItem);
     145    /** Casts const QTreeWidgetItem to const SnapshotWgtItem if possible. */
     146    static const SnapshotWgtItem *toSnapshotItem(const QTreeWidgetItem *pItem);
     147
    143148    /** Holds the machine COM wrapper. */
    144149    CMachine         m_comMachine;
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