VirtualBox

Changeset 88447 in vbox


Ignore:
Timestamp:
Apr 9, 2021 6:11:58 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143699
Message:

FE/Qt: bugref:9532: Fixing deprecated stuff: Replacing QModelIndex::child with QAbstractItemModel::index.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeView.cpp

    r82968 r88447  
    158158    const QModelIndex itemIndex = item()->modelIndex();
    159159    /* Acquire child model-index: */
    160     const QModelIndex childIndex = itemIndex.child(iIndex, 0);
     160    const QModelIndex childIndex = item()->parentTree()->model()->index(iIndex, 0, itemIndex);
    161161
    162162    /* Check whether we have proxy model set or source one otherwise: */
     
    249249    /* Sanity check: */
    250250    AssertPtrReturn(tree(), 0);
     251    AssertPtrReturn(tree()->model(), 0);
    251252    AssertReturn(iIndex >= 0, 0);
    252253    if (iIndex >= childCount())
     
    262263        // printf("Invalid index: %d\n", iIndex);
    263264
    264         // Sanity check:
    265         AssertPtrReturn(tree()->model(), 0);
    266 
    267265        // Take into account we also have header with 'column count' indexes,
    268266        // so we should start enumerating tree indexes since 'column count'.
     
    273271        QModelIndex index = tree()->rootIndex();
    274272        // But if it has child, go deeper:
    275         if (index.child(0, 0).isValid())
    276             index = index.child(0, 0);
     273        if (tree()->model()->index(0, 0, index).isValid())
     274            index = tree()->model()->index(0, 0, index);
    277275
    278276        // Search for sibling with corresponding index:
     
    300298    const QModelIndex rootIndex = tree()->rootIndex();
    301299    /* Acquire child model-index: */
    302     const QModelIndex childIndex = rootIndex.child(iIndex, 0);
     300    const QModelIndex childIndex = tree()->model()->index(iIndex, 0, rootIndex);
    303301
    304302    /* Check whether we have proxy model set or source one otherwise: */
     
    368366    {
    369367        /* Acquire child model-index: */
    370         const QModelIndex childIndex = parentIndex.child(i, 0);
     368        const QModelIndex childIndex = pModel->index(i, 0, parentIndex);
    371369        /* Acquire source child model-index, which can be the same as child model-index: */
    372370        const QModelIndex sourceChildModelIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex;
     
    385383
    386384    /* Return model-index as child of parent model-index: */
    387     return parentIndex.child(iPositionInParent, 0);
     385    return pModel->index(iPositionInParent, 0, parentIndex);
    388386}
    389387
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r87533 r88447  
    787787    /** Returns item specified by @a iRow, @a iColum and @a parentIndex. */
    788788    QModelIndex index(int iRow, int iColumn, const QModelIndex &parentIndex = QModelIndex()) const;
    789     /** Returns parent item of specified @a index item. */
    790     QModelIndex parent(const QModelIndex &index) const;
    791 
    792     /** Returns model data for specified @a index and @a iRole. */
    793     QVariant data(const QModelIndex &index, int iRole) const;
    794     /** Defines model data for specified @a index and @a iRole as @a value. */
    795     bool setData(const QModelIndex &index, const QVariant &value, int iRole);
     789    /** Returns parent item of @a specifiedIndex item. */
     790    QModelIndex parent(const QModelIndex &specifiedIndex) const;
     791
     792    /** Returns model data for @a specifiedIndex and @a iRole. */
     793    QVariant data(const QModelIndex &specifiedIndex, int iRole) const;
     794    /** Defines model data for @a specifiedIndex and @a iRole as @a value. */
     795    bool setData(const QModelIndex &specifiedIndex, const QVariant &value, int iRole);
    796796
    797797    /** Adds controller with certain @a strCtrName, @a enmBus and @a enmType. */
     
    841841private:
    842842
    843     /** Returns model flags for specified @a index. */
    844     Qt::ItemFlags flags(const QModelIndex &index) const;
     843    /** Returns model flags for @a specifiedIndex. */
     844    Qt::ItemFlags flags(const QModelIndex &specifiedIndex) const;
    845845
    846846    /** Holds the root item instance. */
     
    18411841}
    18421842
    1843 QModelIndex StorageModel::parent(const QModelIndex &index) const
    1844 {
    1845     if (!index.isValid())
     1843QModelIndex StorageModel::parent(const QModelIndex &specifiedIndex) const
     1844{
     1845    if (!specifiedIndex.isValid())
    18461846        return QModelIndex();
    18471847
    1848     AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer());
     1848    AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer());
    18491849    AbstractItem *pParentOfItem = pItem->parent();
    18501850    AbstractItem *pParentOfParent = pParentOfItem ? pParentOfItem->parent() : 0;
     
    18571857}
    18581858
    1859 QVariant StorageModel::data(const QModelIndex &index, int iRole) const
    1860 {
    1861     if (!index.isValid())
     1859QVariant StorageModel::data(const QModelIndex &specifiedIndex, int iRole) const
     1860{
     1861    if (!specifiedIndex.isValid())
    18621862        return QVariant();
    18631863
     
    18711871        case Qt::SizeHintRole:
    18721872        {
    1873             QFontMetrics fm(data(index, Qt::FontRole).value<QFont>());
    1874             int iMinimumHeight = qMax(fm.height(), data(index, R_IconSize).toInt());
    1875             int iMargin = data(index, R_Margin).toInt();
     1873            QFontMetrics fm(data(specifiedIndex, Qt::FontRole).value<QFont>());
     1874            int iMinimumHeight = qMax(fm.height(), data(specifiedIndex, R_IconSize).toInt());
     1875            int iMargin = data(specifiedIndex, R_Margin).toInt();
    18761876            return QSize(1 /* ignoring width */, 2 * iMargin + iMinimumHeight);
    18771877        }
    18781878        case Qt::ToolTipRole:
    18791879        {
    1880             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1880            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    18811881            {
    18821882                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
     
    18861886                    {
    18871887                        case ExpanderToolTip:
    1888                             if (index.child(0, 0).isValid())
     1888                            if (index(0, 0, specifiedIndex).isValid())
    18891889                                strTip = UIMachineSettingsStorage::tr("<nobr>Expands/Collapses&nbsp;item.</nobr>");
    18901890                            break;
     
    19111911        case R_ItemId:
    19121912        {
    1913             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1913            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    19141914                return pItem->id();
    19151915            return QUuid();
     
    19171917        case R_ItemPixmap:
    19181918        {
    1919             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1919            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    19201920            {
    19211921                ItemState enmState = State_DefaultItem;
    1922                 if (hasChildren(index))
     1922                if (hasChildren(specifiedIndex))
    19231923                    if (QTreeView *view = qobject_cast<QTreeView*>(QObject::parent()))
    1924                         enmState = view->isExpanded(index) ? State_ExpandedItem : State_CollapsedItem;
     1924                        enmState = view->isExpanded(specifiedIndex) ? State_ExpandedItem : State_CollapsedItem;
    19251925                return pItem->pixmap(enmState);
    19261926            }
     
    19291929        case R_ItemPixmapRect:
    19301930        {
    1931             int iMargin = data(index, R_Margin).toInt();
    1932             int iWidth = data(index, R_IconSize).toInt();
     1931            int iMargin = data(specifiedIndex, R_Margin).toInt();
     1932            int iWidth = data(specifiedIndex, R_IconSize).toInt();
    19331933            return QRect(iMargin, iMargin, iWidth, iWidth);
    19341934        }
    19351935        case R_ItemName:
    19361936        {
    1937             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1937            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    19381938                return pItem->text();
    19391939            return QString();
     
    19411941        case R_ItemNamePoint:
    19421942        {
    1943             int iMargin = data(index, R_Margin).toInt();
    1944             int iSpacing = data(index, R_Spacing).toInt();
    1945             int iWidth = data(index, R_IconSize).toInt();
    1946             QFontMetrics fm(data(index, Qt::FontRole).value<QFont>());
    1947             QSize sizeHint = data(index, Qt::SizeHintRole).toSize();
     1943            int iMargin = data(specifiedIndex, R_Margin).toInt();
     1944            int iSpacing = data(specifiedIndex, R_Spacing).toInt();
     1945            int iWidth = data(specifiedIndex, R_IconSize).toInt();
     1946            QFontMetrics fm(data(specifiedIndex, Qt::FontRole).value<QFont>());
     1947            QSize sizeHint = data(specifiedIndex, Qt::SizeHintRole).toSize();
    19481948            return QPoint(iMargin + iWidth + 2 * iSpacing,
    19491949                          sizeHint.height() / 2 + fm.ascent() / 2 - 1 /* base line */);
     
    19521952        {
    19531953            QVariant result(QVariant::fromValue(AbstractItem::Type_InvalidItem));
    1954             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1954            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    19551955                result.setValue(pItem->rtti());
    19561956            return result;
     
    19581958        case R_IsController:
    19591959        {
    1960             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1960            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    19611961                return pItem->rtti() == AbstractItem::Type_ControllerItem;
    19621962            return false;
     
    19641964        case R_IsAttachment:
    19651965        {
    1966             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     1966            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    19671967                return pItem->rtti() == AbstractItem::Type_AttachmentItem;
    19681968            return false;
     
    20232023        case R_IsMoreAttachmentsPossible:
    20242024        {
    2025             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2025            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    20262026            {
    20272027                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
     
    20292029                    ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem);
    20302030                    CSystemProperties comProps = uiCommon().virtualBox().GetSystemProperties();
    2031                     const bool fIsMoreAttachmentsPossible = (ULONG)rowCount(index) <
     2031                    const bool fIsMoreAttachmentsPossible = (ULONG)rowCount(specifiedIndex) <
    20322032                                                            (comProps.GetMaxPortCountForStorageBus(pItemController->bus()) *
    20332033                                                             comProps.GetMaxDevicesPerPortForStorageBus(pItemController->bus()));
     
    20452045                                        return true;
    20462046                                    case KStorageBus_SATA:
    2047                                         return (uint)rowCount(index) < pItemController->portCount();
     2047                                        return (uint)rowCount(specifiedIndex) < pItemController->portCount();
    20482048                                    default:
    20492049                                        break;
     
    20612061        case R_CtrOldName:
    20622062        {
    2063             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2063            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    20642064                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    20652065                    return qobject_cast<ControllerItem*>(pItem)->oldName();
     
    20682068        case R_CtrName:
    20692069        {
    2070             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2070            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    20712071                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    20722072                    return qobject_cast<ControllerItem*>(pItem)->name();
     
    20762076        {
    20772077            QVariant result(QVariant::fromValue(KStorageControllerType_Null));
    2078             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2078            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    20792079                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    20802080                    result.setValue(qobject_cast<ControllerItem*>(pItem)->type());
     
    20912091        {
    20922092            QVariant result(QVariant::fromValue(ControllerTypeList()));
    2093             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2093            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    20942094                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    20952095                    result.setValue(qobject_cast<ControllerItem*>(pItem)->types(roleToBus((StorageModel::DataRole)iRole)));
     
    20992099        {
    21002100            QVariant result(QVariant::fromValue(DeviceTypeList()));
    2101             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2101            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21022102                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    21032103                    result.setValue(qobject_cast<ControllerItem*>(pItem)->deviceTypeList());
     
    21072107        {
    21082108            QVariant result(QVariant::fromValue(KStorageBus_Null));
    2109             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2109            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21102110                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    21112111                    result.setValue(qobject_cast<ControllerItem*>(pItem)->bus());
     
    21152115        {
    21162116            QVariant result(QVariant::fromValue(ControllerBusList()));
    2117             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2117            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21182118                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    21192119                    result.setValue(qobject_cast<ControllerItem*>(pItem)->buses());
     
    21222122        case R_CtrPortCount:
    21232123        {
    2124             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2124            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21252125                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    21262126                    return qobject_cast<ControllerItem*>(pItem)->portCount();
     
    21292129        case R_CtrMaxPortCount:
    21302130        {
    2131             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2131            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21322132                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    21332133                    return qobject_cast<ControllerItem*>(pItem)->maxPortCount();
     
    21362136        case R_CtrIoCache:
    21372137        {
    2138             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2138            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21392139                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    21402140                    return qobject_cast<ControllerItem*>(pItem)->useIoCache();
     
    21452145        {
    21462146            QVariant result(QVariant::fromValue(StorageSlot()));
    2147             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2147            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21482148                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21492149                    result.setValue(qobject_cast<AttachmentItem*>(pItem)->storageSlot());
     
    21532153        {
    21542154            QVariant result(QVariant::fromValue(SlotsList()));
    2155             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2155            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21562156                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21572157                    result.setValue(qobject_cast<AttachmentItem*>(pItem)->storageSlots());
     
    21612161        {
    21622162            QVariant result(QVariant::fromValue(KDeviceType_Null));
    2163             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2163            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21642164                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21652165                    result.setValue(qobject_cast<AttachmentItem*>(pItem)->deviceType());
     
    21682168        case R_AttMediumId:
    21692169        {
    2170             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2170            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21712171                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21722172                    return qobject_cast<AttachmentItem*>(pItem)->mediumId();
     
    21752175        case R_AttIsHostDrive:
    21762176        {
    2177             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2177            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21782178                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21792179                    return qobject_cast<AttachmentItem*>(pItem)->isHostDrive();
     
    21822182        case R_AttIsPassthrough:
    21832183        {
    2184             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2184            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21852185                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21862186                    return qobject_cast<AttachmentItem*>(pItem)->isPassthrough();
     
    21892189        case R_AttIsTempEject:
    21902190        {
    2191             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2191            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21922192                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    21932193                    return qobject_cast<AttachmentItem*>(pItem)->isTempEject();
     
    21962196        case R_AttIsNonRotational:
    21972197        {
    2198             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2198            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    21992199                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22002200                    return qobject_cast<AttachmentItem*>(pItem)->isNonRotational();
     
    22032203        case R_AttIsHotPluggable:
    22042204        {
    2205             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2205            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22062206                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22072207                    return qobject_cast<AttachmentItem*>(pItem)->isHotPluggable();
     
    22102210        case R_AttSize:
    22112211        {
    2212             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2212            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22132213                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22142214                    return qobject_cast<AttachmentItem*>(pItem)->size();
     
    22172217        case R_AttLogicalSize:
    22182218        {
    2219             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2219            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22202220                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22212221                    return qobject_cast<AttachmentItem*>(pItem)->logicalSize();
     
    22242224        case R_AttLocation:
    22252225        {
    2226             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2226            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22272227                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22282228                    return qobject_cast<AttachmentItem*>(pItem)->location();
     
    22312231        case R_AttFormat:
    22322232        {
    2233             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2233            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22342234                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22352235                    return qobject_cast<AttachmentItem*>(pItem)->format();
     
    22382238        case R_AttDetails:
    22392239        {
    2240             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2240            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22412241                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22422242                    return qobject_cast<AttachmentItem*>(pItem)->details();
     
    22452245        case R_AttUsage:
    22462246        {
    2247             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2247            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22482248                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22492249                    return qobject_cast<AttachmentItem*>(pItem)->usage();
     
    22522252        case R_AttEncryptionPasswordID:
    22532253        {
    2254             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2254            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    22552255                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    22562256                    return qobject_cast<AttachmentItem*>(pItem)->encryptionPasswordId();
     
    23092309        case R_HDPixmapRect:
    23102310        {
    2311             int iMargin = data(index, R_Margin).toInt();
    2312             int iWidth = data(index, R_IconSize).toInt();
     2311            int iMargin = data(specifiedIndex, R_Margin).toInt();
     2312            int iWidth = data(specifiedIndex, R_IconSize).toInt();
    23132313            return QRect(0 - iWidth - iMargin, iMargin, iWidth, iWidth);
    23142314        }
    23152315        case R_CDPixmapRect:
    23162316        {
    2317             int iMargin = data(index, R_Margin).toInt();
    2318             int iSpacing = data(index, R_Spacing).toInt();
    2319             int iWidth = data(index, R_IconSize).toInt();
     2317            int iMargin = data(specifiedIndex, R_Margin).toInt();
     2318            int iSpacing = data(specifiedIndex, R_Spacing).toInt();
     2319            int iWidth = data(specifiedIndex, R_IconSize).toInt();
    23202320            return QRect(0 - iWidth - iSpacing - iWidth - iMargin, iMargin, iWidth, iWidth);
    23212321        }
    23222322        case R_FDPixmapRect:
    23232323        {
    2324             int iMargin = data(index, R_Margin).toInt();
    2325             int iWidth = data(index, R_IconSize).toInt();
     2324            int iMargin = data(specifiedIndex, R_Margin).toInt();
     2325            int iWidth = data(specifiedIndex, R_IconSize).toInt();
    23262326            return QRect(0 - iWidth - iMargin, iMargin, iWidth, iWidth);
    23272327        }
     
    23332333}
    23342334
    2335 bool StorageModel::setData(const QModelIndex &index, const QVariant &aValue, int iRole)
    2336 {
    2337     if (!index.isValid())
    2338         return QAbstractItemModel::setData(index, aValue, iRole);
     2335bool StorageModel::setData(const QModelIndex &specifiedIndex, const QVariant &aValue, int iRole)
     2336{
     2337    if (!specifiedIndex.isValid())
     2338        return QAbstractItemModel::setData(specifiedIndex, aValue, iRole);
    23392339
    23402340    switch (iRole)
     
    23432343        {
    23442344            m_enmToolTipType = aValue.value<ToolTipType>();
    2345             emit dataChanged(index, index);
     2345            emit dataChanged(specifiedIndex, specifiedIndex);
    23462346            return true;
    23472347        }
    23482348        case R_CtrName:
    23492349        {
    2350             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2350            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    23512351                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    23522352                {
    23532353                    qobject_cast<ControllerItem*>(pItem)->setName(aValue.toString());
    2354                     emit dataChanged(index, index);
     2354                    emit dataChanged(specifiedIndex, specifiedIndex);
    23552355                    return true;
    23562356                }
     
    23592359        case R_CtrBusType:
    23602360        {
    2361             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2361            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    23622362                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    23632363                {
     
    23972397                    pItemController->setBus(enmNewCtrBusType);
    23982398                    pItemController->setType(pItemController->types(enmNewCtrBusType).first());
    2399                     emit dataChanged(index, index);
     2399                    emit dataChanged(specifiedIndex, specifiedIndex);
    24002400
    24012401                    /* Make sure each of remaining attachments has valid slot: */
     
    24162416        case R_CtrType:
    24172417        {
    2418             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2418            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24192419                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    24202420                {
    24212421                    qobject_cast<ControllerItem*>(pItem)->setType(aValue.value<KStorageControllerType>());
    2422                     emit dataChanged(index, index);
     2422                    emit dataChanged(specifiedIndex, specifiedIndex);
    24232423                    return true;
    24242424                }
     
    24272427        case R_CtrPortCount:
    24282428        {
    2429             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2429            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24302430                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    24312431                {
    24322432                    qobject_cast<ControllerItem*>(pItem)->setPortCount(aValue.toUInt());
    2433                     emit dataChanged(index, index);
     2433                    emit dataChanged(specifiedIndex, specifiedIndex);
    24342434                    return true;
    24352435                }
     
    24382438        case R_CtrIoCache:
    24392439        {
    2440             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2440            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24412441                if (pItem->rtti() == AbstractItem::Type_ControllerItem)
    24422442                {
    24432443                    qobject_cast<ControllerItem*>(pItem)->setUseIoCache(aValue.toBool());
    2444                     emit dataChanged(index, index);
     2444                    emit dataChanged(specifiedIndex, specifiedIndex);
    24452445                    return true;
    24462446                }
     
    24492449        case R_AttSlot:
    24502450        {
    2451             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2451            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24522452                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    24532453                {
    24542454                    qobject_cast<AttachmentItem*>(pItem)->setStorageSlot(aValue.value<StorageSlot>());
    2455                     emit dataChanged(index, index);
     2455                    emit dataChanged(specifiedIndex, specifiedIndex);
    24562456                    sort();
    24572457                    return true;
     
    24612461        case R_AttDevice:
    24622462        {
    2463             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2463            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24642464                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    24652465                {
    24662466                    qobject_cast<AttachmentItem*>(pItem)->setDeviceType(aValue.value<KDeviceType>());
    2467                     emit dataChanged(index, index);
     2467                    emit dataChanged(specifiedIndex, specifiedIndex);
    24682468                    return true;
    24692469                }
     
    24722472        case R_AttMediumId:
    24732473        {
    2474             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2474            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24752475                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    24762476                {
    24772477                    qobject_cast<AttachmentItem*>(pItem)->setMediumId(aValue.toUuid());
    2478                     emit dataChanged(index, index);
     2478                    emit dataChanged(specifiedIndex, specifiedIndex);
    24792479                    return true;
    24802480                }
     
    24832483        case R_AttIsPassthrough:
    24842484        {
    2485             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2485            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24862486                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    24872487                {
    24882488                    qobject_cast<AttachmentItem*>(pItem)->setPassthrough(aValue.toBool());
    2489                     emit dataChanged(index, index);
     2489                    emit dataChanged(specifiedIndex, specifiedIndex);
    24902490                    return true;
    24912491                }
     
    24942494        case R_AttIsTempEject:
    24952495        {
    2496             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2496            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    24972497                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    24982498                {
    24992499                    qobject_cast<AttachmentItem*>(pItem)->setTempEject(aValue.toBool());
    2500                     emit dataChanged(index, index);
     2500                    emit dataChanged(specifiedIndex, specifiedIndex);
    25012501                    return true;
    25022502                }
     
    25052505        case R_AttIsNonRotational:
    25062506        {
    2507             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2507            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    25082508                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    25092509                {
    25102510                    qobject_cast<AttachmentItem*>(pItem)->setNonRotational(aValue.toBool());
    2511                     emit dataChanged(index, index);
     2511                    emit dataChanged(specifiedIndex, specifiedIndex);
    25122512                    return true;
    25132513                }
     
    25162516        case R_AttIsHotPluggable:
    25172517        {
    2518             if (AbstractItem *pItem = static_cast<AbstractItem*>(index.internalPointer()))
     2518            if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()))
    25192519                if (pItem->rtti() == AbstractItem::Type_AttachmentItem)
    25202520                {
    25212521                    qobject_cast<AttachmentItem*>(pItem)->setHotPluggable(aValue.toBool());
    2522                     emit dataChanged(index, index);
     2522                    emit dataChanged(specifiedIndex, specifiedIndex);
    25232523                    return true;
    25242524                }
     
    28172817}
    28182818
    2819 Qt::ItemFlags StorageModel::flags(const QModelIndex &index) const
    2820 {
    2821     return !index.isValid() ? QAbstractItemModel::flags(index) :
     2819Qt::ItemFlags StorageModel::flags(const QModelIndex &specifiedIndex) const
     2820{
     2821    return !specifiedIndex.isValid() ? QAbstractItemModel::flags(specifiedIndex) :
    28222822           Qt::ItemIsEnabled | Qt::ItemIsSelectable;
    28232823}
     
    32623262    for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
    32633263    {
    3264         const QModelIndex controllerIndex = rootIndex.child(i, 0);
     3264        const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex);
    32653265        const QString ctrName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString();
    32663266
     
    32843284        for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j)
    32853285        {
    3286             const QModelIndex attachmentIndex = controllerIndex.child(j, 0);
     3286            const QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex);
    32873287            const StorageSlot attSlot = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttSlot).value<StorageSlot>();
    32883288            const KDeviceType enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>();
     
    34943494    for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
    34953495    {
    3496         const QModelIndex controllerIndex = rootIndex.child(i, 0);
     3496        const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex);
    34973497        for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j)
    34983498        {
    3499             const QModelIndex attachmentIndex = controllerIndex.child(j, 0);
     3499            const QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex);
    35003500            const QUuid attMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString();
    35013501            if (attMediumId == medium.id())
     
    35153515    for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
    35163516    {
    3517         QModelIndex controllerIndex = rootIndex.child(i, 0);
     3517        QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex);
    35183518        for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j)
    35193519        {
    3520             QModelIndex attachmentIndex = controllerIndex.child(j, 0);
     3520            QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex);
    35213521            QUuid attMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString();
    35223522            if (attMediumId == uMediumId)
     
    52695269    for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
    52705270    {
    5271         const QModelIndex controllerIndex = rootIndex.child(i, 0);
     5271        const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex);
    52725272        const QString strName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString();
    52735273        if (strName.startsWith(strTemplate))
     
    52885288    for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
    52895289    {
    5290         const QModelIndex controllerIndex = rootIndex.child(i, 0);
     5290        const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex);
    52915291        for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j)
    52925292        {
    5293             const QModelIndex attachmentIndex = controllerIndex.child(j, 0);
     5293            const QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex);
    52945294            const KDeviceType enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>();
    52955295            if (enmDeviceType == enmType)
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r87719 r88447  
    17061706    if (srcParenIdx.isValid())
    17071707    {
    1708         QModelIndex i = srcParenIdx.child(iSourceRow, 0);
     1708        QModelIndex i = index(iSourceRow, 0, srcParenIdx);
    17091709        if (i.isValid())
    17101710        {
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