Changeset 18378 in vbox for trunk/src/VBox/Frontends/VirtualBox/include
- Timestamp:
- Mar 27, 2009 10:45:19 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 45165
- Location:
- trunk/src/VBox/Frontends/VirtualBox/include
- Files:
-
- 2 added
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.