Changeset 64688 in vbox
- Timestamp:
- Nov 17, 2016 1:16:10 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
r64686 r64688 48 48 49 49 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. */ 50 /** Describes the interface of Virtual System item. 51 * Represented as a tree structure with a parent & multiple children. */ 54 52 class ModelItem 55 53 { 56 54 public: 57 55 56 /** Constructs item with specified @a number, @a type and @a pParent. */ 58 57 ModelItem(int number, ApplianceModelItemType type, ModelItem *pParent = NULL); 59 58 /** Destructs item. */ 60 59 virtual ~ModelItem(); 61 60 61 /** Returns the parent of the item. */ 62 62 ModelItem *parent() const { return m_pParentItem; } 63 63 64 /** Appends the passed @a pChild to the item's list of children. */ 64 65 void appendChild(ModelItem *pChild); 66 /** Returns the child specified by the @a row. */ 65 67 ModelItem *child(int row) const; 66 68 69 /** Returns the row of the item in the parent. */ 67 70 int row() const; 68 71 72 /** Returns the number of children. */ 69 73 int childCount() const; 74 /** Returns the number of columns. */ 70 75 int columnCount() const { return 3; } 71 76 77 /** Returns the item flags for the given @a column. */ 72 78 virtual Qt::ItemFlags itemFlags(int /* column */) const { return 0; } 79 /** Defines the @a role data for the item at @a column to @a value. */ 73 80 virtual bool setData(int /* column */, const QVariant & /* value */, int /* role */) { return false; } 81 /** Returns the data stored under the given @a role for the item referred to by the @a column. */ 74 82 virtual QVariant data(int /* column */, int /* role */) const { return QVariant(); } 83 /** Returns the widget used to edit the item specified by @a idx for editing. 84 * @param pParent Brings the parent to be assigned for newly created editor. 85 * @param styleOption Bring the style option set for the newly created editor. */ 75 86 virtual QWidget *createEditor(QWidget * /* pParent */, const QStyleOptionViewItem & /* styleOption */, const QModelIndex & /* idx */) const { return NULL; } 87 /** Defines the contents of the given @a pEditor to the data for the item at the given @a idx. */ 76 88 virtual bool setEditorData(QWidget * /* pEditor */, const QModelIndex & /* idx */) const { return false; } 89 /** Defines the data for the item at the given @a idx in the @a pModel to the contents of the given @a pEditor. */ 77 90 virtual bool setModelData(QWidget * /* pEditor */, QAbstractItemModel * /* pModel */, const QModelIndex & /* idx */) { return false; } 78 91 92 /** Restores the default values. */ 79 93 virtual void restoreDefaults() {} 94 /** Cache currently stored values, such as @a finalStates, @a finalValues and @a finalExtraValues. */ 80 95 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 81 96 97 /** Returns the item type. */ 82 98 ApplianceModelItemType type() const { return m_type; } 83 99 84 100 protected: 85 101 86 /* Protected member vars*/102 /** Holds the item number. */ 87 103 int m_number; 104 /** Holds the item type. */ 88 105 ApplianceModelItemType m_type; 89 106 107 /** Holds the parent item reference. */ 90 108 ModelItem *m_pParentItem; 109 /** Holds the list of children item instances. */ 91 110 QList<ModelItem*> m_childItems; 92 111 }; 93 112 94 113 95 /* This class represent a Virtual System with an index. */96 class VirtualSystemItem : public ModelItem114 /** ModelItem subclass representing Virtual System. */ 115 class VirtualSystemItem : public ModelItem 97 116 { 98 117 public: 118 119 /** Constructs item passing @a number and @a pParent to the base-class. 120 * @param aDesc Brings the Virtual System Description. */ 99 121 VirtualSystemItem(int number, CVirtualSystemDescription aDesc, ModelItem *pParent); 100 122 123 /** Returns the data stored under the given @a role for the item referred to by the @a column. */ 101 124 virtual QVariant data(int column, int role) const; 102 125 126 /** Cache currently stored values, such as @a finalStates, @a finalValues and @a finalExtraValues. */ 103 127 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 104 128 105 129 private: 130 131 /** Holds the Virtual System Description. */ 106 132 CVirtualSystemDescription m_desc; 107 133 }; 108 134 109 135 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 136 /** ModelItem subclass representing Virtual System item. */ 137 class HardwareItem : public ModelItem 113 138 { 114 139 friend class VirtualSystemSortProxyModel; 140 115 141 public: 116 142 143 /** Data roles. */ 117 144 enum 118 145 { … … 121 148 }; 122 149 150 /** Constructs item passing @a number and @a pParent to the base-class. 151 * @param type Brings the Virtual System Description type. 152 * @param strRef Brings something totally useless. 153 * @param strOrigValue Brings the original value. 154 * @param strConfigValue Brings the configuration value. 155 * @param strExtraConfigValue Brings the extra configuration value. */ 123 156 HardwareItem(int number, 124 157 KVirtualSystemDescriptionType type, … … 129 162 ModelItem *pParent); 130 163 164 /** Cache currently stored values, such as @a finalStates, @a finalValues and @a finalExtraValues. */ 131 165 virtual void putBack(QVector<BOOL>& finalStates, QVector<QString>& finalValues, QVector<QString>& finalExtraValues); 132 166 167 /** Defines the @a role data for the item at @a column to @a value. */ 133 168 virtual bool setData(int column, const QVariant &value, int role); 169 /** Returns the data stored under the given @a role for the item referred to by the @a column. */ 134 170 virtual QVariant data(int column, int role) const; 135 171 172 /** Returns the item flags for the given @a column. */ 136 173 virtual Qt::ItemFlags itemFlags(int column) const; 137 174 175 /** Returns the widget used to edit the item specified by @a idx for editing. 176 * @param pParent Brings the parent to be assigned for newly created editor. 177 * @param styleOption Bring the style option set for the newly created editor. */ 138 178 virtual QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const; 179 /** Defines the contents of the given @a pEditor to the data for the item at the given @a idx. */ 139 180 virtual bool setEditorData(QWidget *pEditor, const QModelIndex &idx) const; 140 181 /** Defines the data for the item at the given @a idx in the @a pModel to the contents of the given @a pEditor. */ 141 182 virtual bool setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx); 142 183 184 /** Restores the default values. */ 143 185 virtual void restoreDefaults() 144 186 { … … 149 191 private: 150 192 151 /* Private member vars*/193 /** Holds the Virtual System description type. */ 152 194 KVirtualSystemDescriptionType m_type; 195 /** Holds something totally useless. */ 153 196 QString m_strRef; 197 /** Holds the original value. */ 154 198 QString m_strOrigValue; 199 /** Holds the configuration value. */ 155 200 QString m_strConfigValue; 201 /** Holds the default configuration value. */ 156 202 QString m_strConfigDefaultValue; 203 /** Holds the extra configuration value. */ 157 204 QString m_strExtraConfigValue; 205 /** Holds the item check state. */ 158 206 Qt::CheckState m_checkState; 207 /** Holds whether item was modified. */ 159 208 bool m_fModified; 160 209 }; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.h
r64686 r64688 57 57 58 58 59 /** QAbstractItemModel subclass used as Virtual System model. */ 59 60 class VirtualSystemModel : public QAbstractItemModel 60 61 { 61 62 public: 62 63 64 /** Constructs the Virtual System model passing @a pParent to the base-class. 65 * @param aVSDs Brings the Virtual System descriptions. */ 63 66 VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = NULL); 67 /** Destructs the Virtual System model. */ 64 68 ~VirtualSystemModel(); 65 69 70 /** Returns the index of the item in the model specified by the given @a row, @a column and @a parentIdx. */ 66 71 QModelIndex index(int row, int column, const QModelIndex &parentIdx = QModelIndex()) const; 72 /** Returns the parent of the model item with the given @a idx. */ 67 73 QModelIndex parent(const QModelIndex &idx) const; 74 /** Returns the number of rows for the children of the given @a parentIdx. */ 68 75 int rowCount(const QModelIndex &parentIdx = QModelIndex()) const; 76 /** Returns the number of columns for the children of the given @a parentIdx. */ 69 77 int columnCount(const QModelIndex &parentIdx = QModelIndex()) const; 78 /** Defines the @a role data for the item at @a idx to @a value. */ 70 79 bool setData(const QModelIndex &idx, const QVariant &value, int role); 80 /** Returns the data stored under the given @a role for the item referred to by the @a idx. */ 71 81 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const; 82 /** Returns the item flags for the given @a idx. */ 72 83 Qt::ItemFlags flags(const QModelIndex &idx) const; 84 /** Returns the data for the given @a role and @a section in the header with the specified @a orientation. */ 73 85 QVariant headerData(int section, Qt::Orientation orientation, int role) const; 74 86 87 /** Returns a model index for the buddy of the item represented by @a idx. */ 75 88 QModelIndex buddy(const QModelIndex &idx) const; 76 89 90 /** Restores the default values for the item with the given @a parentIdx. */ 77 91 void restoreDefaults(const QModelIndex &parentIdx = QModelIndex()); 92 /** Cache currently stored values. */ 78 93 void putBack(); 79 94 80 95 private: 81 96 82 /* Private member vars*/97 /** Holds the root item reference. */ 83 98 ModelItem *m_pRootItem; 84 99 }; 85 100 86 101 87 /* The delegate is used for creating/handling the different editors for the 88 various types we support. This class forward the requests to the virtual 89 methods of our different ModelItems. If this is not possible the default 90 methods of QItemDelegate are used to get some standard behavior. Note: We 91 have to handle the proxy model ourself. I really don't understand why Qt is 92 not doing this for us. */ 102 /** QItemDelegate subclass used to create various Virtual System model editors. */ 93 103 class VirtualSystemDelegate : public QItemDelegate 94 104 { 95 105 public: 96 106 107 /** Constructs the Virtual System Delegate passing @a pParent to the base-class. 108 * @param pProxy Brings the proxy model reference used to redirect requests to. */ 97 109 VirtualSystemDelegate(QAbstractProxyModel *pProxy, QObject *pParent = NULL); 98 110 111 /** Returns the widget used to edit the item specified by @a idx for editing. 112 * @param pParent Brings the parent to be assigned for newly created editor. 113 * @param styleOption Bring the style option set for the newly created editor. */ 99 114 QWidget *createEditor(QWidget *pParent, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const; 115 /** Defines the contents of the given @a pEditor to the data for the item at the given @a idx. */ 100 116 void setEditorData(QWidget *pEditor, const QModelIndex &idx) const; 117 /** Defines the data for the item at the given @a idx in the @a pModel to the contents of the given @a pEditor. */ 101 118 void setModelData(QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex &idx) const; 119 /** Updates the geometry of the @a pEditor for the item with the given @a idx, according to the rectangle specified in the @a styleOption. */ 102 120 void updateEditorGeometry(QWidget *pEditor, const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const; 103 121 122 /** Returns the size hint for the item at the given @a idx and specified @a styleOption. */ 104 123 QSize sizeHint(const QStyleOptionViewItem &styleOption, const QModelIndex &idx) const 105 124 { … … 117 136 118 137 #ifdef VBOX_WS_MAC 138 /** Filters @a pEvent if this object has been installed as an event filter for the watched @a pObject. */ 119 139 bool eventFilter(QObject *pObject, QEvent *pEvent); 120 140 #endif /* VBOX_WS_MAC */ … … 122 142 private: 123 143 124 /* Private member vars*/144 /** Holds the proxy model reference used to redirect requests to. */ 125 145 QAbstractProxyModel *mProxy; 126 146 }; 127 147 128 148 149 /** QSortFilterProxyModel subclass used as the Virtual System Sorting model. */ 129 150 class VirtualSystemSortProxyModel : public QSortFilterProxyModel 130 151 { 131 152 public: 132 153 154 /** Constructs the Virtual System Sorting model passing @a pParent to the base-class. */ 133 155 VirtualSystemSortProxyModel(QObject *pParent = NULL); 134 156 135 157 protected: 136 158 159 /** Returns whether item in the row indicated by the given @a srcRow and @a srcParenIdx should be included in the model. */ 137 160 bool filterAcceptsRow(int srcRow, const QModelIndex & srcParenIdx) const; 161 /** Returns whether value of the item referred to by the given index @a leftIdx is less 162 * than the value of the item referred to by the given index @a rightIdx. */ 138 163 bool lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const; 139 164 165 /** Holds the array of sorted Virtual System Description types. */ 140 166 static KVirtualSystemDescriptionType m_sortList[]; 141 167 168 /** Holds the filtered list of Virtual System Description types. */ 142 169 QList<KVirtualSystemDescriptionType> m_filterList; 143 170 }; 144 171 145 172 173 /** QWidget subclass used as the Appliance Editor widget. */ 146 174 class UIApplianceEditorWidget : public QIWithRetranslateUI<QWidget> 147 175 { … … 150 178 public: 151 179 180 /** Constructs the Appliance Editor widget passing @a pParent to the base-class. */ 152 181 UIApplianceEditorWidget(QWidget *pParent = NULL); 153 182 183 /** Returns whether the Appliance Editor has valid state. */ 154 184 bool isValid() const { return m_pAppliance != NULL; } 185 /** Returns the currently set appliance reference. */ 155 186 CAppliance* appliance() const { return m_pAppliance; } 156 187 188 /** Returns the minimum guest RAM. */ 157 189 static int minGuestRAM() { return m_minGuestRAM; } 190 /** Returns the maximum guest RAM. */ 158 191 static int maxGuestRAM() { return m_maxGuestRAM; } 192 /** Returns the minimum guest CPU count. */ 159 193 static int minGuestCPUCount() { return m_minGuestCPUCount; } 194 /** Returns the maximum guest CPU count. */ 160 195 static int maxGuestCPUCount() { return m_maxGuestCPUCount; } 161 196 162 197 public slots: 163 198 199 /** Restores the default values. */ 164 200 void restoreDefaults(); 165 201 166 202 protected: 167 203 204 /** Handles translation event. */ 168 205 virtual void retranslateUi(); 169 206 170 /* Protected member vars*/207 /** Holds the currently set appliance reference. */ 171 208 CAppliance *m_pAppliance; 209 /** Holds the Virtual System model reference. */ 172 210 VirtualSystemModel *m_pModel; 173 211 … … 188 226 private: 189 227 228 /** Performs Virtual System settings initialization. */ 190 229 static void initSystemSettings(); 191 230 192 /* Private member vars*/231 /** Holds the minimum guest RAM. */ 193 232 static int m_minGuestRAM; 233 /** Holds the maximum guest RAM. */ 194 234 static int m_maxGuestRAM; 235 /** Holds the minimum guest CPU count. */ 195 236 static int m_minGuestCPUCount; 237 /** Holds the maximum guest CPU count. */ 196 238 static int m_maxGuestCPUCount; 197 239 };
Note:
See TracChangeset
for help on using the changeset viewer.