VirtualBox

Changeset 64686 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 16, 2016 4:18:12 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 130): UIApplianceEditorWidget refactoring: Moving classes to appropriate place.

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  
    4848
    4949
    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. */
     54class ModelItem
     55{
     56public:
     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
     84protected:
     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. */
     96class VirtualSystemItem: public ModelItem
     97{
     98public:
     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
     105private:
     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. */
     112class HardwareItem: public ModelItem
     113{
     114    friend class VirtualSystemSortProxyModel;
     115public:
     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
     149private:
     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*********************************************************************************************************************************/
    52166
    53167/* This & the following derived classes represent the data items of a Virtual
     
    96210}
    97211
    98 ////////////////////////////////////////////////////////////////////////////////
    99 // VirtualSystemItem
     212
     213/*********************************************************************************************************************************
     214*   Class VirtualSystemItem implementation.                                                                                      *
     215*********************************************************************************************************************************/
    100216
    101217VirtualSystemItem::VirtualSystemItem(int number, CVirtualSystemDescription aDesc, ModelItem *pParent)
     
    126242}
    127243
    128 ////////////////////////////////////////////////////////////////////////////////
    129 // HardwareItem
     244
     245/*********************************************************************************************************************************
     246*   Class HardwareItem implementation.                                                                                           *
     247*********************************************************************************************************************************/
    130248
    131249HardwareItem::HardwareItem(int number,
     
    723841}
    724842
    725 ////////////////////////////////////////////////////////////////////////////////
    726 // VirtualSystemModel
     843
     844/*********************************************************************************************************************************
     845*   Class VirtualSystemModel implementation.                                                                                     *
     846*********************************************************************************************************************************/
    727847
    728848/* This class is a wrapper model for our ModelItem. It could be used with any
     
    9311051}
    9321052
    933 ////////////////////////////////////////////////////////////////////////////////
    934 // VirtualSystemDelegate
     1053
     1054/*********************************************************************************************************************************
     1055*   Class VirtualSystemDelegate implementation.                                                                                  *
     1056*********************************************************************************************************************************/
    9351057
    9361058/* The delegate is used for creating/handling the different editors for the
     
    10231145#endif /* VBOX_WS_MAC */
    10241146
    1025 ////////////////////////////////////////////////////////////////////////////////
    1026 // VirtualSystemSortProxyModel
     1147
     1148/*********************************************************************************************************************************
     1149*   Class VirtualSystemSortProxyModel implementation.                                                                            *
     1150*********************************************************************************************************************************/
    10271151
    10281152/* How to sort the items in the tree view */
     
    11061230}
    11071231
    1108 ////////////////////////////////////////////////////////////////////////////////
    1109 // UIApplianceEditorWidget
     1232
     1233/*********************************************************************************************************************************
     1234*   Class UIApplianceEditorWidget implementation.                                                                                *
     1235*********************************************************************************************************************************/
    11101236
    11111237int UIApplianceEditorWidget::m_minGuestRAM      = -1;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.h

    r64685 r64686  
    1616 */
    1717
    18 #ifndef __UIApplianceEditorWidget_h__
    19 #define __UIApplianceEditorWidget_h__
     18#ifndef ___UIApplianceEditorWidget_h___
     19#define ___UIApplianceEditorWidget_h___
    2020
    2121/* Qt includes: */
     
    4747};
    4848
     49
    4950/** Appliance model item types. */
    5051enum ApplianceModelItemType
     
    5657
    5758
    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:
     59class VirtualSystemModel : public QAbstractItemModel
     60{
     61public:
     62
    17963    VirtualSystemModel(QVector<CVirtualSystemDescription>& aVSDs, QObject *pParent = NULL);
    18064    ~VirtualSystemModel();
     
    19579
    19680private:
     81
    19782    /* Private member vars */
    19883    ModelItem *m_pRootItem;
    19984};
    20085
    201 ////////////////////////////////////////////////////////////////////////////////
    202 // VirtualSystemDelegate
    20386
    20487/* The delegate is used for creating/handling the different editors for the
     
    20891   have to handle the proxy model ourself. I really don't understand why Qt is
    20992   not doing this for us. */
    210 class VirtualSystemDelegate: public QItemDelegate
     93class VirtualSystemDelegate : public QItemDelegate
    21194{
    21295public:
     
    243126};
    244127
    245 ////////////////////////////////////////////////////////////////////////////////
    246 // VirtualSystemSortProxyModel
    247 
    248 class VirtualSystemSortProxyModel: public QSortFilterProxyModel
    249 {
    250 public:
     128
     129class VirtualSystemSortProxyModel : public QSortFilterProxyModel
     130{
     131public:
     132
    251133    VirtualSystemSortProxyModel(QObject *pParent = NULL);
    252134
    253135protected:
     136
    254137    bool filterAcceptsRow(int srcRow, const QModelIndex & srcParenIdx) const;
    255138    bool lessThan(const QModelIndex &leftIdx, const QModelIndex &rightIdx) const;
     
    260143};
    261144
    262 ////////////////////////////////////////////////////////////////////////////////
    263 // UIApplianceEditorWidget
    264 
    265 class UIApplianceEditorWidget: public QIWithRetranslateUI<QWidget>
     145
     146class UIApplianceEditorWidget : public QIWithRetranslateUI<QWidget>
    266147{
    267148    Q_OBJECT;
    268149
    269150public:
     151
    270152    UIApplianceEditorWidget(QWidget *pParent = NULL);
    271153
     
    279161
    280162public slots:
     163
    281164    void restoreDefaults();
    282165
    283166protected:
     167
    284168    virtual void retranslateUi();
    285169
     
    303187
    304188private:
     189
    305190    static void initSystemSettings();
    306191
     
    312197};
    313198
    314 #endif /* __UIApplianceEditorWidget_h__ */
    315 
     199#endif /* !___UIApplianceEditorWidget_h___ */
     200
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette