Changeset 88447 in vbox
- Timestamp:
- Apr 9, 2021 6:11:58 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143699
- 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 158 158 const QModelIndex itemIndex = item()->modelIndex(); 159 159 /* Acquire child model-index: */ 160 const QModelIndex childIndex = item Index.child(iIndex, 0);160 const QModelIndex childIndex = item()->parentTree()->model()->index(iIndex, 0, itemIndex); 161 161 162 162 /* Check whether we have proxy model set or source one otherwise: */ … … 249 249 /* Sanity check: */ 250 250 AssertPtrReturn(tree(), 0); 251 AssertPtrReturn(tree()->model(), 0); 251 252 AssertReturn(iIndex >= 0, 0); 252 253 if (iIndex >= childCount()) … … 262 263 // printf("Invalid index: %d\n", iIndex); 263 264 264 // Sanity check:265 AssertPtrReturn(tree()->model(), 0);266 267 265 // Take into account we also have header with 'column count' indexes, 268 266 // so we should start enumerating tree indexes since 'column count'. … … 273 271 QModelIndex index = tree()->rootIndex(); 274 272 // 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); 277 275 278 276 // Search for sibling with corresponding index: … … 300 298 const QModelIndex rootIndex = tree()->rootIndex(); 301 299 /* Acquire child model-index: */ 302 const QModelIndex childIndex = rootIndex.child(iIndex, 0);300 const QModelIndex childIndex = tree()->model()->index(iIndex, 0, rootIndex); 303 301 304 302 /* Check whether we have proxy model set or source one otherwise: */ … … 368 366 { 369 367 /* Acquire child model-index: */ 370 const QModelIndex childIndex = p arentIndex.child(i, 0);368 const QModelIndex childIndex = pModel->index(i, 0, parentIndex); 371 369 /* Acquire source child model-index, which can be the same as child model-index: */ 372 370 const QModelIndex sourceChildModelIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex; … … 385 383 386 384 /* Return model-index as child of parent model-index: */ 387 return p arentIndex.child(iPositionInParent, 0);385 return pModel->index(iPositionInParent, 0, parentIndex); 388 386 } 389 387 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r87533 r88447 787 787 /** Returns item specified by @a iRow, @a iColum and @a parentIndex. */ 788 788 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); 796 796 797 797 /** Adds controller with certain @a strCtrName, @a enmBus and @a enmType. */ … … 841 841 private: 842 842 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; 845 845 846 846 /** Holds the root item instance. */ … … 1841 1841 } 1842 1842 1843 QModelIndex StorageModel::parent(const QModelIndex & index) const1844 { 1845 if (! index.isValid())1843 QModelIndex StorageModel::parent(const QModelIndex &specifiedIndex) const 1844 { 1845 if (!specifiedIndex.isValid()) 1846 1846 return QModelIndex(); 1847 1847 1848 AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer());1848 AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer()); 1849 1849 AbstractItem *pParentOfItem = pItem->parent(); 1850 1850 AbstractItem *pParentOfParent = pParentOfItem ? pParentOfItem->parent() : 0; … … 1857 1857 } 1858 1858 1859 QVariant StorageModel::data(const QModelIndex & index, int iRole) const1860 { 1861 if (! index.isValid())1859 QVariant StorageModel::data(const QModelIndex &specifiedIndex, int iRole) const 1860 { 1861 if (!specifiedIndex.isValid()) 1862 1862 return QVariant(); 1863 1863 … … 1871 1871 case Qt::SizeHintRole: 1872 1872 { 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(); 1876 1876 return QSize(1 /* ignoring width */, 2 * iMargin + iMinimumHeight); 1877 1877 } 1878 1878 case Qt::ToolTipRole: 1879 1879 { 1880 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))1880 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1881 1881 { 1882 1882 if (pItem->rtti() == AbstractItem::Type_ControllerItem) … … 1886 1886 { 1887 1887 case ExpanderToolTip: 1888 if (index .child(0, 0).isValid())1888 if (index(0, 0, specifiedIndex).isValid()) 1889 1889 strTip = UIMachineSettingsStorage::tr("<nobr>Expands/Collapses item.</nobr>"); 1890 1890 break; … … 1911 1911 case R_ItemId: 1912 1912 { 1913 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))1913 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1914 1914 return pItem->id(); 1915 1915 return QUuid(); … … 1917 1917 case R_ItemPixmap: 1918 1918 { 1919 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))1919 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1920 1920 { 1921 1921 ItemState enmState = State_DefaultItem; 1922 if (hasChildren( index))1922 if (hasChildren(specifiedIndex)) 1923 1923 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; 1925 1925 return pItem->pixmap(enmState); 1926 1926 } … … 1929 1929 case R_ItemPixmapRect: 1930 1930 { 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(); 1933 1933 return QRect(iMargin, iMargin, iWidth, iWidth); 1934 1934 } 1935 1935 case R_ItemName: 1936 1936 { 1937 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))1937 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1938 1938 return pItem->text(); 1939 1939 return QString(); … … 1941 1941 case R_ItemNamePoint: 1942 1942 { 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(); 1948 1948 return QPoint(iMargin + iWidth + 2 * iSpacing, 1949 1949 sizeHint.height() / 2 + fm.ascent() / 2 - 1 /* base line */); … … 1952 1952 { 1953 1953 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())) 1955 1955 result.setValue(pItem->rtti()); 1956 1956 return result; … … 1958 1958 case R_IsController: 1959 1959 { 1960 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))1960 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1961 1961 return pItem->rtti() == AbstractItem::Type_ControllerItem; 1962 1962 return false; … … 1964 1964 case R_IsAttachment: 1965 1965 { 1966 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))1966 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1967 1967 return pItem->rtti() == AbstractItem::Type_AttachmentItem; 1968 1968 return false; … … 2023 2023 case R_IsMoreAttachmentsPossible: 2024 2024 { 2025 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2025 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2026 2026 { 2027 2027 if (pItem->rtti() == AbstractItem::Type_ControllerItem) … … 2029 2029 ControllerItem *pItemController = qobject_cast<ControllerItem*>(pItem); 2030 2030 CSystemProperties comProps = uiCommon().virtualBox().GetSystemProperties(); 2031 const bool fIsMoreAttachmentsPossible = (ULONG)rowCount( index) <2031 const bool fIsMoreAttachmentsPossible = (ULONG)rowCount(specifiedIndex) < 2032 2032 (comProps.GetMaxPortCountForStorageBus(pItemController->bus()) * 2033 2033 comProps.GetMaxDevicesPerPortForStorageBus(pItemController->bus())); … … 2045 2045 return true; 2046 2046 case KStorageBus_SATA: 2047 return (uint)rowCount( index) < pItemController->portCount();2047 return (uint)rowCount(specifiedIndex) < pItemController->portCount(); 2048 2048 default: 2049 2049 break; … … 2061 2061 case R_CtrOldName: 2062 2062 { 2063 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2063 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2064 2064 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2065 2065 return qobject_cast<ControllerItem*>(pItem)->oldName(); … … 2068 2068 case R_CtrName: 2069 2069 { 2070 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2070 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2071 2071 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2072 2072 return qobject_cast<ControllerItem*>(pItem)->name(); … … 2076 2076 { 2077 2077 QVariant result(QVariant::fromValue(KStorageControllerType_Null)); 2078 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2078 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2079 2079 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2080 2080 result.setValue(qobject_cast<ControllerItem*>(pItem)->type()); … … 2091 2091 { 2092 2092 QVariant result(QVariant::fromValue(ControllerTypeList())); 2093 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2093 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2094 2094 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2095 2095 result.setValue(qobject_cast<ControllerItem*>(pItem)->types(roleToBus((StorageModel::DataRole)iRole))); … … 2099 2099 { 2100 2100 QVariant result(QVariant::fromValue(DeviceTypeList())); 2101 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2101 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2102 2102 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2103 2103 result.setValue(qobject_cast<ControllerItem*>(pItem)->deviceTypeList()); … … 2107 2107 { 2108 2108 QVariant result(QVariant::fromValue(KStorageBus_Null)); 2109 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2109 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2110 2110 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2111 2111 result.setValue(qobject_cast<ControllerItem*>(pItem)->bus()); … … 2115 2115 { 2116 2116 QVariant result(QVariant::fromValue(ControllerBusList())); 2117 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2117 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2118 2118 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2119 2119 result.setValue(qobject_cast<ControllerItem*>(pItem)->buses()); … … 2122 2122 case R_CtrPortCount: 2123 2123 { 2124 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2124 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2125 2125 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2126 2126 return qobject_cast<ControllerItem*>(pItem)->portCount(); … … 2129 2129 case R_CtrMaxPortCount: 2130 2130 { 2131 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2131 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2132 2132 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2133 2133 return qobject_cast<ControllerItem*>(pItem)->maxPortCount(); … … 2136 2136 case R_CtrIoCache: 2137 2137 { 2138 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2138 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2139 2139 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2140 2140 return qobject_cast<ControllerItem*>(pItem)->useIoCache(); … … 2145 2145 { 2146 2146 QVariant result(QVariant::fromValue(StorageSlot())); 2147 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2147 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2148 2148 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2149 2149 result.setValue(qobject_cast<AttachmentItem*>(pItem)->storageSlot()); … … 2153 2153 { 2154 2154 QVariant result(QVariant::fromValue(SlotsList())); 2155 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2155 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2156 2156 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2157 2157 result.setValue(qobject_cast<AttachmentItem*>(pItem)->storageSlots()); … … 2161 2161 { 2162 2162 QVariant result(QVariant::fromValue(KDeviceType_Null)); 2163 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2163 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2164 2164 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2165 2165 result.setValue(qobject_cast<AttachmentItem*>(pItem)->deviceType()); … … 2168 2168 case R_AttMediumId: 2169 2169 { 2170 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2170 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2171 2171 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2172 2172 return qobject_cast<AttachmentItem*>(pItem)->mediumId(); … … 2175 2175 case R_AttIsHostDrive: 2176 2176 { 2177 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2177 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2178 2178 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2179 2179 return qobject_cast<AttachmentItem*>(pItem)->isHostDrive(); … … 2182 2182 case R_AttIsPassthrough: 2183 2183 { 2184 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2184 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2185 2185 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2186 2186 return qobject_cast<AttachmentItem*>(pItem)->isPassthrough(); … … 2189 2189 case R_AttIsTempEject: 2190 2190 { 2191 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2191 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2192 2192 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2193 2193 return qobject_cast<AttachmentItem*>(pItem)->isTempEject(); … … 2196 2196 case R_AttIsNonRotational: 2197 2197 { 2198 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2198 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2199 2199 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2200 2200 return qobject_cast<AttachmentItem*>(pItem)->isNonRotational(); … … 2203 2203 case R_AttIsHotPluggable: 2204 2204 { 2205 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2205 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2206 2206 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2207 2207 return qobject_cast<AttachmentItem*>(pItem)->isHotPluggable(); … … 2210 2210 case R_AttSize: 2211 2211 { 2212 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2212 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2213 2213 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2214 2214 return qobject_cast<AttachmentItem*>(pItem)->size(); … … 2217 2217 case R_AttLogicalSize: 2218 2218 { 2219 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2219 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2220 2220 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2221 2221 return qobject_cast<AttachmentItem*>(pItem)->logicalSize(); … … 2224 2224 case R_AttLocation: 2225 2225 { 2226 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2226 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2227 2227 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2228 2228 return qobject_cast<AttachmentItem*>(pItem)->location(); … … 2231 2231 case R_AttFormat: 2232 2232 { 2233 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2233 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2234 2234 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2235 2235 return qobject_cast<AttachmentItem*>(pItem)->format(); … … 2238 2238 case R_AttDetails: 2239 2239 { 2240 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2240 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2241 2241 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2242 2242 return qobject_cast<AttachmentItem*>(pItem)->details(); … … 2245 2245 case R_AttUsage: 2246 2246 { 2247 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2247 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2248 2248 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2249 2249 return qobject_cast<AttachmentItem*>(pItem)->usage(); … … 2252 2252 case R_AttEncryptionPasswordID: 2253 2253 { 2254 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2254 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2255 2255 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2256 2256 return qobject_cast<AttachmentItem*>(pItem)->encryptionPasswordId(); … … 2309 2309 case R_HDPixmapRect: 2310 2310 { 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(); 2313 2313 return QRect(0 - iWidth - iMargin, iMargin, iWidth, iWidth); 2314 2314 } 2315 2315 case R_CDPixmapRect: 2316 2316 { 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(); 2320 2320 return QRect(0 - iWidth - iSpacing - iWidth - iMargin, iMargin, iWidth, iWidth); 2321 2321 } 2322 2322 case R_FDPixmapRect: 2323 2323 { 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(); 2326 2326 return QRect(0 - iWidth - iMargin, iMargin, iWidth, iWidth); 2327 2327 } … … 2333 2333 } 2334 2334 2335 bool StorageModel::setData(const QModelIndex & index, const QVariant &aValue, int iRole)2336 { 2337 if (! index.isValid())2338 return QAbstractItemModel::setData( index, aValue, iRole);2335 bool StorageModel::setData(const QModelIndex &specifiedIndex, const QVariant &aValue, int iRole) 2336 { 2337 if (!specifiedIndex.isValid()) 2338 return QAbstractItemModel::setData(specifiedIndex, aValue, iRole); 2339 2339 2340 2340 switch (iRole) … … 2343 2343 { 2344 2344 m_enmToolTipType = aValue.value<ToolTipType>(); 2345 emit dataChanged( index, index);2345 emit dataChanged(specifiedIndex, specifiedIndex); 2346 2346 return true; 2347 2347 } 2348 2348 case R_CtrName: 2349 2349 { 2350 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2350 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2351 2351 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2352 2352 { 2353 2353 qobject_cast<ControllerItem*>(pItem)->setName(aValue.toString()); 2354 emit dataChanged( index, index);2354 emit dataChanged(specifiedIndex, specifiedIndex); 2355 2355 return true; 2356 2356 } … … 2359 2359 case R_CtrBusType: 2360 2360 { 2361 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2361 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2362 2362 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2363 2363 { … … 2397 2397 pItemController->setBus(enmNewCtrBusType); 2398 2398 pItemController->setType(pItemController->types(enmNewCtrBusType).first()); 2399 emit dataChanged( index, index);2399 emit dataChanged(specifiedIndex, specifiedIndex); 2400 2400 2401 2401 /* Make sure each of remaining attachments has valid slot: */ … … 2416 2416 case R_CtrType: 2417 2417 { 2418 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2418 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2419 2419 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2420 2420 { 2421 2421 qobject_cast<ControllerItem*>(pItem)->setType(aValue.value<KStorageControllerType>()); 2422 emit dataChanged( index, index);2422 emit dataChanged(specifiedIndex, specifiedIndex); 2423 2423 return true; 2424 2424 } … … 2427 2427 case R_CtrPortCount: 2428 2428 { 2429 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2429 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2430 2430 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2431 2431 { 2432 2432 qobject_cast<ControllerItem*>(pItem)->setPortCount(aValue.toUInt()); 2433 emit dataChanged( index, index);2433 emit dataChanged(specifiedIndex, specifiedIndex); 2434 2434 return true; 2435 2435 } … … 2438 2438 case R_CtrIoCache: 2439 2439 { 2440 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2440 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2441 2441 if (pItem->rtti() == AbstractItem::Type_ControllerItem) 2442 2442 { 2443 2443 qobject_cast<ControllerItem*>(pItem)->setUseIoCache(aValue.toBool()); 2444 emit dataChanged( index, index);2444 emit dataChanged(specifiedIndex, specifiedIndex); 2445 2445 return true; 2446 2446 } … … 2449 2449 case R_AttSlot: 2450 2450 { 2451 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2451 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2452 2452 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2453 2453 { 2454 2454 qobject_cast<AttachmentItem*>(pItem)->setStorageSlot(aValue.value<StorageSlot>()); 2455 emit dataChanged( index, index);2455 emit dataChanged(specifiedIndex, specifiedIndex); 2456 2456 sort(); 2457 2457 return true; … … 2461 2461 case R_AttDevice: 2462 2462 { 2463 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2463 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2464 2464 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2465 2465 { 2466 2466 qobject_cast<AttachmentItem*>(pItem)->setDeviceType(aValue.value<KDeviceType>()); 2467 emit dataChanged( index, index);2467 emit dataChanged(specifiedIndex, specifiedIndex); 2468 2468 return true; 2469 2469 } … … 2472 2472 case R_AttMediumId: 2473 2473 { 2474 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2474 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2475 2475 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2476 2476 { 2477 2477 qobject_cast<AttachmentItem*>(pItem)->setMediumId(aValue.toUuid()); 2478 emit dataChanged( index, index);2478 emit dataChanged(specifiedIndex, specifiedIndex); 2479 2479 return true; 2480 2480 } … … 2483 2483 case R_AttIsPassthrough: 2484 2484 { 2485 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2485 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2486 2486 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2487 2487 { 2488 2488 qobject_cast<AttachmentItem*>(pItem)->setPassthrough(aValue.toBool()); 2489 emit dataChanged( index, index);2489 emit dataChanged(specifiedIndex, specifiedIndex); 2490 2490 return true; 2491 2491 } … … 2494 2494 case R_AttIsTempEject: 2495 2495 { 2496 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2496 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2497 2497 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2498 2498 { 2499 2499 qobject_cast<AttachmentItem*>(pItem)->setTempEject(aValue.toBool()); 2500 emit dataChanged( index, index);2500 emit dataChanged(specifiedIndex, specifiedIndex); 2501 2501 return true; 2502 2502 } … … 2505 2505 case R_AttIsNonRotational: 2506 2506 { 2507 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2507 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2508 2508 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2509 2509 { 2510 2510 qobject_cast<AttachmentItem*>(pItem)->setNonRotational(aValue.toBool()); 2511 emit dataChanged( index, index);2511 emit dataChanged(specifiedIndex, specifiedIndex); 2512 2512 return true; 2513 2513 } … … 2516 2516 case R_AttIsHotPluggable: 2517 2517 { 2518 if (AbstractItem *pItem = static_cast<AbstractItem*>( index.internalPointer()))2518 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 2519 2519 if (pItem->rtti() == AbstractItem::Type_AttachmentItem) 2520 2520 { 2521 2521 qobject_cast<AttachmentItem*>(pItem)->setHotPluggable(aValue.toBool()); 2522 emit dataChanged( index, index);2522 emit dataChanged(specifiedIndex, specifiedIndex); 2523 2523 return true; 2524 2524 } … … 2817 2817 } 2818 2818 2819 Qt::ItemFlags StorageModel::flags(const QModelIndex & index) const2820 { 2821 return ! index.isValid() ? QAbstractItemModel::flags(index) :2819 Qt::ItemFlags StorageModel::flags(const QModelIndex &specifiedIndex) const 2820 { 2821 return !specifiedIndex.isValid() ? QAbstractItemModel::flags(specifiedIndex) : 2822 2822 Qt::ItemIsEnabled | Qt::ItemIsSelectable; 2823 2823 } … … 3262 3262 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 3263 3263 { 3264 const QModelIndex controllerIndex = rootIndex.child(i, 0);3264 const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex); 3265 3265 const QString ctrName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString(); 3266 3266 … … 3284 3284 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 3285 3285 { 3286 const QModelIndex attachmentIndex = controllerIndex.child(j, 0);3286 const QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex); 3287 3287 const StorageSlot attSlot = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttSlot).value<StorageSlot>(); 3288 3288 const KDeviceType enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>(); … … 3494 3494 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 3495 3495 { 3496 const QModelIndex controllerIndex = rootIndex.child(i, 0);3496 const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex); 3497 3497 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 3498 3498 { 3499 const QModelIndex attachmentIndex = controllerIndex.child(j, 0);3499 const QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex); 3500 3500 const QUuid attMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString(); 3501 3501 if (attMediumId == medium.id()) … … 3515 3515 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 3516 3516 { 3517 QModelIndex controllerIndex = rootIndex.child(i, 0);3517 QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex); 3518 3518 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 3519 3519 { 3520 QModelIndex attachmentIndex = controllerIndex.child(j, 0);3520 QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex); 3521 3521 QUuid attMediumId = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttMediumId).toString(); 3522 3522 if (attMediumId == uMediumId) … … 5269 5269 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 5270 5270 { 5271 const QModelIndex controllerIndex = rootIndex.child(i, 0);5271 const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex); 5272 5272 const QString strName = m_pModelStorage->data(controllerIndex, StorageModel::R_CtrName).toString(); 5273 5273 if (strName.startsWith(strTemplate)) … … 5288 5288 for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i) 5289 5289 { 5290 const QModelIndex controllerIndex = rootIndex.child(i, 0);5290 const QModelIndex controllerIndex = m_pModelStorage->index(i, 0, rootIndex); 5291 5291 for (int j = 0; j < m_pModelStorage->rowCount(controllerIndex); ++j) 5292 5292 { 5293 const QModelIndex attachmentIndex = controllerIndex.child(j, 0);5293 const QModelIndex attachmentIndex = m_pModelStorage->index(j, 0, controllerIndex); 5294 5294 const KDeviceType enmDeviceType = m_pModelStorage->data(attachmentIndex, StorageModel::R_AttDevice).value<KDeviceType>(); 5295 5295 if (enmDeviceType == enmType) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp
r87719 r88447 1706 1706 if (srcParenIdx.isValid()) 1707 1707 { 1708 QModelIndex i = srcParenIdx.child(iSourceRow, 0);1708 QModelIndex i = index(iSourceRow, 0, srcParenIdx); 1709 1709 if (i.isValid()) 1710 1710 {
Note:
See TracChangeset
for help on using the changeset viewer.