VirtualBox

Ignore:
Timestamp:
Dec 1, 2009 6:36:30 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
55525
Message:

FE/Qt4: Divide few settings-related classes declared in VBoxSettingsUtils.h into separate files.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
7 edited
3 copied
1 moved

Legend:

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

    r25114 r25136  
    307307        include/VBoxVMLogViewer.h \
    308308        include/VBoxMediaManagerDlg.h \
    309         include/VBoxSettingsUtils.h \
    310309        include/VBoxVMSettingsGeneral.h \
    311310        include/VBoxVMSettingsSystem.h \
     
    335334        include/VBoxExportApplianceWgt.h \
    336335        include/VBoxExportApplianceWzd.h \
    337         include/VBoxSpecialControls.h
     336        include/VBoxSpecialControls.h \
     337        include/VBoxBootTable.h \
     338        include/VBoxWarningPane.h
    338339
    339340# Sources containing local definitions of classes that use the Q_OBJECT macro.
     
    435436        src/VBoxExportApplianceWgt.cpp \
    436437        src/VBoxExportApplianceWzd.cpp \
    437         src/VBoxSpecialControls.cpp
     438        src/VBoxSpecialControls.cpp \
     439        src/VBoxBootTable.cpp \
     440        src/VBoxWarningPane.cpp
    438441
    439442ifeq ($(filter-out freebsd linux netbsd openbsd solaris,$(KBUILD_TARGET)),) # X11
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxBootTable.h

    r25125 r25136  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * VBoxSettingsUtils class declaration
     4 * VBoxBootTable class declaration
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
    23 #ifndef __VBoxSettingsUtils_h__
    24 #define __VBoxSettingsUtils_h__
     23#ifndef __VBoxBootTable_h__
     24#define __VBoxBootTable_h__
    2525
    26 #include <VBoxGlobal.h>
    27 
    28 /* Qt includes */
    29 #ifdef Q_WS_WIN
    30 #include <QDialog>
    31 #include <QLineEdit>
    32 #include <QPushButton>
    33 #endif
    34 #include <QHBoxLayout>
    35 #include <QLabel>
     26/* Global includes */
    3627#include <QTreeWidget>
    37 #include <QHeaderView>
    38 #include <QKeyEvent>
    39 #include <QTableView>
    40 
    41 enum
    42 {
    43     /* mTwUSBFilters column numbers */
    44     twUSBFilters_Name = 0,
    45 };
    4628
    4729/**
     
    5234 *  Emits itemToggled() signal when the item changed.
    5335 */
    54 class BootItemsTable : public QTreeWidget
     36class VBoxBootTable : public QTreeWidget
    5537{
    5638    Q_OBJECT;
     
    5840public:
    5941
    60     BootItemsTable (QWidget *aParent) : QTreeWidget (aParent)
    61     {
    62         header()->hide();
    63         connect (this, SIGNAL (itemChanged (QTreeWidgetItem *, int)),
    64                  this, SLOT (onItemChanged()));
    65     }
    66 
    67    ~BootItemsTable() {}
     42    VBoxBootTable(QWidget *pParent);
    6843
    6944signals:
     
    7348    void itemToggled();
    7449
     50protected:
     51
     52    void keyPressEvent(QKeyEvent *pEvent);
     53
    7554private slots:
    7655
    77     void onItemChanged()
    78     {
    79         emit itemToggled();
    80     }
    81 
    82     void keyPressEvent (QKeyEvent *aEvent)
    83     {
    84         if (aEvent->QInputEvent::modifiers () == Qt::ControlModifier)
    85         {
    86             switch (aEvent->key())
    87             {
    88                 case Qt::Key_Up:
    89                     emit moveItemUp();
    90                     return;
    91                 case Qt::Key_Down:
    92                     emit moveItemDown();
    93                     return;
    94                 default:
    95                     break;
    96             }
    97         }
    98         QTreeWidget::keyPressEvent (aEvent);
    99     }
     56    void onItemChanged();
    10057};
    10158
    102 class USBListItem : public QTreeWidgetItem
    103 {
    104 public:
     59#endif // __VBoxBootTable_h__
    10560
    106     enum { USBListItemType = 1002 };
    107 
    108     USBListItem (QTreeWidget *aParent)
    109         : QTreeWidgetItem (aParent, QStringList (QString::null), USBListItemType)
    110         , mId (-1) {}
    111 
    112     USBListItem (QTreeWidget *aParent, QTreeWidgetItem *aPreceding)
    113         : QTreeWidgetItem (aParent, aPreceding, USBListItemType)
    114         , mId (-1) {}
    115 
    116     int mId;
    117 };
    118 
    119 /**
    120  *  Table-View class reimplementation to extend standard QTableView.
    121  */
    122 class QITableView : public QTableView
    123 {
    124     Q_OBJECT;
    125 
    126 public:
    127 
    128     QITableView (QWidget *aParent) : QTableView (aParent) {}
    129 
    130 signals:
    131 
    132     void currentChanged (const QModelIndex &aCurrent);
    133 
    134 protected:
    135 
    136     void currentChanged (const QModelIndex &aCurrent,
    137                          const QModelIndex &aPrevious)
    138     {
    139         QTableView::currentChanged (aCurrent, aPrevious);
    140         emit currentChanged (aCurrent);
    141     }
    142 
    143     void focusInEvent (QFocusEvent *aEvent)
    144     {
    145         /* Restore edit-mode on focus in. */
    146         QTableView::focusInEvent (aEvent);
    147         if (model()->flags (currentIndex()) & Qt::ItemIsEditable)
    148             edit (currentIndex());
    149     }
    150 };
    151 
    152 class VBoxWarnIconLabel: public QWidget
    153 {
    154     Q_OBJECT;
    155 
    156 public:
    157 
    158     VBoxWarnIconLabel (QWidget *aParent = NULL)
    159         : QWidget (aParent)
    160     {
    161         QHBoxLayout *layout = new QHBoxLayout (this);
    162         VBoxGlobal::setLayoutMargin (layout, 0);
    163         layout->addWidget (&mIcon);
    164         layout->addWidget (&mLabel);
    165         setVisible (false);
    166     }
    167 
    168     void setWarningPixmap (const QPixmap& aPixmap) { mIcon.setPixmap (aPixmap); }
    169     void setWarningText (const QString& aText) { mLabel.setText (aText); }
    170 
    171 private:
    172 
    173     QLabel mIcon;
    174     QLabel mLabel;
    175 };
    176 
    177 #endif // __VBoxSettingsUtils_h__
    178 
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxSettingsDialog.h

    r21804 r25136  
    3535
    3636/* VBox forwards*/
    37 class VBoxWarnIconLabel;
     37class VBoxWarningPane;
    3838class VBoxSettingsSelector;
    3939class VBoxSettingsPage;
     
    106106    QPixmap mErrorIcon;
    107107    QPixmap mWarnIcon;
    108     VBoxWarnIconLabel *mIconLabel;
     108    VBoxWarningPane *mIconLabel;
    109109
    110110    /* WhatsThis Stuff */
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxWarningPane.h

    r25125 r25136  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * VBoxSettingsUtils class declaration
     4 * VBoxWarningPane class declaration
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
    23 #ifndef __VBoxSettingsUtils_h__
    24 #define __VBoxSettingsUtils_h__
     23#ifndef __VBoxWarningPane_h__
     24#define __VBoxWarningPane_h__
    2525
    26 #include <VBoxGlobal.h>
     26/* Global includes */
     27#include <QWidget>
     28#include <QLabel>
    2729
    28 /* Qt includes */
    29 #ifdef Q_WS_WIN
    30 #include <QDialog>
    31 #include <QLineEdit>
    32 #include <QPushButton>
    33 #endif
    34 #include <QHBoxLayout>
    35 #include <QLabel>
    36 #include <QTreeWidget>
    37 #include <QHeaderView>
    38 #include <QKeyEvent>
    39 #include <QTableView>
    40 
    41 enum
    42 {
    43     /* mTwUSBFilters column numbers */
    44     twUSBFilters_Name = 0,
    45 };
    46 
    47 /**
    48  *  QTreeWidget class reimplementation to use as boot items table.
    49  *  It has one unsorted column without header.
    50  *  Keymapping handlers for ctrl-up & ctrl-down are translated into
    51  *  boot-items up/down moving signals.
    52  *  Emits itemToggled() signal when the item changed.
    53  */
    54 class BootItemsTable : public QTreeWidget
     30class VBoxWarningPane: public QWidget
    5531{
    5632    Q_OBJECT;
     
    5834public:
    5935
    60     BootItemsTable (QWidget *aParent) : QTreeWidget (aParent)
    61     {
    62         header()->hide();
    63         connect (this, SIGNAL (itemChanged (QTreeWidgetItem *, int)),
    64                  this, SLOT (onItemChanged()));
    65     }
     36    VBoxWarningPane(QWidget *pParent = 0);
    6637
    67    ~BootItemsTable() {}
    68 
    69 signals:
    70 
    71     void moveItemUp();
    72     void moveItemDown();
    73     void itemToggled();
    74 
    75 private slots:
    76 
    77     void onItemChanged()
    78     {
    79         emit itemToggled();
    80     }
    81 
    82     void keyPressEvent (QKeyEvent *aEvent)
    83     {
    84         if (aEvent->QInputEvent::modifiers () == Qt::ControlModifier)
    85         {
    86             switch (aEvent->key())
    87             {
    88                 case Qt::Key_Up:
    89                     emit moveItemUp();
    90                     return;
    91                 case Qt::Key_Down:
    92                     emit moveItemDown();
    93                     return;
    94                 default:
    95                     break;
    96             }
    97         }
    98         QTreeWidget::keyPressEvent (aEvent);
    99     }
    100 };
    101 
    102 class USBListItem : public QTreeWidgetItem
    103 {
    104 public:
    105 
    106     enum { USBListItemType = 1002 };
    107 
    108     USBListItem (QTreeWidget *aParent)
    109         : QTreeWidgetItem (aParent, QStringList (QString::null), USBListItemType)
    110         , mId (-1) {}
    111 
    112     USBListItem (QTreeWidget *aParent, QTreeWidgetItem *aPreceding)
    113         : QTreeWidgetItem (aParent, aPreceding, USBListItemType)
    114         , mId (-1) {}
    115 
    116     int mId;
    117 };
    118 
    119 /**
    120  *  Table-View class reimplementation to extend standard QTableView.
    121  */
    122 class QITableView : public QTableView
    123 {
    124     Q_OBJECT;
    125 
    126 public:
    127 
    128     QITableView (QWidget *aParent) : QTableView (aParent) {}
    129 
    130 signals:
    131 
    132     void currentChanged (const QModelIndex &aCurrent);
    133 
    134 protected:
    135 
    136     void currentChanged (const QModelIndex &aCurrent,
    137                          const QModelIndex &aPrevious)
    138     {
    139         QTableView::currentChanged (aCurrent, aPrevious);
    140         emit currentChanged (aCurrent);
    141     }
    142 
    143     void focusInEvent (QFocusEvent *aEvent)
    144     {
    145         /* Restore edit-mode on focus in. */
    146         QTableView::focusInEvent (aEvent);
    147         if (model()->flags (currentIndex()) & Qt::ItemIsEditable)
    148             edit (currentIndex());
    149     }
    150 };
    151 
    152 class VBoxWarnIconLabel: public QWidget
    153 {
    154     Q_OBJECT;
    155 
    156 public:
    157 
    158     VBoxWarnIconLabel (QWidget *aParent = NULL)
    159         : QWidget (aParent)
    160     {
    161         QHBoxLayout *layout = new QHBoxLayout (this);
    162         VBoxGlobal::setLayoutMargin (layout, 0);
    163         layout->addWidget (&mIcon);
    164         layout->addWidget (&mLabel);
    165         setVisible (false);
    166     }
    167 
    168     void setWarningPixmap (const QPixmap& aPixmap) { mIcon.setPixmap (aPixmap); }
    169     void setWarningText (const QString& aText) { mLabel.setText (aText); }
     38    void setWarningPixmap(const QPixmap &imgPixmap);
     39    void setWarningText(const QString &strText);
    17040
    17141private:
    17242
    173     QLabel mIcon;
    174     QLabel mLabel;
     43    QLabel m_icon;
     44    QLabel m_label;
    17545};
    17646
    177 #endif // __VBoxSettingsUtils_h__
     47#endif // __VBoxWarningPane_h__
    17848
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxBootTable.cpp

    r25125 r25136  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * VBoxSettingsUtils class declaration
     4 * VBoxBootTable class implementation
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
    23 #ifndef __VBoxSettingsUtils_h__
    24 #define __VBoxSettingsUtils_h__
    25 
    26 #include <VBoxGlobal.h>
    27 
    28 /* Qt includes */
    29 #ifdef Q_WS_WIN
    30 #include <QDialog>
    31 #include <QLineEdit>
    32 #include <QPushButton>
    33 #endif
    34 #include <QHBoxLayout>
    35 #include <QLabel>
    36 #include <QTreeWidget>
     23/* Global include */
    3724#include <QHeaderView>
    3825#include <QKeyEvent>
    39 #include <QTableView>
    4026
    41 enum
     27/* Local includes */
     28#include "VBoxBootTable.h"
     29#include "VBoxGlobal.h"
     30
     31VBoxBootTable::VBoxBootTable(QWidget *pParent)
     32    : QTreeWidget(pParent)
    4233{
    43     /* mTwUSBFilters column numbers */
    44     twUSBFilters_Name = 0,
    45 };
     34    header()->hide();
     35    connect(this, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(onItemChanged()));
     36}
    4637
    47 /**
    48  *  QTreeWidget class reimplementation to use as boot items table.
    49  *  It has one unsorted column without header.
    50  *  Keymapping handlers for ctrl-up & ctrl-down are translated into
    51  *  boot-items up/down moving signals.
    52  *  Emits itemToggled() signal when the item changed.
    53  */
    54 class BootItemsTable : public QTreeWidget
     38void VBoxBootTable::onItemChanged()
    5539{
    56     Q_OBJECT;
     40    emit itemToggled();
     41}
    5742
    58 public:
     43void VBoxBootTable::keyPressEvent(QKeyEvent *pEvent)
     44{
     45    if (pEvent->QInputEvent::modifiers() == Qt::ControlModifier)
     46    {
     47        switch (pEvent->key())
     48        {
     49            case Qt::Key_Up:
     50                emit moveItemUp();
     51                return;
     52            case Qt::Key_Down:
     53                emit moveItemDown();
     54                return;
     55            default:
     56                break;
     57        }
     58    }
     59    QTreeWidget::keyPressEvent(pEvent);
     60}
    5961
    60     BootItemsTable (QWidget *aParent) : QTreeWidget (aParent)
    61     {
    62         header()->hide();
    63         connect (this, SIGNAL (itemChanged (QTreeWidgetItem *, int)),
    64                  this, SLOT (onItemChanged()));
    65     }
    66 
    67    ~BootItemsTable() {}
    68 
    69 signals:
    70 
    71     void moveItemUp();
    72     void moveItemDown();
    73     void itemToggled();
    74 
    75 private slots:
    76 
    77     void onItemChanged()
    78     {
    79         emit itemToggled();
    80     }
    81 
    82     void keyPressEvent (QKeyEvent *aEvent)
    83     {
    84         if (aEvent->QInputEvent::modifiers () == Qt::ControlModifier)
    85         {
    86             switch (aEvent->key())
    87             {
    88                 case Qt::Key_Up:
    89                     emit moveItemUp();
    90                     return;
    91                 case Qt::Key_Down:
    92                     emit moveItemDown();
    93                     return;
    94                 default:
    95                     break;
    96             }
    97         }
    98         QTreeWidget::keyPressEvent (aEvent);
    99     }
    100 };
    101 
    102 class USBListItem : public QTreeWidgetItem
    103 {
    104 public:
    105 
    106     enum { USBListItemType = 1002 };
    107 
    108     USBListItem (QTreeWidget *aParent)
    109         : QTreeWidgetItem (aParent, QStringList (QString::null), USBListItemType)
    110         , mId (-1) {}
    111 
    112     USBListItem (QTreeWidget *aParent, QTreeWidgetItem *aPreceding)
    113         : QTreeWidgetItem (aParent, aPreceding, USBListItemType)
    114         , mId (-1) {}
    115 
    116     int mId;
    117 };
    118 
    119 /**
    120  *  Table-View class reimplementation to extend standard QTableView.
    121  */
    122 class QITableView : public QTableView
    123 {
    124     Q_OBJECT;
    125 
    126 public:
    127 
    128     QITableView (QWidget *aParent) : QTableView (aParent) {}
    129 
    130 signals:
    131 
    132     void currentChanged (const QModelIndex &aCurrent);
    133 
    134 protected:
    135 
    136     void currentChanged (const QModelIndex &aCurrent,
    137                          const QModelIndex &aPrevious)
    138     {
    139         QTableView::currentChanged (aCurrent, aPrevious);
    140         emit currentChanged (aCurrent);
    141     }
    142 
    143     void focusInEvent (QFocusEvent *aEvent)
    144     {
    145         /* Restore edit-mode on focus in. */
    146         QTableView::focusInEvent (aEvent);
    147         if (model()->flags (currentIndex()) & Qt::ItemIsEditable)
    148             edit (currentIndex());
    149     }
    150 };
    151 
    152 class VBoxWarnIconLabel: public QWidget
    153 {
    154     Q_OBJECT;
    155 
    156 public:
    157 
    158     VBoxWarnIconLabel (QWidget *aParent = NULL)
    159         : QWidget (aParent)
    160     {
    161         QHBoxLayout *layout = new QHBoxLayout (this);
    162         VBoxGlobal::setLayoutMargin (layout, 0);
    163         layout->addWidget (&mIcon);
    164         layout->addWidget (&mLabel);
    165         setVisible (false);
    166     }
    167 
    168     void setWarningPixmap (const QPixmap& aPixmap) { mIcon.setPixmap (aPixmap); }
    169     void setWarningText (const QString& aText) { mLabel.setText (aText); }
    170 
    171 private:
    172 
    173     QLabel mIcon;
    174     QLabel mLabel;
    175 };
    176 
    177 #endif // __VBoxSettingsUtils_h__
    178 
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsDialog.cpp

    r24784 r25136  
    2121 */
    2222#include "VBoxSettingsDialog.h"
    23 #include "VBoxSettingsUtils.h"
     23#include "VBoxWarningPane.h"
    2424#include "VBoxGlobal.h"
    2525#include "VBoxProblemReporter.h"
     
    4747    , mValid (true)
    4848    , mSilent (true)
    49     , mIconLabel (new VBoxWarnIconLabel (this))
     49    , mIconLabel (new VBoxWarningPane (this))
    5050    , mWhatsThisTimer (new QTimer (this))
    5151    , mWhatsThisCandidate (0)
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsSelector.cpp

    r24083 r25136  
    2121 */
    2222
     23/* Global includes */
     24#include <QHeaderView>
     25#include <QTabWidget>
     26
     27/* Local includes */
    2328#include "VBoxSettingsSelector.h"
    24 #include "VBoxSettingsUtils.h"
    2529#include "VBoxSettingsPage.h"
     30#include "VBoxGlobal.h"
     31#include "VBoxToolBar.h"
    2632#include "QITreeWidget.h"
    27 #include "VBoxToolBar.h"
    28 
    29 /* Qt includes */
    30 #include <QTabWidget>
    3133
    3234enum
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsSystem.cpp

    r24900 r25136  
    2121 */
    2222
     23/* Global includes */
     24#include <QHeaderView>
     25
     26/* Local includes */
     27#include "VBoxVMSettingsSystem.h"
     28#include "VBoxGlobal.h"
    2329#include "QIWidgetValidator.h"
    24 #include "VBoxVMSettingsSystem.h"
    25 
    2630#include <iprt/cdefs.h>
    2731
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsUSB.cpp

    r24600 r25136  
    2323#include "VBoxVMSettingsUSB.h"
    2424#include "VBoxVMSettingsUSBFilterDetails.h"
    25 #include "VBoxSettingsUtils.h"
    2625#include "QIWidgetValidator.h"
    2726#include "VBoxToolBar.h"
     
    313312    while (*iterator)
    314313    {
    315         QString filterName = (*iterator)->text (twUSBFilters_Name);
     314        QString filterName = (*iterator)->text (0);
    316315        int pos = regExp.indexIn (filterName);
    317316        if (pos != -1)
     
    462461    {
    463462        filter.SetName (fd.mLeName->text().isEmpty() ? QString::null : fd.mLeName->text());
    464         item->setText (twUSBFilters_Name, fd.mLeName->text());
     463        item->setText (0, fd.mLeName->text());
    465464        filter.SetVendorId (fd.mLeVendorID->text().isEmpty() ? QString::null : fd.mLeVendorID->text());
    466465        filter.SetProductId (fd.mLeProductID->text().isEmpty() ? QString::null : fd.mLeProductID->text());
     
    567566        new QTreeWidgetItem (mTwFilters);
    568567    item->setCheckState (0, aFilter.GetActive() ? Qt::Checked : Qt::Unchecked);
    569     item->setText (twUSBFilters_Name, aFilter.GetName());
     568    item->setText (0, aFilter.GetName());
    570569    item->setToolTip (0, vboxGlobal().toolTip (aFilter));
    571570
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxWarningPane.cpp

    r25125 r25136  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * VBoxSettingsUtils class declaration
     4 * VBoxWarningPane class implementation
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2008 Sun Microsystems, Inc.
     8 * Copyright (C) 2009 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
    23 #ifndef __VBoxSettingsUtils_h__
    24 #define __VBoxSettingsUtils_h__
     23/* Global includes */
     24#include <QHBoxLayout>
    2525
    26 #include <VBoxGlobal.h>
     26/* Local includes */
     27#include "VBoxWarningPane.h"
     28#include "VBoxGlobal.h"
    2729
    28 /* Qt includes */
    29 #ifdef Q_WS_WIN
    30 #include <QDialog>
    31 #include <QLineEdit>
    32 #include <QPushButton>
    33 #endif
    34 #include <QHBoxLayout>
    35 #include <QLabel>
    36 #include <QTreeWidget>
    37 #include <QHeaderView>
    38 #include <QKeyEvent>
    39 #include <QTableView>
     30VBoxWarningPane::VBoxWarningPane(QWidget *pParent)
     31    : QWidget(pParent)
     32{
     33    QHBoxLayout *pLayout = new QHBoxLayout(this);
     34    VBoxGlobal::setLayoutMargin(pLayout, 0);
     35    pLayout->addWidget(&m_icon);
     36    pLayout->addWidget(&m_label);
     37    setVisible(false);
     38}
    4039
    41 enum
     40void VBoxWarningPane::setWarningPixmap(const QPixmap &imgPixmap)
    4241{
    43     /* mTwUSBFilters column numbers */
    44     twUSBFilters_Name = 0,
    45 };
     42    m_icon.setPixmap (imgPixmap);
     43}
    4644
    47 /**
    48  *  QTreeWidget class reimplementation to use as boot items table.
    49  *  It has one unsorted column without header.
    50  *  Keymapping handlers for ctrl-up & ctrl-down are translated into
    51  *  boot-items up/down moving signals.
    52  *  Emits itemToggled() signal when the item changed.
    53  */
    54 class BootItemsTable : public QTreeWidget
     45void VBoxWarningPane::setWarningText(const QString &strText)
    5546{
    56     Q_OBJECT;
     47    m_label.setText (strText);
     48}
    5749
    58 public:
    59 
    60     BootItemsTable (QWidget *aParent) : QTreeWidget (aParent)
    61     {
    62         header()->hide();
    63         connect (this, SIGNAL (itemChanged (QTreeWidgetItem *, int)),
    64                  this, SLOT (onItemChanged()));
    65     }
    66 
    67    ~BootItemsTable() {}
    68 
    69 signals:
    70 
    71     void moveItemUp();
    72     void moveItemDown();
    73     void itemToggled();
    74 
    75 private slots:
    76 
    77     void onItemChanged()
    78     {
    79         emit itemToggled();
    80     }
    81 
    82     void keyPressEvent (QKeyEvent *aEvent)
    83     {
    84         if (aEvent->QInputEvent::modifiers () == Qt::ControlModifier)
    85         {
    86             switch (aEvent->key())
    87             {
    88                 case Qt::Key_Up:
    89                     emit moveItemUp();
    90                     return;
    91                 case Qt::Key_Down:
    92                     emit moveItemDown();
    93                     return;
    94                 default:
    95                     break;
    96             }
    97         }
    98         QTreeWidget::keyPressEvent (aEvent);
    99     }
    100 };
    101 
    102 class USBListItem : public QTreeWidgetItem
    103 {
    104 public:
    105 
    106     enum { USBListItemType = 1002 };
    107 
    108     USBListItem (QTreeWidget *aParent)
    109         : QTreeWidgetItem (aParent, QStringList (QString::null), USBListItemType)
    110         , mId (-1) {}
    111 
    112     USBListItem (QTreeWidget *aParent, QTreeWidgetItem *aPreceding)
    113         : QTreeWidgetItem (aParent, aPreceding, USBListItemType)
    114         , mId (-1) {}
    115 
    116     int mId;
    117 };
    118 
    119 /**
    120  *  Table-View class reimplementation to extend standard QTableView.
    121  */
    122 class QITableView : public QTableView
    123 {
    124     Q_OBJECT;
    125 
    126 public:
    127 
    128     QITableView (QWidget *aParent) : QTableView (aParent) {}
    129 
    130 signals:
    131 
    132     void currentChanged (const QModelIndex &aCurrent);
    133 
    134 protected:
    135 
    136     void currentChanged (const QModelIndex &aCurrent,
    137                          const QModelIndex &aPrevious)
    138     {
    139         QTableView::currentChanged (aCurrent, aPrevious);
    140         emit currentChanged (aCurrent);
    141     }
    142 
    143     void focusInEvent (QFocusEvent *aEvent)
    144     {
    145         /* Restore edit-mode on focus in. */
    146         QTableView::focusInEvent (aEvent);
    147         if (model()->flags (currentIndex()) & Qt::ItemIsEditable)
    148             edit (currentIndex());
    149     }
    150 };
    151 
    152 class VBoxWarnIconLabel: public QWidget
    153 {
    154     Q_OBJECT;
    155 
    156 public:
    157 
    158     VBoxWarnIconLabel (QWidget *aParent = NULL)
    159         : QWidget (aParent)
    160     {
    161         QHBoxLayout *layout = new QHBoxLayout (this);
    162         VBoxGlobal::setLayoutMargin (layout, 0);
    163         layout->addWidget (&mIcon);
    164         layout->addWidget (&mLabel);
    165         setVisible (false);
    166     }
    167 
    168     void setWarningPixmap (const QPixmap& aPixmap) { mIcon.setPixmap (aPixmap); }
    169     void setWarningText (const QString& aText) { mLabel.setText (aText); }
    170 
    171 private:
    172 
    173     QLabel mIcon;
    174     QLabel mLabel;
    175 };
    176 
    177 #endif // __VBoxSettingsUtils_h__
    178 
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsSystem.ui

    r24811 r25136  
    176176         </property>
    177177         <item>
    178           <widget class="BootItemsTable" name="mTwBootOrder">
     178          <widget class="VBoxBootTable" name="mTwBootOrder">
    179179           <property name="sizePolicy">
    180180            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
     
    579579 <customwidgets>
    580580  <customwidget>
    581    <class>BootItemsTable</class>
     581   <class>VBoxBootTable</class>
    582582   <extends>QTreeWidget</extends>
    583    <header>VBoxSettingsUtils.h</header>
     583   <header>VBoxBootTable.h</header>
    584584  </customwidget>
    585585  <customwidget>
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