Changeset 35979 in vbox for trunk/src/VBox
- Timestamp:
- Feb 15, 2011 2:37:12 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxApplianceEditorWgt.cpp
r30976 r35979 130 130 , mExtraConfigValue (aExtraConfigValue) 131 131 , mCheckState (Qt::Checked) 132 , m_fModified(false) 132 133 {} 133 134 … … 159 160 break; 160 161 } 162 case Qt::EditRole: 163 { 164 if (aColumn == OriginalValueSection) 165 mOrigValue = aValue.toString(); 166 else if (aColumn == ConfigValueSection) 167 mConfigValue = aValue.toString(); 168 break; 169 } 161 170 default: break; 162 171 } … … 169 178 switch (aRole) 170 179 { 180 case Qt::EditRole: 181 { 182 if (aColumn == OriginalValueSection) 183 v = mOrigValue; 184 else if (aColumn == ConfigValueSection) 185 v = mConfigValue; 186 break; 187 } 171 188 case Qt::DisplayRole: 172 189 { … … 303 320 mType == KVirtualSystemDescriptionType_NetworkAdapter)) 304 321 v = mCheckState; 322 break; 323 } 324 case HardwareItem::TypeRole: 325 { 326 v = mType; 327 break; 328 } 329 case HardwareItem::ModifiedRole: 330 { 331 if (aColumn == ConfigValueSection) 332 v = m_fModified; 305 333 break; 306 334 } … … 543 571 } 544 572 545 bool HardwareItem::setModelData (QWidget *aEditor, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */)573 bool HardwareItem::setModelData (QWidget *aEditor, QAbstractItemModel *aModel, const QModelIndex & aIndex) 546 574 { 547 575 bool fDone = false; … … 577 605 } 578 606 case KVirtualSystemDescriptionType_Name: 607 { 608 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) 609 { 610 /* When the VM name is changed the path of the disk images 611 * should be also changed. So first of all find all disk 612 * images corresponding to this appliance. Next check if 613 * they are modified by the user already. If not change the 614 * path to the new path. */ 615 /* Create an index of this position, but in column 0. */ 616 QModelIndex c0Index = aModel->index(aIndex.row(), 0, aIndex.parent()); 617 /* Query all items with the type HardDiskImage and which 618 * are child's of this item. */ 619 QModelIndexList list = aModel->match(c0Index, HardwareItem::TypeRole, KVirtualSystemDescriptionType_HardDiskImage, -1, Qt::MatchExactly | Qt::MatchWrap | Qt::MatchRecursive); 620 for (int i = 0; i < list.count(); ++i) 621 { 622 /* Get the index for the config value column. */ 623 QModelIndex hdIndex = aModel->index(list.at(i).row(), ConfigValueSection, list.at(i).parent()); 624 /* Ignore it if was already modified by the user. */ 625 if (!hdIndex.data(ModifiedRole).toBool()) 626 /* Replace any occurrence of the old VM name with 627 * the new VM name. */ 628 aModel->setData(hdIndex, hdIndex.data(Qt::EditRole).toString().replace(mConfigValue, e->text()), Qt::EditRole); 629 } 630 mConfigValue = e->text(); 631 fDone = true; 632 } 633 break; 634 } 579 635 case KVirtualSystemDescriptionType_Product: 580 636 case KVirtualSystemDescriptionType_ProductUrl: … … 627 683 default: break; 628 684 } 685 if (fDone) 686 m_fModified = true; 687 629 688 return fDone; 630 689 } … … 889 948 890 949 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 891 if (!item->setModelData (aEditor, aModel, index))950 if (!item->setModelData (aEditor, aModel, aIndex)) 892 951 QItemDelegate::setModelData (aEditor, aModel, aIndex); 893 952 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxApplianceEditorWgt.h
r28800 r35979 111 111 public: 112 112 113 enum 114 { 115 TypeRole = Qt::UserRole, 116 ModifiedRole 117 }; 118 113 119 HardwareItem (int aNumber, 114 120 KVirtualSystemDescriptionType aType, … … 147 153 QString mExtraConfigValue; 148 154 Qt::CheckState mCheckState; 155 bool m_fModified; 149 156 }; 150 157
Note:
See TracChangeset
for help on using the changeset viewer.