VirtualBox

Changeset 102594 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Dec 14, 2023 2:06:44 PM (14 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10501. Fixing mouse over chart stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp

    r102592 r102594  
    6161/** The time in seconds between metric inquries done to API. */
    6262const ULONG g_iPeriod = 1;
    63 /** The number of data points we store in UIChart. with g_iPeriod=1 it corresponds to 2 min. of data. */
    64 //const int m_iMaximumQueueSize = 120;
     63
    6564/** This is passed to IPerformanceCollector during its setup. When 1 that means IPerformanceCollector object does a data cache of size 1. */
    6665const int g_iMetricSetupCount = 1;
     
    202201       QConicalGradient conicalGradientForDataSeries(const QRectF &rectangle, int iDataIndex);
    203202    /** @} */
     203    int maxDataSize() const;
    204204
    205205    UIMetric *m_pMetric;
     
    487487    const int iX = width() - pEvent->position().x() - m_iMarginRight;
    488488    QPoint eventPosition(pEvent->position().x(), pEvent->position().y());
     489    int iDataSize = maxDataSize();
    489490    m_iDataIndexUnderCursor = -1;
    490     if (m_lineChartRect.contains(eventPosition))
     491    if (iDataSize > 0 && m_lineChartRect.contains(eventPosition))
     492    {
    491493        m_iDataIndexUnderCursor = m_iMaximumQueueSize  - (int)((iX) / m_fPixelPerDataPoint) - 1;
    492     //printf("m_iDataIndexUnderCursor %d\n", m_iDataIndexUnderCursor);
     494        m_iDataIndexUnderCursor = m_iDataIndexUnderCursor - (m_iMaximumQueueSize - iDataSize);
     495    }
     496
    493497    update();
    494498    QIWithRetranslateUI<QWidget>::mouseMoveEvent(pEvent);
     
    614618            }
    615619        }
     620
    616621        /* Draw a horizontal and vertical line on data point under the mouse cursor
    617622         * and draw the value on the left hand side of the chart: */
    618623        if (m_fDrawCurenValueIndicators && m_iDataIndexUnderCursor >= 0 && m_iDataIndexUnderCursor < data->size())
    619624        {
     625
    620626            painter.setPen(QPen(m_dataSeriesColor[k], 0.5));
    621             float fHeight = fH * data->at(data->size() - m_iDataIndexUnderCursor);
    622             if (fHeight > 0)
    623             {
    624                 // painter.drawLine(m_iMarginLeft, height() - (fHeight + m_iMarginBottom),
    625                 //                  width() - m_iMarginRight, height() - (fHeight + m_iMarginBottom));
    626                 painter.setPen(mainAxisColor);
    627                 float fX = (width() - m_iMarginRight) - ((data->size() - m_iDataIndexUnderCursor - 1) * fBarWidth);
    628                 painter.drawLine(fX, 0, fX, height() - m_iMarginBottom);
    629                 //    int iAverageFontWidth = fontMetrics.averageCharWidth();
    630 //                 QString strValue = QString::number(data->at(data->size() - m_iDataIndexUnderCursor));
    631 // #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
    632 //                 painter.drawText(m_iMarginLeft - fontMetrics.horizontalAdvance(strValue) - iAverageFontWidth,
    633 //                                  height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue);
    634 // #else
    635 //                 painter.drawText(m_iMarginLeft - fontMetrics.width(strValue) - iAverageFontWidth,
    636 //                                  height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue);
    637 // #endif
    638 
    639             }
     627            painter.setPen(mainAxisColor);
     628            float fX = (width() - m_iMarginRight) - ((data->size() - m_iDataIndexUnderCursor - 1) * fBarWidth);
     629            painter.drawLine(fX, 0, fX, height() - m_iMarginBottom);
    640630        }
    641631    }
     
    744734    gradient.setColorAt(1, pieColor);
    745735    return gradient;
     736}
     737
     738int UIChart::maxDataSize() const
     739{
     740    int iSize = 0;
     741    for (int k = 0; k < DATA_SERIES_SIZE; ++k)
     742    {
     743        if (m_pMetric->data(k))
     744            iSize = qMax(iSize, m_pMetric->data(k)->size());
     745    }
     746    return iSize;
    746747}
    747748
     
    858859    , m_iMaximumQueueSize(iMaximumQueueSize)
    859860{
    860     RT_NOREF(iMaximumQueueSize); /* Unused according to Clang 11. */
    861861    m_iTotal[0] = 0;
    862862    m_iTotal[1] = 0;
     
    865865UIMetric::UIMetric()
    866866    : m_iMaximum(0)
    867 #if 0 /* Unused according to Clang 11. */
    868     , m_iMaximumQueueSize(0)
    869 #endif
    870867    , m_fRequiresGuestAdditions(false)
    871868    , m_fIsInitialized(false)
     869    , m_iMaximumQueueSize(0)
    872870{
    873871}
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