VirtualBox

Changeset 64495 in vbox for trunk/src


Ignore:
Timestamp:
Oct 31, 2016 3:32:19 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111631
Message:

FE/Qt: bugref:6899: Accessibility support (step 119): Selector UI: Move snapshot pane onto QITreeWidget rails.

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

Legend:

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

    r64494 r64495  
    2828# include <QPointer>
    2929# include <QScrollBar>
    30 # include <QTreeWidget>
    3130# include <QWriteLocker>
    3231
    3332/* GUI includes: */
     33# include "QITreeWidget.h"
    3434# include "UIConverter.h"
    3535# include "UIExtraDataManager.h"
     
    5555
    5656
    57 /** QTreeWidgetItem subclass for snapshots items. */
    58 class UISnapshotItem : public QObject, public QTreeWidgetItem
     57/** QITreeWidgetItem subclass for snapshots items. */
     58class UISnapshotItem : public QITreeWidgetItem
    5959{
    6060    Q_OBJECT;
     
    6767    static const UISnapshotItem *toSnapshotItem(const QTreeWidgetItem *pItem);
    6868
    69     /** Item type for UISnapshotItem. */
    70     enum { ItemType = QTreeWidgetItem::UserType + 1 };
    71 
    7269    /** Constructs normal snapshot item (child of tree-widget). */
    73     UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot);
     70    UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CSnapshot &comSnapshot);
    7471    /** Constructs normal snapshot item (child of tree-widget-item). */
    75     UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot);
     72    UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CSnapshot &comSnapshot);
    7673
    7774    /** Constructs "current state" item (child of tree-widget). */
    78     UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine);
     75    UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CMachine &comMachine);
    7976    /** Constructs "current state" item (child of tree-widget-item). */
    80     UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine);
     77    UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CMachine &comMachine);
    8178
    8279    /** Returns item machine. */
     
    8784    QString snapshotID() const { return m_strSnapshotID; }
    8885
    89     /** Returns the parent snapshot tree. */
    90     UISnapshotTree *parentSnapshotTree() const;
    91     /** Returns the parent snapshot item. */
    92     UISnapshotItem *parentSnapshotItem() const;
    93     /** Returns the child snapshot item with @a iIndex. */
    94     UISnapshotItem *childSnapshotItem(int iIndex) const;
    95 
    9686    /** Returns item data for corresponding @a iColumn and @a iRole. */
    9787    QVariant data(int iColumn, int iRole) const;
     
    166156
    167157
    168 /** QTreeWidget subclass for snapshots items. */
    169 class UISnapshotTree : public QTreeWidget
     158/** QITreeWidget subclass for snapshots items. */
     159class UISnapshotTree : public QITreeWidget
    170160{
    171161    Q_OBJECT;
     
    175165    /** Constructs snapshot tree passing @a pParent to the base-class. */
    176166    UISnapshotTree(QWidget *pParent);
    177 
    178     /** Returns the number of children. */
    179     int childCount() const;
    180     /** Returns the child snapshot item with @a iIndex. */
    181     UISnapshotItem *childSnapshotItem(int iIndex) const;
    182167};
    183168
     
    190175UISnapshotItem *UISnapshotItem::toSnapshotItem(QTreeWidgetItem *pItem)
    191176{
    192     /* Make sure alive UISnapshotItem passed: */
    193     if (!pItem || pItem->type() != UISnapshotItem::ItemType)
     177    /* Get QITreeWidgetItem item first: */
     178    QITreeWidgetItem *pIItem = QITreeWidgetItem::toItem(pItem);
     179    if (!pIItem)
    194180        return 0;
    195181
    196182    /* Return casted UISnapshotItem then: */
    197     return static_cast<UISnapshotItem*>(pItem);
     183    return qobject_cast<UISnapshotItem*>(pIItem);
    198184}
    199185
     
    201187const UISnapshotItem *UISnapshotItem::toSnapshotItem(const QTreeWidgetItem *pItem)
    202188{
    203     /* Make sure alive UISnapshotItem passed: */
    204     if (!pItem || pItem->type() != UISnapshotItem::ItemType)
     189    /* Get QITreeWidgetItem item first: */
     190    const QITreeWidgetItem *pIItem = QITreeWidgetItem::toItem(pItem);
     191    if (!pIItem)
    205192        return 0;
    206193
    207194    /* Return casted UISnapshotItem then: */
    208     return static_cast<const UISnapshotItem*>(pItem);
    209 }
    210 
    211 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CSnapshot &comSnapshot)
    212     : QTreeWidgetItem(pTreeWidget, ItemType)
     195    return qobject_cast<const UISnapshotItem*>(pIItem);
     196}
     197
     198UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CSnapshot &comSnapshot)
     199    : QITreeWidgetItem(pTreeWidget)
    213200    , m_pSnapshotWidget(pSnapshotWidget)
    214201    , m_fCurrentState(false)
     
    217204}
    218205
    219 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CSnapshot &comSnapshot)
    220     : QTreeWidgetItem(pRootItem, ItemType)
     206UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CSnapshot &comSnapshot)
     207    : QITreeWidgetItem(pRootItem)
    221208    , m_pSnapshotWidget(pSnapshotWidget)
    222209    , m_fCurrentState(false)
     
    225212}
    226213
    227 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidget *pTreeWidget, const CMachine &comMachine)
    228     : QTreeWidgetItem(pTreeWidget, ItemType)
     214UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CMachine &comMachine)
     215    : QITreeWidgetItem(pTreeWidget)
    229216    , m_pSnapshotWidget(pSnapshotWidget)
    230217    , m_fCurrentState(true)
     
    235222}
    236223
    237 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QTreeWidgetItem *pRootItem, const CMachine &comMachine)
    238     : QTreeWidgetItem(pRootItem, ItemType)
     224UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CMachine &comMachine)
     225    : QITreeWidgetItem(pRootItem)
    239226    , m_pSnapshotWidget(pSnapshotWidget)
    240227    , m_fCurrentState(true)
     
    243230    /* Fetch current machine state: */
    244231    updateCurrentState(m_comMachine.GetState());
    245 }
    246 
    247 UISnapshotTree *UISnapshotItem::parentSnapshotTree() const
    248 {
    249     /* Return the parent snapshot tree if any: */
    250     return treeWidget() ? qobject_cast<UISnapshotTree*>(treeWidget()) : 0;
    251 }
    252 
    253 UISnapshotItem *UISnapshotItem::parentSnapshotItem() const
    254 {
    255     /* Return the parent snapshot item if any: */
    256     return QTreeWidgetItem::parent() ? toSnapshotItem(QTreeWidgetItem::parent()) : 0;
    257 }
    258 
    259 UISnapshotItem *UISnapshotItem::childSnapshotItem(int iIndex) const
    260 {
    261     /* Return the child snapshot item with iIndex if any: */
    262     return QTreeWidgetItem::child(iIndex) ? toSnapshotItem(QTreeWidgetItem::child(iIndex)) : 0;
    263232}
    264233
     
    531500
    532501UISnapshotTree::UISnapshotTree(QWidget *pParent)
    533     : QTreeWidget(pParent)
     502    : QITreeWidget(pParent)
    534503{
    535504    /* No header: */
     
    555524// #endif
    556525#endif /* QT_VERSION < 0x050000 */
    557 }
    558 
    559 int UISnapshotTree::childCount() const
    560 {
    561     /* Return the number of children: */
    562     return invisibleRootItem()->childCount();
    563 }
    564 
    565 UISnapshotItem *UISnapshotTree::childSnapshotItem(int iIndex) const
    566 {
    567     /* Return the child snapshot item with iIndex if any: */
    568     return invisibleRootItem()->child(iIndex) ? UISnapshotItem::toSnapshotItem(invisibleRootItem()->child(iIndex)) : 0;
    569526}
    570527
     
    709666{
    710667    /* Translate snapshot tree: */
    711     m_pSnapshotTree->setToolTip(tr("Contains snapshot tree of current virtual machine"));
     668    m_pSnapshotTree->setWhatsThis(tr("Contains snapshot tree of current virtual machine"));
    712669
    713670    /* Translate actions names: */
     
    12811238}
    12821239
    1283 void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, QTreeWidgetItem *pItem)
     1240void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem)
    12841241{
    12851242    /* Create a child of passed item: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r64494 r64495  
    3535class UISnapshotItem;
    3636class QTreeWidgetItem;
     37class QITreeWidgetItem;
    3738
    3839
     
    132133    void refreshAll();
    133134    /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */
    134     void populateSnapshots(const CSnapshot &comSnapshot, QTreeWidgetItem *pItem);
     135    void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem);
    135136
    136137    /** Searches for an item with corresponding @a strSnapshotID. */
Note: See TracChangeset for help on using the changeset viewer.

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