VirtualBox

Ignore:
Timestamp:
Apr 18, 2018 2:16:02 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122134
Message:

FE/Qt: bugref:9049: Full cleanup for UIBootTable and move it to VBoxGlobal library.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r71898 r71899  
    556556        src/widgets/UIApplianceExportEditorWidget.h \
    557557        src/widgets/UIApplianceImportEditorWidget.h \
    558         src/widgets/UIBootTable.h \
    559558        src/widgets/UIFilePathSelector.h \
    560559        src/widgets/UIEmptyFilePathSelector.h \
     
    685684        src/selector/UIActionPoolSelector.h \
    686685        src/selector/UIVirtualBoxEventHandler.h \
     686        src/widgets/UIBootTable.h \
    687687        src/widgets/UIHostComboEditor.h \
    688688        src/widgets/UIPopupBox.h \
     
    773773        src/selector/UIActionPoolSelector.h \
    774774        src/selector/UIVirtualBoxEventHandler.h \
     775        src/widgets/UIBootTable.h \
    775776        src/widgets/UIHostComboEditor.h \
    776777        src/widgets/UIPopupBox.h \
     
    10391040        src/widgets/UIApplianceExportEditorWidget.cpp \
    10401041        src/widgets/UIApplianceImportEditorWidget.cpp \
    1041         src/widgets/UIBootTable.cpp \
    10421042        src/widgets/UIFilePathSelector.cpp \
    10431043        src/widgets/UIEmptyFilePathSelector.cpp \
     
    12081208        src/selector/UIVirtualBoxEventHandler.cpp \
    12091209        src/settings/UISettingsDefs.cpp \
     1210        src/widgets/UIBootTable.cpp \
    12101211        src/widgets/UIHostComboEditor.cpp \
    12111212        src/widgets/UIPopupBox.cpp \
     
    13221323        src/selector/UIVirtualBoxEventHandler.cpp \
    13231324        src/settings/UISettingsDefs.cpp \
     1325        src/widgets/UIBootTable.cpp \
    13241326        src/widgets/UIHostComboEditor.cpp \
    13251327        src/widgets/UIPopupBox.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootTable.cpp

    r71027 r71899  
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121
    22 /* Global include */
     22/* Qt includes: */
    2323# include <QScrollBar>
    2424
    25 /* Local includes */
     25/* GUI includes: */
    2626# include "UIBootTable.h"
    2727# include "UIConverter.h"
     
    3131
    3232
    33 UIBootTableItem::UIBootTableItem(KDeviceType type)
    34   : m_type(type)
     33/*********************************************************************************************************************************
     34*   Class UIBootTableItem implementation.                                                                                        *
     35*********************************************************************************************************************************/
     36
     37UIBootTableItem::UIBootTableItem(KDeviceType enmType)
     38    : m_enmType(enmType)
    3539{
    3640    setCheckState(Qt::Unchecked);
    37     switch(type)
     41    switch(enmType)
    3842    {
    3943        case KDeviceType_Floppy:   setIcon(UIIconPool::iconSet(":/fd_16px.png")); break;
     
    4852KDeviceType UIBootTableItem::type() const
    4953{
    50     return m_type;
     54    return m_enmType;
    5155}
    5256
    5357void UIBootTableItem::retranslateUi()
    5458{
    55     setText(gpConverter->toString(m_type));
     59    setText(gpConverter->toString(m_enmType));
    5660}
     61
     62
     63/*********************************************************************************************************************************
     64*   Class UIBootTable implementation.                                                                                            *
     65*********************************************************************************************************************************/
    5766
    5867UIBootTable::UIBootTable(QWidget *pParent /* = 0 */)
    5968    : QIWithRetranslateUI<QListWidget>(pParent)
    6069{
    61     setDragDropMode(QAbstractItemView::InternalMove);
    62     setSelectionMode(QAbstractItemView::SingleSelection);
    63     setDropIndicatorShown(true);
    64     setUniformItemSizes(true);
    65     connect(this, SIGNAL(currentRowChanged(int)),
    66             this, SIGNAL(sigRowChanged(int)));
     70    prepare();
    6771}
    6872
    6973void UIBootTable::adjustSizeToFitContent()
    7074{
    71     int h = 2 * frameWidth();
    72     int w = h;
    73     setFixedSize(sizeHintForColumn(0) + w,
    74                  sizeHintForRow(0) * count() + h);
     75    const int iH = 2 * frameWidth();
     76    const int iW = iH;
     77    setFixedSize(sizeHintForColumn(0) + iW,
     78                 sizeHintForRow(0) * count() + iH);
    7579}
    7680
     
    97101void UIBootTable::dropEvent(QDropEvent *pEvent)
    98102{
     103    /* Call to base-class: */
    99104    QListWidget::dropEvent(pEvent);
     105    /* Separately notify listeners: */
    100106    emit sigRowChanged(currentRow());
    101107}
    102108
    103 QModelIndex UIBootTable::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
     109QModelIndex UIBootTable::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers fModifiers)
    104110{
    105     if (modifiers.testFlag(Qt::ControlModifier))
     111    if (fModifiers.testFlag(Qt::ControlModifier))
    106112    {
    107113        switch (cursorAction)
     
    135141        }
    136142    }
    137     return QListWidget::moveCursor(cursorAction, modifiers);
     143    return QListWidget::moveCursor(cursorAction, fModifiers);
     144}
     145
     146void UIBootTable::prepare()
     147{
     148    setDragDropMode(QAbstractItemView::InternalMove);
     149    setSelectionMode(QAbstractItemView::SingleSelection);
     150    setDropIndicatorShown(true);
     151    setUniformItemSizes(true);
     152    connect(this, &UIBootTable::currentRowChanged,
     153            this, &UIBootTable::sigRowChanged);
    138154}
    139155
    140156QModelIndex UIBootTable::moveItemTo(const QModelIndex &index, int row)
    141157{
     158    /* Check validity: */
    142159    if (!index.isValid())
    143160        return QModelIndex();
    144161
     162    /* Check sanity: */
    145163    if (row < 0 || row > model()->rowCount())
    146164        return QModelIndex();
     
    154172    return QModelIndex(newIndex);
    155173}
    156 
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootTable.h

    r71027 r71899  
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIBootTable_h__
    19 #define __UIBootTable_h__
     18#ifndef ___UIBootTable_h___
     19#define ___UIBootTable_h___
    2020
    2121/* Qt includes: */
     
    2424/* GUI includes: */
    2525#include "QIWithRetranslateUI.h"
     26#include "UILibraryDefs.h"
    2627
    2728/* COM includes: */
    2829#include "COMEnums.h"
    2930
    30 class UIBootTableItem : public QListWidgetItem
     31
     32/** QListWidgetItem extension for our UIBootTable. */
     33class SHARED_LIBRARY_STUFF UIBootTableItem : public QListWidgetItem
    3134{
    3235public:
    3336
    34     UIBootTableItem(KDeviceType type);
     37    /** Constructs boot-table item of passed @a enmType. */
     38    UIBootTableItem(KDeviceType enmType);
    3539
     40    /** Returns the item type. */
    3641    KDeviceType type() const;
    3742
     43    /** Performs item translation. */
    3844    void retranslateUi();
    3945
    4046private:
    4147
    42     /* Private member vars */
    43     KDeviceType m_type;
     48    /** Holds the item type. */
     49    KDeviceType m_enmType;
    4450
    4551};
    4652
    47 class UIBootTable : public QIWithRetranslateUI<QListWidget>
     53
     54/** QListWidget subclass used as system settings boot-table. */
     55class SHARED_LIBRARY_STUFF UIBootTable : public QIWithRetranslateUI<QListWidget>
    4856{
    4957    Q_OBJECT;
    5058
     59signals:
     60
     61    /** Notifies listeners about current table row changed.
     62      * @note  Same as base-class currentRowChanged but in wider cases. */
     63    void sigRowChanged(int iRow);
     64
    5165public:
    5266
     67    /** Constructs boot-table passing @a pParent to the base-class. */
    5368    UIBootTable(QWidget *pParent = 0);
    5469
     70    /** Adjusts table size to fit contents. */
    5571    void adjustSizeToFitContent();
    5672
    5773public slots:
    5874
     75    /** Moves current item up. */
    5976    void sltMoveItemUp();
     77    /** Moves current item down. */
    6078    void sltMoveItemDown();
    61 
    62 signals:
    63 
    64     void sigRowChanged(int);
    6579
    6680protected:
    6781
    68     void retranslateUi();
    69     void dropEvent(QDropEvent *pEvent);
    70     QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
    71     QModelIndex moveItemTo(const QModelIndex &index, int row);
     82    /** Handles translation event. */
     83    virtual void retranslateUi() /* override */;
     84
     85    /** Handles drop @a pEvent. */
     86    virtual void dropEvent(QDropEvent *pEvent) /* override */;
     87
     88    /** Returns a QModelIndex object pointing to the next object in the view,
     89      * based on the given @a cursorAction and keyboard @a fModifiers. */
     90    virtual QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
     91                                   Qt::KeyboardModifiers fModifiers) /* override */;
     92
     93private:
     94
     95    /** Prepares all. */
     96    void prepare();
     97
     98    /** Moves item with passed @a index to specified @a iRow. */
     99    QModelIndex moveItemTo(const QModelIndex &index, int iRow);
    72100};
    73101
    74 #endif // __UIBootTable_h__
    75102
     103#endif /* !___UIBootTable_h___ */
Note: See TracChangeset for help on using the changeset viewer.

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