VirtualBox

Changeset 83475 in vbox


Ignore:
Timestamp:
Mar 30, 2020 11:10:50 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
136714
Message:

FE/Qt: bugref:9686. Adding a flag to detect if the tool is the current one. not complete.

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

    r83469 r83475  
    6060    bool    m_fEnabled;
    6161};
     62
     63
     64/*********************************************************************************************************************************
     65*   Class UIVMResouceMonitorTableView definition.                                                                           *
     66*********************************************************************************************************************************/
     67
     68class UIVMResouceMonitorTableView : public QTableView
     69{
     70    Q_OBJECT;
     71
     72public:
     73
     74    UIVMResouceMonitorTableView(QWidget *pParent = 0);
     75
     76protected:
     77
     78    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
     79
     80private slots:
     81
     82    void sltHeaderResized(int iIndex, int iOldSize, int iNewSize);
     83
     84private:
     85
     86    void resizeHeader();
     87    QSet<int> m_userResizedColums;
     88
     89};
     90
    6291/*********************************************************************************************************************************
    6392*   Class UIVMResouceMonitorItem definition.                                                                           *
     
    7099    UIResourceMonitorItem();
    71100    bool operator==(const UIResourceMonitorItem& other) const;
    72     bool isWithGuestAdditions();
     101    bool isWithGuestAdditions() const;
    73102
    74103    QUuid    m_VMuid;
     
    96125
    97126    CMachineDebugger m_comDebugger;
    98     CGuest           m_comGuest;
     127    mutable CGuest           m_comGuest;
    99128private:
    100129
     
    208237    virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {}
    209238};
     239
     240/*********************************************************************************************************************************
     241*   Class UIVMResouceMonitorTableView implementation.                                                                           *
     242*********************************************************************************************************************************/
     243
     244UIVMResouceMonitorTableView::UIVMResouceMonitorTableView(QWidget *pParent /* = 0 */)
     245    :QTableView(pParent)
     246{
     247    QHeaderView* pHeader = horizontalHeader();
     248    if (pHeader)
     249    {
     250        connect(pHeader, &QHeaderView::sectionResized, this, &UIVMResouceMonitorTableView::sltHeaderResized);
     251        //pHeader->setResizeMode(QHeaderView::ResizeToContents);
     252    }
     253}
     254
     255void UIVMResouceMonitorTableView::resizeEvent(QResizeEvent *pEvent)
     256{
     257    //resizeHeader();
     258    QTableView::resizeEvent(pEvent);
     259}
     260
     261void UIVMResouceMonitorTableView::resizeHeader()
     262{
     263    QHeaderView* pHeader = horizontalHeader();
     264    if (!pHeader)
     265        return;
     266    int iSectionCount = pHeader->count();
     267    if (iSectionCount <= 0)
     268        return;
     269    pHeader->setDefaultSectionSize(width() / iSectionCount);
     270}
     271
     272void UIVMResouceMonitorTableView::sltHeaderResized(int iIndex, int iOldSize, int iNewSize)
     273{
     274    printf("section resize %d %d %d\n", iIndex, iOldSize, iNewSize);
     275}
     276
    210277
    211278/*********************************************************************************************************************************
     
    291358}
    292359
    293 bool UIResourceMonitorItem::isWithGuestAdditions()
     360bool UIResourceMonitorItem::isWithGuestAdditions() const
    294361{
    295362    if (m_comGuest.isNull())
     
    386453    if (!index.isValid() || role != Qt::DisplayRole || index.row() >= rowCount())
    387454        return QVariant();
    388     UIResourceMonitorItem* pItem = static_cast<UIResourceMonitorItem*>(index.internalPointer());
    389455
    390456    switch (index.column())
     
    400466            break;
    401467        case VMResouceMonitorColumn_RAMUsedAndTotal:
    402             if (pItem && pItem->isWithGuestAdditions())
     468            if (m_itemList[index.row()].isWithGuestAdditions())
    403469                return QString("%1/%2").arg(uiCommon().formatSize(_1K * m_itemList[index.row()].m_uUsedRAM, iDecimalCount)).
    404470                    arg(uiCommon().formatSize(_1K * m_itemList[index.row()].m_uTotalRAM, iDecimalCount));
     
    407473            break;
    408474        case VMResouceMonitorColumn_RAMUsedPercentage:
    409             if (pItem && pItem->isWithGuestAdditions())
     475            if (m_itemList[index.row()].isWithGuestAdditions())
    410476                return QString("%1%").arg(QString::number(m_itemList[index.row()].m_fRAMUsagePercentage, 'f', 2));
    411477            else
     
    671737    , m_pModel(0)
    672738    , m_pColumnSelectionMenu(0)
     739    , m_fIsCurrentTool(true)
    673740{
    674741    /* Prepare: */
     
    684751{
    685752    return NULL;
     753}
     754
     755bool UIResourceMonitorWidget::isCurrentTool() const
     756{
     757    return m_fIsCurrentTool;
     758}
     759
     760void UIResourceMonitorWidget::setIsCurrentTool(bool fIsCurrentTool)
     761{
     762    m_fIsCurrentTool = fIsCurrentTool;
    686763}
    687764
     
    753830    m_pProxyModel = new UIResourceMonitorProxyModel(this);
    754831
    755     m_pTableView = new QTableView();
     832    m_pTableView = new UIVMResouceMonitorTableView();
    756833    if (m_pTableView && m_pModel && m_pProxyModel)
    757834    {
     
    768845        m_pTableView->setShowGrid(false);
    769846        m_pTableView->horizontalHeader()->setHighlightSections(false);
    770         m_pTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
     847        //m_pTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    771848        //m_pTableView->horizontalHeader()->setStretchLastSection(true);
    772849
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h

    r83469 r83475  
    3939class UIResourceMonitorProxyModel;
    4040class UIResourceMonitorModel;
     41class UIVMResouceMonitorTableView;
    4142
    4243/** QWidget extension to display a Linux top like utility that sort running vm wrt. resource allocations. */
     
    5354                               bool fShowToolbar = true, QWidget *pParent = 0);
    5455    ~UIResourceMonitorWidget();
     56    QMenu *menu() const;
    5557
    56     QMenu *menu() const;
     58    bool isCurrentTool() const;
     59    void setIsCurrentTool(bool fIsCurrentTool);
    5760
    5861#ifdef VBOX_WS_MAC
     
    103106      * @{ */
    104107        UIToolBar *m_pToolBar;
    105         QTableView *m_pTableView;
     108        UIVMResouceMonitorTableView *m_pTableView;
    106109        UIResourceMonitorProxyModel *m_pProxyModel;
    107110        UIResourceMonitorModel      *m_pModel;
     
    110113        QMap<int, bool>              m_columnVisible;
    111114    /** @} */
    112     QFrame* m_pColumnSelectionMenu;
     115    QFrame *m_pColumnSelectionMenu;
     116    /** Indicates if this widget's host tool is current tool. */
     117    bool    m_fIsCurrentTool;
    113118};
    114119
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