- Timestamp:
- Mar 27, 2009 10:45:19 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 added
- 8 edited
- 2 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r18299 r18378 242 242 include/VBoxOSTypeSelectorButton.h \ 243 243 include/VBoxOSTypeSelectorWidget.h \ 244 include/VBoxLineTextEdit.h \ 244 245 include/VBoxUtils.h \ 245 246 include/VBoxGlobalSettings.h \ … … 291 292 include/VBoxSettingsPage.h \ 292 293 include/VBoxSettingsSelector.h \ 294 include/VBoxApplianceEditorWgt.h \ 293 295 include/VBoxImportApplianceWgt.h \ 294 296 include/VBoxImportApplianceWzd.h \ 297 include/VBoxExportApplianceWgt.h \ 295 298 include/VBoxExportApplianceWzd.h 296 299 … … 327 330 src/VBoxOSTypeSelectorButton.cpp \ 328 331 src/VBoxOSTypeSelectorWidget.cpp \ 332 src/VBoxLineTextEdit.cpp \ 329 333 src/VBoxDefs.cpp \ 330 334 src/VBoxGlobalSettings.cpp \ … … 377 381 src/VBoxMediaManagerDlg.cpp \ 378 382 src/VBoxMedium.cpp \ 383 src/VBoxApplianceEditorWgt.cpp \ 379 384 src/VBoxImportApplianceWgt.cpp \ 380 385 src/VBoxImportApplianceWzd.cpp \ 386 src/VBoxExportApplianceWgt.cpp \ 381 387 src/VBoxExportApplianceWzd.cpp 382 388 -
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r18235 r18378 59 59 ui/VBoxGLSettingsNetwork.ui \ 60 60 ui/VBoxGLSettingsNetworkDetails.ui \ 61 ui/VBox ImportApplianceWgt.ui \61 ui/VBoxApplianceEditorWgt.ui \ 62 62 ui/VBoxImportApplianceWzd.ui \ 63 63 ui/VBoxExportApplianceWzd.ui -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxApplianceEditorWgt.h
r18307 r18378 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * VBox ImportApplianceWgt class declaration4 * VBoxApplianceEditorWgt class declaration 5 5 */ 6 6 … … 21 21 */ 22 22 23 #ifndef __VBoxImportApplianceWgt_h__ 24 #define __VBoxImportApplianceWgt_h__ 25 26 #include "VBoxImportApplianceWgt.gen.h" 23 #ifndef __VBoxApplianceEditorWgt_h__ 24 #define __VBoxApplianceEditorWgt_h__ 25 26 /* VBox includes */ 27 #include "COMDefs.h" 28 #include "VBoxApplianceEditorWgt.gen.h" 27 29 #include "QIWithRetranslateUI.h" 28 30 29 class CAppliance; 30 class VirtualSystemModel; 31 32 class VBoxImportApplianceWgt : public QIWithRetranslateUI<QWidget>, 33 public Ui::VBoxImportApplianceWgt 31 /* Qt includes */ 32 #include <QSortFilterProxyModel> 33 #include <QItemDelegate> 34 35 /* VBox forward declarations */ 36 class ModelItem; 37 38 //////////////////////////////////////////////////////////////////////////////// 39 // Globals 40 41 enum TreeViewSection { DescriptionSection = 0, OriginalValueSection, ConfigValueSection }; 42 43 //////////////////////////////////////////////////////////////////////////////// 44 // ModelItem 45 46 enum ModelItemType { RootType, VirtualSystemType, HardwareType }; 47 48 /* This & the following derived classes represent the data items of a Virtual 49 System. All access/manipulation is done with the help of virtual functions 50 to keep the interface clean. ModelItem is able to handle tree structures 51 with a parent & several children's. */ 52 class ModelItem 53 { 54 public: 55 ModelItem (int aNumber, ModelItemType aType, ModelItem *aParent = NULL); 56 57 ~ModelItem(); 58 59 ModelItem *parent() const { return mParentItem; } 60 61 void appendChild (ModelItem *aChild); 62 ModelItem * child (int aRow) const; 63 64 int row() const; 65 66 int childCount() const; 67 int columnCount() const { return 3; } 68 69 virtual Qt::ItemFlags itemFlags (int /* aColumn */) const { return 0; } 70 virtual bool setData (int /* aColumn */, const QVariant & /* aValue */, int /* aRole */) { return false; } 71 virtual QVariant data (int /* aColumn */, int /* aRole */) const { return QVariant(); } 72 virtual QWidget * createEditor (QWidget * /* aParent */, const QStyleOptionViewItem & /* aOption */, const QModelIndex & /* aIndex */) const { return NULL; } 73 virtual bool setEditorData (QWidget * /* aEditor */, const QModelIndex & /* aIndex */) const { return false; } 74 virtual bool setModelData (QWidget * /* aEditor */, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */) { return false; } 75 76 virtual void restoreDefaults() {} 77 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues); 78 79 ModelItemType type() const { return mType; } 80 81 protected: 82 /* Protected member vars */ 83 int mNumber; 84 ModelItemType mType; 85 86 ModelItem *mParentItem; 87 QList<ModelItem*> mChildItems; 88 }; 89 90 //////////////////////////////////////////////////////////////////////////////// 91 // VirtualSystemItem 92 93 /* This class represent a Virtual System with an index. */ 94 class VirtualSystemItem: public ModelItem 95 { 96 public: 97 VirtualSystemItem (int aNumber, CVirtualSystemDescription aDesc, ModelItem *aParent); 98 99 virtual QVariant data (int aColumn, int aRole) const; 100 101 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues); 102 103 private: 104 CVirtualSystemDescription mDesc; 105 }; 106 107 //////////////////////////////////////////////////////////////////////////////// 108 // HardwareItem 109 110 /* This class represent an hardware item of a Virtual System. All values of 111 KVirtualSystemDescriptionType are supported & handled differently. */ 112 class HardwareItem: public ModelItem 113 { 114 friend class VirtualSystemSortProxyModel; 115 public: 116 117 HardwareItem (int aNumber, 118 KVirtualSystemDescriptionType aType, 119 const QString &aRef, 120 const QString &aOrigValue, 121 const QString &aConfigValue, 122 const QString &aExtraConfigValue, 123 ModelItem *aParent); 124 125 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues); 126 127 virtual bool setData (int aColumn, const QVariant &aValue, int aRole); 128 virtual QVariant data (int aColumn, int aRole) const; 129 130 virtual Qt::ItemFlags itemFlags (int aColumn) const; 131 132 virtual QWidget * createEditor (QWidget *aParent, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const; 133 virtual bool setEditorData (QWidget *aEditor, const QModelIndex &aIndex) const; 134 135 virtual bool setModelData (QWidget *aEditor, QAbstractItemModel *aModel, const QModelIndex &aIndex); 136 137 virtual void restoreDefaults() 138 { 139 mConfigValue = mConfigDefaultValue; 140 mCheckState = Qt::Checked; 141 } 142 143 private: 144 145 /* Private member vars */ 146 KVirtualSystemDescriptionType mType; 147 QString mRef; 148 QString mOrigValue; 149 QString mConfigValue; 150 QString mConfigDefaultValue; 151 QString mExtraConfigValue; 152 Qt::CheckState mCheckState; 153 }; 154 155 //////////////////////////////////////////////////////////////////////////////// 156 // VirtualSystemModel 157 158 class VirtualSystemModel: public QAbstractItemModel 159 { 160 161 public: 162 VirtualSystemModel (QVector<CVirtualSystemDescription>& aVSDs, QObject *aParent = NULL); 163 164 QModelIndex index (int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const; 165 QModelIndex parent (const QModelIndex &aIndex) const; 166 int rowCount (const QModelIndex &aParent = QModelIndex()) const; 167 int columnCount (const QModelIndex &aParent = QModelIndex()) const; 168 bool setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole); 169 QVariant data (const QModelIndex &aIndex, int aRole = Qt::DisplayRole) const; 170 Qt::ItemFlags flags (const QModelIndex &aIndex) const; 171 QVariant headerData (int aSection, Qt::Orientation aOrientation, int aRole) const; 172 173 void restoreDefaults (const QModelIndex& aParent = QModelIndex()); 174 void putBack(); 175 176 private: 177 /* Private member vars */ 178 ModelItem *mRootItem; 179 }; 180 181 //////////////////////////////////////////////////////////////////////////////// 182 // VirtualSystemDelegate 183 184 /* The delegate is used for creating/handling the different editors for the 185 various types we support. This class forward the requests to the virtual 186 methods of our different ModelItems. If this is not possible the default 187 methods of QItemDelegate are used to get some standard behavior. Note: We 188 have to handle the proxy model ourself. I really don't understand why Qt is 189 not doing this for us. */ 190 class VirtualSystemDelegate: public QItemDelegate 191 { 192 public: 193 VirtualSystemDelegate (QAbstractProxyModel *aProxy, QObject *aParent = NULL); 194 195 QWidget * createEditor (QWidget *aParent, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const; 196 void setEditorData (QWidget *aEditor, const QModelIndex &aIndex) const; 197 void setModelData (QWidget *aEditor, QAbstractItemModel *aModel, const QModelIndex &aIndex) const; 198 void updateEditorGeometry (QWidget *aEditor, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const; 199 200 QSize sizeHint (const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const 201 { 202 QSize size = QItemDelegate::sizeHint (aOption, aIndex); 203 #ifdef Q_WS_MAC 204 int h = 28; 205 #else /* Q_WS_MAC */ 206 int h = 24; 207 #endif /* Q_WS_MAC */ 208 size.setHeight (RT_MAX (h, size.height())); 209 return size; 210 } 211 private: 212 /* Private member vars */ 213 QAbstractProxyModel *mProxy; 214 }; 215 216 //////////////////////////////////////////////////////////////////////////////// 217 // VirtualSystemSortProxyModel 218 219 class VirtualSystemSortProxyModel: public QSortFilterProxyModel 220 { 221 public: 222 VirtualSystemSortProxyModel (QObject *aParent = NULL); 223 224 protected: 225 bool filterAcceptsRow (int aSourceRow, const QModelIndex & aSourceParent) const; 226 bool lessThan (const QModelIndex &aLeft, const QModelIndex &aRight) const; 227 228 static KVirtualSystemDescriptionType mSortList[]; 229 230 QList<KVirtualSystemDescriptionType> mFilterList; 231 }; 232 233 //////////////////////////////////////////////////////////////////////////////// 234 // VBoxApplianceEditorWgt 235 236 class VBoxApplianceEditorWgt : public QIWithRetranslateUI<QWidget>, 237 public Ui::VBoxApplianceEditorWgt 34 238 { 35 239 Q_OBJECT; 36 240 37 241 public: 38 VBoxImportApplianceWgt (QWidget *aParent); 39 40 bool setFile (const QString& aFile); 41 void prepareImport(); 42 bool import(); 242 VBoxApplianceEditorWgt (QWidget *aParent = NULL); 43 243 44 244 bool isValid() const { return mAppliance != NULL; } 45 QList < QPair <QString, QString> > licenseAgreements() const; 46 47 static int minGuestRAM() { return mMinGuestRAM; } 48 static int maxGuestRAM() { return mMaxGuestRAM; } 49 static int minGuestCPUCount() { return mMinGuestCPUCount; } 50 static int maxGuestCPUCount() { return mMaxGuestCPUCount; } 245 CAppliance* appliance() const { return mAppliance; } 51 246 52 247 public slots: … … 54 249 55 250 protected: 56 void retranslateUi(); 57 58 private: 59 static void initSystemSettings(); 60 61 /* Private member vars */ 251 virtual void retranslateUi(); 252 253 /* Protected member vars */ 62 254 CAppliance *mAppliance; 63 255 VirtualSystemModel *mModel; 64 65 static int mMinGuestRAM; 66 static int mMaxGuestRAM; 67 static int mMinGuestCPUCount; 68 static int mMaxGuestCPUCount; 69 }; 70 71 #endif /* __VBoxImportApplianceWgt_h__ */ 72 256 }; 257 258 #endif /* __VBoxApplianceEditorWgt_h__ */ 259 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxExportApplianceWzd.h
r18132 r18378 53 53 private: 54 54 void addListViewVMItems (const QString& aSelectName); 55 bool prepare ForExportVMs (CAppliance &aAppliance);55 bool prepareSettingsWidget(); 56 56 bool exportVMs (CAppliance &aAppliance); 57 57 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxImportApplianceWgt.h
r18198 r18378 24 24 #define __VBoxImportApplianceWgt_h__ 25 25 26 #include "VBoxImportApplianceWgt.gen.h" 27 #include " QIWithRetranslateUI.h"26 /* VBox includes */ 27 #include "VBoxApplianceEditorWgt.h" 28 28 29 class CAppliance; 30 class VirtualSystemModel; 31 32 class VBoxImportApplianceWgt : public QIWithRetranslateUI<QWidget>, 33 public Ui::VBoxImportApplianceWgt 29 class VBoxImportApplianceWgt : public VBoxApplianceEditorWgt 34 30 { 35 31 Q_OBJECT; … … 42 38 bool import(); 43 39 44 bool isValid() const { return mAppliance != NULL; }45 40 QList < QPair <QString, QString> > licenseAgreements() const; 46 41 … … 50 45 static int maxGuestCPUCount() { return mMaxGuestCPUCount; } 51 46 52 public slots:53 void restoreDefaults();54 55 protected:56 void retranslateUi();57 58 47 private: 59 48 static void initSystemSettings(); 60 49 61 50 /* Private member vars */ 62 CAppliance *mAppliance;63 VirtualSystemModel *mModel;64 65 51 static int mMinGuestRAM; 66 52 static int mMaxGuestRAM; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxApplianceEditorWgt.cpp
r18307 r18378 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * VBox ImportApplianceWgt class implementation4 * VBoxApplianceEditorWgt class implementation 5 5 */ 6 6 … … 21 21 */ 22 22 23 #include "VBoxImportApplianceWgt.h" 23 /* VBox includes */ 24 #include "VBoxApplianceEditorWgt.h" 24 25 #include "VBoxImportApplianceWzd.h" 25 26 #include "VBoxGlobal.h" … … 27 28 #include "VBoxFilePathSelectorWidget.h" 28 29 #include "VBoxOSTypeSelectorButton.h" 30 #include "VBoxLineTextEdit.h" 29 31 30 32 /* Qt includes */ … … 37 39 #include <QComboBox> 38 40 39 class ModelItem;40 41 ////////////////////////////////////////////////////////////////////////////////42 // Globals43 44 enum TreeViewSection { DescriptionSection = 0, OriginalValueSection, ConfigValueSection };45 46 ////////////////////////////////////////////////////////////////////////////////47 // Private helper class declarations48 49 class VirtualSystemSortProxyModel: public QSortFilterProxyModel50 {51 public:52 VirtualSystemSortProxyModel (QObject *aParent = NULL);53 54 protected:55 bool filterAcceptsRow (int aSourceRow, const QModelIndex & aSourceParent) const;56 bool lessThan (const QModelIndex &aLeft, const QModelIndex &aRight) const;57 58 static KVirtualSystemDescriptionType mSortList[];59 };60 61 class VirtualSystemModel: public QAbstractItemModel62 {63 64 public:65 VirtualSystemModel (QVector<CVirtualSystemDescription>& aVSDs, QObject *aParent = NULL);66 67 inline QModelIndex index (int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const;68 inline QModelIndex parent (const QModelIndex &aIndex) const;69 inline int rowCount (const QModelIndex &aParent = QModelIndex()) const;70 inline int columnCount (const QModelIndex &aParent = QModelIndex()) const;71 inline bool setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole);72 inline QVariant data (const QModelIndex &aIndex, int aRole = Qt::DisplayRole) const;73 inline Qt::ItemFlags flags (const QModelIndex &aIndex) const;74 inline QVariant headerData (int aSection, Qt::Orientation aOrientation, int aRole) const;75 76 inline void restoreDefaults (const QModelIndex& aParent = QModelIndex());77 inline void putBack();78 79 private:80 /* Private member vars */81 ModelItem *mRootItem;82 };83 84 41 //////////////////////////////////////////////////////////////////////////////// 85 42 // ModelItem 86 87 enum ModelItemType { RootType, VirtualSystemType, HardwareType };88 43 89 44 /* This & the following derived classes represent the data items of a Virtual … … 91 46 to keep the interface clean. ModelItem is able to handle tree structures 92 47 with a parent & several children's. */ 93 class ModelItem 94 { 95 public: 96 ModelItem (int aNumber, ModelItemType aType, ModelItem *aParent = NULL) 97 : mNumber (aNumber) 98 , mType (aType) 99 , mParentItem (aParent) 100 {} 101 102 ~ModelItem() 48 ModelItem::ModelItem (int aNumber, ModelItemType aType, ModelItem *aParent /* = NULL */) 49 : mNumber (aNumber) 50 , mType (aType) 51 , mParentItem (aParent) 52 {} 53 54 ModelItem::~ModelItem() 55 { 56 qDeleteAll (mChildItems); 57 } 58 59 void ModelItem::appendChild (ModelItem *aChild) 60 { 61 AssertPtr (aChild); 62 mChildItems << aChild; 63 } 64 65 ModelItem * ModelItem::child (int aRow) const 66 { 67 return mChildItems.value (aRow); 68 } 69 70 int ModelItem::row() const 71 { 72 if (mParentItem) 73 return mParentItem->mChildItems.indexOf (const_cast<ModelItem*> (this)); 74 75 return 0; 76 } 77 78 int ModelItem::childCount() const 79 { 80 return mChildItems.count(); 81 } 82 83 void ModelItem::putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues) 84 { 85 for (int i = 0; i < childCount(); ++i) 86 child (i)->putBack (aFinalStates, aFinalValues, aFinalExtraValues); 87 } 88 89 //////////////////////////////////////////////////////////////////////////////// 90 // VirtualSystemItem 91 92 VirtualSystemItem::VirtualSystemItem (int aNumber, CVirtualSystemDescription aDesc, ModelItem *aParent) 93 : ModelItem (aNumber, VirtualSystemType, aParent) 94 , mDesc (aDesc) 95 {} 96 97 QVariant VirtualSystemItem::data (int aColumn, int aRole) const 98 { 99 QVariant v; 100 if (aColumn == DescriptionSection && 101 aRole == Qt::DisplayRole) 102 v = VBoxImportApplianceWgt::tr ("Virtual System %1").arg (mNumber + 1); 103 return v; 104 } 105 106 void VirtualSystemItem::putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues) 107 { 108 /* Resize the vectors */ 109 unsigned long count = mDesc.GetCount(); 110 aFinalStates.resize (count); 111 aFinalValues.resize (count); 112 aFinalExtraValues.resize (count); 113 /* Recursively fill the vectors */ 114 ModelItem::putBack (aFinalStates, aFinalValues, aFinalExtraValues); 115 /* Set all final values at once */ 116 mDesc.SetFinalValues (aFinalStates, aFinalValues, aFinalExtraValues); 117 } 118 119 //////////////////////////////////////////////////////////////////////////////// 120 // HardwareItem 121 122 HardwareItem::HardwareItem (int aNumber, 123 KVirtualSystemDescriptionType aType, 124 const QString &aRef, 125 const QString &aOrigValue, 126 const QString &aConfigValue, 127 const QString &aExtraConfigValue, 128 ModelItem *aParent) 129 : ModelItem (aNumber, HardwareType, aParent) 130 , mType (aType) 131 , mRef (aRef) 132 , mOrigValue (aOrigValue) 133 , mConfigValue (aConfigValue) 134 , mConfigDefaultValue (aConfigValue) 135 , mExtraConfigValue (aExtraConfigValue) 136 , mCheckState (Qt::Checked) 137 {} 138 139 void HardwareItem::putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues) 140 { 141 aFinalStates[mNumber] = mCheckState == Qt::Checked; 142 aFinalValues[mNumber] = mConfigValue; 143 aFinalExtraValues[mNumber] = mExtraConfigValue; 144 ModelItem::putBack (aFinalStates, aFinalValues, aFinalExtraValues); 145 } 146 147 bool HardwareItem::setData (int aColumn, const QVariant &aValue, int aRole) 148 { 149 bool fDone = false; 150 switch (aRole) 103 151 { 104 qDeleteAll (mChildItems); 105 } 106 107 ModelItem *parent() const { return mParentItem; } 108 109 void appendChild (ModelItem *aChild) 110 { 111 AssertPtr (aChild); 112 mChildItems << aChild; 113 } 114 ModelItem * child (int aRow) const { return mChildItems.value (aRow); } 115 116 int row() const 117 { 118 if (mParentItem) 119 return mParentItem->mChildItems.indexOf (const_cast<ModelItem*> (this)); 120 121 return 0; 122 } 123 124 int childCount() const { return mChildItems.count(); } 125 int columnCount() const { return 3; } 126 127 virtual Qt::ItemFlags itemFlags (int /* aColumn */) const { return 0; } 128 virtual bool setData (int /* aColumn */, const QVariant & /* aValue */, int /* aRole */) { return false; } 129 virtual QVariant data (int /* aColumn */, int /* aRole */) const { return QVariant(); } 130 virtual QWidget * createEditor (QWidget * /* aParent */, const QStyleOptionViewItem & /* aOption */, const QModelIndex & /* aIndex */) const { return NULL; } 131 virtual bool setEditorData (QWidget * /* aEditor */, const QModelIndex & /* aIndex */) const { return false; } 132 virtual bool setModelData (QWidget * /* aEditor */, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */) { return false; } 133 134 virtual void restoreDefaults() {} 135 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues) 136 { 137 for (int i = 0; i < childCount(); ++i) 138 child (i)->putBack (aFinalStates, aFinalValues, aFinalExtraValues); 139 } 140 141 ModelItemType type() const { return mType; } 142 143 protected: 144 int mNumber; 145 ModelItemType mType; 146 147 ModelItem *mParentItem; 148 QList<ModelItem*> mChildItems; 149 }; 150 151 /* This class represent a Virtual System with an index. */ 152 class VirtualSystemItem: public ModelItem 153 { 154 public: 155 VirtualSystemItem (int aNumber, CVirtualSystemDescription aDesc, ModelItem *aParent) 156 : ModelItem (aNumber, VirtualSystemType, aParent) 157 , mDesc (aDesc) 158 {} 159 160 virtual QVariant data (int aColumn, int aRole) const 161 { 162 QVariant v; 163 if (aColumn == DescriptionSection && 164 aRole == Qt::DisplayRole) 165 v = VBoxImportApplianceWgt::tr ("Virtual System %1").arg (mNumber + 1); 166 return v; 167 } 168 169 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues) 170 { 171 /* Resize the vectors */ 172 unsigned long count = mDesc.GetCount(); 173 aFinalStates.resize (count); 174 aFinalValues.resize (count); 175 aFinalExtraValues.resize (count); 176 /* Recursively fill the vectors */ 177 ModelItem::putBack (aFinalStates, aFinalValues, aFinalExtraValues); 178 /* Set all final values at once */ 179 mDesc.SetFinalValues (aFinalStates, aFinalValues, aFinalExtraValues); 180 } 181 182 private: 183 CVirtualSystemDescription mDesc; 184 }; 185 186 /* This class represent an hardware item of a Virtual System. All values of 187 KVirtualSystemDescriptionType are supported & handled differently. */ 188 class HardwareItem: public ModelItem 189 { 190 friend class VirtualSystemSortProxyModel; 191 public: 192 193 HardwareItem (int aNumber, 194 KVirtualSystemDescriptionType aType, 195 const QString &aRef, 196 const QString &aOrigValue, 197 const QString &aConfigValue, 198 const QString &aExtraConfigValue, 199 ModelItem *aParent) 200 : ModelItem (aNumber, HardwareType, aParent) 201 , mType (aType) 202 , mRef (aRef) 203 , mOrigValue (aOrigValue) 204 , mConfigValue (aConfigValue) 205 , mConfigDefaultValue (aConfigValue) 206 , mExtraConfigValue (aExtraConfigValue) 207 , mCheckState (Qt::Checked) 208 {} 209 210 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues) 211 { 212 aFinalStates[mNumber] = mCheckState == Qt::Checked; 213 aFinalValues[mNumber] = mConfigValue; 214 aFinalExtraValues[mNumber] = mExtraConfigValue; 215 ModelItem::putBack (aFinalStates, aFinalValues, aFinalExtraValues); 216 } 217 218 bool setData (int aColumn, const QVariant &aValue, int aRole) 219 { 220 bool fDone = false; 221 switch (aRole) 222 { 223 case Qt::CheckStateRole: 152 case Qt::CheckStateRole: 224 153 { 225 154 if (aColumn == ConfigValueSection && … … 235 164 break; 236 165 } 237 default: break; 238 } 239 return fDone; 166 default: break; 240 167 } 241 242 virtual QVariant data (int aColumn, int aRole) const 168 return fDone; 169 } 170 171 QVariant HardwareItem::data (int aColumn, int aRole) const 172 { 173 QVariant v; 174 switch (aRole) 243 175 { 244 QVariant v; 245 switch (aRole) 246 { 247 case Qt::DisplayRole: 176 case Qt::DisplayRole: 248 177 { 249 178 if (aColumn == DescriptionSection) … … 252 181 { 253 182 case KVirtualSystemDescriptionType_Name: v = VBoxImportApplianceWgt::tr ("Name"); break; 183 case KVirtualSystemDescriptionType_Product: v = VBoxImportApplianceWgt::tr ("Product"); break; 184 case KVirtualSystemDescriptionType_ProductUrl: v = VBoxImportApplianceWgt::tr ("Product-URL"); break; 185 case KVirtualSystemDescriptionType_Vendor: v = VBoxImportApplianceWgt::tr ("Vendor"); break; 186 case KVirtualSystemDescriptionType_VendorUrl: v = VBoxImportApplianceWgt::tr ("Vendor-URL"); break; 187 case KVirtualSystemDescriptionType_Version: v = VBoxImportApplianceWgt::tr ("Version"); break; 254 188 case KVirtualSystemDescriptionType_Description: v = VBoxImportApplianceWgt::tr ("Description"); break; 189 case KVirtualSystemDescriptionType_License: v = VBoxImportApplianceWgt::tr ("License"); break; 255 190 case KVirtualSystemDescriptionType_OS: v = VBoxImportApplianceWgt::tr ("Guest OS Type"); break; 256 191 case KVirtualSystemDescriptionType_CPU: v = VBoxImportApplianceWgt::tr ("CPU"); break; … … 274 209 switch (mType) 275 210 { 211 case KVirtualSystemDescriptionType_Description: 212 case KVirtualSystemDescriptionType_License: 213 { 214 /* Shorten the big text if there is more than 215 * one line */ 216 QString tmp (mConfigValue); 217 tmp.replace (tmp.indexOf ('\n'), tmp.length(), "..."); 218 v = tmp; break; 219 } 276 220 case KVirtualSystemDescriptionType_OS: v = vboxGlobal().vmGuestOSTypeDescription (mConfigValue); break; 277 221 case KVirtualSystemDescriptionType_Memory: v = mConfigValue + " " + VBoxImportApplianceWgt::tr ("MB"); break; … … 283 227 break; 284 228 } 285 229 case Qt::ToolTipRole: 286 230 { 287 231 if (aColumn == ConfigValueSection) … … 292 236 break; 293 237 } 294 238 case Qt::DecorationRole: 295 239 { 296 240 if (aColumn == DescriptionSection) … … 299 243 { 300 244 case KVirtualSystemDescriptionType_Name: v = QIcon (":/name_16px.png"); break; 301 case KVirtualSystemDescriptionType_Description: v = QIcon (":/description_16px.png"); break; 245 case KVirtualSystemDescriptionType_Product: 246 case KVirtualSystemDescriptionType_ProductUrl: 247 case KVirtualSystemDescriptionType_Vendor: 248 case KVirtualSystemDescriptionType_VendorUrl: 249 case KVirtualSystemDescriptionType_Version: 250 case KVirtualSystemDescriptionType_Description: 251 case KVirtualSystemDescriptionType_License: v = QIcon (":/description_16px.png"); break; 302 252 case KVirtualSystemDescriptionType_OS: v = QIcon (":/os_type_16px.png"); break; 303 253 case KVirtualSystemDescriptionType_CPU: v = QIcon (":/cpu_16px.png"); break; … … 322 272 break; 323 273 } 324 274 case Qt::FontRole: 325 275 { 326 276 /* If the item is unchecked mark it with italic text. */ … … 334 284 break; 335 285 } 336 286 case Qt::ForegroundRole: 337 287 { 338 288 /* If the item is unchecked mark it with gray text. */ … … 345 295 break; 346 296 } 347 297 case Qt::CheckStateRole: 348 298 { 349 299 if (aColumn == ConfigValueSection && … … 356 306 break; 357 307 } 358 }359 return v;360 308 } 361 362 virtual Qt::ItemFlags itemFlags (int aColumn) const 309 return v; 310 } 311 312 Qt::ItemFlags HardwareItem::itemFlags (int aColumn) const 313 { 314 Qt::ItemFlags flags = 0; 315 if (aColumn == ConfigValueSection) 363 316 { 364 Qt::ItemFlags flags = 0; 365 if (aColumn == ConfigValueSection) 317 /* Some items are checkable */ 318 if (mType == KVirtualSystemDescriptionType_Floppy || 319 mType == KVirtualSystemDescriptionType_CDROM || 320 mType == KVirtualSystemDescriptionType_USBController || 321 mType == KVirtualSystemDescriptionType_SoundCard || 322 mType == KVirtualSystemDescriptionType_NetworkAdapter) 323 flags |= Qt::ItemIsUserCheckable; 324 /* Some items are editable */ 325 if ((mType == KVirtualSystemDescriptionType_Name || 326 mType == KVirtualSystemDescriptionType_Product || 327 mType == KVirtualSystemDescriptionType_ProductUrl || 328 mType == KVirtualSystemDescriptionType_Vendor || 329 mType == KVirtualSystemDescriptionType_VendorUrl || 330 mType == KVirtualSystemDescriptionType_Version || 331 mType == KVirtualSystemDescriptionType_Description || 332 mType == KVirtualSystemDescriptionType_License || 333 mType == KVirtualSystemDescriptionType_OS || 334 mType == KVirtualSystemDescriptionType_Memory || 335 mType == KVirtualSystemDescriptionType_SoundCard || 336 mType == KVirtualSystemDescriptionType_NetworkAdapter || 337 mType == KVirtualSystemDescriptionType_HardDiskControllerIDE || 338 mType == KVirtualSystemDescriptionType_HardDiskImage) && 339 mCheckState == Qt::Checked) /* Item has to be enabled */ 340 flags |= Qt::ItemIsEditable; 341 } 342 return flags; 343 } 344 345 QWidget * HardwareItem::createEditor (QWidget *aParent, const QStyleOptionViewItem & /* aOption */, const QModelIndex &aIndex) const 346 { 347 QWidget *editor = NULL; 348 if (aIndex.column() == ConfigValueSection) 349 { 350 switch (mType) 366 351 { 367 /* Some items are checkable */ 368 if (mType == KVirtualSystemDescriptionType_Floppy || 369 mType == KVirtualSystemDescriptionType_CDROM || 370 mType == KVirtualSystemDescriptionType_USBController || 371 mType == KVirtualSystemDescriptionType_SoundCard || 372 mType == KVirtualSystemDescriptionType_NetworkAdapter) 373 flags |= Qt::ItemIsUserCheckable; 374 /* Some items are editable */ 375 if ((mType == KVirtualSystemDescriptionType_Name || 376 mType == KVirtualSystemDescriptionType_Description || 377 mType == KVirtualSystemDescriptionType_OS || 378 mType == KVirtualSystemDescriptionType_Memory || 379 mType == KVirtualSystemDescriptionType_SoundCard || 380 mType == KVirtualSystemDescriptionType_NetworkAdapter || 381 mType == KVirtualSystemDescriptionType_HardDiskControllerIDE || 382 mType == KVirtualSystemDescriptionType_HardDiskImage) && 383 mCheckState == Qt::Checked) /* Item has to be enabled */ 384 flags |= Qt::ItemIsEditable; 385 } 386 return flags; 387 } 388 389 virtual QWidget * createEditor (QWidget *aParent, const QStyleOptionViewItem & /* aOption */, const QModelIndex &aIndex) const 390 { 391 QWidget *editor = NULL; 392 if (aIndex.column() == ConfigValueSection) 393 { 394 switch (mType) 395 { 396 case KVirtualSystemDescriptionType_OS: 352 case KVirtualSystemDescriptionType_OS: 397 353 { 398 354 VBoxOSTypeSelectorButton *e = new VBoxOSTypeSelectorButton (aParent); … … 405 361 break; 406 362 } 407 case KVirtualSystemDescriptionType_Name: 363 case KVirtualSystemDescriptionType_Name: 364 case KVirtualSystemDescriptionType_Product: 365 case KVirtualSystemDescriptionType_ProductUrl: 366 case KVirtualSystemDescriptionType_Vendor: 367 case KVirtualSystemDescriptionType_VendorUrl: 368 case KVirtualSystemDescriptionType_Version: 408 369 { 409 370 QLineEdit *e = new QLineEdit (aParent); … … 411 372 break; 412 373 } 413 case KVirtualSystemDescriptionType_Description: 414 { 415 QTextEdit *e = new QTextEdit (aParent); 374 case KVirtualSystemDescriptionType_Description: 375 case KVirtualSystemDescriptionType_License: 376 { 377 VBoxLineTextEdit *e = new VBoxLineTextEdit (aParent); 416 378 editor = e; 417 379 break; 418 380 } 419 381 case KVirtualSystemDescriptionType_CPU: 420 382 { 421 383 QSpinBox *e = new QSpinBox (aParent); … … 424 386 break; 425 387 } 426 388 case KVirtualSystemDescriptionType_Memory: 427 389 { 428 390 QSpinBox *e = new QSpinBox (aParent); … … 432 394 break; 433 395 } 434 396 case KVirtualSystemDescriptionType_SoundCard: 435 397 { 436 398 QComboBox *e = new QComboBox (aParent); … … 440 402 break; 441 403 } 442 404 case KVirtualSystemDescriptionType_NetworkAdapter: 443 405 { 444 406 QComboBox *e = new QComboBox (aParent); … … 452 414 break; 453 415 } 454 416 case KVirtualSystemDescriptionType_HardDiskControllerIDE: 455 417 { 456 418 QComboBox *e = new QComboBox (aParent); … … 461 423 break; 462 424 } 463 464 { 465 /* disabled for now466 VBoxFilePathSelectorWidget *e = new VBoxFilePathSelectorWidget (aParent);467 e->setMode (VBoxFilePathSelectorWidget::Mode_File);468 e->setResetEnabled (false);469 */425 case KVirtualSystemDescriptionType_HardDiskImage: 426 { 427 /* disabled for now 428 VBoxFilePathSelectorWidget *e = new VBoxFilePathSelectorWidget (aParent); 429 e->setMode (VBoxFilePathSelectorWidget::Mode_File); 430 e->setResetEnabled (false); 431 */ 470 432 QLineEdit *e = new QLineEdit (aParent); 471 433 editor = e; 472 434 break; 473 435 } 474 default: break; 475 } 436 default: break; 476 437 } 477 return editor;478 438 } 479 480 virtual bool setEditorData (QWidget *aEditor, const QModelIndex & /* aIndex */) const 439 return editor; 440 } 441 442 bool HardwareItem::setEditorData (QWidget *aEditor, const QModelIndex & /* aIndex */) const 443 { 444 bool fDone = false; 445 switch (mType) 481 446 { 482 bool fDone = false; 483 switch (mType) 484 { 485 case KVirtualSystemDescriptionType_OS: 447 case KVirtualSystemDescriptionType_OS: 486 448 { 487 449 if (VBoxOSTypeSelectorButton *e = qobject_cast<VBoxOSTypeSelectorButton*> (aEditor)) … … 492 454 break; 493 455 } 494 456 case KVirtualSystemDescriptionType_HardDiskControllerIDE: 495 457 { 496 458 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor)) … … 503 465 break; 504 466 } 505 506 467 case KVirtualSystemDescriptionType_CPU: 468 case KVirtualSystemDescriptionType_Memory: 507 469 { 508 470 if (QSpinBox *e = qobject_cast<QSpinBox*> (aEditor)) … … 513 475 break; 514 476 } 515 case KVirtualSystemDescriptionType_Name: 477 case KVirtualSystemDescriptionType_Name: 478 case KVirtualSystemDescriptionType_Product: 479 case KVirtualSystemDescriptionType_ProductUrl: 480 case KVirtualSystemDescriptionType_Vendor: 481 case KVirtualSystemDescriptionType_VendorUrl: 482 case KVirtualSystemDescriptionType_Version: 516 483 { 517 484 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) … … 522 489 break; 523 490 } 524 case KVirtualSystemDescriptionType_Description: 525 { 526 if (QTextEdit *e = qobject_cast<QTextEdit*> (aEditor)) 527 { 528 e->setPlainText (mConfigValue); 529 fDone = true; 530 } 531 break; 532 } 533 case KVirtualSystemDescriptionType_SoundCard: 534 case KVirtualSystemDescriptionType_NetworkAdapter: 491 case KVirtualSystemDescriptionType_Description: 492 case KVirtualSystemDescriptionType_License: 493 { 494 if (VBoxLineTextEdit *e = qobject_cast<VBoxLineTextEdit*> (aEditor)) 495 { 496 e->setText (mConfigValue); 497 fDone = true; 498 } 499 break; 500 } 501 case KVirtualSystemDescriptionType_SoundCard: 502 case KVirtualSystemDescriptionType_NetworkAdapter: 535 503 { 536 504 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor)) … … 543 511 break; 544 512 } 545 513 case KVirtualSystemDescriptionType_HardDiskImage: 546 514 { 547 515 /* disabled for now 548 if (VBoxFilePathSelectorWidget *e = qobject_cast<VBoxFilePathSelectorWidget*> (aEditor)) 549 { 550 e->setPath (mConfigValue); 551 */ 516 if (VBoxFilePathSelectorWidget *e = qobject_cast<VBoxFilePathSelectorWidget*> (aEditor)) 517 { 518 e->setPath (mConfigValue); 519 } 520 */ 552 521 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) 553 522 { … … 557 526 break; 558 527 } 559 default: break; 528 default: break; 529 } 530 return fDone; 531 } 532 533 bool HardwareItem::setModelData (QWidget *aEditor, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */) 534 { 535 bool fDone = false; 536 switch (mType) 537 { 538 case KVirtualSystemDescriptionType_OS: 539 { 540 if (VBoxOSTypeSelectorButton *e = qobject_cast<VBoxOSTypeSelectorButton*> (aEditor)) 541 { 542 mConfigValue = e->osTypeId(); 543 fDone = true; 544 } 545 break; 546 } 547 case KVirtualSystemDescriptionType_HardDiskControllerIDE: 548 { 549 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor)) 550 { 551 mConfigValue = e->itemData (e->currentIndex()).toString(); 552 fDone = true; 553 } 554 break; 555 } 556 case KVirtualSystemDescriptionType_CPU: 557 case KVirtualSystemDescriptionType_Memory: 558 { 559 if (QSpinBox *e = qobject_cast<QSpinBox*> (aEditor)) 560 { 561 mConfigValue = QString::number (e->value()); 562 fDone = true; 563 } 564 break; 565 } 566 case KVirtualSystemDescriptionType_Name: 567 case KVirtualSystemDescriptionType_Product: 568 case KVirtualSystemDescriptionType_ProductUrl: 569 case KVirtualSystemDescriptionType_Vendor: 570 case KVirtualSystemDescriptionType_VendorUrl: 571 case KVirtualSystemDescriptionType_Version: 572 { 573 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) 574 { 575 mConfigValue = e->text(); 576 fDone = true; 577 } 578 break; 579 } 580 case KVirtualSystemDescriptionType_Description: 581 case KVirtualSystemDescriptionType_License: 582 { 583 if (VBoxLineTextEdit *e = qobject_cast<VBoxLineTextEdit*> (aEditor)) 584 { 585 mConfigValue = e->text(); 586 fDone = true; 587 } 588 break; 589 } 590 case KVirtualSystemDescriptionType_SoundCard: 591 case KVirtualSystemDescriptionType_NetworkAdapter: 592 { 593 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor)) 594 { 595 mConfigValue = e->itemData (e->currentIndex()).toString(); 596 fDone = true; 597 } 598 break; 599 } 600 case KVirtualSystemDescriptionType_HardDiskImage: 601 { 602 /* disabled for now 603 if (VBoxFilePathSelectorWidget *e = qobject_cast<VBoxFilePathSelectorWidget*> (aEditor)) 604 { 605 mConfigValue = e->path(); 606 } 607 */ 608 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) 609 { 610 mConfigValue = e->text(); 611 fDone = true; 612 } 613 break; 614 } 615 default: break; 616 } 617 return fDone; 618 } 619 620 //////////////////////////////////////////////////////////////////////////////// 621 // VirtualSystemModel 622 623 /* This class is a wrapper model for our ModelItem. It could be used with any 624 TreeView & forward mostly all calls to the methods of ModelItem. The 625 ModelItems itself are stored as internal pointers in the QModelIndex class. */ 626 VirtualSystemModel::VirtualSystemModel (QVector<CVirtualSystemDescription>& aVSDs, QObject *aParent /* = NULL */) 627 : QAbstractItemModel (aParent) 628 { 629 mRootItem = new ModelItem (0, RootType); 630 for (int a = 0; a < aVSDs.size(); ++a) 631 { 632 CVirtualSystemDescription vs = aVSDs[a]; 633 634 VirtualSystemItem *vi = new VirtualSystemItem (a, vs, mRootItem); 635 mRootItem->appendChild (vi); 636 637 /* @todo: ask Dmitry about include/COMDefs.h:232 */ 638 QVector<KVirtualSystemDescriptionType> types; 639 QVector<QString> refs; 640 QVector<QString> origValues; 641 QVector<QString> configValues; 642 QVector<QString> extraConfigValues; 643 644 QList<int> hdIndizies; 645 QMap<int, HardwareItem*> controllerMap; 646 vs.GetDescription (types, refs, origValues, configValues, extraConfigValues); 647 for (int i = 0; i < types.size(); ++i) 648 { 649 /* We add the hard disk images in an second step, so save a 650 reference to them. */ 651 if (types[i] == KVirtualSystemDescriptionType_HardDiskImage) 652 hdIndizies << i; 653 else 654 { 655 HardwareItem *hi = new HardwareItem (i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], vi); 656 vi->appendChild (hi); 657 /* Save the hard disk controller types in an extra map */ 658 if (types[i] == KVirtualSystemDescriptionType_HardDiskControllerIDE || 659 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSATA || 660 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSCSI) 661 controllerMap[i] = hi; 662 } 560 663 } 561 return fDone; 664 QRegExp rx ("controller=(\\d+);?"); 665 /* Now process the hard disk images */ 666 for (int a = 0; a < hdIndizies.size(); ++a) 667 { 668 int i = hdIndizies[a]; 669 QString ecnf = extraConfigValues[i]; 670 if (rx.indexIn (ecnf) != -1) 671 { 672 /* Get the controller */ 673 HardwareItem *ci = controllerMap[rx.cap (1).toInt()]; 674 if (ci) 675 { 676 /* New hardware item as child of the controller */ 677 HardwareItem *hi = new HardwareItem (i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], ci); 678 ci->appendChild (hi); 679 } 680 } 681 } 562 682 } 563 564 virtual bool setModelData (QWidget *aEditor, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */) 683 } 684 685 QModelIndex VirtualSystemModel::index (int aRow, int aColumn, const QModelIndex &aParent /* = QModelIndex() */) const 686 { 687 if (!hasIndex (aRow, aColumn, aParent)) 688 return QModelIndex(); 689 690 ModelItem *parentItem; 691 692 if (!aParent.isValid()) 693 parentItem = mRootItem; 694 else 695 parentItem = static_cast<ModelItem*> (aParent.internalPointer()); 696 697 ModelItem *childItem = parentItem->child (aRow); 698 if (childItem) 699 return createIndex (aRow, aColumn, childItem); 700 else 701 return QModelIndex(); 702 } 703 704 QModelIndex VirtualSystemModel::parent (const QModelIndex &aIndex) const 705 { 706 if (!aIndex.isValid()) 707 return QModelIndex(); 708 709 ModelItem *childItem = static_cast<ModelItem*> (aIndex.internalPointer()); 710 ModelItem *parentItem = childItem->parent(); 711 712 if (parentItem == mRootItem) 713 return QModelIndex(); 714 715 return createIndex (parentItem->row(), 0, parentItem); 716 } 717 718 int VirtualSystemModel::rowCount (const QModelIndex &aParent /* = QModelIndex() */) const 719 { 720 ModelItem *parentItem; 721 if (aParent.column() > 0) 722 return 0; 723 724 if (!aParent.isValid()) 725 parentItem = mRootItem; 726 else 727 parentItem = static_cast<ModelItem*> (aParent.internalPointer()); 728 729 return parentItem->childCount(); 730 } 731 732 int VirtualSystemModel::columnCount (const QModelIndex &aParent /* = QModelIndex() */) const 733 { 734 if (aParent.isValid()) 735 return static_cast<ModelItem*> (aParent.internalPointer())->columnCount(); 736 else 737 return mRootItem->columnCount(); 738 } 739 740 bool VirtualSystemModel::setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole) 741 { 742 if (!aIndex.isValid()) 743 return false; 744 745 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer()); 746 747 return item->setData (aIndex.column(), aValue, aRole); 748 } 749 750 QVariant VirtualSystemModel::data (const QModelIndex &aIndex, int aRole /* = Qt::DisplayRole */) const 751 { 752 if (!aIndex.isValid()) 753 return QVariant(); 754 755 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer()); 756 757 return item->data (aIndex.column(), aRole); 758 } 759 760 Qt::ItemFlags VirtualSystemModel::flags (const QModelIndex &aIndex) const 761 { 762 if (!aIndex.isValid()) 763 return 0; 764 765 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer()); 766 767 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | item->itemFlags (aIndex.column()); 768 } 769 770 QVariant VirtualSystemModel::headerData (int aSection, Qt::Orientation aOrientation, int aRole) const 771 { 772 if (aRole != Qt::DisplayRole || 773 aOrientation != Qt::Horizontal) 774 return QVariant(); 775 776 QString title; 777 switch (aSection) 565 778 { 566 bool fDone = false; 567 switch (mType) 568 { 569 case KVirtualSystemDescriptionType_OS: 570 { 571 if (VBoxOSTypeSelectorButton *e = qobject_cast<VBoxOSTypeSelectorButton*> (aEditor)) 572 { 573 mConfigValue = e->osTypeId(); 574 fDone = true; 575 } 576 break; 577 } 578 case KVirtualSystemDescriptionType_HardDiskControllerIDE: 579 { 580 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor)) 581 { 582 mConfigValue = e->itemData (e->currentIndex()).toString(); 583 fDone = true; 584 } 585 break; 586 } 587 case KVirtualSystemDescriptionType_CPU: 588 case KVirtualSystemDescriptionType_Memory: 589 { 590 if (QSpinBox *e = qobject_cast<QSpinBox*> (aEditor)) 591 { 592 mConfigValue = QString::number (e->value()); 593 fDone = true; 594 } 595 break; 596 } 597 case KVirtualSystemDescriptionType_Name: 598 { 599 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) 600 { 601 mConfigValue = e->text(); 602 fDone = true; 603 } 604 break; 605 } 606 case KVirtualSystemDescriptionType_Description: 607 { 608 if (QTextEdit *e = qobject_cast<QTextEdit*> (aEditor)) 609 { 610 mConfigValue = e->toPlainText(); 611 fDone = true; 612 } 613 break; 614 } 615 case KVirtualSystemDescriptionType_SoundCard: 616 case KVirtualSystemDescriptionType_NetworkAdapter: 617 { 618 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor)) 619 { 620 mConfigValue = e->itemData (e->currentIndex()).toString(); 621 fDone = true; 622 } 623 break; 624 } 625 case KVirtualSystemDescriptionType_HardDiskImage: 626 { 627 /* disabled for now 628 if (VBoxFilePathSelectorWidget *e = qobject_cast<VBoxFilePathSelectorWidget*> (aEditor)) 629 { 630 mConfigValue = e->path(); 631 */ 632 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor)) 633 { 634 mConfigValue = e->text(); 635 fDone = true; 636 } 637 break; 638 } 639 default: break; 640 } 641 return fDone; 779 case DescriptionSection: title = VBoxImportApplianceWgt::tr ("Description"); break; 780 case ConfigValueSection: title = VBoxImportApplianceWgt::tr ("Configuration"); break; 642 781 } 643 644 virtual void restoreDefaults() 782 return title; 783 } 784 785 void VirtualSystemModel::restoreDefaults (const QModelIndex& aParent /* = QModelIndex() */) 786 { 787 ModelItem *parentItem; 788 789 if (!aParent.isValid()) 790 parentItem = mRootItem; 791 else 792 parentItem = static_cast<ModelItem*> (aParent.internalPointer()); 793 794 for (int i = 0; i < parentItem->childCount(); ++i) 645 795 { 646 mConfigValue = mConfigDefaultValue;647 mCheckState = Qt::Checked;796 parentItem->child (i)->restoreDefaults(); 797 restoreDefaults (index (i, 0, aParent)); 648 798 } 649 650 private: 651 652 /* Private member vars */ 653 KVirtualSystemDescriptionType mType; 654 QString mRef; 655 QString mOrigValue; 656 QString mConfigValue; 657 QString mConfigDefaultValue; 658 QString mExtraConfigValue; 659 Qt::CheckState mCheckState; 660 }; 799 emit dataChanged (index (0, 0, aParent), index (parentItem->childCount()-1, 0, aParent)); 800 } 801 802 void VirtualSystemModel::putBack() 803 { 804 QVector<BOOL> v1; 805 QVector<QString> v2; 806 QVector<QString> v3; 807 mRootItem->putBack (v1, v2, v3); 808 } 661 809 662 810 //////////////////////////////////////////////////////////////////////////////// … … 669 817 have to handle the proxy model ourself. I really don't understand why Qt is 670 818 not doing this for us. */ 671 class VirtualSystemDelegate: public QItemDelegate 672 { 673 public: 674 VirtualSystemDelegate (QAbstractProxyModel *aProxy, QObject *aParent = NULL) 675 : QItemDelegate (aParent) 676 , mProxy (aProxy) 677 {} 678 679 QWidget * createEditor (QWidget *aParent, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const 680 { 681 if (!aIndex.isValid()) 682 return QItemDelegate::createEditor (aParent, aOption, aIndex); 683 684 QModelIndex index (aIndex); 685 if (mProxy) 686 index = mProxy->mapToSource (aIndex); 687 688 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 689 QWidget *editor = item->createEditor (aParent, aOption, index); 690 691 if (editor == NULL) 692 return QItemDelegate::createEditor (aParent, aOption, index); 693 else 694 return editor; 695 } 696 697 void setEditorData (QWidget *aEditor, const QModelIndex &aIndex) const 698 { 699 if (!aIndex.isValid()) 700 return QItemDelegate::setEditorData (aEditor, aIndex); 701 702 QModelIndex index (aIndex); 703 if (mProxy) 704 index = mProxy->mapToSource (aIndex); 705 706 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 707 708 if (!item->setEditorData (aEditor, index)) 709 QItemDelegate::setEditorData (aEditor, index); 710 } 711 712 void setModelData (QWidget *aEditor, QAbstractItemModel *aModel, const QModelIndex &aIndex) const 713 { 714 if (!aIndex.isValid()) 715 return QItemDelegate::setModelData (aEditor, aModel, aIndex); 716 717 QModelIndex index = aModel->index (aIndex.row(), aIndex.column()); 718 if (mProxy) 719 index = mProxy->mapToSource (aIndex); 720 721 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 722 if (!item->setModelData (aEditor, aModel, index)) 723 QItemDelegate::setModelData (aEditor, aModel, aIndex); 724 } 725 726 void updateEditorGeometry (QWidget *aEditor, const QStyleOptionViewItem &aOption, const QModelIndex & /* aIndex */) const 727 { 728 if (aEditor) 729 aEditor->setGeometry (aOption.rect); 730 } 731 732 QSize sizeHint (const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const 733 { 734 QSize size = QItemDelegate::sizeHint (aOption, aIndex); 735 #ifdef Q_WS_MAC 736 int h = 28; 737 #else /* Q_WS_MAC */ 738 int h = 24; 739 #endif /* Q_WS_MAC */ 740 size.setHeight (RT_MAX (h, size.height())); 741 return size; 742 } 743 private: 744 /* Private member vars */ 745 QAbstractProxyModel *mProxy; 746 }; 819 VirtualSystemDelegate::VirtualSystemDelegate (QAbstractProxyModel *aProxy, QObject *aParent /* = NULL */) 820 : QItemDelegate (aParent) 821 , mProxy (aProxy) 822 {} 823 824 QWidget * VirtualSystemDelegate::createEditor (QWidget *aParent, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const 825 { 826 if (!aIndex.isValid()) 827 return QItemDelegate::createEditor (aParent, aOption, aIndex); 828 829 QModelIndex index (aIndex); 830 if (mProxy) 831 index = mProxy->mapToSource (aIndex); 832 833 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 834 QWidget *editor = item->createEditor (aParent, aOption, index); 835 836 if (editor == NULL) 837 return QItemDelegate::createEditor (aParent, aOption, index); 838 else 839 return editor; 840 } 841 842 void VirtualSystemDelegate::setEditorData (QWidget *aEditor, const QModelIndex &aIndex) const 843 { 844 if (!aIndex.isValid()) 845 return QItemDelegate::setEditorData (aEditor, aIndex); 846 847 QModelIndex index (aIndex); 848 if (mProxy) 849 index = mProxy->mapToSource (aIndex); 850 851 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 852 853 if (!item->setEditorData (aEditor, index)) 854 QItemDelegate::setEditorData (aEditor, index); 855 } 856 857 void VirtualSystemDelegate::setModelData (QWidget *aEditor, QAbstractItemModel *aModel, const QModelIndex &aIndex) const 858 { 859 if (!aIndex.isValid()) 860 return QItemDelegate::setModelData (aEditor, aModel, aIndex); 861 862 QModelIndex index = aModel->index (aIndex.row(), aIndex.column()); 863 if (mProxy) 864 index = mProxy->mapToSource (aIndex); 865 866 ModelItem *item = static_cast<ModelItem*> (index.internalPointer()); 867 if (!item->setModelData (aEditor, aModel, index)) 868 QItemDelegate::setModelData (aEditor, aModel, aIndex); 869 } 870 871 void VirtualSystemDelegate::updateEditorGeometry (QWidget *aEditor, const QStyleOptionViewItem &aOption, const QModelIndex & /* aIndex */) const 872 { 873 if (aEditor) 874 aEditor->setGeometry (aOption.rect); 875 } 747 876 748 877 //////////////////////////////////////////////////////////////////////////////// … … 753 882 { 754 883 KVirtualSystemDescriptionType_Name, 884 KVirtualSystemDescriptionType_Product, 885 KVirtualSystemDescriptionType_ProductUrl, 886 KVirtualSystemDescriptionType_Vendor, 887 KVirtualSystemDescriptionType_VendorUrl, 888 KVirtualSystemDescriptionType_Version, 755 889 KVirtualSystemDescriptionType_Description, 890 KVirtualSystemDescriptionType_License, 756 891 KVirtualSystemDescriptionType_OS, 757 KVirtualSystemDescriptionType_License,758 892 KVirtualSystemDescriptionType_CPU, 759 893 KVirtualSystemDescriptionType_Memory, … … 786 920 HardwareItem *hwItem = static_cast<HardwareItem*> (item); 787 921 /* The license type shouldn't be displayed */ 788 if ( hwItem->mType == KVirtualSystemDescriptionType_License)922 if (mFilterList.contains (hwItem->mType)) 789 923 return false; 790 924 } … … 824 958 825 959 //////////////////////////////////////////////////////////////////////////////// 826 // VirtualSystemModel 827 828 /* This class is a wrapper model for our ModelItem. It could be used with any 829 TreeView & forward mostly all calls to the methods of ModelItem. The 830 ModelItems itself are stored as internal pointers in the QModelIndex class. */ 831 VirtualSystemModel::VirtualSystemModel (QVector<CVirtualSystemDescription>& aVSDs, QObject *aParent /* = NULL */) 832 : QAbstractItemModel (aParent) 833 { 834 mRootItem = new ModelItem (0, RootType); 835 for (int a = 0; a < aVSDs.size(); ++a) 836 { 837 CVirtualSystemDescription vs = aVSDs[a]; 838 839 VirtualSystemItem *vi = new VirtualSystemItem (a, vs, mRootItem); 840 mRootItem->appendChild (vi); 841 842 /* @todo: ask Dmitry about include/COMDefs.h:232 */ 843 QVector<KVirtualSystemDescriptionType> types; 844 QVector<QString> refs; 845 QVector<QString> origValues; 846 QVector<QString> configValues; 847 QVector<QString> extraConfigValues; 848 849 QList<int> hdIndizies; 850 QMap<int, HardwareItem*> controllerMap; 851 vs.GetDescription (types, refs, origValues, configValues, extraConfigValues); 852 for (int i = 0; i < types.size(); ++i) 853 { 854 /* We add the hard disk images in an second step, so save a 855 reference to them. */ 856 if (types[i] == KVirtualSystemDescriptionType_HardDiskImage) 857 hdIndizies << i; 858 else 859 { 860 HardwareItem *hi = new HardwareItem (i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], vi); 861 vi->appendChild (hi); 862 /* Save the hard disk controller types in an extra map */ 863 if (types[i] == KVirtualSystemDescriptionType_HardDiskControllerIDE || 864 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSATA || 865 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSCSI) 866 controllerMap[i] = hi; 867 } 868 } 869 QRegExp rx ("controller=(\\d+);?"); 870 /* Now process the hard disk images */ 871 for (int a = 0; a < hdIndizies.size(); ++a) 872 { 873 int i = hdIndizies[a]; 874 QString ecnf = extraConfigValues[i]; 875 if (rx.indexIn (ecnf) != -1) 876 { 877 /* Get the controller */ 878 HardwareItem *ci = controllerMap[rx.cap (1).toInt()]; 879 if (ci) 880 { 881 /* New hardware item as child of the controller */ 882 HardwareItem *hi = new HardwareItem (i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], ci); 883 ci->appendChild (hi); 884 } 885 } 886 } 887 } 888 } 889 890 QModelIndex VirtualSystemModel::index (int aRow, int aColumn, const QModelIndex &aParent /* = QModelIndex() */) const 891 { 892 if (!hasIndex (aRow, aColumn, aParent)) 893 return QModelIndex(); 894 895 ModelItem *parentItem; 896 897 if (!aParent.isValid()) 898 parentItem = mRootItem; 899 else 900 parentItem = static_cast<ModelItem*> (aParent.internalPointer()); 901 902 ModelItem *childItem = parentItem->child (aRow); 903 if (childItem) 904 return createIndex (aRow, aColumn, childItem); 905 else 906 return QModelIndex(); 907 } 908 909 QModelIndex VirtualSystemModel::parent (const QModelIndex &aIndex) const 910 { 911 if (!aIndex.isValid()) 912 return QModelIndex(); 913 914 ModelItem *childItem = static_cast<ModelItem*> (aIndex.internalPointer()); 915 ModelItem *parentItem = childItem->parent(); 916 917 if (parentItem == mRootItem) 918 return QModelIndex(); 919 920 return createIndex (parentItem->row(), 0, parentItem); 921 } 922 923 int VirtualSystemModel::rowCount (const QModelIndex &aParent /* = QModelIndex() */) const 924 { 925 ModelItem *parentItem; 926 if (aParent.column() > 0) 927 return 0; 928 929 if (!aParent.isValid()) 930 parentItem = mRootItem; 931 else 932 parentItem = static_cast<ModelItem*> (aParent.internalPointer()); 933 934 return parentItem->childCount(); 935 } 936 937 int VirtualSystemModel::columnCount (const QModelIndex &aParent /* = QModelIndex() */) const 938 { 939 if (aParent.isValid()) 940 return static_cast<ModelItem*> (aParent.internalPointer())->columnCount(); 941 else 942 return mRootItem->columnCount(); 943 } 944 945 bool VirtualSystemModel::setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole) 946 { 947 if (!aIndex.isValid()) 948 return false; 949 950 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer()); 951 952 return item->setData (aIndex.column(), aValue, aRole); 953 } 954 955 QVariant VirtualSystemModel::data (const QModelIndex &aIndex, int aRole /* = Qt::DisplayRole */) const 956 { 957 if (!aIndex.isValid()) 958 return QVariant(); 959 960 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer()); 961 962 return item->data (aIndex.column(), aRole); 963 } 964 965 Qt::ItemFlags VirtualSystemModel::flags (const QModelIndex &aIndex) const 966 { 967 if (!aIndex.isValid()) 968 return 0; 969 970 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer()); 971 972 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | item->itemFlags (aIndex.column()); 973 } 974 975 QVariant VirtualSystemModel::headerData (int aSection, Qt::Orientation aOrientation, int aRole) const 976 { 977 if (aRole != Qt::DisplayRole || 978 aOrientation != Qt::Horizontal) 979 return QVariant(); 980 981 QString title; 982 switch (aSection) 983 { 984 case DescriptionSection: title = VBoxImportApplianceWgt::tr ("Description"); break; 985 case ConfigValueSection: title = VBoxImportApplianceWgt::tr ("Configuration"); break; 986 } 987 return title; 988 } 989 990 void VirtualSystemModel::restoreDefaults (const QModelIndex& aParent /* = QModelIndex() */) 991 { 992 ModelItem *parentItem; 993 994 if (!aParent.isValid()) 995 parentItem = mRootItem; 996 else 997 parentItem = static_cast<ModelItem*> (aParent.internalPointer()); 998 999 for (int i = 0; i < parentItem->childCount(); ++i) 1000 { 1001 parentItem->child (i)->restoreDefaults(); 1002 restoreDefaults (index (i, 0, aParent)); 1003 } 1004 emit dataChanged (index (0, 0, aParent), index (parentItem->childCount()-1, 0, aParent)); 1005 } 1006 1007 void VirtualSystemModel::putBack() 1008 { 1009 QVector<BOOL> v1; 1010 QVector<QString> v2; 1011 QVector<QString> v3; 1012 mRootItem->putBack (v1, v2, v3); 1013 } 1014 1015 //////////////////////////////////////////////////////////////////////////////// 1016 // VBoxImportApplianceWgt 1017 1018 int VBoxImportApplianceWgt::mMinGuestRAM = -1; 1019 int VBoxImportApplianceWgt::mMaxGuestRAM = -1; 1020 int VBoxImportApplianceWgt::mMinGuestCPUCount = -1; 1021 int VBoxImportApplianceWgt::mMaxGuestCPUCount = -1; 1022 1023 VBoxImportApplianceWgt::VBoxImportApplianceWgt (QWidget *aParent) 960 // VBoxApplianceEditorWgt 961 962 VBoxApplianceEditorWgt::VBoxApplianceEditorWgt (QWidget *aParent /* = NULL */) 1024 963 : QIWithRetranslateUI<QWidget> (aParent) 1025 964 , mAppliance (NULL) 1026 965 , mModel (NULL) 1027 966 { 1028 /* Make sure all static content is properly initialized */1029 initSystemSettings();1030 1031 967 /* Apply UI decorations */ 1032 Ui::VBox ImportApplianceWgt::setupUi (this);968 Ui::VBoxApplianceEditorWgt::setupUi (this); 1033 969 1034 970 /* Make the tree looking nicer */ … … 1042 978 } 1043 979 1044 bool VBoxImportApplianceWgt::setFile (const QString& aFile) 1045 { 1046 bool fResult = false; 1047 if (!aFile.isEmpty()) 1048 { 1049 CVirtualBox vbox = vboxGlobal().virtualBox(); 1050 /* Create a appliance object */ 1051 mAppliance = new CAppliance(vbox.CreateAppliance()); 1052 fResult = mAppliance->isOk(); 1053 if (fResult) 1054 { 1055 /* Read the appliance */ 1056 mAppliance->Read (aFile); 1057 fResult = mAppliance->isOk(); 1058 if (fResult) 1059 { 1060 /* Now we have to interpret that stuff */ 1061 mAppliance->Interpret(); 1062 fResult = mAppliance->isOk(); 1063 if (fResult) 1064 { 1065 if (mModel) 1066 delete mModel; 1067 1068 QVector<CVirtualSystemDescription> vsds = mAppliance->GetVirtualSystemDescriptions(); 1069 1070 mModel = new VirtualSystemModel (vsds, this); 1071 1072 VirtualSystemSortProxyModel *proxy = new VirtualSystemSortProxyModel (this); 1073 proxy->setSourceModel (mModel); 1074 proxy->sort (DescriptionSection, Qt::DescendingOrder); 1075 1076 VirtualSystemDelegate *delegate = new VirtualSystemDelegate (proxy, this); 1077 1078 /* Set our own model */ 1079 mTvSettings->setModel (proxy); 1080 /* Set our own delegate */ 1081 mTvSettings->setItemDelegate (delegate); 1082 /* For now we hide the original column. This data is displayed as tooltip 1083 also. */ 1084 mTvSettings->setColumnHidden (OriginalValueSection, true); 1085 mTvSettings->expandAll(); 1086 1087 /* Check for warnings & if there are one display them. */ 1088 bool fWarningsEnabled = false; 1089 QVector<QString> warnings = mAppliance->GetWarnings(); 1090 if (warnings.size() > 0) 1091 { 1092 foreach (const QString& text, warnings) 1093 mWarningTextEdit->append ("- " + text); 1094 fWarningsEnabled = true; 1095 } 1096 mWarningWidget->setShown (fWarningsEnabled); 1097 } 1098 } 1099 } 1100 if (!fResult) 1101 { 1102 vboxProblem().cannotImportAppliance (mAppliance, this); 1103 /* Delete the appliance in a case of an error */ 1104 delete mAppliance; 1105 mAppliance = NULL; 1106 } 1107 } 1108 return fResult; 1109 } 1110 1111 void VBoxImportApplianceWgt::prepareImport() 1112 { 1113 if (mAppliance) 1114 mModel->putBack(); 1115 } 1116 1117 bool VBoxImportApplianceWgt::import() 1118 { 1119 if (mAppliance) 1120 { 1121 /* Start the import asynchronously */ 1122 CProgress progress; 1123 progress = mAppliance->ImportMachines(); 1124 bool fResult = mAppliance->isOk(); 1125 if (fResult) 1126 { 1127 /* Show some progress, so the user know whats going on */ 1128 vboxProblem().showModalProgressDialog (progress, tr ("Importing Appliance ..."), this); 1129 if (!progress.isOk() || progress.GetResultCode() != 0) 1130 { 1131 vboxProblem().cannotImportAppliance (progress, mAppliance, this); 1132 return false; 1133 } 1134 else 1135 return true; 1136 } 1137 if (!fResult) 1138 vboxProblem().cannotImportAppliance (mAppliance, this); 1139 } 1140 return false; 1141 } 1142 1143 QList < QPair<QString, QString> > VBoxImportApplianceWgt::licenseAgreements() const 1144 { 1145 QList < QPair<QString, QString> > list; 1146 1147 CVirtualSystemDescriptionVector vsds = mAppliance->GetVirtualSystemDescriptions(); 1148 for (int i=0; i < vsds.size(); ++i) 1149 { 1150 QVector<QString> license; 1151 license = vsds[i].GetValuesByType (KVirtualSystemDescriptionType_License, 1152 KVirtualSystemDescriptionValueType_Original); 1153 if (!license.isEmpty()) 1154 { 1155 QVector<QString> name; 1156 name = vsds[i].GetValuesByType (KVirtualSystemDescriptionType_Name, 1157 KVirtualSystemDescriptionValueType_Auto); 1158 list << QPair<QString, QString> (name.first(), license.first()); 1159 } 1160 } 1161 1162 return list; 1163 } 1164 1165 void VBoxImportApplianceWgt::restoreDefaults() 980 void VBoxApplianceEditorWgt::restoreDefaults() 1166 981 { 1167 982 mModel->restoreDefaults(); 1168 983 } 1169 984 1170 void VBox ImportApplianceWgt::retranslateUi()985 void VBoxApplianceEditorWgt::retranslateUi() 1171 986 { 1172 987 /* Translate uic generated strings */ 1173 Ui::VBoxImportApplianceWgt::retranslateUi (this); 1174 } 1175 1176 /* static */ 1177 void VBoxImportApplianceWgt::initSystemSettings() 1178 { 1179 if (mMinGuestRAM == -1) 1180 { 1181 /* We need some global defaults from the current VirtualBox 1182 installation */ 1183 CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); 1184 mMinGuestRAM = sp.GetMinGuestRAM(); 1185 mMaxGuestRAM = sp.GetMaxGuestRAM(); 1186 mMinGuestCPUCount = sp.GetMinGuestCPUCount(); 1187 mMaxGuestCPUCount = sp.GetMaxGuestCPUCount(); 1188 } 1189 } 1190 988 Ui::VBoxApplianceEditorWgt::retranslateUi (this); 989 } 990 991 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxExportApplianceWzd.cpp
r18214 r18378 82 82 #endif /* Q_WS_MAC */ 83 83 84 /* Connect the restore button with the settings widget */ 85 connect (mBtnRestore, SIGNAL (clicked()), 86 mExportSettingsWgt, SLOT (restoreDefaults())); 87 84 88 /* Validator for the file selector page */ 85 89 mWValFileSelector = new QIWidgetValidator (mFileSelectPage, this); … … 131 135 void VBoxExportApplianceWzd::accept() 132 136 { 133 CAppliance appliance; 134 /* Prepare the export of the VM's. */ 135 if (prepareForExportVMs (appliance)) 136 { 137 QFileInfo fi (mFileSelector->path()); 138 QStringList files; 139 files << mFileSelector->path(); 140 /* We need to know every filename which will be created, so that we can 141 * ask the user for confirmation of overwriting. For that we iterating 142 * over all virtual systems & fetch all descriptions of the type 143 * HardDiskImage. */ 144 CVirtualSystemDescriptionVector vsds = appliance.GetVirtualSystemDescriptions(); 145 for (int i=0; i < vsds.size(); ++i) 146 { 147 QVector<KVirtualSystemDescriptionType> types; 148 QVector<QString> refs, origValues, configValues, extraConfigValues; 149 150 vsds[i].GetDescriptionByType (KVirtualSystemDescriptionType_HardDiskImage, types, refs, origValues, configValues, extraConfigValues); 151 foreach (const QString &s, origValues) 152 files << QString ("%1/%2").arg (fi.absolutePath()).arg (s); 153 } 154 /* Check if the file exists already, if yes get confirmation for 155 * overwriting from the user. */ 156 if (!vboxProblem().askForOverridingFilesIfExists (files, this)) 157 return; 158 /* Export the VMs, on success we are finished */ 159 if (exportVMs(appliance)) 160 QIAbstractWizard::accept(); 161 } 137 CAppliance *appliance = mExportSettingsWgt->appliance(); 138 QFileInfo fi (mFileSelector->path()); 139 QStringList files; 140 files << mFileSelector->path(); 141 /* We need to know every filename which will be created, so that we can 142 * ask the user for confirmation of overwriting. For that we iterating 143 * over all virtual systems & fetch all descriptions of the type 144 * HardDiskImage. */ 145 CVirtualSystemDescriptionVector vsds = appliance->GetVirtualSystemDescriptions(); 146 for (int i=0; i < vsds.size(); ++i) 147 { 148 QVector<KVirtualSystemDescriptionType> types; 149 QVector<QString> refs, origValues, configValues, extraConfigValues; 150 151 vsds[i].GetDescriptionByType (KVirtualSystemDescriptionType_HardDiskImage, types, refs, origValues, configValues, extraConfigValues); 152 foreach (const QString &s, origValues) 153 files << QString ("%1/%2").arg (fi.absolutePath()).arg (s); 154 } 155 /* Check if the file exists already, if yes get confirmation for 156 * overwriting from the user. */ 157 if (!vboxProblem().askForOverridingFilesIfExists (files, this)) 158 return; 159 /* Export the VMs, on success we are finished */ 160 if (exportVMs(*appliance)) 161 QIAbstractWizard::accept(); 162 162 } 163 163 … … 166 166 /* We propose a filename the first time the second page is displayed */ 167 167 if (sender() == mBtnNext1) 168 { 169 prepareSettingsWidget(); 170 } 171 else if (sender() == mBtnNext2) 172 { 168 173 if (mFileSelector->path().isEmpty()) 169 174 { … … 178 183 mWValFileSelector->revalidate(); 179 184 } 185 mExportSettingsWgt->prepareExport(); 186 } 180 187 181 188 QIAbstractWizard::showNextPage(); … … 236 243 } 237 244 238 bool VBoxExportApplianceWzd::prepare ForExportVMs (CAppliance &aAppliance)245 bool VBoxExportApplianceWzd::prepareSettingsWidget() 239 246 { 240 247 CVirtualBox vbox = vboxGlobal().virtualBox(); 241 /* Create a appliance object */ 242 aAppliance = vbox.CreateAppliance(); 243 bool fResult = aAppliance.isOk(); 248 CAppliance *appliance = mExportSettingsWgt->init(); 249 bool fResult = appliance->isOk(); 244 250 if (fResult) 245 251 { … … 256 262 { 257 263 /* Add the export description to our appliance object */ 258 CVirtualSystemDescription vsd = m.Export ( aAppliance);264 CVirtualSystemDescription vsd = m.Export (*appliance); 259 265 fResult = m.isOk(); 260 266 if (!fResult) 261 267 { 262 vboxProblem().cannotExportAppliance (m, &aAppliance, this);268 vboxProblem().cannotExportAppliance (m, appliance, this); 263 269 return false; 264 270 } 271 /* Now add some new fields the user may change */ 272 vsd.AddDescription (KVirtualSystemDescriptionType_Product, "", ""); 273 vsd.AddDescription (KVirtualSystemDescriptionType_ProductUrl, "", ""); 274 vsd.AddDescription (KVirtualSystemDescriptionType_Vendor, "", ""); 275 vsd.AddDescription (KVirtualSystemDescriptionType_VendorUrl, "", ""); 276 vsd.AddDescription (KVirtualSystemDescriptionType_Version, "", ""); 277 vsd.AddDescription (KVirtualSystemDescriptionType_License, "", ""); 265 278 } 266 279 else 267 280 break; 268 281 } 282 /* Make sure the settings widget get the new descriptions */ 283 mExportSettingsWgt->populate(); 269 284 } 270 285 if (!fResult) 271 vboxProblem().cannotExportAppliance ( &aAppliance, this);286 vboxProblem().cannotExportAppliance (appliance, this); 272 287 return fResult; 273 288 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxImportApplianceWgt.cpp
r18216 r18378 21 21 */ 22 22 23 /* VBox includes */ 23 24 #include "VBoxImportApplianceWgt.h" 24 #include "VBoxImportApplianceWzd.h"25 25 #include "VBoxGlobal.h" 26 26 #include "VBoxProblemReporter.h" 27 #include "VBoxFilePathSelectorWidget.h"28 #include "VBoxOSTypeSelectorButton.h"29 30 /* Qt includes */31 #include <QItemDelegate>32 #include <QSortFilterProxyModel>33 #include <QHeaderView>34 #include <QLineEdit>35 #include <QTextEdit>36 #include <QSpinBox>37 #include <QComboBox>38 39 class ModelItem;40 27 41 28 //////////////////////////////////////////////////////////////////////////////// 42 // Globals29 // ImportSortProxyModel 43 30 44 enum TreeViewSection { DescriptionSection = 0, OriginalValueSection, ConfigValueSection }; 45 46 //////////////////////////////////////////////////////////////////////////////// 47 // Private helper class declarations 48 49 class VirtualSystemSortProxyModel: public QSortFilterProxyModel 31 class ImportSortProxyModel: public VirtualSystemSortProxyModel 50 32 { 51 33 public: 52 VirtualSystemSortProxyModel (QObject *aParent = NULL); 53 54 protected: 55 bool filterAcceptsRow (int aSourceRow, const QModelIndex & aSourceParent) const; 56 bool lessThan (const QModelIndex &aLeft, const QModelIndex &aRight) const; 57 58 static KVirtualSystemDescriptionType mSortList[]; 34 ImportSortProxyModel (QObject *aParent = NULL) 35 : VirtualSystemSortProxyModel (aParent) 36 { 37 mFilterList << KVirtualSystemDescriptionType_License; 38 } 59 39 }; 60 61 class VirtualSystemModel: public QAbstractItemModel62 {63 64 public:65 VirtualSystemModel (QVector<CVirtualSystemDescription>& aVSDs, QObject *aParent = NULL);66 67 inline QModelIndex index (int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const;68 inline QModelIndex parent (const QModelIndex &aIndex) const;69 inline int rowCount (const QModelIndex &aParent = QModelIndex()) const;70 inline int columnCount (const QModelIndex &aParent = QModelIndex()) const;71 inline bool setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole);72 inline QVariant data (const QModelIndex &aIndex, int aRole = Qt::DisplayRole) const;73 inline Qt::ItemFlags flags (const QModelIndex &aIndex) const;74 inline QVariant headerData (int aSection, Qt::Orientation aOrientation, int aRole) const;75 76 inline void restoreDefaults (const QModelIndex& aParent = QModelIndex());77 inline void putBack();78 79 private:80 /* Private member vars */81 ModelItem *mRootItem;82 };83 84 ////////////////////////////////////////////////////////////////////////////////85 // ModelItem86 87 enum ModelItemType { RootType, VirtualSystemType, HardwareType };88 89 /* This & the following derived classes represent the data items of a Virtual90 System. All access/manipulation is done with the help of virtual functions91 to keep the interface clean. ModelItem is able to handle tree structures92 with a parent & several children's. */93 class ModelItem94 {95 public:96 ModelItem (int aNumber, ModelItemType aType, ModelItem *aParent = NULL)97 : mNumber (aNumber)98 , mType (aType)99 , mParentItem (aParent)100 {}101 102 ~ModelItem()103 {104 qDeleteAll (mChildItems);105 }106 107 ModelItem *parent() const { return mParentItem; }108 109 void appendChild (ModelItem *aChild)110 {111 AssertPtr (aChild);112 mChildItems << aChild;113 }114 ModelItem * child (int aRow) const { return mChildItems.value (aRow); }115 116 int row() const117 {118 if (mParentItem)119 return mParentItem->mChildItems.indexOf (const_cast<ModelItem*> (this));120 121 return 0;122 }123 124 int childCount() const { return mChildItems.count(); }125 int columnCount() const { return 3; }126 127 virtual Qt::ItemFlags itemFlags (int /* aColumn */) const { return 0; }128 virtual bool setData (int /* aColumn */, const QVariant & /* aValue */, int /* aRole */) { return false; }129 virtual QVariant data (int /* aColumn */, int /* aRole */) const { return QVariant(); }130 virtual QWidget * createEditor (QWidget * /* aParent */, const QStyleOptionViewItem & /* aOption */, const QModelIndex & /* aIndex */) const { return NULL; }131 virtual bool setEditorData (QWidget * /* aEditor */, const QModelIndex & /* aIndex */) const { return false; }132 virtual bool setModelData (QWidget * /* aEditor */, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */) { return false; }133 134 virtual void restoreDefaults() {}135 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues)136 {137 for (int i = 0; i < childCount(); ++i)138 child (i)->putBack (aFinalStates, aFinalValues, aFinalExtraValues);139 }140 141 ModelItemType type() const { return mType; }142 143 protected:144 int mNumber;145 ModelItemType mType;146 147 ModelItem *mParentItem;148 QList<ModelItem*> mChildItems;149 };150 151 /* This class represent a Virtual System with an index. */152 class VirtualSystemItem: public ModelItem153 {154 public:155 VirtualSystemItem (int aNumber, CVirtualSystemDescription aDesc, ModelItem *aParent)156 : ModelItem (aNumber, VirtualSystemType, aParent)157 , mDesc (aDesc)158 {}159 160 virtual QVariant data (int aColumn, int aRole) const161 {162 QVariant v;163 if (aColumn == DescriptionSection &&164 aRole == Qt::DisplayRole)165 v = VBoxImportApplianceWgt::tr ("Virtual System %1").arg (mNumber + 1);166 return v;167 }168 169 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues)170 {171 /* Resize the vectors */172 unsigned long count = mDesc.GetCount();173 aFinalStates.resize (count);174 aFinalValues.resize (count);175 aFinalExtraValues.resize (count);176 /* Recursively fill the vectors */177 ModelItem::putBack (aFinalStates, aFinalValues, aFinalExtraValues);178 /* Set all final values at once */179 mDesc.SetFinalValues (aFinalStates, aFinalValues, aFinalExtraValues);180 }181 182 private:183 CVirtualSystemDescription mDesc;184 };185 186 /* This class represent an hardware item of a Virtual System. All values of187 KVirtualSystemDescriptionType are supported & handled differently. */188 class HardwareItem: public ModelItem189 {190 friend class VirtualSystemSortProxyModel;191 public:192 193 HardwareItem (int aNumber,194 KVirtualSystemDescriptionType aType,195 const QString &aRef,196 const QString &aOrigValue,197 const QString &aConfigValue,198 const QString &aExtraConfigValue,199 ModelItem *aParent)200 : ModelItem (aNumber, HardwareType, aParent)201 , mType (aType)202 , mRef (aRef)203 , mOrigValue (aOrigValue)204 , mConfigValue (aConfigValue)205 , mConfigDefaultValue (aConfigValue)206 , mExtraConfigValue (aExtraConfigValue)207 , mCheckState (Qt::Checked)208 {}209 210 virtual void putBack (QVector<BOOL>& aFinalStates, QVector<QString>& aFinalValues, QVector<QString>& aFinalExtraValues)211 {212 aFinalStates[mNumber] = mCheckState == Qt::Checked;213 aFinalValues[mNumber] = mConfigValue;214 aFinalExtraValues[mNumber] = mExtraConfigValue;215 ModelItem::putBack (aFinalStates, aFinalValues, aFinalExtraValues);216 }217 218 bool setData (int aColumn, const QVariant &aValue, int aRole)219 {220 bool fDone = false;221 switch (aRole)222 {223 case Qt::CheckStateRole:224 {225 if (aColumn == ConfigValueSection &&226 (mType == KVirtualSystemDescriptionType_Floppy ||227 mType == KVirtualSystemDescriptionType_CDROM ||228 mType == KVirtualSystemDescriptionType_USBController ||229 mType == KVirtualSystemDescriptionType_SoundCard ||230 mType == KVirtualSystemDescriptionType_NetworkAdapter))231 {232 mCheckState = static_cast<Qt::CheckState> (aValue.toInt());233 fDone = true;234 }235 break;236 }237 default: break;238 }239 return fDone;240 }241 242 virtual QVariant data (int aColumn, int aRole) const243 {244 QVariant v;245 switch (aRole)246 {247 case Qt::DisplayRole:248 {249 if (aColumn == DescriptionSection)250 {251 switch (mType)252 {253 case KVirtualSystemDescriptionType_Name: v = VBoxImportApplianceWgt::tr ("Name"); break;254 case KVirtualSystemDescriptionType_Description: v = VBoxImportApplianceWgt::tr ("Description"); break;255 case KVirtualSystemDescriptionType_OS: v = VBoxImportApplianceWgt::tr ("Guest OS Type"); break;256 case KVirtualSystemDescriptionType_CPU: v = VBoxImportApplianceWgt::tr ("CPU"); break;257 case KVirtualSystemDescriptionType_Memory: v = VBoxImportApplianceWgt::tr ("RAM"); break;258 case KVirtualSystemDescriptionType_HardDiskControllerIDE: v = VBoxImportApplianceWgt::tr ("Hard Disk Controller IDE"); break;259 case KVirtualSystemDescriptionType_HardDiskControllerSATA: v = VBoxImportApplianceWgt::tr ("Hard Disk Controller SATA"); break;260 case KVirtualSystemDescriptionType_HardDiskControllerSCSI: v = VBoxImportApplianceWgt::tr ("Hard Disk Controller SCSI"); break;261 case KVirtualSystemDescriptionType_CDROM: v = VBoxImportApplianceWgt::tr ("DVD"); break;262 case KVirtualSystemDescriptionType_Floppy: v = VBoxImportApplianceWgt::tr ("Floppy"); break;263 case KVirtualSystemDescriptionType_NetworkAdapter: v = VBoxImportApplianceWgt::tr ("Network Adapter"); break;264 case KVirtualSystemDescriptionType_USBController: v = VBoxImportApplianceWgt::tr ("USB Controller"); break;265 case KVirtualSystemDescriptionType_SoundCard: v = VBoxImportApplianceWgt::tr ("Sound Card"); break;266 case KVirtualSystemDescriptionType_HardDiskImage: v = VBoxImportApplianceWgt::tr ("Virtual Disk Image"); break;267 default: v = VBoxImportApplianceWgt::tr ("Unknown Hardware Item"); break;268 }269 }270 else if (aColumn == OriginalValueSection)271 v = mOrigValue;272 else if (aColumn == ConfigValueSection)273 {274 switch (mType)275 {276 case KVirtualSystemDescriptionType_OS: v = vboxGlobal().vmGuestOSTypeDescription (mConfigValue); break;277 case KVirtualSystemDescriptionType_Memory: v = mConfigValue + " " + VBoxImportApplianceWgt::tr ("MB"); break;278 case KVirtualSystemDescriptionType_SoundCard: v = vboxGlobal().toString (static_cast<KAudioControllerType> (mConfigValue.toInt())); break;279 case KVirtualSystemDescriptionType_NetworkAdapter: v = vboxGlobal().toString (static_cast<KNetworkAdapterType> (mConfigValue.toInt())); break;280 default: v = mConfigValue; break;281 }282 }283 break;284 }285 case Qt::ToolTipRole:286 {287 if (aColumn == ConfigValueSection)288 {289 if (!mOrigValue.isEmpty())290 v = VBoxImportApplianceWgt::tr ("<b>Original Value:</b> %1").arg (mOrigValue);291 }292 break;293 }294 case Qt::DecorationRole:295 {296 if (aColumn == DescriptionSection)297 {298 switch (mType)299 {300 case KVirtualSystemDescriptionType_Name: v = QIcon (":/name_16px.png"); break;301 case KVirtualSystemDescriptionType_Description: v = QIcon (":/description_16px.png"); break;302 case KVirtualSystemDescriptionType_OS: v = QIcon (":/os_type_16px.png"); break;303 case KVirtualSystemDescriptionType_CPU: v = QIcon (":/cpu_16px.png"); break;304 case KVirtualSystemDescriptionType_Memory: v = QIcon (":/ram_16px.png"); break;305 case KVirtualSystemDescriptionType_HardDiskControllerIDE: v = QIcon (":/ide_16px.png"); break;306 case KVirtualSystemDescriptionType_HardDiskControllerSATA: v = QIcon (":/sata_16px.png"); break;307 case KVirtualSystemDescriptionType_HardDiskControllerSCSI: v = QIcon (":/scsi_16px.png"); break;308 case KVirtualSystemDescriptionType_HardDiskImage: v = QIcon (":/hd_16px.png"); break;309 case KVirtualSystemDescriptionType_CDROM: v = QIcon (":/cd_16px.png"); break;310 case KVirtualSystemDescriptionType_Floppy: v = QIcon (":/fd_16px.png"); break;311 case KVirtualSystemDescriptionType_NetworkAdapter: v = QIcon (":/nw_16px.png"); break;312 case KVirtualSystemDescriptionType_USBController: v = QIcon (":/usb_16px.png"); break;313 case KVirtualSystemDescriptionType_SoundCard: v = QIcon (":/sound_16px.png"); break;314 default: break;315 }316 }317 else if (aColumn == ConfigValueSection &&318 mType == KVirtualSystemDescriptionType_OS)319 {320 v = vboxGlobal().vmGuestOSTypeIcon (mConfigValue).scaledToHeight (16, Qt::SmoothTransformation);321 }322 break;323 }324 case Qt::FontRole:325 {326 /* If the item is unchecked mark it with italic text. */327 if (aColumn == ConfigValueSection &&328 mCheckState == Qt::Unchecked)329 {330 QFont font = qApp->font();331 font.setItalic (true);332 v = font;333 }334 break;335 }336 case Qt::ForegroundRole:337 {338 /* If the item is unchecked mark it with gray text. */339 if (aColumn == ConfigValueSection &&340 mCheckState == Qt::Unchecked)341 {342 QPalette pal = qApp->palette();343 v = pal.brush (QPalette::Disabled, QPalette::WindowText);344 }345 break;346 }347 case Qt::CheckStateRole:348 {349 if (aColumn == ConfigValueSection &&350 (mType == KVirtualSystemDescriptionType_Floppy ||351 mType == KVirtualSystemDescriptionType_CDROM ||352 mType == KVirtualSystemDescriptionType_USBController ||353 mType == KVirtualSystemDescriptionType_SoundCard ||354 mType == KVirtualSystemDescriptionType_NetworkAdapter))355 v = mCheckState;356 break;357 }358 }359 return v;360 }361 362 virtual Qt::ItemFlags itemFlags (int aColumn) const363 {364 Qt::ItemFlags flags = 0;365 if (aColumn == ConfigValueSection)366 {367 /* Some items are checkable */368 if (mType == KVirtualSystemDescriptionType_Floppy ||369 mType == KVirtualSystemDescriptionType_CDROM ||370 mType == KVirtualSystemDescriptionType_USBController ||371 mType == KVirtualSystemDescriptionType_SoundCard ||372 mType == KVirtualSystemDescriptionType_NetworkAdapter)373 flags |= Qt::ItemIsUserCheckable;374 /* Some items are editable */375 if ((mType == KVirtualSystemDescriptionType_Name ||376 mType == KVirtualSystemDescriptionType_Description ||377 mType == KVirtualSystemDescriptionType_OS ||378 mType == KVirtualSystemDescriptionType_Memory ||379 mType == KVirtualSystemDescriptionType_SoundCard ||380 mType == KVirtualSystemDescriptionType_NetworkAdapter ||381 mType == KVirtualSystemDescriptionType_HardDiskControllerIDE ||382 mType == KVirtualSystemDescriptionType_HardDiskImage) &&383 mCheckState == Qt::Checked) /* Item has to be enabled */384 flags |= Qt::ItemIsEditable;385 }386 return flags;387 }388 389 virtual QWidget * createEditor (QWidget *aParent, const QStyleOptionViewItem & /* aOption */, const QModelIndex &aIndex) const390 {391 QWidget *editor = NULL;392 if (aIndex.column() == ConfigValueSection)393 {394 switch (mType)395 {396 case KVirtualSystemDescriptionType_OS:397 {398 VBoxOSTypeSelectorButton *e = new VBoxOSTypeSelectorButton (aParent);399 /* Fill the background with the highlight color in the case400 * the button hasn't a rectangle shape. This prevents the401 * display of parts from the current text on the Mac. */402 e->setAutoFillBackground (true);403 e->setBackgroundRole (QPalette::Highlight);404 editor = e;405 break;406 }407 case KVirtualSystemDescriptionType_Name:408 {409 QLineEdit *e = new QLineEdit (aParent);410 editor = e;411 break;412 }413 case KVirtualSystemDescriptionType_Description:414 {415 QTextEdit *e = new QTextEdit (aParent);416 editor = e;417 break;418 }419 case KVirtualSystemDescriptionType_CPU:420 {421 QSpinBox *e = new QSpinBox (aParent);422 e->setRange (VBoxImportApplianceWgt::minGuestCPUCount(), VBoxImportApplianceWgt::maxGuestCPUCount());423 editor = e;424 break;425 }426 case KVirtualSystemDescriptionType_Memory:427 {428 QSpinBox *e = new QSpinBox (aParent);429 e->setRange (VBoxImportApplianceWgt::minGuestRAM(), VBoxImportApplianceWgt::maxGuestRAM());430 e->setSuffix (" " + VBoxImportApplianceWgt::tr ("MB"));431 editor = e;432 break;433 }434 case KVirtualSystemDescriptionType_SoundCard:435 {436 QComboBox *e = new QComboBox (aParent);437 e->addItem (vboxGlobal().toString (KAudioControllerType_AC97), KAudioControllerType_AC97);438 e->addItem (vboxGlobal().toString (KAudioControllerType_SB16), KAudioControllerType_SB16);439 editor = e;440 break;441 }442 case KVirtualSystemDescriptionType_NetworkAdapter:443 {444 QComboBox *e = new QComboBox (aParent);445 e->addItem (vboxGlobal().toString (KNetworkAdapterType_Am79C970A), KNetworkAdapterType_Am79C970A);446 e->addItem (vboxGlobal().toString (KNetworkAdapterType_Am79C973), KNetworkAdapterType_Am79C973);447 #ifdef VBOX_WITH_E1000448 e->addItem (vboxGlobal().toString (KNetworkAdapterType_I82540EM), KNetworkAdapterType_I82540EM);449 e->addItem (vboxGlobal().toString (KNetworkAdapterType_I82543GC), KNetworkAdapterType_I82543GC);450 #endif /* VBOX_WITH_E1000 */451 editor = e;452 break;453 }454 case KVirtualSystemDescriptionType_HardDiskControllerIDE:455 {456 QComboBox *e = new QComboBox (aParent);457 e->addItem (vboxGlobal().toString (KStorageControllerType_PIIX3), "PIIX3");458 e->addItem (vboxGlobal().toString (KStorageControllerType_PIIX4), "PIIX4");459 e->addItem (vboxGlobal().toString (KStorageControllerType_ICH6), "ICH6");460 editor = e;461 break;462 }463 case KVirtualSystemDescriptionType_HardDiskImage:464 {465 /* disabled for now466 VBoxFilePathSelectorWidget *e = new VBoxFilePathSelectorWidget (aParent);467 e->setMode (VBoxFilePathSelectorWidget::Mode_File);468 e->setResetEnabled (false);469 */470 QLineEdit *e = new QLineEdit (aParent);471 editor = e;472 break;473 }474 default: break;475 }476 }477 return editor;478 }479 480 virtual bool setEditorData (QWidget *aEditor, const QModelIndex & /* aIndex */) const481 {482 bool fDone = false;483 switch (mType)484 {485 case KVirtualSystemDescriptionType_OS:486 {487 if (VBoxOSTypeSelectorButton *e = qobject_cast<VBoxOSTypeSelectorButton*> (aEditor))488 {489 e->setOSTypeId (mConfigValue);490 fDone = true;491 }492 break;493 }494 case KVirtualSystemDescriptionType_HardDiskControllerIDE:495 {496 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor))497 {498 int i = e->findData (mConfigValue);499 if (i != -1)500 e->setCurrentIndex (i);501 fDone = true;502 }503 break;504 }505 case KVirtualSystemDescriptionType_CPU:506 case KVirtualSystemDescriptionType_Memory:507 {508 if (QSpinBox *e = qobject_cast<QSpinBox*> (aEditor))509 {510 e->setValue (mConfigValue.toInt());511 fDone = true;512 }513 break;514 }515 case KVirtualSystemDescriptionType_Name:516 {517 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor))518 {519 e->setText (mConfigValue);520 fDone = true;521 }522 break;523 }524 case KVirtualSystemDescriptionType_Description:525 {526 if (QTextEdit *e = qobject_cast<QTextEdit*> (aEditor))527 {528 e->setPlainText (mConfigValue);529 fDone = true;530 }531 break;532 }533 case KVirtualSystemDescriptionType_SoundCard:534 case KVirtualSystemDescriptionType_NetworkAdapter:535 {536 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor))537 {538 int i = e->findData (mConfigValue.toInt());539 if (i != -1)540 e->setCurrentIndex (i);541 fDone = true;542 }543 break;544 }545 case KVirtualSystemDescriptionType_HardDiskImage:546 {547 /* disabled for now548 if (VBoxFilePathSelectorWidget *e = qobject_cast<VBoxFilePathSelectorWidget*> (aEditor))549 {550 e->setPath (mConfigValue);551 */552 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor))553 {554 e->setText (mConfigValue);555 fDone = true;556 }557 break;558 }559 default: break;560 }561 return fDone;562 }563 564 virtual bool setModelData (QWidget *aEditor, QAbstractItemModel * /* aModel */, const QModelIndex & /* aIndex */)565 {566 bool fDone = false;567 switch (mType)568 {569 case KVirtualSystemDescriptionType_OS:570 {571 if (VBoxOSTypeSelectorButton *e = qobject_cast<VBoxOSTypeSelectorButton*> (aEditor))572 {573 mConfigValue = e->osTypeId();574 fDone = true;575 }576 break;577 }578 case KVirtualSystemDescriptionType_HardDiskControllerIDE:579 {580 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor))581 {582 mConfigValue = e->itemData (e->currentIndex()).toString();583 fDone = true;584 }585 break;586 }587 case KVirtualSystemDescriptionType_CPU:588 case KVirtualSystemDescriptionType_Memory:589 {590 if (QSpinBox *e = qobject_cast<QSpinBox*> (aEditor))591 {592 mConfigValue = QString::number (e->value());593 fDone = true;594 }595 break;596 }597 case KVirtualSystemDescriptionType_Name:598 {599 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor))600 {601 mConfigValue = e->text();602 fDone = true;603 }604 break;605 }606 case KVirtualSystemDescriptionType_Description:607 {608 if (QTextEdit *e = qobject_cast<QTextEdit*> (aEditor))609 {610 mConfigValue = e->toPlainText();611 fDone = true;612 }613 break;614 }615 case KVirtualSystemDescriptionType_SoundCard:616 case KVirtualSystemDescriptionType_NetworkAdapter:617 {618 if (QComboBox *e = qobject_cast<QComboBox*> (aEditor))619 {620 mConfigValue = e->itemData (e->currentIndex()).toString();621 fDone = true;622 }623 break;624 }625 case KVirtualSystemDescriptionType_HardDiskImage:626 {627 /* disabled for now628 if (VBoxFilePathSelectorWidget *e = qobject_cast<VBoxFilePathSelectorWidget*> (aEditor))629 {630 mConfigValue = e->path();631 */632 if (QLineEdit *e = qobject_cast<QLineEdit*> (aEditor))633 {634 mConfigValue = e->text();635 fDone = true;636 }637 break;638 }639 default: break;640 }641 return fDone;642 }643 644 virtual void restoreDefaults()645 {646 mConfigValue = mConfigDefaultValue;647 mCheckState = Qt::Checked;648 }649 650 private:651 652 /* Private member vars */653 KVirtualSystemDescriptionType mType;654 QString mRef;655 QString mOrigValue;656 QString mConfigValue;657 QString mConfigDefaultValue;658 QString mExtraConfigValue;659 Qt::CheckState mCheckState;660 };661 662 ////////////////////////////////////////////////////////////////////////////////663 // VirtualSystemDelegate664 665 /* The delegate is used for creating/handling the different editors for the666 various types we support. This class forward the requests to the virtual667 methods of our different ModelItems. If this is not possible the default668 methods of QItemDelegate are used to get some standard behavior. Note: We669 have to handle the proxy model ourself. I really don't understand why Qt is670 not doing this for us. */671 class VirtualSystemDelegate: public QItemDelegate672 {673 public:674 VirtualSystemDelegate (QAbstractProxyModel *aProxy, QObject *aParent = NULL)675 : QItemDelegate (aParent)676 , mProxy (aProxy)677 {}678 679 QWidget * createEditor (QWidget *aParent, const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const680 {681 if (!aIndex.isValid())682 return QItemDelegate::createEditor (aParent, aOption, aIndex);683 684 QModelIndex index (aIndex);685 if (mProxy)686 index = mProxy->mapToSource (aIndex);687 688 ModelItem *item = static_cast<ModelItem*> (index.internalPointer());689 QWidget *editor = item->createEditor (aParent, aOption, index);690 691 if (editor == NULL)692 return QItemDelegate::createEditor (aParent, aOption, index);693 else694 return editor;695 }696 697 void setEditorData (QWidget *aEditor, const QModelIndex &aIndex) const698 {699 if (!aIndex.isValid())700 return QItemDelegate::setEditorData (aEditor, aIndex);701 702 QModelIndex index (aIndex);703 if (mProxy)704 index = mProxy->mapToSource (aIndex);705 706 ModelItem *item = static_cast<ModelItem*> (index.internalPointer());707 708 if (!item->setEditorData (aEditor, index))709 QItemDelegate::setEditorData (aEditor, index);710 }711 712 void setModelData (QWidget *aEditor, QAbstractItemModel *aModel, const QModelIndex &aIndex) const713 {714 if (!aIndex.isValid())715 return QItemDelegate::setModelData (aEditor, aModel, aIndex);716 717 QModelIndex index = aModel->index (aIndex.row(), aIndex.column());718 if (mProxy)719 index = mProxy->mapToSource (aIndex);720 721 ModelItem *item = static_cast<ModelItem*> (index.internalPointer());722 if (!item->setModelData (aEditor, aModel, index))723 QItemDelegate::setModelData (aEditor, aModel, aIndex);724 }725 726 void updateEditorGeometry (QWidget *aEditor, const QStyleOptionViewItem &aOption, const QModelIndex & /* aIndex */) const727 {728 if (aEditor)729 aEditor->setGeometry (aOption.rect);730 }731 732 QSize sizeHint (const QStyleOptionViewItem &aOption, const QModelIndex &aIndex) const733 {734 QSize size = QItemDelegate::sizeHint (aOption, aIndex);735 #ifdef Q_WS_MAC736 int h = 28;737 #else /* Q_WS_MAC */738 int h = 24;739 #endif /* Q_WS_MAC */740 size.setHeight (RT_MAX (h, size.height()));741 return size;742 }743 private:744 /* Private member vars */745 QAbstractProxyModel *mProxy;746 };747 748 ////////////////////////////////////////////////////////////////////////////////749 // VirtualSystemSortProxyModel750 751 /* How to sort the items in the tree view */752 KVirtualSystemDescriptionType VirtualSystemSortProxyModel::mSortList[] =753 {754 KVirtualSystemDescriptionType_Name,755 KVirtualSystemDescriptionType_Description,756 KVirtualSystemDescriptionType_OS,757 KVirtualSystemDescriptionType_License,758 KVirtualSystemDescriptionType_CPU,759 KVirtualSystemDescriptionType_Memory,760 KVirtualSystemDescriptionType_Floppy,761 KVirtualSystemDescriptionType_CDROM,762 KVirtualSystemDescriptionType_USBController,763 KVirtualSystemDescriptionType_SoundCard,764 KVirtualSystemDescriptionType_NetworkAdapter,765 KVirtualSystemDescriptionType_HardDiskControllerIDE,766 KVirtualSystemDescriptionType_HardDiskControllerSATA,767 KVirtualSystemDescriptionType_HardDiskControllerSCSI768 };769 770 VirtualSystemSortProxyModel::VirtualSystemSortProxyModel (QObject *aParent)771 : QSortFilterProxyModel (aParent)772 {}773 774 bool VirtualSystemSortProxyModel::filterAcceptsRow (int aSourceRow, const QModelIndex & aSourceParent) const775 {776 /* By default enable all, we will explicitly filter out below */777 if (aSourceParent.isValid())778 {779 QModelIndex i = aSourceParent.child (aSourceRow, 0);780 if (i.isValid())781 {782 ModelItem *item = static_cast<ModelItem*> (i.internalPointer());783 /* We filter hardware types only */784 if (item->type() == HardwareType)785 {786 HardwareItem *hwItem = static_cast<HardwareItem*> (item);787 /* The license type shouldn't be displayed */788 if (hwItem->mType == KVirtualSystemDescriptionType_License)789 return false;790 }791 }792 }793 return true;794 }795 796 bool VirtualSystemSortProxyModel::lessThan (const QModelIndex &aLeft, const QModelIndex &aRight) const797 {798 if (!aLeft.isValid() ||799 !aRight.isValid())800 return false;801 802 ModelItem *leftItem = static_cast<ModelItem*> (aLeft.internalPointer());803 ModelItem *rightItem = static_cast<ModelItem*> (aRight.internalPointer());804 805 /* We sort hardware types only */806 if (!(leftItem->type() == HardwareType &&807 rightItem->type() == HardwareType))808 return false;809 810 HardwareItem *hwLeft = static_cast<HardwareItem*> (leftItem);811 HardwareItem *hwRight = static_cast<HardwareItem*> (rightItem);812 813 for (unsigned int i = 0; i < RT_ELEMENTS (mSortList); ++i)814 if (hwLeft->mType == mSortList[i])815 {816 for (unsigned int a = 0; a <= i; ++a)817 if (hwRight->mType == mSortList[a])818 return true;819 return false;820 }821 822 return true;823 }824 825 ////////////////////////////////////////////////////////////////////////////////826 // VirtualSystemModel827 828 /* This class is a wrapper model for our ModelItem. It could be used with any829 TreeView & forward mostly all calls to the methods of ModelItem. The830 ModelItems itself are stored as internal pointers in the QModelIndex class. */831 VirtualSystemModel::VirtualSystemModel (QVector<CVirtualSystemDescription>& aVSDs, QObject *aParent /* = NULL */)832 : QAbstractItemModel (aParent)833 {834 mRootItem = new ModelItem (0, RootType);835 for (int a = 0; a < aVSDs.size(); ++a)836 {837 CVirtualSystemDescription vs = aVSDs[a];838 839 VirtualSystemItem *vi = new VirtualSystemItem (a, vs, mRootItem);840 mRootItem->appendChild (vi);841 842 /* @todo: ask Dmitry about include/COMDefs.h:232 */843 QVector<KVirtualSystemDescriptionType> types;844 QVector<QString> refs;845 QVector<QString> origValues;846 QVector<QString> configValues;847 QVector<QString> extraConfigValues;848 849 QList<int> hdIndizies;850 QMap<int, HardwareItem*> controllerMap;851 vs.GetDescription (types, refs, origValues, configValues, extraConfigValues);852 for (int i = 0; i < types.size(); ++i)853 {854 /* We add the hard disk images in an second step, so save a855 reference to them. */856 if (types[i] == KVirtualSystemDescriptionType_HardDiskImage)857 hdIndizies << i;858 else859 {860 HardwareItem *hi = new HardwareItem (i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], vi);861 vi->appendChild (hi);862 /* Save the hard disk controller types in an extra map */863 if (types[i] == KVirtualSystemDescriptionType_HardDiskControllerIDE ||864 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSATA ||865 types[i] == KVirtualSystemDescriptionType_HardDiskControllerSCSI)866 controllerMap[i] = hi;867 }868 }869 QRegExp rx ("controller=(\\d+);?");870 /* Now process the hard disk images */871 for (int a = 0; a < hdIndizies.size(); ++a)872 {873 int i = hdIndizies[a];874 QString ecnf = extraConfigValues[i];875 if (rx.indexIn (ecnf) != -1)876 {877 /* Get the controller */878 HardwareItem *ci = controllerMap[rx.cap (1).toInt()];879 if (ci)880 {881 /* New hardware item as child of the controller */882 HardwareItem *hi = new HardwareItem (i, types[i], refs[i], origValues[i], configValues[i], extraConfigValues[i], ci);883 ci->appendChild (hi);884 }885 }886 }887 }888 }889 890 QModelIndex VirtualSystemModel::index (int aRow, int aColumn, const QModelIndex &aParent /* = QModelIndex() */) const891 {892 if (!hasIndex (aRow, aColumn, aParent))893 return QModelIndex();894 895 ModelItem *parentItem;896 897 if (!aParent.isValid())898 parentItem = mRootItem;899 else900 parentItem = static_cast<ModelItem*> (aParent.internalPointer());901 902 ModelItem *childItem = parentItem->child (aRow);903 if (childItem)904 return createIndex (aRow, aColumn, childItem);905 else906 return QModelIndex();907 }908 909 QModelIndex VirtualSystemModel::parent (const QModelIndex &aIndex) const910 {911 if (!aIndex.isValid())912 return QModelIndex();913 914 ModelItem *childItem = static_cast<ModelItem*> (aIndex.internalPointer());915 ModelItem *parentItem = childItem->parent();916 917 if (parentItem == mRootItem)918 return QModelIndex();919 920 return createIndex (parentItem->row(), 0, parentItem);921 }922 923 int VirtualSystemModel::rowCount (const QModelIndex &aParent /* = QModelIndex() */) const924 {925 ModelItem *parentItem;926 if (aParent.column() > 0)927 return 0;928 929 if (!aParent.isValid())930 parentItem = mRootItem;931 else932 parentItem = static_cast<ModelItem*> (aParent.internalPointer());933 934 return parentItem->childCount();935 }936 937 int VirtualSystemModel::columnCount (const QModelIndex &aParent /* = QModelIndex() */) const938 {939 if (aParent.isValid())940 return static_cast<ModelItem*> (aParent.internalPointer())->columnCount();941 else942 return mRootItem->columnCount();943 }944 945 bool VirtualSystemModel::setData (const QModelIndex &aIndex, const QVariant &aValue, int aRole)946 {947 if (!aIndex.isValid())948 return false;949 950 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer());951 952 return item->setData (aIndex.column(), aValue, aRole);953 }954 955 QVariant VirtualSystemModel::data (const QModelIndex &aIndex, int aRole /* = Qt::DisplayRole */) const956 {957 if (!aIndex.isValid())958 return QVariant();959 960 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer());961 962 return item->data (aIndex.column(), aRole);963 }964 965 Qt::ItemFlags VirtualSystemModel::flags (const QModelIndex &aIndex) const966 {967 if (!aIndex.isValid())968 return 0;969 970 ModelItem *item = static_cast<ModelItem*> (aIndex.internalPointer());971 972 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | item->itemFlags (aIndex.column());973 }974 975 QVariant VirtualSystemModel::headerData (int aSection, Qt::Orientation aOrientation, int aRole) const976 {977 if (aRole != Qt::DisplayRole ||978 aOrientation != Qt::Horizontal)979 return QVariant();980 981 QString title;982 switch (aSection)983 {984 case DescriptionSection: title = VBoxImportApplianceWgt::tr ("Description"); break;985 case ConfigValueSection: title = VBoxImportApplianceWgt::tr ("Configuration"); break;986 }987 return title;988 }989 990 void VirtualSystemModel::restoreDefaults (const QModelIndex& aParent /* = QModelIndex() */)991 {992 ModelItem *parentItem;993 994 if (!aParent.isValid())995 parentItem = mRootItem;996 else997 parentItem = static_cast<ModelItem*> (aParent.internalPointer());998 999 for (int i = 0; i < parentItem->childCount(); ++i)1000 {1001 parentItem->child (i)->restoreDefaults();1002 restoreDefaults (index (i, 0, aParent));1003 }1004 emit dataChanged (index (0, 0, aParent), index (parentItem->childCount()-1, 0, aParent));1005 }1006 1007 void VirtualSystemModel::putBack()1008 {1009 QVector<BOOL> v1;1010 QVector<QString> v2;1011 QVector<QString> v3;1012 mRootItem->putBack (v1, v2, v3);1013 }1014 40 1015 41 //////////////////////////////////////////////////////////////////////////////// … … 1022 48 1023 49 VBoxImportApplianceWgt::VBoxImportApplianceWgt (QWidget *aParent) 1024 : QIWithRetranslateUI<QWidget> (aParent) 1025 , mAppliance (NULL) 1026 , mModel (NULL) 50 : VBoxApplianceEditorWgt (aParent) 1027 51 { 1028 52 /* Make sure all static content is properly initialized */ 1029 53 initSystemSettings(); 1030 1031 /* Apply UI decorations */1032 Ui::VBoxImportApplianceWgt::setupUi (this);1033 1034 /* Make the tree looking nicer */1035 mTvSettings->setRootIsDecorated (false);1036 mTvSettings->setAlternatingRowColors (true);1037 mTvSettings->header()->setStretchLastSection (true);1038 mTvSettings->header()->setResizeMode (QHeaderView::ResizeToContents);1039 1040 /* Applying language settings */1041 retranslateUi();1042 54 } 1043 55 … … 1070 82 mModel = new VirtualSystemModel (vsds, this); 1071 83 1072 VirtualSystemSortProxyModel *proxy = new VirtualSystemSortProxyModel (this);84 ImportSortProxyModel *proxy = new ImportSortProxyModel (this); 1073 85 proxy->setSourceModel (mModel); 1074 86 proxy->sort (DescriptionSection, Qt::DescendingOrder); … … 1163 175 } 1164 176 1165 void VBoxImportApplianceWgt::restoreDefaults()1166 {1167 mModel->restoreDefaults();1168 }1169 1170 void VBoxImportApplianceWgt::retranslateUi()1171 {1172 /* Translate uic generated strings */1173 Ui::VBoxImportApplianceWgt::retranslateUi (this);1174 }1175 1176 177 /* static */ 1177 178 void VBoxImportApplianceWgt::initSystemSettings() -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxApplianceEditorWgt.ui
r18307 r18378 18 18 additional information or have any questions. 19 19 </comment> 20 <class>VBox ImportApplianceWgt</class>21 <widget class="QWidget" name="VBox ImportApplianceWgt">20 <class>VBoxApplianceEditorWgt</class> 21 <widget class="QWidget" name="VBoxApplianceEditorWgt"> 22 22 <property name="geometry"> 23 23 <rect> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxExportApplianceWzd.ui
r17790 r18378 2 2 <ui version="4.0"> 3 3 <comment> 4 VBox frontends: Qt4 GUI ( "VirtualBox"):4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 6 Copyright (C) 2009 Sun Microsystems, Inc. … … 10 10 you can redistribute it and/or modify it under the terms of the GNU 11 11 General Public License (GPL) as published by the Free Software 12 Foundation, in version 2 as it comes in the "COPYING"file of the12 Foundation, in version 2 as it comes in the "COPYING" file of the 13 13 VirtualBox OSE distribution. VirtualBox OSE is distributed in the 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. … … 38 38 <widget class="QStackedWidget" name="mPageStack"> 39 39 <property name="currentIndex"> 40 <number> 0</number>40 <number>1</number> 41 41 </property> 42 42 <widget class="QWidget" name="mVMSelectPage"> … … 187 187 </layout> 188 188 </widget> 189 <widget class="QWidget" name="m FileSelectPage">190 <layout class="QVBoxLayout" name="verticalLayout_ 3">189 <widget class="QWidget" name="mVMSettingsPage"> 190 <layout class="QVBoxLayout" name="verticalLayout_4"> 191 191 <item> 192 192 <widget class="QLabel" name="mPageSettingsHdr"> … … 205 205 </item> 206 206 <item> 207 <widget class="Line" name="line21_2"> 208 <property name="orientation"> 209 <enum>Qt::Horizontal</enum> 210 </property> 211 </widget> 212 </item> 213 <item> 214 <layout class="QGridLayout" name="gridLayout_3"> 215 <item row="0" column="0" rowspan="2"> 216 <widget class="QLabel" name="mLogoSettings"> 217 <property name="sizePolicy"> 218 <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> 219 <horstretch>0</horstretch> 220 <verstretch>0</verstretch> 221 </sizepolicy> 222 </property> 223 <property name="autoFillBackground"> 224 <bool>true</bool> 225 </property> 226 <property name="text"> 227 <string/> 228 </property> 229 <property name="pixmap"> 230 <pixmap resource="../VirtualBox.qrc">:/vmw_ovf_import.png</pixmap> 231 </property> 232 <property name="alignment"> 233 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> 234 </property> 235 </widget> 236 </item> 237 <item row="0" column="1"> 238 <widget class="QILabel" name="mTextSettings"> 239 <property name="sizePolicy"> 240 <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> 241 <horstretch>0</horstretch> 242 <verstretch>0</verstretch> 243 </sizepolicy> 244 </property> 245 <property name="minimumSize"> 246 <size> 247 <width>300</width> 248 <height>0</height> 249 </size> 250 </property> 251 <property name="text"> 252 <string>Here you can change additional configuration values of the selected Virtual Machines. You can modify most of the shown properties by double clicking on the items.</string> 253 </property> 254 <property name="wordWrap"> 255 <bool>true</bool> 256 </property> 257 </widget> 258 </item> 259 <item row="1" column="1"> 260 <widget class="VBoxExportApplianceWgt" name="mExportSettingsWgt" native="true"> 261 <property name="enabled"> 262 <bool>true</bool> 263 </property> 264 <property name="sizePolicy"> 265 <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> 266 <horstretch>0</horstretch> 267 <verstretch>0</verstretch> 268 </sizepolicy> 269 </property> 270 <property name="minimumSize"> 271 <size> 272 <width>0</width> 273 <height>0</height> 274 </size> 275 </property> 276 <property name="baseSize"> 277 <size> 278 <width>0</width> 279 <height>0</height> 280 </size> 281 </property> 282 </widget> 283 </item> 284 </layout> 285 </item> 286 <item> 287 <widget class="Line" name="line22_2"> 288 <property name="orientation"> 289 <enum>Qt::Horizontal</enum> 290 </property> 291 </widget> 292 </item> 293 <item> 294 <layout class="QHBoxLayout" name="_4"> 295 <item> 296 <widget class="QPushButton" name="mBtnRestore"> 297 <property name="text"> 298 <string>Restore Defaults</string> 299 </property> 300 </widget> 301 </item> 302 <item> 303 <spacer> 304 <property name="orientation"> 305 <enum>Qt::Horizontal</enum> 306 </property> 307 <property name="sizeHint" stdset="0"> 308 <size> 309 <width>0</width> 310 <height>0</height> 311 </size> 312 </property> 313 </spacer> 314 </item> 315 <item> 316 <widget class="QPushButton" name="mBtnBack2"> 317 <property name="text"> 318 <string>< &Back</string> 319 </property> 320 </widget> 321 </item> 322 <item> 323 <widget class="QPushButton" name="mBtnNext2"> 324 <property name="text"> 325 <string>&Next ></string> 326 </property> 327 </widget> 328 </item> 329 <item> 330 <spacer> 331 <property name="orientation"> 332 <enum>Qt::Horizontal</enum> 333 </property> 334 <property name="sizeType"> 335 <enum>QSizePolicy::Fixed</enum> 336 </property> 337 <property name="sizeHint" stdset="0"> 338 <size> 339 <width>5</width> 340 <height>0</height> 341 </size> 342 </property> 343 </spacer> 344 </item> 345 <item> 346 <widget class="QPushButton" name="mBtnCancel2"> 347 <property name="text"> 348 <string>Cancel</string> 349 </property> 350 </widget> 351 </item> 352 </layout> 353 </item> 354 </layout> 355 </widget> 356 <widget class="QWidget" name="mFileSelectPage"> 357 <layout class="QVBoxLayout" name="verticalLayout_3"> 358 <item> 359 <widget class="QLabel" name="mPageFileSelectHdr"> 360 <property name="font"> 361 <font> 362 <family>Arial</family> 363 <pointsize>12</pointsize> 364 <weight>75</weight> 365 <bold>true</bold> 366 </font> 367 </property> 368 <property name="text"> 369 <string>Appliance Export Settings</string> 370 </property> 371 </widget> 372 </item> 373 <item> 207 374 <widget class="Line" name="line21"> 208 375 <property name="orientation"> … … 214 381 <layout class="QGridLayout" name="gridLayout_2"> 215 382 <item row="0" column="0" rowspan="3"> 216 <widget class="QLabel" name="mLogo Settings">383 <widget class="QLabel" name="mLogoFileSelect"> 217 384 <property name="sizePolicy"> 218 385 <sizepolicy hsizetype="Maximum" vsizetype="Minimum"> … … 236 403 </item> 237 404 <item row="0" column="1"> 238 <widget class="QILabel" name="mText Settings">405 <widget class="QILabel" name="mTextFileSelect"> 239 406 <property name="sizePolicy"> 240 407 <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> … … 298 465 </item> 299 466 <item> 300 <widget class="QPushButton" name="mBtnBack 2">467 <widget class="QPushButton" name="mBtnBack3"> 301 468 <property name="text"> 302 469 <string>< &Back</string> … … 328 495 </item> 329 496 <item> 330 <widget class="QPushButton" name="mBtnCancel 2">497 <widget class="QPushButton" name="mBtnCancel3"> 331 498 <property name="text"> 332 499 <string>Cancel</string> … … 353 520 <header>VBoxFilePathSelectorWidget.h</header> 354 521 </customwidget> 522 <customwidget> 523 <class>VBoxExportApplianceWgt</class> 524 <extends>QWidget</extends> 525 <header>VBoxExportApplianceWgt.h</header> 526 <container>1</container> 527 </customwidget> 355 528 </customwidgets> 356 529 <resources> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxImportApplianceWzd.ui
r17790 r18378 2 2 <ui version="4.0"> 3 3 <comment> 4 VBox frontends: Qt4 GUI ( "VirtualBox"):4 VBox frontends: Qt4 GUI ("VirtualBox"): 5 5 6 6 Copyright (C) 2009 Sun Microsystems, Inc. … … 10 10 you can redistribute it and/or modify it under the terms of the GNU 11 11 General Public License (GPL) as published by the Free Software 12 Foundation, in version 2 as it comes in the "COPYING"file of the12 Foundation, in version 2 as it comes in the "COPYING" file of the 13 13 VirtualBox OSE distribution. VirtualBox OSE is distributed in the 14 14 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. … … 38 38 <widget class="QStackedWidget" name="mPageStack"> 39 39 <property name="currentIndex"> 40 <number> 0</number>40 <number>1</number> 41 41 </property> 42 42 <widget class="QWidget" name="mFileSelectPage"> … … 378 378 </customwidget> 379 379 <customwidget> 380 <class>VBoxFilePathSelectorWidget</class> 381 <extends>QComboBox</extends> 382 <header>VBoxFilePathSelectorWidget.h</header> 383 </customwidget> 384 <customwidget> 380 385 <class>VBoxImportApplianceWgt</class> 381 386 <extends>QWidget</extends> 382 387 <header>VBoxImportApplianceWgt.h</header> 383 388 <container>1</container> 384 </customwidget>385 <customwidget>386 <class>VBoxFilePathSelectorWidget</class>387 <extends>QComboBox</extends>388 <header>VBoxFilePathSelectorWidget.h</header>389 389 </customwidget> 390 390 </customwidgets>
Note:
See TracChangeset
for help on using the changeset viewer.