Changeset 64686 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 16, 2016 4:18:12 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp
r64685 r64686 48 48 49 49 50 //////////////////////////////////////////////////////////////////////////////// 51 // ModelItem 50 /* This & the following derived classes represent the data items of a Virtual 51 System. All access/manipulation is done with the help of virtual functions 52 to keep the interface clean. ModelItem is able to handle tree structures 53 with a parent & several children's. */ 54 class ModelItem 55 { 56 public: 57 58 ModelItem(int number, ApplianceModelItemType type, ModelItem *pParent = NULL); 59 60 virtual ~ModelItem(); 61 62 ModelItem *parent() const { return m_pParentItem; } 63 64 void appendChild(ModelItem *pChild); 65 ModelItem *child(int row) const; 66 67 int row() const; 68 69 int childCount() const; 70 int columnCount() const { return 3; } 71 72 virtual Qt::ItemFlags itemFlags(int /* column */) const { return 0; } 73 virtual bool setData(int /* column */, const QVariant & /* value */, int /* role */) { return false; } 74 virtual QVariant data(int /* column */, int /* role */) const { return QVariant(); } 75 virtual QWidget *createEditor(QWidget * /* pParent */, const QStyleOptionViewItem & /* styleOption */, const QModelIndex & /* idx */) const { return NULL; } 76 virtual bool setEditorData(QWidget * /* pEditor */, const QModelIndex & /* idx */) const { return false; } 77 virtual bool setModelData(QWidget * /* pEditor */, QAbstractItemModel * /* pModel */, const QModelIndex & /* idx */) { return false; } 78 79 virtual void restoreDefaults() {} 80 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 81 82 ApplianceModelItemType type() const { return m_type; } 83 84 protected: 85 86 /* Protected member vars */ 87 int m_number; 88 ApplianceModelItemType m_type; 89 90 ModelItem *m_pParentItem; 91 QList<ModelItem*> m_childItems; 92 }; 93 94 95 /* This class represent a Virtual System with an index. */ 96 class VirtualSystemItem: public ModelItem 97 { 98 public: 99 VirtualSystemItem(int number, CVirtualSystemDescription aDesc, ModelItem *pParent); 100 101 virtual QVariant data(int column, int role) const; 102 103 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 104 105 private: 106 CVirtualSystemDescription m_desc; 107 }; 108 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 enum 118 { 119 TypeRole = Qt::UserRole, 120 ModifiedRole 121 }; 122 123 HardwareItem(int number, 124 KVirtualSystemDescriptionType type, 125 const QString &strRef, 126 const QString &strOrigValue, 127 const QString &strConfigValue, 128 const QString &strExtraConfigValue, 129 ModelItem *pParent); 130 131 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 132 133 virtual bool setData(int column, const QVariant &value, int role); 134 virtual QVariant data(int column, int role) const; 135 136 virtual Qt::ItemFlags itemFlags(int column) const; 137 138 virtual QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const; 139 virtual bool setEditorData(QWidget *pEditor, const QModelIndex &idx) const; 140 141 virtual bool setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx); 142 143 virtual void restoreDefaults() 144 { 145 m_strConfigValue = m_strConfigDefaultValue; 146 m_checkState = Qt::Checked; 147 } 148 149 private: 150 151 /* Private member vars */ 152 KVirtualSystemDescriptionType m_type; 153 QString m_strRef; 154 QString m_strOrigValue; 155 QString m_strConfigValue; 156 QString m_strConfigDefaultValue; 157 QString m_strExtraConfigValue; 158 Qt::CheckState m_checkState; 159 bool m_fModified; 160 }; 161 162 163 /********************************************************************************************************************************* 164 * Class ModelItem implementation. * 165 *********************************************************************************************************************************/ 52 166 53 167 /* This & the following derived classes represent the data items of a Virtual … … 96 210 } 97 211 98 //////////////////////////////////////////////////////////////////////////////// 99 // VirtualSystemItem 212 213 /********************************************************************************************************************************* 214 * Class VirtualSystemItem implementation. * 215 *********************************************************************************************************************************/ 100 216 101 217 VirtualSystemItem::VirtualSystemItem(int number, CVirtualSystemDescription aDesc, ModelItem *pParent) … … 126 242 } 127 243 128 //////////////////////////////////////////////////////////////////////////////// 129 // HardwareItem 244 245 /********************************************************************************************************************************* 246 * Class HardwareItem implementation. * 247 *********************************************************************************************************************************/ 130 248 131 249 HardwareItem::HardwareItem(int number, … … 723 841 } 724 842 725 //////////////////////////////////////////////////////////////////////////////// 726 // VirtualSystemModel 843 844 /********************************************************************************************************************************* 845 * Class VirtualSystemModel implementation. * 846 *********************************************************************************************************************************/ 727 847 728 848 /* This class is a wrapper model for our ModelItem. It could be used with any … … 931 1051 } 932 1052 933 //////////////////////////////////////////////////////////////////////////////// 934 // VirtualSystemDelegate 1053 1054 /********************************************************************************************************************************* 1055 * Class VirtualSystemDelegate implementation. * 1056 *********************************************************************************************************************************/ 935 1057 936 1058 /* The delegate is used for creating/handling the different editors for the … … 1023 1145 #endif /* VBOX_WS_MAC */ 1024 1146 1025 //////////////////////////////////////////////////////////////////////////////// 1026 // VirtualSystemSortProxyModel 1147 1148 /********************************************************************************************************************************* 1149 * Class VirtualSystemSortProxyModel implementation. * 1150 *********************************************************************************************************************************/ 1027 1151 1028 1152 /* How to sort the items in the tree view */ … … 1106 1230 } 1107 1231 1108 //////////////////////////////////////////////////////////////////////////////// 1109 // UIApplianceEditorWidget 1232 1233 /********************************************************************************************************************************* 1234 * Class UIApplianceEditorWidget implementation. * 1235 *********************************************************************************************************************************/ 1110 1236 1111 1237 int UIApplianceEditorWidget::m_minGuestRAM = -1; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.h
r64685 r64686 16 16 */ 17 17 18 #ifndef __ UIApplianceEditorWidget_h__19 #define __ UIApplianceEditorWidget_h__18 #ifndef ___UIApplianceEditorWidget_h___ 19 #define ___UIApplianceEditorWidget_h___ 20 20 21 21 /* Qt includes: */ … … 47 47 }; 48 48 49 49 50 /** Appliance model item types. */ 50 51 enum ApplianceModelItemType … … 56 57 57 58 58 /* This & the following derived classes represent the data items of a Virtual 59 System. All access/manipulation is done with the help of virtual functions 60 to keep the interface clean. ModelItem is able to handle tree structures 61 with a parent & several children's. */ 62 class ModelItem 63 { 64 public: 65 ModelItem(int number, ApplianceModelItemType type, ModelItem *pParent = NULL); 66 67 virtual ~ModelItem(); 68 69 ModelItem *parent() const { return m_pParentItem; } 70 71 void appendChild(ModelItem *pChild); 72 ModelItem *child(int row) const; 73 74 int row() const; 75 76 int childCount() const; 77 int columnCount() const { return 3; } 78 79 virtual Qt::ItemFlags itemFlags(int /* column */) const { return 0; } 80 virtual bool setData(int /* column */, const QVariant & /* value */, int /* role */) { return false; } 81 virtual QVariant data(int /* column */, int /* role */) const { return QVariant(); } 82 virtual QWidget *createEditor(QWidget * /* pParent */, const QStyleOptionViewItem & /* styleOption */, const QModelIndex & /* idx */) const { return NULL; } 83 virtual bool setEditorData(QWidget * /* pEditor */, const QModelIndex & /* idx */) const { return false; } 84 virtual bool setModelData(QWidget * /* pEditor */, QAbstractItemModel * /* pModel */, const QModelIndex & /* idx */) { return false; } 85 86 virtual void restoreDefaults() {} 87 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 88 89 ApplianceModelItemType type() const { return m_type; } 90 91 protected: 92 /* Protected member vars */ 93 int m_number; 94 ApplianceModelItemType m_type; 95 96 ModelItem *m_pParentItem; 97 QList<ModelItem*> m_childItems; 98 }; 99 100 //////////////////////////////////////////////////////////////////////////////// 101 // VirtualSystemItem 102 103 /* This class represent a Virtual System with an index. */ 104 class VirtualSystemItem: public ModelItem 105 { 106 public: 107 VirtualSystemItem(int number, CVirtualSystemDescription aDesc, ModelItem *pParent); 108 109 virtual QVariant data(int column, int role) const; 110 111 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 112 113 private: 114 CVirtualSystemDescription m_desc; 115 }; 116 117 //////////////////////////////////////////////////////////////////////////////// 118 // HardwareItem 119 120 /* This class represent an hardware item of a Virtual System. All values of 121 KVirtualSystemDescriptionType are supported & handled differently. */ 122 class HardwareItem: public ModelItem 123 { 124 friend class VirtualSystemSortProxyModel; 125 public: 126 127 enum 128 { 129 TypeRole = Qt::UserRole, 130 ModifiedRole 131 }; 132 133 HardwareItem(int number, 134 KVirtualSystemDescriptionType type, 135 const QString &strRef, 136 const QString &strOrigValue, 137 const QString &strConfigValue, 138 const QString &strExtraConfigValue, 139 ModelItem *pParent); 140 141 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 142 143 virtual bool setData(int column, const QVariant &value, int role); 144 virtual QVariant data(int column, int role) const; 145 146 virtual Qt::ItemFlags itemFlags(int column) const; 147 148 virtual QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const; 149 virtual bool setEditorData(QWidget *pEditor, const QModelIndex &idx) const; 150 151 virtual bool setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx); 152 153 virtual void restoreDefaults() 154 { 155 m_strConfigValue = m_strConfigDefaultValue; 156 m_checkState = Qt::Checked; 157 } 158 159 private: 160 161 /* Private member vars */ 162 KVirtualSystemDescriptionType m_type; 163 QString m_strRef; 164 QString m_strOrigValue; 165 QString m_strConfigValue; 166 QString m_strConfigDefaultValue; 167 QString m_strExtraConfigValue; 168 Qt::CheckState m_checkState; 169 bool m_fModified; 170 }; 171 172 //////////////////////////////////////////////////////////////////////////////// 173 // VirtualSystemModel 174 175 class VirtualSystemModel: public QAbstractItemModel 176 { 177 178 public: 59 class VirtualSystemModel : public QAbstractItemModel 60 { 61 public: 62 179 63 VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = NULL); 180 64 ~VirtualSystemModel(); … … 195 79 196 80 private: 81 197 82 /* Private member vars */ 198 83 ModelItem *m_pRootItem; 199 84 }; 200 85 201 ////////////////////////////////////////////////////////////////////////////////202 // VirtualSystemDelegate203 86 204 87 /* The delegate is used for creating/handling the different editors for the … … 208 91 have to handle the proxy model ourself. I really don't understand why Qt is 209 92 not doing this for us. */ 210 class VirtualSystemDelegate : public QItemDelegate93 class VirtualSystemDelegate : public QItemDelegate 211 94 { 212 95 public: … … 243 126 }; 244 127 245 //////////////////////////////////////////////////////////////////////////////// 246 // VirtualSystemSortProxyModel 247 248 class VirtualSystemSortProxyModel: public QSortFilterProxyModel 249 { 250 public: 128 129 class VirtualSystemSortProxyModel : public QSortFilterProxyModel 130 { 131 public: 132 251 133 VirtualSystemSortProxyModel(QObject *pParent = NULL); 252 134 253 135 protected: 136 254 137 bool filterAcceptsRow(int srcRow, const QModelIndex & srcParenIdx) const; 255 138 bool lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const; … … 260 143 }; 261 144 262 //////////////////////////////////////////////////////////////////////////////// 263 // UIApplianceEditorWidget 264 265 class UIApplianceEditorWidget: public QIWithRetranslateUI<QWidget> 145 146 class UIApplianceEditorWidget : public QIWithRetranslateUI<QWidget> 266 147 { 267 148 Q_OBJECT; 268 149 269 150 public: 151 270 152 UIApplianceEditorWidget(QWidget *pParent = NULL); 271 153 … … 279 161 280 162 public slots: 163 281 164 void restoreDefaults(); 282 165 283 166 protected: 167 284 168 virtual void retranslateUi(); 285 169 … … 303 187 304 188 private: 189 305 190 static void initSystemSettings(); 306 191 … … 312 197 }; 313 198 314 #endif /* __UIApplianceEditorWidget_h__ */315 199 #endif /* !___UIApplianceEditorWidget_h___ */ 200
Note:
See TracChangeset
for help on using the changeset viewer.