VirtualBox

Changeset 64692 in vbox for trunk


Ignore:
Timestamp:
Nov 17, 2016 3:22:44 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 134): UIApplianceEditorWidget more refactoring.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r64691 r64692  
    4646
    4747
    48 /** Describes the interface of Virtual System item.
     48/** Describes the interface of Appliance item.
    4949  * Represented as a tree structure with a parent & multiple children. */
    50 class ModelItem
     50class UIApplianceModelItem
    5151{
    5252public:
    5353
    5454    /** Constructs item with specified @a iNumber, @a enmType and @a pParentItem. */
    55     ModelItem(int iNumber, ApplianceModelItemType enmType, ModelItem *pParentItem = 0);
     55    UIApplianceModelItem(int iNumber, ApplianceModelItemType enmType, UIApplianceModelItem *pParentItem = 0);
    5656    /** Destructs item. */
    57     virtual ~ModelItem();
     57    virtual ~UIApplianceModelItem();
    5858
    5959    /** Returns the item type. */
     
    6161
    6262    /** Returns the parent of the item. */
    63     ModelItem *parent() const { return m_pParentItem; }
     63    UIApplianceModelItem *parent() const { return m_pParentItem; }
    6464
    6565    /** Appends the passed @a pChildItem to the item's list of children. */
    66     void appendChild(ModelItem *pChildItem);
     66    void appendChild(UIApplianceModelItem *pChildItem);
    6767    /** Returns the child specified by the @a iRow. */
    68     ModelItem *child(int iRow) const;
     68    UIApplianceModelItem *child(int iRow) const;
    6969
    7070    /** Returns the row of the item in the parent. */
     
    108108
    109109    /** Holds the parent item reference. */
    110     ModelItem              *m_pParentItem;
     110    UIApplianceModelItem         *m_pParentItem;
    111111    /** Holds the list of children item instances. */
    112     QList<ModelItem*>       m_childItems;
     112    QList<UIApplianceModelItem*>  m_childItems;
    113113};
    114114
    115115
    116 /** ModelItem subclass representing Virtual System. */
    117 class VirtualSystemItem : public ModelItem
     116/** UIApplianceModelItem subclass representing Appliance Virtual System item. */
     117class UIVirtualSystemItem : public UIApplianceModelItem
    118118{
    119119public:
    120120
    121121    /** Constructs item passing @a iNumber and @a pParentItem to the base-class.
    122       * @param  enmDescription  Brings the Virtual System Description. */
    123     VirtualSystemItem(int iNumber, CVirtualSystemDescription enmDescription, ModelItem *pParentItem);
     122      * @param  comDescription  Brings the Virtual System Description. */
     123    UIVirtualSystemItem(int iNumber, CVirtualSystemDescription comDescription, UIApplianceModelItem *pParentItem);
    124124
    125125    /** Returns the data stored under the given @a iRole for the item referred to by the @a iColumn. */
     
    132132
    133133    /** Holds the Virtual System Description. */
    134     CVirtualSystemDescription m_enmDescription;
     134    CVirtualSystemDescription m_comDescription;
    135135};
    136136
    137137
    138 /** ModelItem subclass representing Virtual System item. */
    139 class HardwareItem : public ModelItem
    140 {
    141     friend class VirtualSystemSortProxyModel;
     138/** UIApplianceModelItem subclass representing Appliance Virtual Hardware item. */
     139class UIVirtualHardwareItem : public UIApplianceModelItem
     140{
     141    friend class UIApplianceSortProxyModel;
    142142
    143143    /** Data roles. */
     
    156156      * @param  strConfigValue       Brings the configuration value.
    157157      * @param  strExtraConfigValue  Brings the extra configuration value. */
    158     HardwareItem(int iNumber,
    159                  KVirtualSystemDescriptionType enmType,
    160                  const QString &strRef,
    161                  const QString &strOrigValue,
    162                  const QString &strConfigValue,
    163                  const QString &strExtraConfigValue,
    164                  ModelItem *pParentItem);
     158    UIVirtualHardwareItem(int iNumber,
     159                          KVirtualSystemDescriptionType enmType,
     160                          const QString &strRef,
     161                          const QString &strOrigValue,
     162                          const QString &strConfigValue,
     163                          const QString &strExtraConfigValue,
     164                          UIApplianceModelItem *pParentItem);
    165165
    166166    /** Returns the item flags for the given @a iColumn. */
     
    190190private:
    191191
    192     /** Holds the Virtual System description type. */
     192    /** Holds the Virtual System Description type. */
    193193    KVirtualSystemDescriptionType m_enmType;
    194194    /** Holds something totally useless. */
     
    210210
    211211/*********************************************************************************************************************************
    212 *   Class ModelItem implementation.                                                                                              *
     212*   Class UIApplianceModelItem implementation.                                                                                   *
    213213*********************************************************************************************************************************/
    214214
    215 ModelItem::ModelItem(int iNumber, ApplianceModelItemType enmType, ModelItem *pParentItem /* = 0 */)
     215UIApplianceModelItem::UIApplianceModelItem(int iNumber, ApplianceModelItemType enmType, UIApplianceModelItem *pParentItem /* = 0 */)
    216216    : m_iNumber(iNumber)
    217217    , m_enmType(enmType)
     
    220220}
    221221
    222 ModelItem::~ModelItem()
     222UIApplianceModelItem::~UIApplianceModelItem()
    223223{
    224224    qDeleteAll(m_childItems);
    225225}
    226226
    227 void ModelItem::appendChild(ModelItem *pChildItem)
     227void UIApplianceModelItem::appendChild(UIApplianceModelItem *pChildItem)
    228228{
    229229    AssertPtr(pChildItem);
     
    231231}
    232232
    233 ModelItem *ModelItem::child(int iRow) const
     233UIApplianceModelItem *UIApplianceModelItem::child(int iRow) const
    234234{
    235235    return m_childItems.value(iRow);
    236236}
    237237
    238 int ModelItem::row() const
     238int UIApplianceModelItem::row() const
    239239{
    240240    if (m_pParentItem)
    241         return m_pParentItem->m_childItems.indexOf(const_cast<ModelItem*>(this));
     241        return m_pParentItem->m_childItems.indexOf(const_cast<UIApplianceModelItem*>(this));
    242242
    243243    return 0;
    244244}
    245245
    246 int ModelItem::childCount() const
     246int UIApplianceModelItem::childCount() const
    247247{
    248248    return m_childItems.count();
    249249}
    250250
    251 void ModelItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)
     251void UIApplianceModelItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)
    252252{
    253253    for (int i = 0; i < childCount(); ++i)
     
    257257
    258258/*********************************************************************************************************************************
    259 *   Class VirtualSystemItem implementation.                                                                                      *
     259*   Class UIVirtualSystemItem implementation.                                                                                    *
    260260*********************************************************************************************************************************/
    261261
    262 VirtualSystemItem::VirtualSystemItem(int iNumber, CVirtualSystemDescription enmDescription, ModelItem *pParentItem)
    263     : ModelItem(iNumber, ApplianceModelItemType_VirtualSystem, pParentItem)
    264     , m_enmDescription(enmDescription)
    265 {
    266 }
    267 
    268 QVariant VirtualSystemItem::data(int iColumn, int iRole) const
     262UIVirtualSystemItem::UIVirtualSystemItem(int iNumber, CVirtualSystemDescription comDescription, UIApplianceModelItem *pParentItem)
     263    : UIApplianceModelItem(iNumber, ApplianceModelItemType_VirtualSystem, pParentItem)
     264    , m_comDescription(comDescription)
     265{
     266}
     267
     268QVariant UIVirtualSystemItem::data(int iColumn, int iRole) const
    269269{
    270270    QVariant value;
     
    275275}
    276276
    277 void VirtualSystemItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)
     277void UIVirtualSystemItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)
    278278{
    279279    /* Resize the vectors */
    280     unsigned long iCount = m_enmDescription.GetCount();
     280    unsigned long iCount = m_comDescription.GetCount();
    281281    finalStates.resize(iCount);
    282282    finalValues.resize(iCount);
    283283    finalExtraValues.resize(iCount);
    284284    /* Recursively fill the vectors */
    285     ModelItem::putBack(finalStates, finalValues, finalExtraValues);
     285    UIApplianceModelItem::putBack(finalStates, finalValues, finalExtraValues);
    286286    /* Set all final values at once */
    287     m_enmDescription.SetFinalValues(finalStates, finalValues, finalExtraValues);
     287    m_comDescription.SetFinalValues(finalStates, finalValues, finalExtraValues);
    288288}
    289289
    290290
    291291/*********************************************************************************************************************************
    292 *   Class HardwareItem implementation.                                                                                           *
     292*   Class UIVirtualHardwareItem implementation.                                                                                  *
    293293*********************************************************************************************************************************/
    294294
    295 HardwareItem::HardwareItem(int iNumber,
    296                            KVirtualSystemDescriptionType enmType,
    297                            const QString &strRef,
    298                            const QString &aOrigValue,
    299                            const QString &strConfigValue,
    300                            const QString &strExtraConfigValue,
    301                            ModelItem *pParentItem)
    302     : ModelItem(iNumber, ApplianceModelItemType_Hardware, pParentItem)
     295UIVirtualHardwareItem::UIVirtualHardwareItem(int iNumber,
     296                                             KVirtualSystemDescriptionType enmType,
     297                                             const QString &strRef,
     298                                             const QString &aOrigValue,
     299                                             const QString &strConfigValue,
     300                                             const QString &strExtraConfigValue,
     301                                             UIApplianceModelItem *pParentItem)
     302    : UIApplianceModelItem(iNumber, ApplianceModelItemType_VirtualHardware, pParentItem)
    303303    , m_enmType(enmType)
    304304    , m_strRef(strRef)
     
    312312}
    313313
    314 Qt::ItemFlags HardwareItem::itemFlags(int iColumn) const
     314Qt::ItemFlags UIVirtualHardwareItem::itemFlags(int iColumn) const
    315315{
    316316    Qt::ItemFlags enmFlags = 0;
     
    346346}
    347347
    348 bool HardwareItem::setData(int iColumn, const QVariant &value, int iRole)
     348bool UIVirtualHardwareItem::setData(int iColumn, const QVariant &value, int iRole)
    349349{
    350350    bool fDone = false;
     
    378378}
    379379
    380 QVariant HardwareItem::data(int iColumn, int iRole) const
     380QVariant UIVirtualHardwareItem::data(int iColumn, int iRole) const
    381381{
    382382    QVariant value;
     
    529529            break;
    530530        }
    531         case HardwareItem::TypeRole:
     531        case UIVirtualHardwareItem::TypeRole:
    532532        {
    533533            value = m_enmType;
    534534            break;
    535535        }
    536         case HardwareItem::ModifiedRole:
     536        case UIVirtualHardwareItem::ModifiedRole:
    537537        {
    538538            if (iColumn == ApplianceViewSection_ConfigValue)
     
    544544}
    545545
    546 QWidget *HardwareItem::createEditor(QWidget *pParent, const QStyleOptionViewItem & /* styleOption */, const QModelIndex &idx) const
     546QWidget *UIVirtualHardwareItem::createEditor(QWidget *pParent, const QStyleOptionViewItem & /* styleOption */, const QModelIndex &idx) const
    547547{
    548548    QWidget *pEditor = 0;
     
    653653}
    654654
    655 bool HardwareItem::setEditorData(QWidget *pEditor, const QModelIndex & /* idx */) const
     655bool UIVirtualHardwareItem::setEditorData(QWidget *pEditor, const QModelIndex & /* idx */) const
    656656{
    657657    bool fDone = false;
     
    744744}
    745745
    746 bool HardwareItem::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex & idx)
     746bool UIVirtualHardwareItem::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex & idx)
    747747{
    748748    bool fDone = false;
     
    791791                 * are child's of this item. */
    792792                QModelIndexList list = pModel->match(c0Index,
    793                                                      HardwareItem::TypeRole,
     793                                                     UIVirtualHardwareItem::TypeRole,
    794794                                                     KVirtualSystemDescriptionType_HardDiskImage,
    795795                                                     -1,
     
    880880}
    881881
    882 void HardwareItem::restoreDefaults()
     882void UIVirtualHardwareItem::restoreDefaults()
    883883{
    884884    m_strConfigValue = m_strConfigDefaultValue;
     
    886886}
    887887
    888 void HardwareItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)
     888void UIVirtualHardwareItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)
    889889{
    890890    finalStates[m_iNumber] = m_checkState == Qt::Checked;
    891891    finalValues[m_iNumber] = m_strConfigValue;
    892892    finalExtraValues[m_iNumber] = m_strExtraConfigValue;
    893     ModelItem::putBack(finalStates, finalValues, finalExtraValues);
     893    UIApplianceModelItem::putBack(finalStates, finalValues, finalExtraValues);
    894894}
    895895
    896896
    897897/*********************************************************************************************************************************
    898 *   Class VirtualSystemModel implementation.                                                                                     *
     898*   Class UIApplianceModel implementation.                                                                                       *
    899899*********************************************************************************************************************************/
    900900
    901 VirtualSystemModel::VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent /* = 0 */)
     901UIApplianceModel::UIApplianceModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent /* = 0 */)
    902902    : QAbstractItemModel(pParent)
    903903{
    904     m_pRootItem = new ModelItem(0, ApplianceModelItemType_Root);
     904    m_pRootItem = new UIApplianceModelItem(0, ApplianceModelItemType_Root);
    905905    for (int iVSDIndex = 0; iVSDIndex < aVSDs.size(); ++iVSDIndex)
    906906    {
    907907        CVirtualSystemDescription vsd = aVSDs[iVSDIndex];
    908908
    909         VirtualSystemItem *pVirtualSystemItem = new VirtualSystemItem(iVSDIndex, vsd, m_pRootItem);
     909        UIVirtualSystemItem *pVirtualSystemItem = new UIVirtualSystemItem(iVSDIndex, vsd, m_pRootItem);
    910910        m_pRootItem->appendChild(pVirtualSystemItem);
    911911
     
    918918
    919919        QList<int> hdIndexes;
    920         QMap<int, HardwareItem*> controllerMap;
     920        QMap<int, UIVirtualHardwareItem*> controllerMap;
    921921        vsd.GetDescription(types, refs, origValues, configValues, extraConfigValues);
    922922        for (int i = 0; i < types.size(); ++i)
     
    928928            else
    929929            {
    930                 HardwareItem *pHardwareItem = new HardwareItem(i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], pVirtualSystemItem);
     930                UIVirtualHardwareItem *pHardwareItem = new UIVirtualHardwareItem(i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], pVirtualSystemItem);
    931931                pVirtualSystemItem->appendChild(pHardwareItem);
    932932                /* Save the hard disk controller types in an extra map */
     
    947947            {
    948948                /* Get the controller */
    949                 HardwareItem *pControllerItem = controllerMap[rx.cap(1).toInt()];
     949                UIVirtualHardwareItem *pControllerItem = controllerMap[rx.cap(1).toInt()];
    950950                if (pControllerItem)
    951951                {
    952952                    /* New hardware item as child of the controller */
    953                     HardwareItem *pStorageItem = new HardwareItem(i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], pControllerItem);
     953                    UIVirtualHardwareItem *pStorageItem = new UIVirtualHardwareItem(i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], pControllerItem);
    954954                    pControllerItem->appendChild(pStorageItem);
    955955                }
     
    959959}
    960960
    961 VirtualSystemModel::~VirtualSystemModel()
     961UIApplianceModel::~UIApplianceModel()
    962962{
    963963    if (m_pRootItem)
     
    965965}
    966966
    967 QModelIndex VirtualSystemModel::index(int iRow, int iColumn, const QModelIndex &parentIdx /* = QModelIndex() */) const
     967QModelIndex UIApplianceModel::index(int iRow, int iColumn, const QModelIndex &parentIdx /* = QModelIndex() */) const
    968968{
    969969    if (!hasIndex(iRow, iColumn, parentIdx))
    970970        return QModelIndex();
    971971
    972     ModelItem *pParentItem;
     972    UIApplianceModelItem *pParentItem;
    973973
    974974    if (!parentIdx.isValid())
    975975        pParentItem = m_pRootItem;
    976976    else
    977         pParentItem = static_cast<ModelItem*>(parentIdx.internalPointer());
    978 
    979     ModelItem *pChildItem = pParentItem->child(iRow);
     977        pParentItem = static_cast<UIApplianceModelItem*>(parentIdx.internalPointer());
     978
     979    UIApplianceModelItem *pChildItem = pParentItem->child(iRow);
    980980    if (pChildItem)
    981981        return createIndex(iRow, iColumn, pChildItem);
     
    984984}
    985985
    986 QModelIndex VirtualSystemModel::parent(const QModelIndex &idx) const
     986QModelIndex UIApplianceModel::parent(const QModelIndex &idx) const
    987987{
    988988    if (!idx.isValid())
    989989        return QModelIndex();
    990990
    991     ModelItem *pChildItem = static_cast<ModelItem*>(idx.internalPointer());
    992     ModelItem *pParentItem = pChildItem->parent();
     991    UIApplianceModelItem *pChildItem = static_cast<UIApplianceModelItem*>(idx.internalPointer());
     992    UIApplianceModelItem *pParentItem = pChildItem->parent();
    993993
    994994    if (pParentItem == m_pRootItem)
     
    998998}
    999999
    1000 int VirtualSystemModel::rowCount(const QModelIndex &parentIdx /* = QModelIndex() */) const
    1001 {
    1002     ModelItem *pParentItem;
     1000int UIApplianceModel::rowCount(const QModelIndex &parentIdx /* = QModelIndex() */) const
     1001{
     1002    UIApplianceModelItem *pParentItem;
    10031003    if (parentIdx.column() > 0)
    10041004        return 0;
     
    10071007        pParentItem = m_pRootItem;
    10081008    else
    1009         pParentItem = static_cast<ModelItem*>(parentIdx.internalPointer());
     1009        pParentItem = static_cast<UIApplianceModelItem*>(parentIdx.internalPointer());
    10101010
    10111011    return pParentItem->childCount();
    10121012}
    10131013
    1014 int VirtualSystemModel::columnCount(const QModelIndex &parentIdx /* = QModelIndex() */) const
     1014int UIApplianceModel::columnCount(const QModelIndex &parentIdx /* = QModelIndex() */) const
    10151015{
    10161016    if (parentIdx.isValid())
    1017         return static_cast<ModelItem*>(parentIdx.internalPointer())->columnCount();
     1017        return static_cast<UIApplianceModelItem*>(parentIdx.internalPointer())->columnCount();
    10181018    else
    10191019        return m_pRootItem->columnCount();
    10201020}
    10211021
    1022 Qt::ItemFlags VirtualSystemModel::flags(const QModelIndex &idx) const
     1022Qt::ItemFlags UIApplianceModel::flags(const QModelIndex &idx) const
    10231023{
    10241024    if (!idx.isValid())
    10251025        return 0;
    10261026
    1027     ModelItem *pItem = static_cast<ModelItem*>(idx.internalPointer());
     1027    UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(idx.internalPointer());
    10281028
    10291029    return Qt::ItemIsEnabled | Qt::ItemIsSelectable | pItem->itemFlags(idx.column());
    10301030}
    10311031
    1032 QVariant VirtualSystemModel::headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const
     1032QVariant UIApplianceModel::headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const
    10331033{
    10341034    if (iRole != Qt::DisplayRole ||
     
    10451045}
    10461046
    1047 bool VirtualSystemModel::setData(const QModelIndex &idx, const QVariant &value, int iRole)
     1047bool UIApplianceModel::setData(const QModelIndex &idx, const QVariant &value, int iRole)
    10481048{
    10491049    if (!idx.isValid())
    10501050        return false;
    10511051
    1052     ModelItem *pTtem = static_cast<ModelItem*>(idx.internalPointer());
     1052    UIApplianceModelItem *pTtem = static_cast<UIApplianceModelItem*>(idx.internalPointer());
    10531053
    10541054    return pTtem->setData(idx.column(), value, iRole);
    10551055}
    10561056
    1057 QVariant VirtualSystemModel::data(const QModelIndex &idx, int iRole /* = Qt::DisplayRole */) const
     1057QVariant UIApplianceModel::data(const QModelIndex &idx, int iRole /* = Qt::DisplayRole */) const
    10581058{
    10591059    if (!idx.isValid())
    10601060        return QVariant();
    10611061
    1062     ModelItem *pTtem = static_cast<ModelItem*>(idx.internalPointer());
     1062    UIApplianceModelItem *pTtem = static_cast<UIApplianceModelItem*>(idx.internalPointer());
    10631063
    10641064    return pTtem->data(idx.column(), iRole);
    10651065}
    10661066
    1067 QModelIndex VirtualSystemModel::buddy(const QModelIndex &idx) const
     1067QModelIndex UIApplianceModel::buddy(const QModelIndex &idx) const
    10681068{
    10691069    if (!idx.isValid())
     
    10761076}
    10771077
    1078 void VirtualSystemModel::restoreDefaults(const QModelIndex &parentIdx /* = QModelIndex() */)
    1079 {
    1080     ModelItem *pParentItem;
     1078void UIApplianceModel::restoreDefaults(const QModelIndex &parentIdx /* = QModelIndex() */)
     1079{
     1080    UIApplianceModelItem *pParentItem;
    10811081
    10821082    if (!parentIdx.isValid())
    10831083        pParentItem = m_pRootItem;
    10841084    else
    1085         pParentItem = static_cast<ModelItem*>(parentIdx.internalPointer());
     1085        pParentItem = static_cast<UIApplianceModelItem*>(parentIdx.internalPointer());
    10861086
    10871087    for (int i = 0; i < pParentItem->childCount(); ++i)
     
    10931093}
    10941094
    1095 void VirtualSystemModel::putBack()
     1095void UIApplianceModel::putBack()
    10961096{
    10971097    QVector<BOOL> v1;
     
    11031103
    11041104/*********************************************************************************************************************************
    1105 *   Class VirtualSystemDelegate implementation.                                                                                  *
     1105*   Class UIApplianceDelegate implementation.                                                                                    *
    11061106*********************************************************************************************************************************/
    11071107
    1108 VirtualSystemDelegate::VirtualSystemDelegate(QAbstractProxyModel *pProxy, QObject *pParent /* = 0 */)
     1108UIApplianceDelegate::UIApplianceDelegate(QAbstractProxyModel *pProxy, QObject *pParent /* = 0 */)
    11091109    : QItemDelegate(pParent)
    11101110    , m_pProxy(pProxy)
     
    11121112}
    11131113
    1114 QWidget *VirtualSystemDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const
     1114QWidget *UIApplianceDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const
    11151115{
    11161116    if (!idx.isValid())
     
    11211121        index = m_pProxy->mapToSource(idx);
    11221122
    1123     ModelItem *pItem = static_cast<ModelItem*>(index.internalPointer());
     1123    UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(index.internalPointer());
    11241124    QWidget *pEditor = pItem->createEditor(pParent, styleOption, index);
    11251125
     
    11341134}
    11351135
    1136 void VirtualSystemDelegate::setEditorData(QWidget *pEditor, const QModelIndex &idx) const
     1136void UIApplianceDelegate::setEditorData(QWidget *pEditor, const QModelIndex &idx) const
    11371137{
    11381138    if (!idx.isValid())
     
    11431143        index = m_pProxy->mapToSource(idx);
    11441144
    1145     ModelItem *pItem = static_cast<ModelItem*>(index.internalPointer());
     1145    UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(index.internalPointer());
    11461146
    11471147    if (!pItem->setEditorData(pEditor, index))
     
    11491149}
    11501150
    1151 void VirtualSystemDelegate::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx) const
     1151void UIApplianceDelegate::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx) const
    11521152{
    11531153    if (!idx.isValid())
     
    11581158        index = m_pProxy->mapToSource(idx);
    11591159
    1160     ModelItem *pItem = static_cast<ModelItem*>(index.internalPointer());
     1160    UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(index.internalPointer());
    11611161    if (!pItem->setModelData(pEditor, pModel, idx))
    11621162        QItemDelegate::setModelData(pEditor, pModel, idx);
    11631163}
    11641164
    1165 void VirtualSystemDelegate::updateEditorGeometry(QWidget *pEditor, const QStyleOptionViewItem &styleOption, const QModelIndex & /* idx */) const
     1165void UIApplianceDelegate::updateEditorGeometry(QWidget *pEditor, const QStyleOptionViewItem &styleOption, const QModelIndex & /* idx */) const
    11661166{
    11671167    if (pEditor)
     
    11691169}
    11701170
    1171 QSize VirtualSystemDelegate::sizeHint(const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const
     1171QSize UIApplianceDelegate::sizeHint(const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const
    11721172{
    11731173    QSize size = QItemDelegate::sizeHint(styleOption, idx);
     
    11821182
    11831183#ifdef VBOX_WS_MAC
    1184 bool VirtualSystemDelegate::eventFilter(QObject *pObject, QEvent *pEvent)
     1184bool UIApplianceDelegate::eventFilter(QObject *pObject, QEvent *pEvent)
    11851185{
    11861186    if (pEvent->type() == QEvent::FocusOut)
     
    12041204
    12051205/*********************************************************************************************************************************
    1206 *   Class VirtualSystemSortProxyModel implementation.                                                                            *
     1206*   Class UIApplianceSortProxyModel implementation.                                                                              *
    12071207*********************************************************************************************************************************/
    12081208
    12091209/* static */
    1210 KVirtualSystemDescriptionType VirtualSystemSortProxyModel::s_aSortList[] =
     1210KVirtualSystemDescriptionType UIApplianceSortProxyModel::s_aSortList[] =
    12111211{
    12121212    KVirtualSystemDescriptionType_Name,
     
    12321232};
    12331233
    1234 VirtualSystemSortProxyModel::VirtualSystemSortProxyModel(QObject *pParent)
     1234UIApplianceSortProxyModel::UIApplianceSortProxyModel(QObject *pParent)
    12351235    : QSortFilterProxyModel(pParent)
    12361236{
    12371237}
    12381238
    1239 bool VirtualSystemSortProxyModel::filterAcceptsRow(int iSourceRow, const QModelIndex &srcParenIdx) const
     1239bool UIApplianceSortProxyModel::filterAcceptsRow(int iSourceRow, const QModelIndex &srcParenIdx) const
    12401240{
    12411241    /* By default enable all, we will explicitly filter out below */
     
    12451245        if (i.isValid())
    12461246        {
    1247             ModelItem *pItem = static_cast<ModelItem*>(i.internalPointer());
     1247            UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(i.internalPointer());
    12481248            /* We filter hardware types only */
    1249             if (pItem->type() == ApplianceModelItemType_Hardware)
    1250             {
    1251                 HardwareItem *hwItem = static_cast<HardwareItem*>(pItem);
     1249            if (pItem->type() == ApplianceModelItemType_VirtualHardware)
     1250            {
     1251                UIVirtualHardwareItem *hwItem = static_cast<UIVirtualHardwareItem*>(pItem);
    12521252                /* The license type shouldn't be displayed */
    12531253                if (m_aFilteredList.contains(hwItem->m_enmType))
     
    12591259}
    12601260
    1261 bool VirtualSystemSortProxyModel::lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const
     1261bool UIApplianceSortProxyModel::lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const
    12621262{
    12631263    if (!leftIdx.isValid() ||
     
    12651265        return false;
    12661266
    1267     ModelItem *pLeftItem = static_cast<ModelItem*>(leftIdx.internalPointer());
    1268     ModelItem *pRightItem = static_cast<ModelItem*>(rightIdx.internalPointer());
     1267    UIApplianceModelItem *pLeftItem = static_cast<UIApplianceModelItem*>(leftIdx.internalPointer());
     1268    UIApplianceModelItem *pRightItem = static_cast<UIApplianceModelItem*>(rightIdx.internalPointer());
    12691269
    12701270    /* We sort hardware types only */
    1271     if (!(pLeftItem->type() == ApplianceModelItemType_Hardware &&
    1272           pRightItem->type() == ApplianceModelItemType_Hardware))
     1271    if (!(pLeftItem->type() == ApplianceModelItemType_VirtualHardware &&
     1272          pRightItem->type() == ApplianceModelItemType_VirtualHardware))
    12731273        return false;
    12741274
    1275     HardwareItem *pHwLeft = static_cast<HardwareItem*>(pLeftItem);
    1276     HardwareItem *pHwRight = static_cast<HardwareItem*>(pRightItem);
     1275    UIVirtualHardwareItem *pHwLeft = static_cast<UIVirtualHardwareItem*>(pLeftItem);
     1276    UIVirtualHardwareItem *pHwRight = static_cast<UIVirtualHardwareItem*>(pRightItem);
    12771277
    12781278    for (unsigned int i = 0; i < RT_ELEMENTS(s_aSortList); ++i)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.h

    r64691 r64692  
    3333
    3434/* Forward declarations: */
    35 class ModelItem;
     35class UIApplianceModelItem;
    3636class QCheckBox;
    3737class QLabel;
     
    5454    ApplianceModelItemType_Root,
    5555    ApplianceModelItemType_VirtualSystem,
    56     ApplianceModelItemType_Hardware
    57 };
    58 
    59 
    60 /** QAbstractItemModel subclass used as Virtual System model. */
    61 class VirtualSystemModel : public QAbstractItemModel
    62 {
    63 public:
    64 
    65     /** Constructs the Virtual System model passing @a pParent to the base-class.
     56    ApplianceModelItemType_VirtualHardware
     57};
     58
     59
     60/** QAbstractItemModel subclass used as Appliance model. */
     61class UIApplianceModel : public QAbstractItemModel
     62{
     63public:
     64
     65    /** Constructs the Appliance model passing @a pParent to the base-class.
    6666      * @param  aVSDs  Brings the Virtual System descriptions. */
    67     VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = 0);
    68     /** Destructs the Virtual System model. */
    69     ~VirtualSystemModel();
     67    UIApplianceModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = 0);
     68    /** Destructs the Appliance model. */
     69    ~UIApplianceModel();
    7070
    7171    /** Returns the index of the item in the model specified by the given @a iRow, @a iColumn and @a parentIdx. */
     
    101101
    102102    /** Holds the root item reference. */
    103     ModelItem *m_pRootItem;
    104 };
    105 
    106 
    107 /** QItemDelegate subclass used to create various Virtual System model editors. */
    108 class VirtualSystemDelegate : public QItemDelegate
    109 {
    110 public:
    111 
    112     /** Constructs the Virtual System Delegate passing @a pParent to the base-class.
     103    UIApplianceModelItem *m_pRootItem;
     104};
     105
     106
     107/** QItemDelegate subclass used to create various Appliance model editors. */
     108class UIApplianceDelegate : public QItemDelegate
     109{
     110public:
     111
     112    /** Constructs the Appliance Delegate passing @a pParent to the base-class.
    113113      * @param  pProxy  Brings the proxy model reference used to redirect requests to. */
    114     VirtualSystemDelegate(QAbstractProxyModel *pProxy, QObject *pParent = 0);
     114    UIApplianceDelegate(QAbstractProxyModel *pProxy, QObject *pParent = 0);
    115115
    116116    /** Returns the widget used to edit the item specified by @a idx for editing.
     
    144144
    145145
    146 /** QSortFilterProxyModel subclass used as the Virtual System Sorting model. */
    147 class VirtualSystemSortProxyModel : public QSortFilterProxyModel
    148 {
    149 public:
    150 
    151     /** Constructs the Virtual System Sorting model passing @a pParent to the base-class. */
    152     VirtualSystemSortProxyModel(QObject *pParent = 0);
     146/** QSortFilterProxyModel subclass used as the Appliance Sorting Proxy model. */
     147class UIApplianceSortProxyModel : public QSortFilterProxyModel
     148{
     149public:
     150
     151    /** Constructs the Appliance Sorting Proxy model passing @a pParent to the base-class. */
     152    UIApplianceSortProxyModel(QObject *pParent = 0);
    153153
    154154protected:
     
    205205    /** Holds the currently set appliance reference. */
    206206    CAppliance         *m_pAppliance;
    207     /** Holds the Virtual System model reference. */
    208     VirtualSystemModel *m_pModel;
     207    /** Holds the Appliance model reference. */
     208    UIApplianceModel *m_pModel;
    209209
    210210    /** Holds the information pane instance. */
     
    224224private:
    225225
    226     /** Performs Virtual System settings initialization. */
     226    /** Performs Appliance settings initialization. */
    227227    static void initSystemSettings();
    228228
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.cpp

    r64691 r64692  
    3838// ExportSortProxyModel
    3939
    40 class ExportSortProxyModel: public VirtualSystemSortProxyModel
     40class ExportSortProxyModel: public UIApplianceSortProxyModel
    4141{
    4242public:
    4343    ExportSortProxyModel(QObject *pParent = NULL)
    44       : VirtualSystemSortProxyModel(pParent)
     44      : UIApplianceSortProxyModel(pParent)
    4545    {
    4646        m_aFilteredList
     
    8686    QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions();
    8787
    88     m_pModel = new VirtualSystemModel(vsds, this);
     88    m_pModel = new UIApplianceModel(vsds, this);
    8989
    9090    ExportSortProxyModel *pProxy = new ExportSortProxyModel(this);
     
    9292    pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
    9393
    94     VirtualSystemDelegate *pDelegate = new VirtualSystemDelegate(pProxy, this);
     94    UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy, this);
    9595
    9696    /* Set our own model */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.cpp

    r64691 r64692  
    3939// ImportSortProxyModel
    4040
    41 class ImportSortProxyModel: public VirtualSystemSortProxyModel
     41class ImportSortProxyModel: public UIApplianceSortProxyModel
    4242{
    4343public:
    4444    ImportSortProxyModel(QObject *pParent = NULL)
    45       : VirtualSystemSortProxyModel(pParent)
     45      : UIApplianceSortProxyModel(pParent)
    4646    {
    4747        m_aFilteredList << KVirtualSystemDescriptionType_License;
     
    9292                        QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions();
    9393
    94                         m_pModel = new VirtualSystemModel(vsds, this);
     94                        m_pModel = new UIApplianceModel(vsds, this);
    9595
    9696                        ImportSortProxyModel *pProxy = new ImportSortProxyModel(this);
     
    9898                        pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder);
    9999
    100                         VirtualSystemDelegate *pDelegate = new VirtualSystemDelegate(pProxy, this);
     100                        UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy, this);
    101101
    102102                        /* Set our own model */
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