VirtualBox

Changeset 83466 in vbox for trunk


Ignore:
Timestamp:
Mar 27, 2020 12:57:00 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9686. Using QMap instead of QVector.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp

    r83452 r83466  
    7070    UIResourceMonitorItem();
    7171    bool operator==(const UIResourceMonitorItem& other) const;
     72    bool isWithGuestAdditions();
     73
    7274    QUuid    m_VMuid;
    7375    QString  m_strVMName;
     
    9496
    9597    CMachineDebugger m_comDebugger;
    96 
     98    CGuest           m_comGuest;
    9799private:
    98100
     
    130132    UIResourceMonitorProxyModel(QObject *parent = 0);
    131133    void dataUpdate();
    132     void setColumnShown(const QVector<bool>& columnShown);
     134    void setColumnVisible(const QMap<int, bool>& columnVisible);
    133135
    134136protected:
     
    139141private:
    140142
    141     QVector<bool> m_columnShown;
     143    QMap<int, bool> m_columnVisible;
    142144
    143145};
     
    234236        CConsole comConsole = comSession.GetConsole();
    235237        if (!comConsole.isNull())
     238        {
     239            m_comGuest = comConsole.GetGuest();
    236240            m_comDebugger = comConsole.GetDebugger();
     241        }
    237242    }
    238243}
     
    285290}
    286291
     292bool UIResourceMonitorItem::isWithGuestAdditions()
     293{
     294    if (m_comGuest.isNull())
     295        return false;
     296    return m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel());
     297}
     298
    287299
    288300/*********************************************************************************************************************************
     
    323335{
    324336    Q_UNUSED(sourceParent);
    325     if (iSourceColumn >= m_columnShown.size())
    326         return true;
    327     return m_columnShown[iSourceColumn];
    328 }
    329 
    330 void UIResourceMonitorProxyModel::setColumnShown(const QVector<bool>& columnShown)
     337    return m_columnVisible.value(iSourceColumn, true);
     338}
     339
     340void UIResourceMonitorProxyModel::setColumnVisible(const QMap<int, bool>& columnVisible)
    331341{
    332342    emit layoutAboutToBeChanged();
    333     m_columnShown = columnShown;
     343    m_columnVisible = columnVisible;
    334344    invalidateFilter();
    335345    emit layoutChanged();
     
    720730        connect(m_pModel, &UIResourceMonitorModel::sigDataUpdate, this, &UIResourceMonitorWidget::sltHandleDataUpdate);
    721731
    722         m_pProxyModel->setColumnShown(m_columnShown);
     732        m_pProxyModel->setColumnVisible(m_columnVisible);
    723733    }
    724734}
     
    743753        pLayout->addWidget(pCheckBox);
    744754        pCheckBox->setData(i);
    745         if (i < m_columnShown.size())
    746             pCheckBox->setChecked(m_columnShown[i]);
     755        pCheckBox->setChecked(columnVisible(i));
    747756        if (i == (int)VMResouceMonitorColumn_Name)
    748757            pCheckBox->setEnabled(false);
     
    789798{
    790799    QStringList hiddenColumnList = gEDataManager->VMResourceMonitorHiddenColumnList();
    791     m_columnShown.resize(VMResouceMonitorColumn_Max);
    792     for (int i = 0; i < m_columnShown.size(); ++i)
    793         m_columnShown[i] = true;
     800    for (int i = (int)VMResouceMonitorColumn_Name; i < (int)VMResouceMonitorColumn_Max; ++i)
     801        m_columnVisible[i] = true;
    794802    foreach(const QString& strColumn, hiddenColumnList)
    795     {
    796         VMResouceMonitorColumn enmColumn = gpConverter->fromInternalString<VMResouceMonitorColumn>(strColumn);
    797         if ((int)enmColumn < m_columnShown.size())
    798             m_columnShown[(int)enmColumn] = false;
    799     }
     803        setColumnVisible((int)gpConverter->fromInternalString<VMResouceMonitorColumn>(strColumn), false);
    800804}
    801805
     
    803807{
    804808    QStringList hiddenColumnList;
    805     for (int i = 0; i < m_columnShown.size(); ++i)
    806     {
    807         if (!m_columnShown[i])
     809    for (int i = 0; i < m_columnVisible.size(); ++i)
     810    {
     811        if (!columnVisible(i))
    808812            hiddenColumnList << gpConverter->toInternalString((VMResouceMonitorColumn) i);
    809813    }
     
    844848    if (!pSender)
    845849        return;
    846     int iColumnId = pSender->data().toInt();
    847     if (iColumnId >= m_columnShown.size())
    848         return;
    849     setColumnShown(iColumnId, fChecked);
     850    setColumnVisible(pSender->data().toInt(), fChecked);
    850851}
    851852
     
    856857}
    857858
    858 void UIResourceMonitorWidget::setColumnShown(int iColumnId, bool fShown)
    859 {
    860     if (iColumnId >= m_columnShown.size())
     859void UIResourceMonitorWidget::setColumnVisible(int iColumnId, bool fVisible)
     860{
     861    if (m_columnVisible.contains(iColumnId) && m_columnVisible[iColumnId] == fVisible)
    861862        return;
    862     if (m_columnShown[iColumnId] == fShown)
    863         return;
    864     m_columnShown[iColumnId] = fShown;
     863    m_columnVisible[iColumnId] = fVisible;
    865864    if (m_pProxyModel)
    866         m_pProxyModel->setColumnShown(m_columnShown);
     865        m_pProxyModel->setColumnVisible(m_columnVisible);
     866}
     867
     868bool UIResourceMonitorWidget::columnVisible(int iColumnId) const
     869{
     870    return m_columnVisible.value(iColumnId, true);
    867871}
    868872
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h

    r83452 r83466  
    7878private:
    7979
    80     void setColumnShown(int iColumnId, bool fShown);
     80    void setColumnVisible(int iColumnId, bool fVisible);
     81    bool columnVisible(int iColumnId) const;
     82
    8183    /** @name Prepare/cleanup cascade.
    8284      * @{ */
     
    104106        UIResourceMonitorModel      *m_pModel;
    105107        QVector<QString>             m_columnCaptions;
    106         QVector<bool>                m_columnShown;
     108        /* The key is the column id (VMResouceMonitorColumn) and value is true if the column is visible. */
     109        QMap<int, bool>              m_columnVisible;
    107110    /** @} */
    108111    QFrame* m_pColumnSelectionMenu;
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