- Timestamp:
- Nov 17, 2016 3:22:44 PM (8 years ago)
- 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 46 46 47 47 48 /** Describes the interface of Virtual Systemitem.48 /** Describes the interface of Appliance item. 49 49 * Represented as a tree structure with a parent & multiple children. */ 50 class ModelItem50 class UIApplianceModelItem 51 51 { 52 52 public: 53 53 54 54 /** 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); 56 56 /** Destructs item. */ 57 virtual ~ ModelItem();57 virtual ~UIApplianceModelItem(); 58 58 59 59 /** Returns the item type. */ … … 61 61 62 62 /** Returns the parent of the item. */ 63 ModelItem *parent() const { return m_pParentItem; }63 UIApplianceModelItem *parent() const { return m_pParentItem; } 64 64 65 65 /** Appends the passed @a pChildItem to the item's list of children. */ 66 void appendChild( ModelItem *pChildItem);66 void appendChild(UIApplianceModelItem *pChildItem); 67 67 /** Returns the child specified by the @a iRow. */ 68 ModelItem *child(int iRow) const;68 UIApplianceModelItem *child(int iRow) const; 69 69 70 70 /** Returns the row of the item in the parent. */ … … 108 108 109 109 /** Holds the parent item reference. */ 110 ModelItem*m_pParentItem;110 UIApplianceModelItem *m_pParentItem; 111 111 /** Holds the list of children item instances. */ 112 QList< ModelItem*>m_childItems;112 QList<UIApplianceModelItem*> m_childItems; 113 113 }; 114 114 115 115 116 /** ModelItem subclass representing Virtual System. */117 class VirtualSystemItem : publicModelItem116 /** UIApplianceModelItem subclass representing Appliance Virtual System item. */ 117 class UIVirtualSystemItem : public UIApplianceModelItem 118 118 { 119 119 public: 120 120 121 121 /** 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); 124 124 125 125 /** Returns the data stored under the given @a iRole for the item referred to by the @a iColumn. */ … … 132 132 133 133 /** Holds the Virtual System Description. */ 134 CVirtualSystemDescription m_ enmDescription;134 CVirtualSystemDescription m_comDescription; 135 135 }; 136 136 137 137 138 /** ModelItem subclass representing Virtual Systemitem. */139 class HardwareItem : publicModelItem140 { 141 friend class VirtualSystemSortProxyModel;138 /** UIApplianceModelItem subclass representing Appliance Virtual Hardware item. */ 139 class UIVirtualHardwareItem : public UIApplianceModelItem 140 { 141 friend class UIApplianceSortProxyModel; 142 142 143 143 /** Data roles. */ … … 156 156 * @param strConfigValue Brings the configuration value. 157 157 * @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); 165 165 166 166 /** Returns the item flags for the given @a iColumn. */ … … 190 190 private: 191 191 192 /** Holds the Virtual System description type. */192 /** Holds the Virtual System Description type. */ 193 193 KVirtualSystemDescriptionType m_enmType; 194 194 /** Holds something totally useless. */ … … 210 210 211 211 /********************************************************************************************************************************* 212 * Class ModelItem implementation.*212 * Class UIApplianceModelItem implementation. * 213 213 *********************************************************************************************************************************/ 214 214 215 ModelItem::ModelItem(int iNumber, ApplianceModelItemType enmType,ModelItem *pParentItem /* = 0 */)215 UIApplianceModelItem::UIApplianceModelItem(int iNumber, ApplianceModelItemType enmType, UIApplianceModelItem *pParentItem /* = 0 */) 216 216 : m_iNumber(iNumber) 217 217 , m_enmType(enmType) … … 220 220 } 221 221 222 ModelItem::~ModelItem()222 UIApplianceModelItem::~UIApplianceModelItem() 223 223 { 224 224 qDeleteAll(m_childItems); 225 225 } 226 226 227 void ModelItem::appendChild(ModelItem *pChildItem)227 void UIApplianceModelItem::appendChild(UIApplianceModelItem *pChildItem) 228 228 { 229 229 AssertPtr(pChildItem); … … 231 231 } 232 232 233 ModelItem *ModelItem::child(int iRow) const233 UIApplianceModelItem *UIApplianceModelItem::child(int iRow) const 234 234 { 235 235 return m_childItems.value(iRow); 236 236 } 237 237 238 int ModelItem::row() const238 int UIApplianceModelItem::row() const 239 239 { 240 240 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)); 242 242 243 243 return 0; 244 244 } 245 245 246 int ModelItem::childCount() const246 int UIApplianceModelItem::childCount() const 247 247 { 248 248 return m_childItems.count(); 249 249 } 250 250 251 void ModelItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)251 void UIApplianceModelItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues) 252 252 { 253 253 for (int i = 0; i < childCount(); ++i) … … 257 257 258 258 /********************************************************************************************************************************* 259 * Class VirtualSystemItem implementation.*259 * Class UIVirtualSystemItem implementation. * 260 260 *********************************************************************************************************************************/ 261 261 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) const262 UIVirtualSystemItem::UIVirtualSystemItem(int iNumber, CVirtualSystemDescription comDescription, UIApplianceModelItem *pParentItem) 263 : UIApplianceModelItem(iNumber, ApplianceModelItemType_VirtualSystem, pParentItem) 264 , m_comDescription(comDescription) 265 { 266 } 267 268 QVariant UIVirtualSystemItem::data(int iColumn, int iRole) const 269 269 { 270 270 QVariant value; … … 275 275 } 276 276 277 void VirtualSystemItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)277 void UIVirtualSystemItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues) 278 278 { 279 279 /* Resize the vectors */ 280 unsigned long iCount = m_ enmDescription.GetCount();280 unsigned long iCount = m_comDescription.GetCount(); 281 281 finalStates.resize(iCount); 282 282 finalValues.resize(iCount); 283 283 finalExtraValues.resize(iCount); 284 284 /* Recursively fill the vectors */ 285 ModelItem::putBack(finalStates, finalValues, finalExtraValues);285 UIApplianceModelItem::putBack(finalStates, finalValues, finalExtraValues); 286 286 /* Set all final values at once */ 287 m_ enmDescription.SetFinalValues(finalStates, finalValues, finalExtraValues);287 m_comDescription.SetFinalValues(finalStates, finalValues, finalExtraValues); 288 288 } 289 289 290 290 291 291 /********************************************************************************************************************************* 292 * Class HardwareItem implementation.*292 * Class UIVirtualHardwareItem implementation. * 293 293 *********************************************************************************************************************************/ 294 294 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)295 UIVirtualHardwareItem::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) 303 303 , m_enmType(enmType) 304 304 , m_strRef(strRef) … … 312 312 } 313 313 314 Qt::ItemFlags HardwareItem::itemFlags(int iColumn) const314 Qt::ItemFlags UIVirtualHardwareItem::itemFlags(int iColumn) const 315 315 { 316 316 Qt::ItemFlags enmFlags = 0; … … 346 346 } 347 347 348 bool HardwareItem::setData(int iColumn, const QVariant &value, int iRole)348 bool UIVirtualHardwareItem::setData(int iColumn, const QVariant &value, int iRole) 349 349 { 350 350 bool fDone = false; … … 378 378 } 379 379 380 QVariant HardwareItem::data(int iColumn, int iRole) const380 QVariant UIVirtualHardwareItem::data(int iColumn, int iRole) const 381 381 { 382 382 QVariant value; … … 529 529 break; 530 530 } 531 case HardwareItem::TypeRole:531 case UIVirtualHardwareItem::TypeRole: 532 532 { 533 533 value = m_enmType; 534 534 break; 535 535 } 536 case HardwareItem::ModifiedRole:536 case UIVirtualHardwareItem::ModifiedRole: 537 537 { 538 538 if (iColumn == ApplianceViewSection_ConfigValue) … … 544 544 } 545 545 546 QWidget * HardwareItem::createEditor(QWidget *pParent, const QStyleOptionViewItem & /* styleOption */, const QModelIndex &idx) const546 QWidget *UIVirtualHardwareItem::createEditor(QWidget *pParent, const QStyleOptionViewItem & /* styleOption */, const QModelIndex &idx) const 547 547 { 548 548 QWidget *pEditor = 0; … … 653 653 } 654 654 655 bool HardwareItem::setEditorData(QWidget *pEditor, const QModelIndex & /* idx */) const655 bool UIVirtualHardwareItem::setEditorData(QWidget *pEditor, const QModelIndex & /* idx */) const 656 656 { 657 657 bool fDone = false; … … 744 744 } 745 745 746 bool HardwareItem::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex & idx)746 bool UIVirtualHardwareItem::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex & idx) 747 747 { 748 748 bool fDone = false; … … 791 791 * are child's of this item. */ 792 792 QModelIndexList list = pModel->match(c0Index, 793 HardwareItem::TypeRole,793 UIVirtualHardwareItem::TypeRole, 794 794 KVirtualSystemDescriptionType_HardDiskImage, 795 795 -1, … … 880 880 } 881 881 882 void HardwareItem::restoreDefaults()882 void UIVirtualHardwareItem::restoreDefaults() 883 883 { 884 884 m_strConfigValue = m_strConfigDefaultValue; … … 886 886 } 887 887 888 void HardwareItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues)888 void UIVirtualHardwareItem::putBack(QVector<BOOL> &finalStates, QVector<QString> &finalValues, QVector<QString> &finalExtraValues) 889 889 { 890 890 finalStates[m_iNumber] = m_checkState == Qt::Checked; 891 891 finalValues[m_iNumber] = m_strConfigValue; 892 892 finalExtraValues[m_iNumber] = m_strExtraConfigValue; 893 ModelItem::putBack(finalStates, finalValues, finalExtraValues);893 UIApplianceModelItem::putBack(finalStates, finalValues, finalExtraValues); 894 894 } 895 895 896 896 897 897 /********************************************************************************************************************************* 898 * Class VirtualSystemModel implementation.*898 * Class UIApplianceModel implementation. * 899 899 *********************************************************************************************************************************/ 900 900 901 VirtualSystemModel::VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent /* = 0 */)901 UIApplianceModel::UIApplianceModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent /* = 0 */) 902 902 : QAbstractItemModel(pParent) 903 903 { 904 m_pRootItem = new ModelItem(0, ApplianceModelItemType_Root);904 m_pRootItem = new UIApplianceModelItem(0, ApplianceModelItemType_Root); 905 905 for (int iVSDIndex = 0; iVSDIndex < aVSDs.size(); ++iVSDIndex) 906 906 { 907 907 CVirtualSystemDescription vsd = aVSDs[iVSDIndex]; 908 908 909 VirtualSystemItem *pVirtualSystemItem = newVirtualSystemItem(iVSDIndex, vsd, m_pRootItem);909 UIVirtualSystemItem *pVirtualSystemItem = new UIVirtualSystemItem(iVSDIndex, vsd, m_pRootItem); 910 910 m_pRootItem->appendChild(pVirtualSystemItem); 911 911 … … 918 918 919 919 QList<int> hdIndexes; 920 QMap<int, HardwareItem*> controllerMap;920 QMap<int, UIVirtualHardwareItem*> controllerMap; 921 921 vsd.GetDescription(types, refs, origValues, configValues, extraConfigValues); 922 922 for (int i = 0; i < types.size(); ++i) … … 928 928 else 929 929 { 930 HardwareItem *pHardwareItem = newHardwareItem(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); 931 931 pVirtualSystemItem->appendChild(pHardwareItem); 932 932 /* Save the hard disk controller types in an extra map */ … … 947 947 { 948 948 /* Get the controller */ 949 HardwareItem *pControllerItem = controllerMap[rx.cap(1).toInt()];949 UIVirtualHardwareItem *pControllerItem = controllerMap[rx.cap(1).toInt()]; 950 950 if (pControllerItem) 951 951 { 952 952 /* New hardware item as child of the controller */ 953 HardwareItem *pStorageItem = newHardwareItem(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); 954 954 pControllerItem->appendChild(pStorageItem); 955 955 } … … 959 959 } 960 960 961 VirtualSystemModel::~VirtualSystemModel()961 UIApplianceModel::~UIApplianceModel() 962 962 { 963 963 if (m_pRootItem) … … 965 965 } 966 966 967 QModelIndex VirtualSystemModel::index(int iRow, int iColumn, const QModelIndex &parentIdx /* = QModelIndex() */) const967 QModelIndex UIApplianceModel::index(int iRow, int iColumn, const QModelIndex &parentIdx /* = QModelIndex() */) const 968 968 { 969 969 if (!hasIndex(iRow, iColumn, parentIdx)) 970 970 return QModelIndex(); 971 971 972 ModelItem *pParentItem;972 UIApplianceModelItem *pParentItem; 973 973 974 974 if (!parentIdx.isValid()) 975 975 pParentItem = m_pRootItem; 976 976 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); 980 980 if (pChildItem) 981 981 return createIndex(iRow, iColumn, pChildItem); … … 984 984 } 985 985 986 QModelIndex VirtualSystemModel::parent(const QModelIndex &idx) const986 QModelIndex UIApplianceModel::parent(const QModelIndex &idx) const 987 987 { 988 988 if (!idx.isValid()) 989 989 return QModelIndex(); 990 990 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(); 993 993 994 994 if (pParentItem == m_pRootItem) … … 998 998 } 999 999 1000 int VirtualSystemModel::rowCount(const QModelIndex &parentIdx /* = QModelIndex() */) const1001 { 1002 ModelItem *pParentItem;1000 int UIApplianceModel::rowCount(const QModelIndex &parentIdx /* = QModelIndex() */) const 1001 { 1002 UIApplianceModelItem *pParentItem; 1003 1003 if (parentIdx.column() > 0) 1004 1004 return 0; … … 1007 1007 pParentItem = m_pRootItem; 1008 1008 else 1009 pParentItem = static_cast< ModelItem*>(parentIdx.internalPointer());1009 pParentItem = static_cast<UIApplianceModelItem*>(parentIdx.internalPointer()); 1010 1010 1011 1011 return pParentItem->childCount(); 1012 1012 } 1013 1013 1014 int VirtualSystemModel::columnCount(const QModelIndex &parentIdx /* = QModelIndex() */) const1014 int UIApplianceModel::columnCount(const QModelIndex &parentIdx /* = QModelIndex() */) const 1015 1015 { 1016 1016 if (parentIdx.isValid()) 1017 return static_cast< ModelItem*>(parentIdx.internalPointer())->columnCount();1017 return static_cast<UIApplianceModelItem*>(parentIdx.internalPointer())->columnCount(); 1018 1018 else 1019 1019 return m_pRootItem->columnCount(); 1020 1020 } 1021 1021 1022 Qt::ItemFlags VirtualSystemModel::flags(const QModelIndex &idx) const1022 Qt::ItemFlags UIApplianceModel::flags(const QModelIndex &idx) const 1023 1023 { 1024 1024 if (!idx.isValid()) 1025 1025 return 0; 1026 1026 1027 ModelItem *pItem = static_cast<ModelItem*>(idx.internalPointer());1027 UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(idx.internalPointer()); 1028 1028 1029 1029 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | pItem->itemFlags(idx.column()); 1030 1030 } 1031 1031 1032 QVariant VirtualSystemModel::headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const1032 QVariant UIApplianceModel::headerData(int iSection, Qt::Orientation enmOrientation, int iRole) const 1033 1033 { 1034 1034 if (iRole != Qt::DisplayRole || … … 1045 1045 } 1046 1046 1047 bool VirtualSystemModel::setData(const QModelIndex &idx, const QVariant &value, int iRole)1047 bool UIApplianceModel::setData(const QModelIndex &idx, const QVariant &value, int iRole) 1048 1048 { 1049 1049 if (!idx.isValid()) 1050 1050 return false; 1051 1051 1052 ModelItem *pTtem = static_cast<ModelItem*>(idx.internalPointer());1052 UIApplianceModelItem *pTtem = static_cast<UIApplianceModelItem*>(idx.internalPointer()); 1053 1053 1054 1054 return pTtem->setData(idx.column(), value, iRole); 1055 1055 } 1056 1056 1057 QVariant VirtualSystemModel::data(const QModelIndex &idx, int iRole /* = Qt::DisplayRole */) const1057 QVariant UIApplianceModel::data(const QModelIndex &idx, int iRole /* = Qt::DisplayRole */) const 1058 1058 { 1059 1059 if (!idx.isValid()) 1060 1060 return QVariant(); 1061 1061 1062 ModelItem *pTtem = static_cast<ModelItem*>(idx.internalPointer());1062 UIApplianceModelItem *pTtem = static_cast<UIApplianceModelItem*>(idx.internalPointer()); 1063 1063 1064 1064 return pTtem->data(idx.column(), iRole); 1065 1065 } 1066 1066 1067 QModelIndex VirtualSystemModel::buddy(const QModelIndex &idx) const1067 QModelIndex UIApplianceModel::buddy(const QModelIndex &idx) const 1068 1068 { 1069 1069 if (!idx.isValid()) … … 1076 1076 } 1077 1077 1078 void VirtualSystemModel::restoreDefaults(const QModelIndex &parentIdx /* = QModelIndex() */)1079 { 1080 ModelItem *pParentItem;1078 void UIApplianceModel::restoreDefaults(const QModelIndex &parentIdx /* = QModelIndex() */) 1079 { 1080 UIApplianceModelItem *pParentItem; 1081 1081 1082 1082 if (!parentIdx.isValid()) 1083 1083 pParentItem = m_pRootItem; 1084 1084 else 1085 pParentItem = static_cast< ModelItem*>(parentIdx.internalPointer());1085 pParentItem = static_cast<UIApplianceModelItem*>(parentIdx.internalPointer()); 1086 1086 1087 1087 for (int i = 0; i < pParentItem->childCount(); ++i) … … 1093 1093 } 1094 1094 1095 void VirtualSystemModel::putBack()1095 void UIApplianceModel::putBack() 1096 1096 { 1097 1097 QVector<BOOL> v1; … … 1103 1103 1104 1104 /********************************************************************************************************************************* 1105 * Class VirtualSystemDelegate implementation.*1105 * Class UIApplianceDelegate implementation. * 1106 1106 *********************************************************************************************************************************/ 1107 1107 1108 VirtualSystemDelegate::VirtualSystemDelegate(QAbstractProxyModel *pProxy, QObject *pParent /* = 0 */)1108 UIApplianceDelegate::UIApplianceDelegate(QAbstractProxyModel *pProxy, QObject *pParent /* = 0 */) 1109 1109 : QItemDelegate(pParent) 1110 1110 , m_pProxy(pProxy) … … 1112 1112 } 1113 1113 1114 QWidget * VirtualSystemDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const1114 QWidget *UIApplianceDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const 1115 1115 { 1116 1116 if (!idx.isValid()) … … 1121 1121 index = m_pProxy->mapToSource(idx); 1122 1122 1123 ModelItem *pItem = static_cast<ModelItem*>(index.internalPointer());1123 UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(index.internalPointer()); 1124 1124 QWidget *pEditor = pItem->createEditor(pParent, styleOption, index); 1125 1125 … … 1134 1134 } 1135 1135 1136 void VirtualSystemDelegate::setEditorData(QWidget *pEditor, const QModelIndex &idx) const1136 void UIApplianceDelegate::setEditorData(QWidget *pEditor, const QModelIndex &idx) const 1137 1137 { 1138 1138 if (!idx.isValid()) … … 1143 1143 index = m_pProxy->mapToSource(idx); 1144 1144 1145 ModelItem *pItem = static_cast<ModelItem*>(index.internalPointer());1145 UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(index.internalPointer()); 1146 1146 1147 1147 if (!pItem->setEditorData(pEditor, index)) … … 1149 1149 } 1150 1150 1151 void VirtualSystemDelegate::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx) const1151 void UIApplianceDelegate::setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx) const 1152 1152 { 1153 1153 if (!idx.isValid()) … … 1158 1158 index = m_pProxy->mapToSource(idx); 1159 1159 1160 ModelItem *pItem = static_cast<ModelItem*>(index.internalPointer());1160 UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(index.internalPointer()); 1161 1161 if (!pItem->setModelData(pEditor, pModel, idx)) 1162 1162 QItemDelegate::setModelData(pEditor, pModel, idx); 1163 1163 } 1164 1164 1165 void VirtualSystemDelegate::updateEditorGeometry(QWidget *pEditor, const QStyleOptionViewItem &styleOption, const QModelIndex & /* idx */) const1165 void UIApplianceDelegate::updateEditorGeometry(QWidget *pEditor, const QStyleOptionViewItem &styleOption, const QModelIndex & /* idx */) const 1166 1166 { 1167 1167 if (pEditor) … … 1169 1169 } 1170 1170 1171 QSize VirtualSystemDelegate::sizeHint(const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const1171 QSize UIApplianceDelegate::sizeHint(const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const 1172 1172 { 1173 1173 QSize size = QItemDelegate::sizeHint(styleOption, idx); … … 1182 1182 1183 1183 #ifdef VBOX_WS_MAC 1184 bool VirtualSystemDelegate::eventFilter(QObject *pObject, QEvent *pEvent)1184 bool UIApplianceDelegate::eventFilter(QObject *pObject, QEvent *pEvent) 1185 1185 { 1186 1186 if (pEvent->type() == QEvent::FocusOut) … … 1204 1204 1205 1205 /********************************************************************************************************************************* 1206 * Class VirtualSystemSortProxyModel implementation.*1206 * Class UIApplianceSortProxyModel implementation. * 1207 1207 *********************************************************************************************************************************/ 1208 1208 1209 1209 /* static */ 1210 KVirtualSystemDescriptionType VirtualSystemSortProxyModel::s_aSortList[] =1210 KVirtualSystemDescriptionType UIApplianceSortProxyModel::s_aSortList[] = 1211 1211 { 1212 1212 KVirtualSystemDescriptionType_Name, … … 1232 1232 }; 1233 1233 1234 VirtualSystemSortProxyModel::VirtualSystemSortProxyModel(QObject *pParent)1234 UIApplianceSortProxyModel::UIApplianceSortProxyModel(QObject *pParent) 1235 1235 : QSortFilterProxyModel(pParent) 1236 1236 { 1237 1237 } 1238 1238 1239 bool VirtualSystemSortProxyModel::filterAcceptsRow(int iSourceRow, const QModelIndex &srcParenIdx) const1239 bool UIApplianceSortProxyModel::filterAcceptsRow(int iSourceRow, const QModelIndex &srcParenIdx) const 1240 1240 { 1241 1241 /* By default enable all, we will explicitly filter out below */ … … 1245 1245 if (i.isValid()) 1246 1246 { 1247 ModelItem *pItem = static_cast<ModelItem*>(i.internalPointer());1247 UIApplianceModelItem *pItem = static_cast<UIApplianceModelItem*>(i.internalPointer()); 1248 1248 /* 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); 1252 1252 /* The license type shouldn't be displayed */ 1253 1253 if (m_aFilteredList.contains(hwItem->m_enmType)) … … 1259 1259 } 1260 1260 1261 bool VirtualSystemSortProxyModel::lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const1261 bool UIApplianceSortProxyModel::lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const 1262 1262 { 1263 1263 if (!leftIdx.isValid() || … … 1265 1265 return false; 1266 1266 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()); 1269 1269 1270 1270 /* 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)) 1273 1273 return false; 1274 1274 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); 1277 1277 1278 1278 for (unsigned int i = 0; i < RT_ELEMENTS(s_aSortList); ++i) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.h
r64691 r64692 33 33 34 34 /* Forward declarations: */ 35 class ModelItem;35 class UIApplianceModelItem; 36 36 class QCheckBox; 37 37 class QLabel; … … 54 54 ApplianceModelItemType_Root, 55 55 ApplianceModelItemType_VirtualSystem, 56 ApplianceModelItemType_ Hardware57 }; 58 59 60 /** QAbstractItemModel subclass used as Virtual Systemmodel. */61 class VirtualSystemModel : public QAbstractItemModel62 { 63 public: 64 65 /** Constructs the Virtual Systemmodel passing @a pParent to the base-class.56 ApplianceModelItemType_VirtualHardware 57 }; 58 59 60 /** QAbstractItemModel subclass used as Appliance model. */ 61 class UIApplianceModel : public QAbstractItemModel 62 { 63 public: 64 65 /** Constructs the Appliance model passing @a pParent to the base-class. 66 66 * @param aVSDs Brings the Virtual System descriptions. */ 67 VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = 0);68 /** Destructs the Virtual Systemmodel. */69 ~ VirtualSystemModel();67 UIApplianceModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = 0); 68 /** Destructs the Appliance model. */ 69 ~UIApplianceModel(); 70 70 71 71 /** Returns the index of the item in the model specified by the given @a iRow, @a iColumn and @a parentIdx. */ … … 101 101 102 102 /** Holds the root item reference. */ 103 ModelItem *m_pRootItem;104 }; 105 106 107 /** QItemDelegate subclass used to create various Virtual Systemmodel editors. */108 class VirtualSystemDelegate : public QItemDelegate109 { 110 public: 111 112 /** Constructs the Virtual SystemDelegate passing @a pParent to the base-class.103 UIApplianceModelItem *m_pRootItem; 104 }; 105 106 107 /** QItemDelegate subclass used to create various Appliance model editors. */ 108 class UIApplianceDelegate : public QItemDelegate 109 { 110 public: 111 112 /** Constructs the Appliance Delegate passing @a pParent to the base-class. 113 113 * @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); 115 115 116 116 /** Returns the widget used to edit the item specified by @a idx for editing. … … 144 144 145 145 146 /** QSortFilterProxyModel subclass used as the Virtual System Sortingmodel. */147 class VirtualSystemSortProxyModel : public QSortFilterProxyModel148 { 149 public: 150 151 /** Constructs the Virtual System Sortingmodel passing @a pParent to the base-class. */152 VirtualSystemSortProxyModel(QObject *pParent = 0);146 /** QSortFilterProxyModel subclass used as the Appliance Sorting Proxy model. */ 147 class UIApplianceSortProxyModel : public QSortFilterProxyModel 148 { 149 public: 150 151 /** Constructs the Appliance Sorting Proxy model passing @a pParent to the base-class. */ 152 UIApplianceSortProxyModel(QObject *pParent = 0); 153 153 154 154 protected: … … 205 205 /** Holds the currently set appliance reference. */ 206 206 CAppliance *m_pAppliance; 207 /** Holds the Virtual Systemmodel reference. */208 VirtualSystemModel *m_pModel;207 /** Holds the Appliance model reference. */ 208 UIApplianceModel *m_pModel; 209 209 210 210 /** Holds the information pane instance. */ … … 224 224 private: 225 225 226 /** Performs Virtual Systemsettings initialization. */226 /** Performs Appliance settings initialization. */ 227 227 static void initSystemSettings(); 228 228 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.cpp
r64691 r64692 38 38 // ExportSortProxyModel 39 39 40 class ExportSortProxyModel: public VirtualSystemSortProxyModel40 class ExportSortProxyModel: public UIApplianceSortProxyModel 41 41 { 42 42 public: 43 43 ExportSortProxyModel(QObject *pParent = NULL) 44 : VirtualSystemSortProxyModel(pParent)44 : UIApplianceSortProxyModel(pParent) 45 45 { 46 46 m_aFilteredList … … 86 86 QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions(); 87 87 88 m_pModel = new VirtualSystemModel(vsds, this);88 m_pModel = new UIApplianceModel(vsds, this); 89 89 90 90 ExportSortProxyModel *pProxy = new ExportSortProxyModel(this); … … 92 92 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder); 93 93 94 VirtualSystemDelegate *pDelegate = new VirtualSystemDelegate(pProxy, this);94 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy, this); 95 95 96 96 /* Set our own model */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.cpp
r64691 r64692 39 39 // ImportSortProxyModel 40 40 41 class ImportSortProxyModel: public VirtualSystemSortProxyModel41 class ImportSortProxyModel: public UIApplianceSortProxyModel 42 42 { 43 43 public: 44 44 ImportSortProxyModel(QObject *pParent = NULL) 45 : VirtualSystemSortProxyModel(pParent)45 : UIApplianceSortProxyModel(pParent) 46 46 { 47 47 m_aFilteredList << KVirtualSystemDescriptionType_License; … … 92 92 QVector<CVirtualSystemDescription> vsds = m_pAppliance->GetVirtualSystemDescriptions(); 93 93 94 m_pModel = new VirtualSystemModel(vsds, this);94 m_pModel = new UIApplianceModel(vsds, this); 95 95 96 96 ImportSortProxyModel *pProxy = new ImportSortProxyModel(this); … … 98 98 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder); 99 99 100 VirtualSystemDelegate *pDelegate = new VirtualSystemDelegate(pProxy, this);100 UIApplianceDelegate *pDelegate = new UIApplianceDelegate(pProxy, this); 101 101 102 102 /* Set our own model */
Note:
See TracChangeset
for help on using the changeset viewer.