VirtualBox

Changeset 101101 in vbox


Ignore:
Timestamp:
Sep 13, 2023 12:43:15 AM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159070
Message:

VBoxDbg: Crude implemenation of the 'Refresh' / Ctrl-R action.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/VBoxDbgStatsQt.cpp

    r101100 r101101  
    221221
    222222    /**
    223      * Updates the data matching the specified pattern.
     223     * Updates the data matching the specified pattern, normally for the whole tree
     224     * but optionally a sub-tree if @a a_pSubTree is given.
    224225     *
    225226     * This will should invoke updatePrep, updateCallback and updateDone.
     
    230231     *
    231232     * @returns true if we reset the model and it's necessary to set the root index.
    232      * @param   a_rPatStr       The selection pattern.
     233     * @param   a_rPatStr   The selection pattern.
     234     * @param   a_pSubTree  The node / sub-tree to update if this is partial update.
     235     *                      This is NULL for a full tree update.
    233236     *
    234237     * @remarks The default implementation is an empty stub.
    235238     */
    236     virtual bool updateStatsByPattern(const QString &a_rPatStr);
     239    virtual bool updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree = NULL);
    237240
    238241    /**
     
    240243     * will not remove anything that's outside that tree.
    241244     *
     245     * The default implementation will call redirect to updateStatsByPattern().
     246     *
    242247     * @param   a_rIndex    The sub-tree root. Invalid index means root.
    243      *
    244      * @todo    Create a default implementation using updateStatsByPattern.
    245248     */
    246249    virtual void updateStatsByIndex(QModelIndex const &a_rIndex);
     
    334337     *
    335338     * @returns Success indicator.
    336      */
    337     bool updatePrepare(void);
     339     * @param   a_pSubTree  The node / sub-tree to update if this is partial update.
     340     *                      This is NULL for a full tree update.
     341     */
     342    bool updatePrepare(PDBGGUISTATSNODE a_pSubTree = NULL);
    338343
    339344    /**
    340345     * Called by updateStatsByPattern(), finalizes the update.
    341346     *
    342      * @return See updateStatsByPattern().
    343      *
    344      * @param  a_fSuccess   Whether the update was successful or not.
    345      *
    346      */
    347     bool updateDone(bool a_fSuccess);
     347     * @returns See updateStatsByPattern().
     348     *
     349     * @param   a_fSuccess  Whether the update was successful or not.
     350     * @param   a_pSubTree  The node / sub-tree to update if this is partial update.
     351     *                      This is NULL for a full tree update.
     352     */
     353    bool updateDone(bool a_fSuccess, PDBGGUISTATSNODE a_pSubTree = NULL);
    348354
    349355    /**
     
    398404     */
    399405    static char *getNodePath2(PCDBGGUISTATSNODE pNode, char *psz, ssize_t cch);
     406
     407    /**
     408     * Returns the pattern for the node, optionally including the entire sub-tree
     409     * under it.
     410     *
     411     * @returns Pattern.
     412     * @param   pNode       The node.
     413     * @param   fSubTree    Whether to include the sub-tree in the pattern.
     414     */
     415    static QString getNodePattern(PCDBGGUISTATSNODE pNode, bool fSubTree = true);
    400416
    401417    /**
     
    601617    virtual ~VBoxDbgStatsModelVM();
    602618
    603     virtual bool updateStatsByPattern(const QString &a_rPatStr);
     619    virtual bool updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree = NULL);
    604620    virtual void resetStatsByPattern(const QString &a_rPatStr);
    605621
     
    13801396}
    13811397
     1398
     1399/*static*/ QString
     1400VBoxDbgStatsModel::getNodePattern(PCDBGGUISTATSNODE pNode, bool fSubTree /*= true*/)
     1401{
     1402    /* the node pattern. */
     1403    char szPat[1024+1024+4];
     1404    ssize_t cch = getNodePath(pNode, szPat, 1024);
     1405    AssertReturn(cch >= 0, QString("//////////////////////////////////////////////////////"));
     1406
     1407    /* the sub-tree pattern. */
     1408    if (fSubTree && pNode->cChildren)
     1409    {
     1410        char *psz = &szPat[cch];
     1411        *psz++ = '|';
     1412        memcpy(psz, szPat, cch);
     1413        psz += cch;
     1414        *psz++ = '/';
     1415        *psz++ = '*';
     1416        *psz++ = '\0';
     1417    }
     1418    return szPat;
     1419}
    13821420
    13831421
     
    18421880
    18431881bool
    1844 VBoxDbgStatsModel::updatePrepare(void)
     1882VBoxDbgStatsModel::updatePrepare(PDBGGUISTATSNODE a_pSubTree /*= NULL*/)
    18451883{
    18461884    /*
     
    18481886     * node to be updated.
    18491887     */
     1888    PDBGGUISTATSNODE pFirst;
    18501889    Assert(m_pRoot);
    18511890    Assert(m_pRoot->enmType == STAMTYPE_INVALID);
    1852     PDBGGUISTATSNODE pFirst = nextDataNode(m_pRoot);
     1891    if (!a_pSubTree)
     1892        pFirst = nextDataNode(m_pRoot);
     1893    else
     1894        pFirst = a_pSubTree->enmType != STAMTYPE_INVALID ? a_pSubTree : nextDataNode(a_pSubTree);
    18531895    if (pFirst)
    18541896    {
     
    18781920
    18791921bool
    1880 VBoxDbgStatsModel::updateDone(bool a_fSuccess)
     1922VBoxDbgStatsModel::updateDone(bool a_fSuccess, PDBGGUISTATSNODE a_pSubTree /*= NULL*/)
    18811923{
    18821924    /*
     
    18841926     */
    18851927    if (    a_fSuccess
    1886         &&  m_iUpdateChild != UINT32_MAX)
     1928        &&  m_iUpdateChild != UINT32_MAX
     1929        &&  a_pSubTree == NULL)
    18871930    {
    18881931        PDBGGUISTATSNODE const pLast = prevDataNode(m_pUpdateParent->papChildren[m_iUpdateChild]);
     
    19281971         */
    19291972        DBGGUISTATSSTACK    Stack;
    1930         Stack.a[0].pNode = m_pRoot;
     1973        Stack.a[0].pNode  = !a_pSubTree ? m_pRoot : a_pSubTree;
    19311974        Stack.a[0].iChild = -1;
    19321975        Stack.iTop = 0;
     
    19862029            }
    19872030        }
    1988         /* emit layoutChanged(); - hrmpf, doesn't work reliably... */
     2031
     2032        /*
     2033         * If a_pSubTree is not an intermediate node, invalidate it explicitly.
     2034         */
     2035        if (a_pSubTree && a_pSubTree->enmType != STAMTYPE_INVALID)
     2036        {
     2037            int         const iRightCol   = a_pSubTree->enmType != STAMTYPE_PROFILE && a_pSubTree->enmType != STAMTYPE_PROFILE_ADV
     2038                                          ? 4 : 7;
     2039            QModelIndex const BottomRight = createIndex(a_pSubTree->iSelf, iRightCol, a_pSubTree);
     2040            QModelIndex const TopLeft     = createIndex(a_pSubTree->iSelf, 2, a_pSubTree);
     2041            emit dataChanged(TopLeft, BottomRight);
     2042        }
    19892043    }
    19902044
     
    19942048
    19952049bool
    1996 VBoxDbgStatsModel::updateStatsByPattern(const QString &a_rPatStr)
     2050VBoxDbgStatsModel::updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree /*= NULL*/)
     2051{
     2052    /* stub */
     2053    RT_NOREF(a_rPatStr, a_pSubTree);
     2054    return false;
     2055}
     2056
     2057
     2058void
     2059VBoxDbgStatsModel::updateStatsByIndex(QModelIndex const &a_rIndex)
     2060{
     2061    PDBGGUISTATSNODE pNode = nodeFromIndex(a_rIndex);
     2062    if (pNode == m_pRoot || !a_rIndex.isValid())
     2063        updateStatsByPattern(QString());
     2064    else if (pNode)
     2065        /** @todo this doesn't quite work if pNode is excluded by the m_PatStr.   */
     2066        updateStatsByPattern(getNodePattern(pNode, true /*fSubTree*/), pNode);
     2067}
     2068
     2069
     2070void
     2071VBoxDbgStatsModel::resetStatsByPattern(QString const &a_rPatStr)
    19972072{
    19982073    /* stub */
    19992074    NOREF(a_rPatStr);
    2000     return false;
    2001 }
    2002 
    2003 
    2004 void
    2005 VBoxDbgStatsModel::updateStatsByIndex(QModelIndex const &a_rIndex)
    2006 {
    2007     /** @todo implement this based on updateStatsByPattern. */
    2008     NOREF(a_rIndex);
    2009 }
    2010 
    2011 
    2012 void
    2013 VBoxDbgStatsModel::resetStatsByPattern(QString const &a_rPatStr)
    2014 {
    2015     /* stub */
    2016     NOREF(a_rPatStr);
    20172075}
    20182076
     
    20242082    if (pNode == m_pRoot || !a_rIndex.isValid())
    20252083    {
     2084        /* The root can't be reset, so only take action if fSubTree is set. */
    20262085        if (fSubTree)
    2027         {
    2028             /* everything from the root down. */
    20292086            resetStatsByPattern(QString());
    2030         }
    20312087    }
    20322088    else if (pNode)
    2033     {
    2034         /* the node pattern. */
    2035         char szPat[1024+1024+4];
    2036         ssize_t cch = getNodePath(pNode, szPat, 1024);
    2037         AssertReturnVoid(cch >= 0);
    2038 
    2039         /* the sub-tree pattern. */
    2040         if (fSubTree && pNode->cChildren)
    2041         {
    2042             char *psz = &szPat[cch];
    2043             *psz++ = '|';
    2044             memcpy(psz, szPat, cch);
    2045             psz += cch;
    2046             *psz++ = '/';
    2047             *psz++ = '*';
    2048             *psz++ = '\0';
    2049         }
    2050 
    2051         resetStatsByPattern(szPat);
    2052     }
     2089        resetStatsByPattern(getNodePattern(pNode, fSubTree));
    20532090}
    20542091
     
    27162753
    27172754bool
    2718 VBoxDbgStatsModelVM::updateStatsByPattern(const QString &a_rPatStr)
     2755VBoxDbgStatsModelVM::updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree /*= NULL*/)
    27192756{
    27202757    /** @todo the way we update this stuff is independent of the source (XML, file, STAM), our only
    27212758     * ASSUMPTION is that the input is strictly ordered by (fully slashed) name. So, all this stuff
    27222759     * should really move up into the parent class. */
    2723     bool fRc = updatePrepare();
     2760    bool fRc = updatePrepare(a_pSubTree);
    27242761    if (fRc)
    27252762    {
    27262763        int rc = stamEnum(a_rPatStr, updateCallback, this);
    2727         fRc = updateDone(RT_SUCCESS(rc));
     2764        fRc = updateDone(RT_SUCCESS(rc), a_pSubTree);
    27282765    }
    27292766    return fRc;
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