Changeset 101101 in vbox
- Timestamp:
- Sep 13, 2023 12:43:15 AM (19 months ago)
- svn:sync-xref-src-repo-rev:
- 159070
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgStatsQt.cpp
r101100 r101101 221 221 222 222 /** 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. 224 225 * 225 226 * This will should invoke updatePrep, updateCallback and updateDone. … … 230 231 * 231 232 * @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. 233 236 * 234 237 * @remarks The default implementation is an empty stub. 235 238 */ 236 virtual bool updateStatsByPattern(const QString &a_rPatStr );239 virtual bool updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree = NULL); 237 240 238 241 /** … … 240 243 * will not remove anything that's outside that tree. 241 244 * 245 * The default implementation will call redirect to updateStatsByPattern(). 246 * 242 247 * @param a_rIndex The sub-tree root. Invalid index means root. 243 *244 * @todo Create a default implementation using updateStatsByPattern.245 248 */ 246 249 virtual void updateStatsByIndex(QModelIndex const &a_rIndex); … … 334 337 * 335 338 * @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); 338 343 339 344 /** 340 345 * Called by updateStatsByPattern(), finalizes the update. 341 346 * 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); 348 354 349 355 /** … … 398 404 */ 399 405 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); 400 416 401 417 /** … … 601 617 virtual ~VBoxDbgStatsModelVM(); 602 618 603 virtual bool updateStatsByPattern(const QString &a_rPatStr );619 virtual bool updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree = NULL); 604 620 virtual void resetStatsByPattern(const QString &a_rPatStr); 605 621 … … 1380 1396 } 1381 1397 1398 1399 /*static*/ QString 1400 VBoxDbgStatsModel::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 } 1382 1420 1383 1421 … … 1842 1880 1843 1881 bool 1844 VBoxDbgStatsModel::updatePrepare( void)1882 VBoxDbgStatsModel::updatePrepare(PDBGGUISTATSNODE a_pSubTree /*= NULL*/) 1845 1883 { 1846 1884 /* … … 1848 1886 * node to be updated. 1849 1887 */ 1888 PDBGGUISTATSNODE pFirst; 1850 1889 Assert(m_pRoot); 1851 1890 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); 1853 1895 if (pFirst) 1854 1896 { … … 1878 1920 1879 1921 bool 1880 VBoxDbgStatsModel::updateDone(bool a_fSuccess )1922 VBoxDbgStatsModel::updateDone(bool a_fSuccess, PDBGGUISTATSNODE a_pSubTree /*= NULL*/) 1881 1923 { 1882 1924 /* … … 1884 1926 */ 1885 1927 if ( a_fSuccess 1886 && m_iUpdateChild != UINT32_MAX) 1928 && m_iUpdateChild != UINT32_MAX 1929 && a_pSubTree == NULL) 1887 1930 { 1888 1931 PDBGGUISTATSNODE const pLast = prevDataNode(m_pUpdateParent->papChildren[m_iUpdateChild]); … … 1928 1971 */ 1929 1972 DBGGUISTATSSTACK Stack; 1930 Stack.a[0].pNode = m_pRoot;1973 Stack.a[0].pNode = !a_pSubTree ? m_pRoot : a_pSubTree; 1931 1974 Stack.a[0].iChild = -1; 1932 1975 Stack.iTop = 0; … … 1986 2029 } 1987 2030 } 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 } 1989 2043 } 1990 2044 … … 1994 2048 1995 2049 bool 1996 VBoxDbgStatsModel::updateStatsByPattern(const QString &a_rPatStr) 2050 VBoxDbgStatsModel::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 2058 void 2059 VBoxDbgStatsModel::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 2070 void 2071 VBoxDbgStatsModel::resetStatsByPattern(QString const &a_rPatStr) 1997 2072 { 1998 2073 /* stub */ 1999 2074 NOREF(a_rPatStr); 2000 return false;2001 }2002 2003 2004 void2005 VBoxDbgStatsModel::updateStatsByIndex(QModelIndex const &a_rIndex)2006 {2007 /** @todo implement this based on updateStatsByPattern. */2008 NOREF(a_rIndex);2009 }2010 2011 2012 void2013 VBoxDbgStatsModel::resetStatsByPattern(QString const &a_rPatStr)2014 {2015 /* stub */2016 NOREF(a_rPatStr);2017 2075 } 2018 2076 … … 2024 2082 if (pNode == m_pRoot || !a_rIndex.isValid()) 2025 2083 { 2084 /* The root can't be reset, so only take action if fSubTree is set. */ 2026 2085 if (fSubTree) 2027 {2028 /* everything from the root down. */2029 2086 resetStatsByPattern(QString()); 2030 }2031 2087 } 2032 2088 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)); 2053 2090 } 2054 2091 … … 2716 2753 2717 2754 bool 2718 VBoxDbgStatsModelVM::updateStatsByPattern(const QString &a_rPatStr )2755 VBoxDbgStatsModelVM::updateStatsByPattern(const QString &a_rPatStr, PDBGGUISTATSNODE a_pSubTree /*= NULL*/) 2719 2756 { 2720 2757 /** @todo the way we update this stuff is independent of the source (XML, file, STAM), our only 2721 2758 * ASSUMPTION is that the input is strictly ordered by (fully slashed) name. So, all this stuff 2722 2759 * should really move up into the parent class. */ 2723 bool fRc = updatePrepare( );2760 bool fRc = updatePrepare(a_pSubTree); 2724 2761 if (fRc) 2725 2762 { 2726 2763 int rc = stamEnum(a_rPatStr, updateCallback, this); 2727 fRc = updateDone(RT_SUCCESS(rc) );2764 fRc = updateDone(RT_SUCCESS(rc), a_pSubTree); 2728 2765 } 2729 2766 return fRc;
Note:
See TracChangeset
for help on using the changeset viewer.