VirtualBox

Changeset 50968 in vbox


Ignore:
Timestamp:
Apr 3, 2014 3:53:37 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Medium Manager rework/cleanup: .ui file absorption.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro

    r48622 r50968  
    2626    src/VBoxTakeSnapshotDlg.ui \
    2727    src/UIVMLogViewer.ui \
    28     src/medium/UIMediumManager.ui \
    2928    src/settings/UISettingsDialog.ui \
    3029    src/settings/global/UIGlobalSettingsGeneral.ui \
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r50967 r50968  
    2121
    2222/* Qt includes: */
     23#include <QFrame>
    2324#include <QLabel>
    2425#include <QMenuBar>
     
    3233#include "UIWizardCloneVD.h"
    3334#include "UIMessageCenter.h"
     35#include "QITabWidget.h"
     36#include "QITreeWidget.h"
     37#include "QILabel.h"
     38#include "QIDialogButtonBox.h"
    3439#include "UIToolBar.h"
    3540#include "UIIconPool.h"
     
    650655    , m_fRefresh(fRefresh)
    651656    , m_fPreventChangeCurrentItem(false)
     657    , m_pTabWidget(0)
     658    , m_iTabCount(3)
    652659    , m_fInaccessibleHD(false)
    653660    , m_fInaccessibleCD(false)
     
    662669    , m_pActionRemove(0), m_pActionRelease(0)
    663670    , m_pActionRefresh(0)
     671    , m_pButtonBox(0)
    664672    , m_pProgressBar(0)
    665673{
     
    747755
    748756    /* Reset tab-widget icons: */
    749     if (mTabWidget)
    750     {
    751         mTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD);
    752         mTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD);
    753         mTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD);
     757    if (m_pTabWidget)
     758    {
     759        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD);
     760        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD);
     761        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD);
    754762    }
    755763
     
    820828    /* Update HD information-panes: */
    821829    if (fResult)
    822         updateInformationPanesHD();
     830        updateInformationFieldsHD();
    823831}
    824832
     
    916924{
    917925    /* Get all the tree-widgets: */
    918     QList<QTreeWidget*> trees;
    919     trees << treeWidget(UIMediumType_HardDisk);
    920     trees << treeWidget(UIMediumType_DVD);
    921     trees << treeWidget(UIMediumType_Floppy);
     926    const QList<QTreeWidget*> trees = m_trees.values();
    922927
    923928    /* Calculate deduction for every header: */
     
    959964
    960965    /* Initialize information-panes: */
    961     updateInformationPanes(UIMediumType_All);
     966    updateInformationFields(UIMediumType_All);
    962967
    963968    /* Start medium-enumeration (if necessary): */
     
    978983void UIMediumManager::prepareThis()
    979984{
     985    /* Initial size: */
     986    resize(620, 460);
     987
    980988    /* Dialog should delete itself on 'close': */
    981989    setAttribute(Qt::WA_DeleteOnClose);
     
    988996    setWindowIcon(UIIconPool::iconSetFull(QSize(32, 32), QSize(16, 16),
    989997                                          ":/diskimage_32px.png", ":/diskimage_16px.png"));
    990 
    991     /* Apply UI decorations: */
    992     Ui::UIMediumManager::setupUi(this);
    993998
    994999    /* Prepare connections: */
     
    11041109void UIMediumManager::prepareCentralWidget()
    11051110{
    1106     /* Prepare tool-bar: */
    1107     prepareToolBar();
    1108     /* Prepare tab-widget: */
    1109     prepareTabWidget();
    1110     /* Prepare button-box: */
    1111     prepareButtonBox();
     1111    /* Create central-widget: */
     1112    setCentralWidget(new QWidget);
     1113    AssertPtrReturnVoid(centralWidget());
     1114    {
     1115        /* Create main-layout: */
     1116        new QVBoxLayout(centralWidget());
     1117        AssertPtrReturnVoid(centralWidget()->layout());
     1118        {
     1119            /* Prepare tool-bar: */
     1120            prepareToolBar();
     1121            /* Prepare tab-widget: */
     1122            prepareTabWidget();
     1123            /* Prepare button-box: */
     1124            prepareButtonBox();
     1125        }
     1126    }
    11121127}
    11131128
     
    11541169void UIMediumManager::prepareTabWidget()
    11551170{
    1156     /* Tab-widget created in .ui file. */
    1157     {
    1158         /* Prepare tabs: */
    1159         for (int i = (int)UIMediumType_HardDisk; i <= (int)UIMediumType_Floppy; ++i)
    1160             prepareTab((UIMediumType)i);
     1171    /* Create tab-widget: */
     1172    m_pTabWidget = new QITabWidget;
     1173    AssertPtrReturnVoid(m_pTabWidget);
     1174    {
     1175        /* Create tabs: */
     1176        for (int i = 0; i < m_iTabCount; ++i)
     1177            prepareTab(mediumType(i));
    11611178        /* Configure tab-widget: */
    1162         mTabWidget->setFocusPolicy(Qt::TabFocus);
    1163         mTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD);
    1164         mTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD);
    1165         mTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD);
    1166         connect(mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged()));
     1179        m_pTabWidget->setFocusPolicy(Qt::TabFocus);
     1180        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_HardDisk), m_iconHD);
     1181        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_DVD), m_iconCD);
     1182        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD);
     1183        connect(m_pTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged()));
     1184        /* Add tab-widget into central layout: */
     1185        centralWidget()->layout()->addWidget(m_pTabWidget);
    11671186        /* Focus current tree-widget: */
    11681187        if (currentTreeWidget())
     
    11751194void UIMediumManager::prepareTab(UIMediumType type)
    11761195{
    1177     /* Tab created in .ui file. */
    1178     {
    1179         /* Tab layout created in .ui file. */
     1196    /* Create tab: */
     1197    m_pTabWidget->addTab(new QWidget, QString());
     1198    QWidget *pTab = tab(type);
     1199    AssertPtrReturnVoid(pTab);
     1200    {
     1201        /* Create tab layout: */
     1202        new QVBoxLayout(pTab);
     1203        AssertPtrReturnVoid(pTab->layout());
    11801204        {
    11811205            /* Prepare tree-widget: */
     
    11891213void UIMediumManager::prepareTreeWidget(UIMediumType type, int iColumns)
    11901214{
    1191     /* Tree-widget created in .ui file. */
     1215    /* Create tree-widget: */
     1216    m_trees.insert(tabIndex(type), new QITreeWidget);
     1217    QTreeWidget *pTreeWidget = treeWidget(type);
     1218    AssertPtrReturnVoid(pTreeWidget);
    11921219    {
    11931220        /* Configure tree-widget: */
    1194         QTreeWidget *pTreeWidget = treeWidget(type);
     1221        pTreeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     1222        pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
     1223        pTreeWidget->setAlternatingRowColors(true);
     1224        pTreeWidget->setAllColumnsShowFocus(true);
     1225        pTreeWidget->setAcceptDrops(true);
    11951226        pTreeWidget->setColumnCount(iColumns);
    11961227        pTreeWidget->sortItems(0, Qt::AscendingOrder);
     
    12131244        connect(pTreeWidget->header(), SIGNAL(sectionResized(int, int, int)),
    12141245                this, SLOT(sltPerformTablesAdjustment()), Qt::QueuedConnection);
     1246        /* Add tree-widget into tab layout: */
     1247        tab(type)->layout()->addWidget(pTreeWidget);
    12151248    }
    12161249}
     
    12181251void UIMediumManager::prepareInformationContainer(UIMediumType type, int iFields)
    12191252{
    1220     /* Information-panes created in .ui file. */
    1221     {
    1222         /* Configure information-panes: */
    1223         for (int i = 0; i < iFields; ++i)
    1224         {
    1225             QILabel *pField = infoField(type, i);
    1226             if (pField)
    1227                 pField->setFullSizeSelection(true);
    1228         }
     1253    /* Create information-container: */
     1254    int iIndex = tabIndex(type);
     1255    m_containers.insert(iIndex, new QFrame);
     1256    QFrame *pInformationContainer = infoContainer(type);
     1257    AssertPtrReturnVoid(pInformationContainer);
     1258    {
     1259        /* Configure information-container: */
     1260        pInformationContainer->setFrameShape(QFrame::Box);
     1261        pInformationContainer->setFrameShadow(QFrame::Sunken);
     1262        /* Create information-container layout: */
     1263        new QGridLayout(pInformationContainer);
     1264        QGridLayout *pInformationContainerLayout = qobject_cast<QGridLayout*>(pInformationContainer->layout());
     1265        AssertPtrReturnVoid(pInformationContainerLayout);
     1266        {
     1267            /* Configure information-container layout: */
     1268            pInformationContainerLayout->setVerticalSpacing(0);
     1269            pInformationContainerLayout->setContentsMargins(5, 5, 5, 5);
     1270            pInformationContainerLayout->setColumnStretch(1, 1);
     1271            /* Create information-container labels & fields: */
     1272            for (int i = 0; i < iFields; ++i)
     1273            {
     1274                /* Create information-label: */
     1275                m_labels[iIndex] << new QLabel;
     1276                QLabel *pLabel = infoLabel(type, i);
     1277                AssertPtrReturnVoid(pLabel);
     1278                /* Create information-field: */
     1279                m_fields[iIndex] << new QILabel;
     1280                QILabel *pField = infoField(type, i);
     1281                AssertPtrReturnVoid(pField);
     1282                {
     1283                    /* Configure information-field: */
     1284                    pField->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
     1285                    pField->setFullSizeSelection(true);
     1286                }
     1287                /* Add information-container labels & fields into container layout: */
     1288                pInformationContainerLayout->addWidget(pLabel, i, 0);
     1289                pInformationContainerLayout->addWidget(pField, i, 1);
     1290            }
     1291        }
     1292        /* Add information-container into tab layout: */
     1293        tab(type)->layout()->addWidget(pInformationContainer);
    12291294    }
    12301295}
     
    12321297void UIMediumManager::prepareButtonBox()
    12331298{
    1234     /* Button-box created in .ui file. */
     1299    /* Create button-box: */
     1300    m_pButtonBox = new QIDialogButtonBox;
     1301    AssertPtrReturnVoid(m_pButtonBox);
    12351302    {
    12361303        /* Configure button-box: */
    1237         mButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
    1238         connect(mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    1239         connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
     1304        m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Close);
     1305        m_pButtonBox->button(QDialogButtonBox::Close)->setDefault(true);
     1306        connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
     1307        connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(close()));
     1308        /* Add button-box into central layout: */
     1309        centralWidget()->layout()->addWidget(m_pButtonBox);
    12401310        /* Prepare progress-bar: */
    12411311        prepareProgressBar();
     
    12521322        m_pProgressBar->hide();
    12531323        /* Add progress-bar into button-box layout: */
    1254         mButtonBox->addExtraWidget(m_pProgressBar);
     1324        m_pButtonBox->addExtraWidget(m_pProgressBar);
    12551325    }
    12561326}
     
    13311401
    13321402    /* Update corresponding information-panes: */
    1333     updateInformationPanes(type);
     1403    updateInformationFields(type);
    13341404}
    13351405
     
    13821452{
    13831453    QString strPrefix = "hd";
    1384     if (mTabWidget)
     1454    if (m_pTabWidget)
    13851455    {
    13861456        switch (currentMediumType())
     
    14601530            *pfInaccessible = true;
    14611531
    1462             if (mTabWidget)
    1463                 mTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon());
     1532            if (m_pTabWidget)
     1533                m_pTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon());
    14641534
    14651535            break;
     
    14951565            }
    14961566
    1497             if (mTabWidget)
     1567            if (m_pTabWidget)
    14981568            {
    14991569                if (*pfInaccessible)
    1500                     mTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon());
     1570                    m_pTabWidget->setTabIcon(tabIndex(mediumType), vboxGlobal().warningIcon());
    15011571                else
    1502                     mTabWidget->setTabIcon(tabIndex(mediumType), *pIcon);
     1572                    m_pTabWidget->setTabIcon(tabIndex(mediumType), *pIcon);
    15031573            }
    15041574
     
    15081578}
    15091579
    1510 void UIMediumManager::updateInformationPanes(UIMediumType type /* = UIMediumType_Invalid */)
     1580void UIMediumManager::updateInformationFields(UIMediumType type /* = UIMediumType_Invalid */)
    15111581{
    15121582    /* Make sure type is valid: */
     
    15171587    switch (type)
    15181588    {
    1519         case UIMediumType_HardDisk: updateInformationPanesHD(); break;
    1520         case UIMediumType_DVD:      updateInformationPanesCD(); break;
    1521         case UIMediumType_Floppy:   updateInformationPanesFD(); break;
     1589        case UIMediumType_HardDisk: updateInformationFieldsHD(); break;
     1590        case UIMediumType_DVD:      updateInformationFieldsCD(); break;
     1591        case UIMediumType_Floppy:   updateInformationFieldsFD(); break;
    15221592        case UIMediumType_All:
    1523             updateInformationPanesHD();
    1524             updateInformationPanesCD();
    1525             updateInformationPanesFD();
     1593            updateInformationFieldsHD();
     1594            updateInformationFieldsCD();
     1595            updateInformationFieldsFD();
    15261596            break;
    15271597        default: break;
     
    15291599}
    15301600
    1531 void UIMediumManager::updateInformationPanesHD()
     1601void UIMediumManager::updateInformationFieldsHD()
    15321602{
    15331603    /* Get current hard-drive medium-item: */
     
    15381608    {
    15391609        /* Just clear information panes: */
    1540         for (int i = 0; i < 5; ++i)
     1610        for (int i = 0; i < m_fields[tabIndex(UIMediumType_HardDisk)].size(); ++i)
    15411611            infoField(UIMediumType_HardDisk, i)->clear();
    15421612    }
     
    15471617        QString strDetails = pCurrentItem->details();
    15481618        QString strUsage = pCurrentItem->usage().isNull() ?
    1549                            formatPaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not&nbsp;Attached</i>"), false) :
    1550                            formatPaneText(pCurrentItem->usage());
     1619                           formatFieldText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not&nbsp;Attached</i>"), false) :
     1620                           formatFieldText(pCurrentItem->usage());
    15511621        if (infoField(UIMediumType_HardDisk, 0))
    15521622            infoField(UIMediumType_HardDisk, 0)->setText(pCurrentItem->hardDiskType());
    15531623        if (infoField(UIMediumType_HardDisk, 1))
    1554             infoField(UIMediumType_HardDisk, 1)->setText(formatPaneText(pCurrentItem->location(), true, "end"));
     1624            infoField(UIMediumType_HardDisk, 1)->setText(formatFieldText(pCurrentItem->location(), true, "end"));
    15551625        if (infoField(UIMediumType_HardDisk, 2))
    15561626            infoField(UIMediumType_HardDisk, 2)->setText(pCurrentItem->hardDiskFormat());
     
    15661636}
    15671637
    1568 void UIMediumManager::updateInformationPanesCD()
     1638void UIMediumManager::updateInformationFieldsCD()
    15691639{
    15701640    /* Get current optical medium-item: */
     
    15751645    {
    15761646        /* Just clear information panes: */
    1577         for (int i = 0; i < 2; ++i)
     1647        for (int i = 0; i < m_fields[tabIndex(UIMediumType_DVD)].size(); ++i)
    15781648            infoField(UIMediumType_DVD, i)->clear();
    15791649    }
     
    15831653        /* Update required details: */
    15841654        QString strUsage = pCurrentItem->usage().isNull() ?
    1585                            formatPaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not&nbsp;Attached</i>"), false) :
    1586                            formatPaneText(pCurrentItem->usage());
     1655                           formatFieldText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not&nbsp;Attached</i>"), false) :
     1656                           formatFieldText(pCurrentItem->usage());
    15871657        if (infoField(UIMediumType_DVD, 0))
    1588             infoField(UIMediumType_DVD, 0)->setText(formatPaneText(pCurrentItem->location(), true, "end"));
     1658            infoField(UIMediumType_DVD, 0)->setText(formatFieldText(pCurrentItem->location(), true, "end"));
    15891659        if (infoField(UIMediumType_DVD, 1))
    15901660            infoField(UIMediumType_DVD, 1)->setText(strUsage);
     
    15961666}
    15971667
    1598 void UIMediumManager::updateInformationPanesFD()
     1668void UIMediumManager::updateInformationFieldsFD()
    15991669{
    16001670    /* Get current floppy medium-item: */
     
    16051675    {
    16061676        /* Just clear information panes: */
    1607         for (int i = 0; i < 2; ++i)
     1677        for (int i = 0; i < m_fields[tabIndex(UIMediumType_Floppy)].size(); ++i)
    16081678            infoField(UIMediumType_Floppy, i)->clear();
    16091679    }
     
    16131683        /* Update required details: */
    16141684        QString strUsage = pCurrentItem->usage().isNull() ?
    1615                            formatPaneText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not&nbsp;Attached</i>"), false) :
    1616                            formatPaneText(pCurrentItem->usage());
     1685                           formatFieldText(QApplication::translate("VBoxMediaManagerDlg", "<i>Not&nbsp;Attached</i>"), false) :
     1686                           formatFieldText(pCurrentItem->usage());
    16171687        if (infoField(UIMediumType_Floppy, 0))
    1618             infoField(UIMediumType_Floppy, 0)->setText(formatPaneText(pCurrentItem->location(), true, "end"));
     1688            infoField(UIMediumType_Floppy, 0)->setText(formatFieldText(pCurrentItem->location(), true, "end"));
    16191689        if (infoField(UIMediumType_Floppy, 1))
    16201690            infoField(UIMediumType_Floppy, 1)->setText(strUsage);
     
    17011771
    17021772    /* Translate tab-widget: */
    1703     if (mTabWidget)
    1704     {
    1705         mTabWidget->setTabText(tabIndex(UIMediumType_HardDisk), tr("&Hard drives"));
    1706         mTabWidget->setTabText(tabIndex(UIMediumType_DVD), tr("&Optical disks"));
    1707         mTabWidget->setTabText(tabIndex(UIMediumType_Floppy), tr("&Floppy disks"));
     1773    if (m_pTabWidget)
     1774    {
     1775        m_pTabWidget->setTabText(tabIndex(UIMediumType_HardDisk), tr("&Hard drives"));
     1776        m_pTabWidget->setTabText(tabIndex(UIMediumType_DVD), tr("&Optical disks"));
     1777        m_pTabWidget->setTabText(tabIndex(UIMediumType_Floppy), tr("&Floppy disks"));
    17081778    }
    17091779
     
    17661836        m_pProgressBar->adjustSize();
    17671837        int h = m_pProgressBar->height();
    1768         if (mButtonBox)
    1769             mButtonBox->setMinimumHeight(h + 12);
     1838        if (m_pButtonBox)
     1839            m_pButtonBox->setMinimumHeight(h + 12);
    17701840#endif /* Q_WS_MAC */
    17711841    }
     
    19832053}
    19842054
     2055QWidget* UIMediumManager::tab(UIMediumType type) const
     2056{
     2057    /* Determine tab index for passed medium type: */
     2058    int iIndex = tabIndex(type);
     2059
     2060    /* Return tab for known tab index: */
     2061    if (iIndex >= 0 && iIndex < m_iTabCount)
     2062        return iIndex < m_pTabWidget->count() ? m_pTabWidget->widget(iIndex) : 0;
     2063
     2064    /* Null by default: */
     2065    return 0;
     2066}
     2067
    19852068QTreeWidget* UIMediumManager::treeWidget(UIMediumType type) const
    19862069{
    1987     /* Return corresponding tree-widget for known medium types: */
    1988     switch (type)
    1989     {
    1990         case UIMediumType_HardDisk: return mTwHD;
    1991         case UIMediumType_DVD:      return mTwCD;
    1992         case UIMediumType_Floppy:   return mTwFD;
    1993         default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break;
    1994     }
     2070    /* Determine tab index for passed medium type: */
     2071    int iIndex = tabIndex(type);
     2072
     2073    /* Return tree-widget for known tab index: */
     2074    if (iIndex >= 0 && iIndex < m_iTabCount)
     2075        return m_trees.value(iIndex, 0);
     2076
    19952077    /* Null by default: */
    19962078    return 0;
     
    20072089QFrame* UIMediumManager::infoContainer(UIMediumType type) const
    20082090{
    2009     /* Return corresponding tree-widget for known medium types: */
    2010     switch (type)
    2011     {
    2012         case UIMediumType_HardDisk: return mHDContainer;
    2013         case UIMediumType_DVD:      return mCDContainer;
    2014         case UIMediumType_Floppy:   return mFDContainer;
    2015         default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break;
    2016     }
     2091    /* Determine tab index for passed medium type: */
     2092    int iIndex = tabIndex(type);
     2093
     2094    /* Return information-container for known tab index: */
     2095    if (iIndex >= 0 && iIndex < m_iTabCount)
     2096        return m_containers.value(iIndex, 0);
     2097
    20172098    /* Null by default: */
    20182099    return 0;
     
    20212102QLabel* UIMediumManager::infoLabel(UIMediumType type, int iLabelIndex) const
    20222103{
    2023     /* Return corresponding tree-widget for known medium types: */
    2024     switch (type)
    2025     {
    2026         case UIMediumType_HardDisk:
    2027         {
    2028             switch (iLabelIndex)
    2029             {
    2030                 case 0: return m_pTypeLabel;
    2031                 case 1: return m_pLocationLabel;
    2032                 case 2: return m_pFormatLabel;
    2033                 case 3: return m_pDetailsLabel;
    2034                 case 4: return m_pUsageLabel;
    2035                 default: AssertMsgFailed(("Label index out of bounds: %d\n", iLabelIndex)); break;
    2036             }
    2037             break;
    2038         }
    2039         case UIMediumType_DVD:
    2040         {
    2041             switch (iLabelIndex)
    2042             {
    2043                 case 0: return mLbCD1;
    2044                 case 1: return mLbCD2;
    2045                 default: AssertMsgFailed(("Label index out of bounds: %d\n", iLabelIndex)); break;
    2046             }
    2047             break;
    2048         }
    2049         case UIMediumType_Floppy:
    2050         {
    2051             switch (iLabelIndex)
    2052             {
    2053                 case 0: return mLbFD1;
    2054                 case 1: return mLbFD2;
    2055                 default: AssertMsgFailed(("Label index out of bounds: %d\n", iLabelIndex)); break;
    2056             }
    2057             break;
    2058         }
    2059         default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break;
    2060     }
     2104    /* Determine tab index for passed medium type: */
     2105    int iIndex = tabIndex(type);
     2106
     2107    /* Look for corresponding information-label list for known tab index: */
     2108    if (iIndex >= 0 && iIndex < m_iTabCount)
     2109    {
     2110        const QList<QLabel*> labels = m_labels.value(iIndex, QList<QLabel*>());
     2111
     2112        /* Return information-label for known index: */
     2113        return labels.value(iLabelIndex, 0);
     2114    }
     2115
    20612116    /* Null by default: */
    20622117    return 0;
     
    20652120QILabel* UIMediumManager::infoField(UIMediumType type, int iFieldIndex) const
    20662121{
    2067     /* Return corresponding tree-widget for known medium types: */
    2068     switch (type)
    2069     {
    2070         case UIMediumType_HardDisk:
    2071         {
    2072             switch (iFieldIndex)
    2073             {
    2074                 case 0: return m_pTypePane;
    2075                 case 1: return m_pLocationPane;
    2076                 case 2: return m_pFormatPane;
    2077                 case 3: return m_pDetailsPane;
    2078                 case 4: return m_pUsagePane;
    2079                 default: AssertMsgFailed(("Field index out of bounds: %d\n", iFieldIndex)); break;
    2080             }
    2081             break;
    2082         }
    2083         case UIMediumType_DVD:
    2084         {
    2085             switch (iFieldIndex)
    2086             {
    2087                 case 0: return mIpCD1;
    2088                 case 1: return mIpCD2;
    2089                 default: AssertMsgFailed(("Field index out of bounds: %d\n", iFieldIndex)); break;
    2090             }
    2091             break;
    2092         }
    2093         case UIMediumType_Floppy:
    2094         {
    2095             switch (iFieldIndex)
    2096             {
    2097                 case 0: return mIpFD1;
    2098                 case 1: return mIpFD2;
    2099                 default: AssertMsgFailed(("Field index out of bounds: %d\n", iFieldIndex)); break;
    2100             }
    2101             break;
    2102         }
    2103         default: AssertMsgFailed(("Unknown medium type: %d\n", type)); break;
    2104     }
     2122    /* Determine tab index for passed medium type: */
     2123    int iIndex = tabIndex(type);
     2124
     2125    /* Look for corresponding information-field list for known tab index: */
     2126    if (iIndex >= 0 && iIndex < m_iTabCount)
     2127    {
     2128        const QList<QILabel*> fields = m_fields.value(iIndex, QList<QILabel*>());
     2129
     2130        /* Return information-field for known index: */
     2131        return fields.value(iFieldIndex, 0);
     2132    }
     2133
    21052134    /* Null by default: */
    21062135    return 0;
     
    21092138UIMediumType UIMediumManager::mediumType(QTreeWidget *pTreeWidget) const
    21102139{
    2111     /* Hard-drive tree-widget: */
    2112     if (pTreeWidget == treeWidget(UIMediumType_HardDisk)) return UIMediumType_HardDisk;
    2113     /* Optical-image tree-widget: */
    2114     if (pTreeWidget == treeWidget(UIMediumType_DVD)) return UIMediumType_DVD;
    2115     /* Floppy-image tree-widget: */
    2116     if (pTreeWidget == treeWidget(UIMediumType_Floppy)) return UIMediumType_Floppy;
     2140    /* Determine tab index of passed tree-widget: */
     2141    int iIndex = m_trees.key(pTreeWidget, -1);
     2142
     2143    /* Return medium type for known tab index: */
     2144    if (iIndex >= 0 && iIndex < m_iTabCount)
     2145        return mediumType(iIndex);
     2146
    21172147    /* Invalid by default: */
    21182148    AssertFailedReturn(UIMediumType_Invalid);
     
    21222152{
    21232153    /* Invalid if tab-widget doesn't exists: */
    2124     if (!mTabWidget)
     2154    if (!m_pTabWidget)
    21252155        return UIMediumType_Invalid;
    21262156
    21272157    /* Return current medium type: */
    2128     return mediumType(mTabWidget->currentIndex());
     2158    return mediumType(m_pTabWidget->currentIndex());
    21292159}
    21302160
     
    22842314
    22852315/* static */
    2286 QString UIMediumManager::formatPaneText(const QString &strText, bool fCompact /* = true */,
    2287                                         const QString &strElipsis /* = "middle" */)
     2316QString UIMediumManager::formatFieldText(const QString &strText, bool fCompact /* = true */,
     2317                                         const QString &strElipsis /* = "middle" */)
    22882318{
    22892319    QString compactString = QString("<compact elipsis=\"%1\">").arg(strElipsis);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r50967 r50968  
    1919
    2020/* GUI includes: */
    21 #include "UIMediumManager.gen.h"
     21
    2222#include "QIWithRetranslateUI.h"
    2323#include "QIMainDialog.h"
     
    2929class UIToolBar;
    3030class UIEnumerationProgressBar;
     31class QTabWidget;
     32class QTreeWidget;
     33class QTreeWidgetItem;
     34class QFrame;
     35class QLabel;
     36class QILabel;
     37class QIDialogButtonBox;
    3138
    3239/** Functor interface allowing to check if passed UIMediumItem is suitable. */
     
    3946
    4047/** Medium Manager dialog. */
    41 class UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>, public Ui::UIMediumManager
     48class UIMediumManager : public QIWithRetranslateUI2<QIMainDialog>
    4249{
    4350    Q_OBJECT;
     
    146153    /** Update tab icons according last @a action happened with @a pItem. */
    147154    void updateTabIcons(UIMediumItem *pItem, Action action);
    148     /** Update information pane of passed medium @a type. */
    149     void updateInformationPanes(UIMediumType type = UIMediumType_Invalid);
    150     /** Update information pane for hard-drive tab. */
    151     void updateInformationPanesHD();
    152     /** Update information pane for optical-disk tab. */
    153     void updateInformationPanesCD();
    154     /** Update information pane for floppy-disk tab. */
    155     void updateInformationPanesFD();
     155    /** Update information fields of passed medium @a type. */
     156    void updateInformationFields(UIMediumType type = UIMediumType_Invalid);
     157    /** Update information fields for hard-drive tab. */
     158    void updateInformationFieldsHD();
     159    /** Update information fields for optical-disk tab. */
     160    void updateInformationFieldsCD();
     161    /** Update information fields for floppy-disk tab. */
     162    void updateInformationFieldsFD();
    156163
    157164#ifdef Q_WS_MAC
     
    174181    void deleteMediumItem(const QString &strMediumID);
    175182
     183    /** Returns tab for passed medium @a type. */
     184    QWidget* tab(UIMediumType type) const;
    176185    /** Returns tree-widget for passed medium @a type. */
    177186    QTreeWidget* treeWidget(UIMediumType type) const;
     
    214223    static UIMediumItem* toMediumItem(QTreeWidgetItem *pItem);
    215224
    216     /** Format information-pane content. */
    217     static QString formatPaneText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle");
     225    /** Format information-field content. */
     226    static QString formatFieldText(const QString &strText, bool fCompact = true, const QString &strElipsis = "middle");
    218227
    219228    /** Determines if passed @a medium attached to hidden machines only. */
     
    235244    /** @name Tab-widget variables.
    236245     * @{ */
     246    /** Tab-widget itself. */
     247    QTabWidget *m_pTabWidget;
     248    /** Tab-widget tab-count. */
     249    const int m_iTabCount;
     250    /** Tree-widgets. */
     251    QMap<int, QTreeWidget*> m_trees;
     252    /** Information-containers. */
     253    QMap<int, QFrame*> m_containers;
     254    /** Information-container labels. */
     255    QMap<int, QList<QLabel*> > m_labels;
     256    /** Information-container fields. */
     257    QMap<int, QList<QILabel*> > m_fields;
    237258    /** Holds whether hard-drive tab-widget have inaccessible item. */
    238259    bool m_fInaccessibleHD;
     
    275296    /** @} */
    276297
    277     /** @name Progress-bar variables.
     298    /** @name Button-box variables.
    278299     * @{ */
     300    /** Dialog button-box. */
     301    QIDialogButtonBox *m_pButtonBox;
    279302    /** Progress-bar widget. */
    280303    UIEnumerationProgressBar *m_pProgressBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r50907 r50968  
    2626#include <QDesktopServices>
    2727#include <QMenuBar>
     28#include <QStatusBar>
    2829#include <QResizeEvent>
    2930#include <QStackedWidget>
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