Changeset 64685 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 16, 2016 3:42:15 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
r64683 r64685 55 55 to keep the interface clean. ModelItem is able to handle tree structures 56 56 with a parent & several children's. */ 57 ModelItem::ModelItem(int number, ModelItem_type type, ModelItem *pParent /* = NULL */)57 ModelItem::ModelItem(int number, ApplianceModelItemType type, ModelItem *pParent /* = NULL */) 58 58 : m_number(number) 59 59 , m_type(type) … … 100 100 101 101 VirtualSystemItem::VirtualSystemItem(int number, CVirtualSystemDescription aDesc, ModelItem *pParent) 102 : ModelItem(number, VirtualSystem_type, pParent)102 : ModelItem(number, ApplianceModelItemType_VirtualSystem, pParent) 103 103 , m_desc(aDesc) 104 104 {} … … 107 107 { 108 108 QVariant v; 109 if (column == DescriptionSection &&109 if (column == ApplianceViewSection_Description && 110 110 role == Qt::DisplayRole) 111 111 v = UIApplianceEditorWidget::tr("Virtual System %1").arg(m_number + 1); … … 136 136 const QString &strExtraConfigValue, 137 137 ModelItem *pParent) 138 : ModelItem(number, HardwareType, pParent)138 : ModelItem(number, ApplianceModelItemType_Hardware, pParent) 139 139 , m_type(type) 140 140 , m_strRef(strRef) … … 162 162 case Qt::CheckStateRole: 163 163 { 164 if (column == ConfigValueSection&&164 if (column == ApplianceViewSection_ConfigValue && 165 165 (m_type == KVirtualSystemDescriptionType_Floppy || 166 166 m_type == KVirtualSystemDescriptionType_CDROM || … … 176 176 case Qt::EditRole: 177 177 { 178 if (column == OriginalValueSection)178 if (column == ApplianceViewSection_OriginalValue) 179 179 m_strOrigValue = value.toString(); 180 else if (column == ConfigValueSection)180 else if (column == ApplianceViewSection_ConfigValue) 181 181 m_strConfigValue = value.toString(); 182 182 break; … … 194 194 case Qt::EditRole: 195 195 { 196 if (column == OriginalValueSection)196 if (column == ApplianceViewSection_OriginalValue) 197 197 v = m_strOrigValue; 198 else if (column == ConfigValueSection)198 else if (column == ApplianceViewSection_ConfigValue) 199 199 v = m_strConfigValue; 200 200 break; … … 202 202 case Qt::DisplayRole: 203 203 { 204 if (column == DescriptionSection)204 if (column == ApplianceViewSection_Description) 205 205 { 206 206 switch (m_type) … … 230 230 } 231 231 } 232 else if (column == OriginalValueSection)232 else if (column == ApplianceViewSection_OriginalValue) 233 233 v = m_strOrigValue; 234 else if (column == ConfigValueSection)234 else if (column == ApplianceViewSection_ConfigValue) 235 235 { 236 236 switch (m_type) … … 258 258 case Qt::ToolTipRole: 259 259 { 260 if (column == ConfigValueSection)260 if (column == ApplianceViewSection_ConfigValue) 261 261 { 262 262 if (!m_strOrigValue.isEmpty()) … … 267 267 case Qt::DecorationRole: 268 268 { 269 if (column == DescriptionSection)269 if (column == ApplianceViewSection_Description) 270 270 { 271 271 switch (m_type) … … 295 295 } 296 296 } 297 else if (column == ConfigValueSection&&297 else if (column == ApplianceViewSection_ConfigValue && 298 298 m_type == KVirtualSystemDescriptionType_OS) 299 299 { … … 307 307 { 308 308 /* If the item is unchecked mark it with italic text. */ 309 if (column == ConfigValueSection&&309 if (column == ApplianceViewSection_ConfigValue && 310 310 m_checkState == Qt::Unchecked) 311 311 { … … 319 319 { 320 320 /* If the item is unchecked mark it with gray text. */ 321 if (column == ConfigValueSection&&321 if (column == ApplianceViewSection_ConfigValue && 322 322 m_checkState == Qt::Unchecked) 323 323 { … … 329 329 case Qt::CheckStateRole: 330 330 { 331 if (column == ConfigValueSection&&331 if (column == ApplianceViewSection_ConfigValue && 332 332 (m_type == KVirtualSystemDescriptionType_Floppy || 333 333 m_type == KVirtualSystemDescriptionType_CDROM || … … 345 345 case HardwareItem::ModifiedRole: 346 346 { 347 if (column == ConfigValueSection)347 if (column == ApplianceViewSection_ConfigValue) 348 348 v = m_fModified; 349 349 break; … … 356 356 { 357 357 Qt::ItemFlags flags = 0; 358 if (column == ConfigValueSection)358 if (column == ApplianceViewSection_ConfigValue) 359 359 { 360 360 /* Some items are checkable */ … … 390 390 { 391 391 QWidget *editor = NULL; 392 if (idx.column() == ConfigValueSection)392 if (idx.column() == ApplianceViewSection_ConfigValue) 393 393 { 394 394 switch (m_type) … … 641 641 { 642 642 /* Get the index for the config value column. */ 643 QModelIndex hdIndex = pModel->index(list.at(i).row(), ConfigValueSection, list.at(i).parent());643 QModelIndex hdIndex = pModel->index(list.at(i).row(), ApplianceViewSection_ConfigValue, list.at(i).parent()); 644 644 /* Ignore it if was already modified by the user. */ 645 645 if (!hdIndex.data(ModifiedRole).toBool()) … … 732 732 : QAbstractItemModel(pParent) 733 733 { 734 m_pRootItem = new ModelItem(0, RootType);734 m_pRootItem = new ModelItem(0, ApplianceModelItemType_Root); 735 735 for (int a = 0; a < aVSDs.size(); ++a) 736 736 { … … 889 889 switch (section) 890 890 { 891 case DescriptionSection: title = UIApplianceEditorWidget::tr("Description"); break;892 case ConfigValueSection: title = UIApplianceEditorWidget::tr("Configuration"); break;891 case ApplianceViewSection_Description: title = UIApplianceEditorWidget::tr("Description"); break; 892 case ApplianceViewSection_ConfigValue: title = UIApplianceEditorWidget::tr("Configuration"); break; 893 893 } 894 894 return title; … … 900 900 return QModelIndex(); 901 901 902 if (idx.column() == ConfigValueSection)902 if (idx.column() == ApplianceViewSection_ConfigValue) 903 903 return idx; 904 904 else 905 return index(idx.row(), ConfigValueSection, idx.parent());905 return index(idx.row(), ApplianceViewSection_ConfigValue, idx.parent()); 906 906 } 907 907 … … 1065 1065 ModelItem *item = static_cast<ModelItem*>(i.internalPointer()); 1066 1066 /* We filter hardware types only */ 1067 if (item->type() == HardwareType)1067 if (item->type() == ApplianceModelItemType_Hardware) 1068 1068 { 1069 1069 HardwareItem *hwItem = static_cast<HardwareItem*>(item); … … 1087 1087 1088 1088 /* We sort hardware types only */ 1089 if (!(pLeftItem->type() == HardwareType &&1090 pRightItem->type() == HardwareType))1089 if (!(pLeftItem->type() == ApplianceModelItemType_Hardware && 1090 pRightItem->type() == ApplianceModelItemType_Hardware)) 1091 1091 return false; 1092 1092 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.h
r64683 r64685 38 38 class QTextEdit; 39 39 40 //////////////////////////////////////////////////////////////////////////////// 41 // Globals 42 43 enum TreeViewSection { DescriptionSection = 0, OriginalValueSection, ConfigValueSection }; 44 45 //////////////////////////////////////////////////////////////////////////////// 46 // ModelItem 47 48 enum ModelItem_type { RootType, VirtualSystem_type, HardwareType }; 40 41 /** Appliance tree-view section types. */ 42 enum ApplianceViewSection 43 { 44 ApplianceViewSection_Description = 0, 45 ApplianceViewSection_OriginalValue, 46 ApplianceViewSection_ConfigValue 47 }; 48 49 /** Appliance model item types. */ 50 enum ApplianceModelItemType 51 { 52 ApplianceModelItemType_Root, 53 ApplianceModelItemType_VirtualSystem, 54 ApplianceModelItemType_Hardware 55 }; 56 49 57 50 58 /* This & the following derived classes represent the data items of a Virtual … … 55 63 { 56 64 public: 57 ModelItem(int number, ModelItem_type type, ModelItem *pParent = NULL);65 ModelItem(int number, ApplianceModelItemType type, ModelItem *pParent = NULL); 58 66 59 67 virtual ~ModelItem(); … … 79 87 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 80 88 81 ModelItem_type type() const { return m_type; }89 ApplianceModelItemType type() const { return m_type; } 82 90 83 91 protected: 84 92 /* Protected member vars */ 85 int m_number;86 ModelItem_typem_type;87 88 ModelItem *m_pParentItem;89 QList<ModelItem*> m_childItems;93 int m_number; 94 ApplianceModelItemType m_type; 95 96 ModelItem *m_pParentItem; 97 QList<ModelItem*> m_childItems; 90 98 }; 91 99 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceExportEditorWidget.cpp
r64683 r64685 90 90 ExportSortProxyModel *pProxy = new ExportSortProxyModel(this); 91 91 pProxy->setSourceModel(m_pModel); 92 pProxy->sort( DescriptionSection, Qt::DescendingOrder);92 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder); 93 93 94 94 VirtualSystemDelegate *pDelegate = new VirtualSystemDelegate(pProxy, this); … … 100 100 /* For now we hide the original column. This data is displayed as tooltip 101 101 also. */ 102 m_pTreeViewSettings->setColumnHidden( OriginalValueSection, true);102 m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true); 103 103 m_pTreeViewSettings->expandAll(); 104 104 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.cpp
r64683 r64685 96 96 ImportSortProxyModel *pProxy = new ImportSortProxyModel(this); 97 97 pProxy->setSourceModel(m_pModel); 98 pProxy->sort( DescriptionSection, Qt::DescendingOrder);98 pProxy->sort(ApplianceViewSection_Description, Qt::DescendingOrder); 99 99 100 100 VirtualSystemDelegate *pDelegate = new VirtualSystemDelegate(pProxy, this); … … 106 106 /* For now we hide the original column. This data is displayed as tooltip 107 107 also. */ 108 m_pTreeViewSettings->setColumnHidden( OriginalValueSection, true);108 m_pTreeViewSettings->setColumnHidden(ApplianceViewSection_OriginalValue, true); 109 109 m_pTreeViewSettings->expandAll(); 110 110
Note:
See TracChangeset
for help on using the changeset viewer.