VirtualBox

Changeset 65287 in vbox for trunk


Ignore:
Timestamp:
Jan 13, 2017 3:45:43 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 173): A bit of care for UIInformationDataItem sub-classes: Coding-style fixes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationDataItem.cpp

    r65285 r65287  
    2525
    2626/* GUI includes: */
     27# include "VBoxGlobal.h"
    2728# include "UIMachine.h"
    2829# include "UISession.h"
    29 # include "UIIconPool.h"
    30 # include "VBoxGlobal.h"
    3130# include "UIConverter.h"
    32 # include "UIMessageCenter.h"
    3331# include "UIInformationItem.h"
    3432# include "UIInformationModel.h"
    3533# include "UIInformationDataItem.h"
    36 # include "UIGraphicsRotatorButton.h"
    3734
    3835/* COM includes: */
    39 # include "COMEnums.h"
    4036# include "CMedium.h"
    41 # include "CMachine.h"
     37# include "CSerialPort.h"
    4238# include "CVRDEServer.h"
    43 # include "CSerialPort.h"
    4439# include "CAudioAdapter.h"
    4540# include "CParallelPort.h"
     
    5045# include "CUSBDeviceFilter.h"
    5146# include "CMediumAttachment.h"
     47# include "CSystemProperties.h"
    5248# include "CUSBDeviceFilters.h"
    53 # include "CSystemProperties.h"
    5449# include "CStorageController.h"
    5550
    56 /* Other VBox includes: */
    57 # include <iprt/time.h>
    58 
    5951#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    6052
     
    6456*********************************************************************************************************************************/
    6557
    66 UIInformationDataItem::UIInformationDataItem(InformationElementType type, const CMachine &machine, const CConsole &console, UIInformationModel *pModel)
    67     : m_type(type)
     58UIInformationDataItem::UIInformationDataItem(InformationElementType enmType, const CMachine &machine, const CConsole &console, UIInformationModel *pModel)
     59    : m_enmType(enmType)
    6860    , m_machine(machine)
    6961    , m_console(console)
     
    7264}
    7365
    74 UIInformationDataItem::~UIInformationDataItem()
    75 {
    76 }
    77 
    78 QVariant UIInformationDataItem::data(const QModelIndex &index, int role) const
    79 {
    80     RT_NOREF(index);
    81 
    82     /* For particular role: */
    83     switch (role)
    84     {
    85         case Qt::DisplayRole:
    86         {
    87             return gpConverter->toString(m_type);
    88         }
    89         break;
    90 
    91         case Qt::UserRole + 2:
    92         {
    93             return m_type;
    94         }
    95         break;
    96 
    97         default:
    98         break;
     66QVariant UIInformationDataItem::data(const QModelIndex & /* index */, int role) const
     67{
     68    /* For particular role: */
     69    switch (role)
     70    {
     71        case Qt::DisplayRole:  return gpConverter->toString(m_enmType);
     72        case Qt::UserRole + 2: return m_enmType;
     73        default:               break;
    9974    }
    10075
     
    12297            return QString(":/machine_16px.png");
    12398        }
    124         break;
    12599
    126100        case Qt::UserRole + 1:
     
    131105            return QVariant::fromValue(p_text);
    132106        }
    133         break;
    134 
    135         default:
    136         break;
     107
     108        default:
     109            break;
    137110    }
    138111
     
    160133            return QString(":/chipset_16px.png");
    161134        }
    162         break;
    163135
    164136        case Qt::UserRole + 1:
     
    226198            return QVariant::fromValue(p_text);
    227199        }
    228         break;
    229 
    230         default:
    231         break;
     200
     201        default:
     202            break;
    232203    }
    233204
     
    255226            return QString(":/vrdp_16px.png");
    256227        }
    257         break;
    258 
    259         case Qt::UserRole+1:
     228
     229        case Qt::UserRole + 1:
    260230        {
    261231            UITextTable p_text;
     
    291261            return QVariant::fromValue(p_text);
    292262        }
    293         break;
    294 
    295         default:
    296         break;
     263
     264        default:
     265            break;
    297266    }
    298267
     
    316285    switch (role)
    317286    {
    318 
    319287        case Qt::DecorationRole:
    320288        {
    321289            return QString(":/hd_16px.png");
    322290        }
    323         break;
    324 
    325         case Qt::UserRole+1:
     291
     292        case Qt::UserRole + 1:
    326293        {
    327294            UITextTable p_text;
     
    361328            return QVariant::fromValue(p_text);
    362329        }
    363         break;
    364 
    365         default:
    366         break;
     330
     331        default:
     332            break;
    367333    }
    368334
     
    390356            return QString(":/sound_16px.png");
    391357        }
    392         break;
    393358
    394359        case Qt::UserRole + 1:
     
    405370            return QVariant::fromValue(p_text);
    406371        }
    407         break;
    408 
    409         default:
    410         break;
     372
     373        default:
     374            break;
    411375    }
    412376
     
    434398            return QString(":/nw_16px.png");
    435399        }
    436         break;
    437 
    438         case Qt::UserRole+1:
     400
     401        case Qt::UserRole + 1:
    439402        {
    440403            UITextTable p_text;
     
    447410                {
    448411                    KNetworkAttachmentType type = adapter.GetAttachmentType();
    449                     QString attType = gpConverter->toString (adapter.GetAdapterType())
    450                                       .replace (QRegExp ("\\s\\(.+\\)"), " (%1)");
     412                    QString attType = gpConverter->toString(adapter.GetAdapterType())
     413                                      .replace(QRegExp ("\\s\\(.+\\)"), " (%1)");
    451414                    /* don't use the adapter type string for types that have
    452415                     * an additional symbolic network/interface name field, use
    453416                     * this name instead */
    454417                    if (type == KNetworkAttachmentType_Bridged)
    455                         attType = attType.arg (tr ("Bridged adapter, %1",
    456                             "details report (network)").arg (adapter.GetBridgedInterface()));
     418                        attType = attType.arg(tr("Bridged adapter, %1",
     419                            "details report (network)").arg(adapter.GetBridgedInterface()));
    457420                    else if (type == KNetworkAttachmentType_Internal)
    458                         attType = attType.arg (tr ("Internal network, '%1'",
    459                             "details report (network)").arg (adapter.GetInternalNetwork()));
     421                        attType = attType.arg(tr("Internal network, '%1'",
     422                            "details report (network)").arg(adapter.GetInternalNetwork()));
    460423                    else if (type == KNetworkAttachmentType_HostOnly)
    461                         attType = attType.arg (tr ("Host-only adapter, '%1'",
    462                             "details report (network)").arg (adapter.GetHostOnlyInterface()));
     424                        attType = attType.arg(tr("Host-only adapter, '%1'",
     425                            "details report (network)").arg(adapter.GetHostOnlyInterface()));
    463426                    else if (type == KNetworkAttachmentType_Generic)
    464                         attType = attType.arg (tr ("Generic, '%1'",
    465                             "details report (network)").arg (adapter.GetGenericDriver()));
     427                        attType = attType.arg(tr("Generic, '%1'",
     428                            "details report (network)").arg(adapter.GetGenericDriver()));
    466429                    else if (type == KNetworkAttachmentType_NATNetwork)
    467                         attType = attType.arg (tr ("NAT network, '%1'",
    468                             "details report (network)").arg (adapter.GetNATNetwork()));
     430                        attType = attType.arg(tr("NAT network, '%1'",
     431                            "details report (network)").arg(adapter.GetNATNetwork()));
    469432                    else
    470                         attType = attType.arg (gpConverter->toString (type));
     433                        attType = attType.arg(gpConverter->toString(type));
    471434
    472435                    p_text << UITextTableLine(tr("Adapter %1", "details report (network)").arg(adapter.GetSlot() + 1), attType);
     
    476439            return QVariant::fromValue(p_text);
    477440        }
    478         break;
    479 
    480         default:
    481         break;
     441
     442        default:
     443            break;
    482444    }
    483445
     
    505467            return QString(":/serial_port_16px.png");
    506468        }
    507         break;
    508469
    509470        case Qt::UserRole + 1:
     
    514475            for (ulong slot = 0; slot < count; slot++)
    515476            {
    516                 CSerialPort port = m_machine.GetSerialPort (slot);
     477                CSerialPort port = m_machine.GetSerialPort(slot);
    517478                if (port.GetEnabled())
    518479                {
    519480                    KPortMode mode = port.GetHostMode();
    520                     QString data = vboxGlobal().toCOMPortName (port.GetIRQ(), port.GetIOBase()) + ", ";
     481                    QString data = vboxGlobal().toCOMPortName(port.GetIRQ(), port.GetIOBase()) + ", ";
    521482                    if (mode == KPortMode_HostPipe ||
    522483                        mode == KPortMode_HostDevice ||
    523484                        mode == KPortMode_TCP ||
    524485                        mode == KPortMode_RawFile)
    525                         data += QString ("%1 (<nobr>%2</nobr>)")
    526                                 .arg (gpConverter->toString (mode))
    527                                 .arg (QDir::toNativeSeparators (port.GetPath()));
     486                        data += QString("%1 (<nobr>%2</nobr>)")
     487                                       .arg(gpConverter->toString(mode))
     488                                       .arg(QDir::toNativeSeparators(port.GetPath()));
    528489                    else
    529490                        data += gpConverter->toString(mode);
     
    535496            return QVariant::fromValue(p_text);
    536497        }
    537         break;
    538 
    539         default:
    540         break;
     498
     499        default:
     500            break;
    541501    }
    542502
     
    565525            return QString(":/parallel_port_16px.png");
    566526        }
    567         break;
    568527
    569528        case Qt::UserRole + 1:
     
    575534                if (port.GetEnabled())
    576535                {
    577                     QString data = vboxGlobal().toLPTPortName (port.GetIRQ(), port.GetIOBase()) +
    578                         QString (" (<nobr>%1</nobr>)")
    579                         .arg (QDir::toNativeSeparators (port.GetPath()));
     536                    QString data = vboxGlobal().toLPTPortName(port.GetIRQ(), port.GetIOBase()) +
     537                        QString(" (<nobr>%1</nobr>)")
     538                               .arg(QDir::toNativeSeparators(port.GetPath()));
    580539                    p_text << UITextTableLine(tr("Port %1", "details report (parallel ports)").arg(port.GetSlot() + 1), data);
    581540                }
     
    584543                p_text << UITextTableLine(tr("Disabled", "details report (parallel ports)"), QString());
    585544        }
    586         break;
    587 
    588         default:
    589         break;
     545
     546        default:
     547            break;
    590548    }
    591549    return QVariant();
     
    612570            return QString(":/usb_16px.png");
    613571        }
    614         break;
    615572
    616573        case Qt::UserRole + 1:
     
    634591
    635592                    p_text << UITextTableLine(tr("Device Filters", "details report (USB)"), tr("%1 (%2 active)", "details report (USB)")
    636                                                  .arg(coll.size()).arg(active));
     593                                                                                              .arg(coll.size()).arg(active));
    637594                }
    638595            }
    639596        }
    640         break;
    641 
    642         default:
    643         break;
     597
     598        default:
     599            break;
    644600    }
    645601
     
    668624            return QString(":/sf_16px.png");
    669625        }
    670         break;
    671626
    672627        case Qt::UserRole + 1:
     
    680635            return QVariant::fromValue(p_text);
    681636        }
    682         break;
    683 
    684         default:
    685         break;
     637
     638        default:
     639            break;
    686640    }
    687641
     
    714668            return QString(":/state_running_16px.png");
    715669        }
    716         break;
    717670
    718671        case Qt::UserRole + 1:
     
    833786            return QVariant::fromValue(p_text);
    834787        }
    835         break;
    836 
    837         default:
    838         break;
     788
     789        default:
     790            break;
    839791    }
    840792
     
    888840    }
    889841
    890      m_pTimer = new QTimer(this);
     842    m_pTimer = new QTimer(this);
    891843
    892844    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics()));
     
    906858            return QString(":/nw_16px.png");
    907859        }
    908         break;
    909860
    910861        case Qt::UserRole + 1:
     
    928879            return QVariant::fromValue(p_text);
    929880        }
    930         break;
    931 
    932         default:
    933         break;
     881
     882        default:
     883            break;
    934884    }
    935885
     
    11031053            return QString(":/hd_16px.png");
    11041054        }
    1105         break;
    11061055
    11071056        case Qt::UserRole + 1:
     
    11671116            return QVariant::fromValue(p_text);
    11681117        }
    1169         break;
    1170 
    1171         default:
    1172         break;
     1118
     1119        default:
     1120            break;
    11731121    }
    11741122
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationDataItem.h

    r65285 r65287  
    2424
    2525/* GUI includes: */
    26 #include "UIThreadPool.h"
    2726#include "UIExtraDataDefs.h"
    28 #include "UIInformationDataItem.h"
    2927
    3028/* COM includes: */
    3129#include "COMEnums.h"
    32 #include "CGuest.h"
    3330#include "CMachine.h"
    3431#include "CConsole.h"
    35 #include "CDisplay.h"
    36 #include "CNetworkAdapter.h"
    37 #include "CMachineDebugger.h"
    38 #include "CMediumAttachment.h"
    39 #include "CSystemProperties.h"
    40 #include "CStorageController.h"
    4132
    4233/* Forward declarations: */
    43 class CNetworkAdapter;
    44 class QTextLayout;
    4534class UIInformationModel;
    4635
     
    5443public:
    5544
    56     /** Constructs information data-item of type @a type.
    57       * @param  machine  Brings the machine reference.
    58       * @param  console  Brings the machine console reference.
    59       * @param  pModel   Brings the information model this item belings to. */
    60     UIInformationDataItem(InformationElementType type, const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    61 
    62     /** Destructs information data-item. */
    63     ~UIInformationDataItem();
     45    /** Constructs information data-item of type @a enmType.
     46      * @param  machine  Brings the machine reference.
     47      * @param  console  Brings the machine console reference.
     48      * @param  pModel   Brings the information model this item belings to. */
     49    UIInformationDataItem(InformationElementType enmType, const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    6450
    6551    /** Returns type of information data-item. */
    66     InformationElementType elementType() const { return m_type; }
    67 
    68     /** Returns data for item specified by @a index for the @a role. */
    69     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     52    InformationElementType elementType() const { return m_enmType; }
     53
     54    /** Returns data for item specified by @a index for the @a iRole. */
     55    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    7056
    7157protected:
    7258
    7359    /** Holds the type of information data-item. */
    74     InformationElementType m_type;
     60    InformationElementType m_enmType;
    7561
    7662    /** Holds the pixmap of information data-item. */
     
    10490    UIInformationDataGeneral(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    10591
    106     /** Returns data for item specified by @a index for the @a role. */
    107     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     92    /** Returns data for item specified by @a index for the @a iRole. */
     93    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    10894};
    10995
     
    122108    UIInformationDataSystem(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    123109
    124     /** Returns data for item specified by @a index for the @a role. */
    125     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     110    /** Returns data for item specified by @a index for the @a iRole. */
     111    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    126112};
    127113
     
    140126    UIInformationDataDisplay(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    141127
    142     /** Returns data for item specified by @a index for the @a role. */
    143     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     128    /** Returns data for item specified by @a index for the @a iRole. */
     129    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    144130};
    145131
     
    158144    UIInformationDataStorage(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    159145
    160     /** Returns data for item specified by @a index for the @a role. */
    161     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     146    /** Returns data for item specified by @a index for the @a iRole. */
     147    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    162148};
    163149
     
    176162    UIInformationDataAudio(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    177163
    178     /** Returns data for item specified by @a index for the @a role. */
    179     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     164    /** Returns data for item specified by @a index for the @a iRole. */
     165    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    180166};
    181167
     
    194180    UIInformationDataNetwork(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    195181
    196     /** Returns data for item specified by @a index for the @a role. */
    197     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     182    /** Returns data for item specified by @a index for the @a iRole. */
     183    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    198184};
    199185
     
    212198    UIInformationDataSerialPorts(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    213199
    214     /** Returns data for item specified by @a index for the @a role. */
    215     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     200    /** Returns data for item specified by @a index for the @a iRole. */
     201    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    216202};
    217203
     
    231217    UIInformationDataParallelPorts(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    232218
    233     /** Returns data for item specified by @a index for the @a role. */
    234     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     219    /** Returns data for item specified by @a index for the @a iRole. */
     220    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    235221};
    236222#endif /* VBOX_WITH_PARALLEL_PORTS */
     
    250236    UIInformationDataUSB(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    251237
    252     /** Returns data for item specified by @a index for the @a role. */
    253     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     238    /** Returns data for item specified by @a index for the @a iRole. */
     239    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    254240};
    255241
     
    268254    UIInformationDataSharedFolders(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    269255
    270     /** Returns data for item specified by @a index for the @a role. */
    271     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     256    /** Returns data for item specified by @a index for the @a iRole. */
     257    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    272258
    273259protected slots:
     
    291277    UIInformationDataRuntimeAttributes(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    292278
    293     /** Returns data for item specified by @a index for the @a role. */
    294     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     279    /** Returns data for item specified by @a index for the @a iRole. */
     280    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    295281};
    296282
     
    309295    UIInformationDataNetworkStatistics(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    310296
    311     /** Returns data for item specified by @a index for the @a role. */
    312     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     297    /** Returns data for item specified by @a index for the @a iRole. */
     298    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    313299
    314300private slots:
     
    323309
    324310    /** VM statistics counter data map. */
    325     typedef QMap <QString, QString> DataMapType;
     311    typedef QMap<QString, QString> DataMapType;
    326312    /** VM statistics counter links map. */
    327     typedef QMap <QString, QStringList> LinksMapType;
     313    typedef QMap<QString, QStringList> LinksMapType;
    328314    /** VM statistics counter struct. */
    329315    struct CounterElementType { QString type; DataMapType list; };
    330316
    331317    /** Holds the VM statistics counter names. */
    332     DataMapType        m_names;
     318    DataMapType   m_names;
    333319    /** Holds the VM statistics counter values. */
    334     DataMapType        m_values;
     320    DataMapType   m_values;
    335321    /** Holds the VM statistics counter units. */
    336     DataMapType        m_units;
     322    DataMapType   m_units;
    337323    /** Holds the VM statistics counter links. */
    338     LinksMapType       m_links;
     324    LinksMapType  m_links;
    339325    /** Holds the VM statistics update timer instance. */
    340     QTimer            *m_pTimer;
     326    QTimer       *m_pTimer;
    341327};
    342328
     
    355341    UIInformationDataStorageStatistics(const CMachine &machine, const CConsole &console, UIInformationModel *pModel);
    356342
    357     /** Returns data for item specified by @a index for the @a role. */
    358     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     343    /** Returns data for item specified by @a index for the @a iRole. */
     344    virtual QVariant data(const QModelIndex &index, int iRole = Qt::DisplayRole) const;
    359345
    360346private slots:
     
    372358
    373359    /** VM statistics counter data map. */
    374     typedef QMap <QString, QString> DataMapType;
     360    typedef QMap<QString, QString> DataMapType;
    375361    /** VM statistics counter links map. */
    376     typedef QMap <QString, QStringList> LinksMapType;
     362    typedef QMap<QString, QStringList> LinksMapType;
    377363    /** VM statistics counter struct. */
    378364    struct CounterElementType { QString type; DataMapType list; };
    379365
    380366    /** Holds the VM statistics counter names. */
    381     DataMapType        m_names;
     367    DataMapType   m_names;
    382368    /** Holds the VM statistics counter values. */
    383     DataMapType        m_values;
     369    DataMapType   m_values;
    384370    /** Holds the VM statistics counter units. */
    385     DataMapType        m_units;
     371    DataMapType   m_units;
    386372    /** Holds the VM statistics counter links. */
    387     LinksMapType       m_links;
     373    LinksMapType  m_links;
    388374    /** Holds the VM statistics update timer instance. */
    389     QTimer            *m_pTimer;
     375    QTimer       *m_pTimer;
    390376};
    391377
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