Changeset 103403 in vbox
- Timestamp:
- Feb 17, 2024 1:51:52 AM (10 months ago)
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgStatsQt.cpp
r102839 r103403 37 37 #include <QSpinBox> 38 38 #include <QLabel> 39 #include <QCheckBox> 39 40 #include <QClipboard> 40 41 #include <QApplication> … … 45 46 #include <QContextMenuEvent> 46 47 #include <QHeaderView> 48 #include <QSortFilterProxyModel> 47 49 48 50 #include <iprt/errcore.h> … … 60 62 /** The number of column. */ 61 63 #define DBGGUI_STATS_COLUMNS 9 64 65 /** Enables the sorting and filtering. */ 66 #define VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 62 67 63 68 … … 545 550 void logTree(QModelIndex &a_rRoot, bool a_fReleaseLog) const; 546 551 547 protected:548 552 /** Gets the unit. */ 549 553 static QString strUnit(PCDBGGUISTATSNODE pNode); 550 554 /** Gets the value/times. */ 551 555 static QString strValueTimes(PCDBGGUISTATSNODE pNode); 556 /** Gets the value/times. */ 557 static uint64_t getValueTimesAsUInt(PCDBGGUISTATSNODE pNode); 552 558 /** Gets the minimum value. */ 553 559 static QString strMinValue(PCDBGGUISTATSNODE pNode); 560 /** Gets the minimum value. */ 561 static uint64_t getMinValueAsUInt(PCDBGGUISTATSNODE pNode); 554 562 /** Gets the average value. */ 555 563 static QString strAvgValue(PCDBGGUISTATSNODE pNode); 564 /** Gets the average value. */ 565 static uint64_t getAvgValueAsUInt(PCDBGGUISTATSNODE pNode); 556 566 /** Gets the maximum value. */ 557 567 static QString strMaxValue(PCDBGGUISTATSNODE pNode); 568 /** Gets the maximum value. */ 569 static uint64_t getMaxValueAsUInt(PCDBGGUISTATSNODE pNode); 558 570 /** Gets the total value. */ 559 571 static QString strTotalValue(PCDBGGUISTATSNODE pNode); 572 /** Gets the total value. */ 573 static uint64_t getTotalValueAsUInt(PCDBGGUISTATSNODE pNode); 560 574 /** Gets the delta value. */ 561 575 static QString strDeltaValue(PCDBGGUISTATSNODE pNode); 562 576 577 578 protected: 563 579 /** 564 580 * Destroys a node and all its children. … … 585 601 /** @name Overridden QAbstractItemModel methods 586 602 * @{ */ 587 virtual int columnCount(const QModelIndex &a_rParent) const ;588 virtual QVariant data(const QModelIndex &a_rIndex, int a_eRole) const ;589 virtual Qt::ItemFlags flags(const QModelIndex &a_rIndex) const ;590 virtual bool hasChildren(const QModelIndex &a_rParent) const ;591 virtual QVariant headerData(int a_iSection, Qt::Orientation a_ePrientation, int a_eRole) const ;592 virtual QModelIndex index(int a_iRow, int a_iColumn, const QModelIndex &a_rParent) const ;593 virtual QModelIndex parent(const QModelIndex &a_rChild) const ;594 virtual int rowCount(const QModelIndex &a_rParent) const ;595 ///virtual void sort(int a_iColumn, Qt::SortOrder a_eOrder) ;603 virtual int columnCount(const QModelIndex &a_rParent) const RT_OVERRIDE; 604 virtual QVariant data(const QModelIndex &a_rIndex, int a_eRole) const RT_OVERRIDE; 605 virtual Qt::ItemFlags flags(const QModelIndex &a_rIndex) const RT_OVERRIDE; 606 virtual bool hasChildren(const QModelIndex &a_rParent) const RT_OVERRIDE; 607 virtual QVariant headerData(int a_iSection, Qt::Orientation a_ePrientation, int a_eRole) const RT_OVERRIDE; 608 virtual QModelIndex index(int a_iRow, int a_iColumn, const QModelIndex &a_rParent) const RT_OVERRIDE; 609 virtual QModelIndex parent(const QModelIndex &a_rChild) const RT_OVERRIDE; 610 virtual int rowCount(const QModelIndex &a_rParent) const RT_OVERRIDE; 611 ///virtual void sort(int a_iColumn, Qt::SortOrder a_eOrder) RT_OVERRIDE; 596 612 /** @} */ 597 613 }; … … 640 656 PCVMMR3VTABLE m_pVMM; 641 657 }; 658 659 660 #ifdef VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 661 /** 662 * Model using the VM / STAM interface as data source. 663 */ 664 class VBoxDbgStatsSortFileProxyModel : public QSortFilterProxyModel 665 { 666 public: 667 /** 668 * Constructor. 669 * 670 * @param a_pParent The parent object. 671 */ 672 VBoxDbgStatsSortFileProxyModel(QObject *a_pParent); 673 674 /** Destructor */ 675 virtual ~VBoxDbgStatsSortFileProxyModel() 676 {} 677 678 /** Sets whether or not to show unused rows (all zeros). */ 679 void setShowUnusedRows(bool a_fHide); 680 681 protected: 682 /** 683 * Converts an index to a node pointer. 684 * 685 * @returns Pointer to the node, NULL if invalid reference. 686 * @param a_rIndex Reference to the index 687 */ 688 inline PDBGGUISTATSNODE nodeFromIndex(const QModelIndex &a_rIndex) const 689 { 690 if (RT_LIKELY(a_rIndex.isValid())) 691 return (PDBGGUISTATSNODE)a_rIndex.internalPointer(); 692 return NULL; 693 } 694 695 /** Does the row filtering. */ 696 bool filterAcceptsRow(int a_iSrcRow, const QModelIndex &a_rSrcParent) const RT_OVERRIDE; 697 /** For implementing the sorting. */ 698 bool lessThan(const QModelIndex &a_rSrcLeft, const QModelIndex &a_rSrcRight) const RT_OVERRIDE; 699 700 /** Whether to show unused rows (all zeros) or not. */ 701 bool m_fShowUnusedRows; 702 }; 703 #endif /* VBOXDBG_WITH_SORTED_AND_FILTERED_STATS */ 642 704 643 705 … … 975 1037 else 976 1038 { 977 beginInsertRows(createIndex(pParent->iSelf, 0, pParent), 0, 0);1039 beginInsertRows(createIndex(pParent->iSelf, 0, pParent), iPosition, iPosition); 978 1040 pNode = createAndInsertNode(pParent, pszName, cchName, iPosition); 979 1041 endInsertRows(); … … 2219 2281 2220 2282 /* root? */ 2221 AssertReturn(a_rParent.isValid() , QModelIndex());2283 AssertReturn(a_rParent.isValid() || (iRow == 0 && iColumn >= 0), QModelIndex()); 2222 2284 AssertMsgReturn(iRow == 0 && (unsigned)iColumn < DBGGUI_STATS_COLUMNS, ("iRow=%d iColumn=%d", iRow, iColumn), QModelIndex()); 2223 2285 return createIndex(0, iColumn, m_pRoot); … … 2368 2430 2369 2431 2432 /*static*/ uint64_t 2433 VBoxDbgStatsModel::getValueTimesAsUInt(PCDBGGUISTATSNODE pNode) 2434 { 2435 switch (pNode->enmType) 2436 { 2437 case STAMTYPE_COUNTER: 2438 return pNode->Data.Counter.c; 2439 2440 case STAMTYPE_PROFILE: 2441 case STAMTYPE_PROFILE_ADV: 2442 return pNode->Data.Profile.cPeriods; 2443 2444 case STAMTYPE_RATIO_U32: 2445 case STAMTYPE_RATIO_U32_RESET: 2446 return RT_MAKE_U64(pNode->Data.RatioU32.u32A, pNode->Data.RatioU32.u32B); 2447 2448 case STAMTYPE_CALLBACK: 2449 return UINT64_MAX; 2450 2451 case STAMTYPE_U8: 2452 case STAMTYPE_U8_RESET: 2453 case STAMTYPE_X8: 2454 case STAMTYPE_X8_RESET: 2455 return pNode->Data.u8; 2456 2457 case STAMTYPE_U16: 2458 case STAMTYPE_U16_RESET: 2459 case STAMTYPE_X16: 2460 case STAMTYPE_X16_RESET: 2461 return pNode->Data.u16; 2462 2463 case STAMTYPE_U32: 2464 case STAMTYPE_U32_RESET: 2465 case STAMTYPE_X32: 2466 case STAMTYPE_X32_RESET: 2467 return pNode->Data.u32; 2468 2469 case STAMTYPE_U64: 2470 case STAMTYPE_U64_RESET: 2471 case STAMTYPE_X64: 2472 case STAMTYPE_X64_RESET: 2473 return pNode->Data.u64; 2474 2475 case STAMTYPE_BOOL: 2476 case STAMTYPE_BOOL_RESET: 2477 return pNode->Data.f; 2478 2479 default: 2480 AssertMsgFailed(("%d\n", pNode->enmType)); 2481 RT_FALL_THRU(); 2482 case STAMTYPE_INVALID: 2483 return UINT64_MAX; 2484 } 2485 } 2486 2487 2370 2488 /*static*/ QString 2371 2489 VBoxDbgStatsModel::strMinValue(PCDBGGUISTATSNODE pNode) … … 2386 2504 2387 2505 2506 /*static*/ uint64_t 2507 VBoxDbgStatsModel::getMinValueAsUInt(PCDBGGUISTATSNODE pNode) 2508 { 2509 switch (pNode->enmType) 2510 { 2511 case STAMTYPE_PROFILE: 2512 case STAMTYPE_PROFILE_ADV: 2513 if (pNode->Data.Profile.cPeriods) 2514 return pNode->Data.Profile.cTicksMin; 2515 return 0; /* cTicksMin is set to UINT64_MAX */ 2516 default: 2517 return UINT64_MAX; 2518 } 2519 } 2520 2521 2388 2522 /*static*/ QString 2389 2523 VBoxDbgStatsModel::strAvgValue(PCDBGGUISTATSNODE pNode) … … 2404 2538 2405 2539 2540 /*static*/ uint64_t 2541 VBoxDbgStatsModel::getAvgValueAsUInt(PCDBGGUISTATSNODE pNode) 2542 { 2543 switch (pNode->enmType) 2544 { 2545 case STAMTYPE_PROFILE: 2546 case STAMTYPE_PROFILE_ADV: 2547 if (pNode->Data.Profile.cPeriods) 2548 return pNode->Data.Profile.cTicks / pNode->Data.Profile.cPeriods; 2549 return 0; 2550 default: 2551 return UINT64_MAX; 2552 } 2553 } 2554 2555 2556 2406 2557 /*static*/ QString 2407 2558 VBoxDbgStatsModel::strMaxValue(PCDBGGUISTATSNODE pNode) … … 2420 2571 2421 2572 2573 /*static*/ uint64_t 2574 VBoxDbgStatsModel::getMaxValueAsUInt(PCDBGGUISTATSNODE pNode) 2575 { 2576 switch (pNode->enmType) 2577 { 2578 case STAMTYPE_PROFILE: 2579 case STAMTYPE_PROFILE_ADV: 2580 return pNode->Data.Profile.cTicksMax; 2581 default: 2582 return UINT64_MAX; 2583 } 2584 } 2585 2586 2422 2587 /*static*/ QString 2423 2588 VBoxDbgStatsModel::strTotalValue(PCDBGGUISTATSNODE pNode) … … 2432 2597 default: 2433 2598 return ""; 2599 } 2600 } 2601 2602 2603 /*static*/ uint64_t 2604 VBoxDbgStatsModel::getTotalValueAsUInt(PCDBGGUISTATSNODE pNode) 2605 { 2606 switch (pNode->enmType) 2607 { 2608 case STAMTYPE_PROFILE: 2609 case STAMTYPE_PROFILE_ADV: 2610 return pNode->Data.Profile.cTicks; 2611 default: 2612 return UINT64_MAX; 2434 2613 } 2435 2614 } … … 2856 3035 /* 2857 3036 * 3037 * V B o x D b g S t a t s S o r t F i l e P r o x y M o d e l 3038 * V B o x D b g S t a t s S o r t F i l e P r o x y M o d e l 3039 * V B o x D b g S t a t s S o r t F i l e P r o x y M o d e l 3040 * 3041 * 3042 */ 3043 3044 #ifdef VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 3045 3046 VBoxDbgStatsSortFileProxyModel::VBoxDbgStatsSortFileProxyModel(QObject *a_pParent) 3047 : QSortFilterProxyModel(a_pParent) 3048 , m_fShowUnusedRows(false) 3049 { 3050 3051 } 3052 3053 3054 bool 3055 VBoxDbgStatsSortFileProxyModel::filterAcceptsRow(int a_iSrcRow, const QModelIndex &a_rSrcParent) const 3056 { 3057 if (!m_fShowUnusedRows) 3058 { 3059 PDBGGUISTATSNODE const pParent = nodeFromIndex(a_rSrcParent); 3060 if (pParent) 3061 { 3062 if ((unsigned)a_iSrcRow < pParent->cChildren) 3063 { 3064 PDBGGUISTATSNODE const pNode = pParent->papChildren[a_iSrcRow]; 3065 if (pNode) /* paranoia */ 3066 { 3067 /* Only relevant for leaf nodes. */ 3068 if (pNode->cChildren == 0) 3069 { 3070 if (pNode->enmState != kDbgGuiStatsNodeState_kInvalid) 3071 { 3072 if (pNode->i64Delta == 0) 3073 { 3074 /* Is the cached statistics value zero? */ 3075 switch (pNode->enmType) 3076 { 3077 case STAMTYPE_COUNTER: 3078 if (pNode->Data.Counter.c != 0) 3079 break; 3080 return false; 3081 3082 case STAMTYPE_PROFILE: 3083 case STAMTYPE_PROFILE_ADV: 3084 if (pNode->Data.Profile.cPeriods) 3085 break; 3086 return false; 3087 3088 case STAMTYPE_RATIO_U32: 3089 case STAMTYPE_RATIO_U32_RESET: 3090 if (pNode->Data.RatioU32.u32A || pNode->Data.RatioU32.u32B) 3091 break; 3092 return false; 3093 3094 case STAMTYPE_CALLBACK: 3095 if (pNode->Data.pStr && !pNode->Data.pStr->isEmpty()) 3096 break; 3097 return false; 3098 3099 case STAMTYPE_U8: 3100 case STAMTYPE_U8_RESET: 3101 case STAMTYPE_X8: 3102 case STAMTYPE_X8_RESET: 3103 if (pNode->Data.u8) 3104 break; 3105 return false; 3106 3107 case STAMTYPE_U16: 3108 case STAMTYPE_U16_RESET: 3109 case STAMTYPE_X16: 3110 case STAMTYPE_X16_RESET: 3111 if (pNode->Data.u16) 3112 break; 3113 return false; 3114 3115 case STAMTYPE_U32: 3116 case STAMTYPE_U32_RESET: 3117 case STAMTYPE_X32: 3118 case STAMTYPE_X32_RESET: 3119 if (pNode->Data.u32) 3120 break; 3121 return false; 3122 3123 case STAMTYPE_U64: 3124 case STAMTYPE_U64_RESET: 3125 case STAMTYPE_X64: 3126 case STAMTYPE_X64_RESET: 3127 if (pNode->Data.u64) 3128 break; 3129 return false; 3130 3131 case STAMTYPE_BOOL: 3132 case STAMTYPE_BOOL_RESET: 3133 /* not possible to detect */ 3134 return false; 3135 3136 case STAMTYPE_INVALID: 3137 break; 3138 3139 default: 3140 AssertMsgFailedBreak(("enmType=%d\n", pNode->enmType)); 3141 } 3142 } 3143 } 3144 else 3145 return false; 3146 } 3147 } 3148 } 3149 } 3150 } 3151 return true; 3152 } 3153 3154 3155 bool 3156 VBoxDbgStatsSortFileProxyModel::lessThan(const QModelIndex &a_rSrcLeft, const QModelIndex &a_rSrcRight) const 3157 { 3158 PCDBGGUISTATSNODE const pLeft = nodeFromIndex(a_rSrcLeft); 3159 PCDBGGUISTATSNODE const pRight = nodeFromIndex(a_rSrcRight); 3160 if (pLeft == pRight) 3161 return false; 3162 if (pLeft && pRight) 3163 { 3164 if (pLeft->pParent == pRight->pParent) 3165 { 3166 switch (a_rSrcLeft.column()) 3167 { 3168 case 0: 3169 return RTStrCmp(pLeft->pszName, pRight->pszName) < 0; 3170 case 1: 3171 return RTStrCmp(pLeft->pszUnit, pRight->pszUnit) < 0; 3172 case 2: 3173 return VBoxDbgStatsModel::getValueTimesAsUInt(pLeft) < VBoxDbgStatsModel::getValueTimesAsUInt(pRight); 3174 case 3: 3175 return pLeft->i64Delta < pRight->i64Delta; 3176 case 4: 3177 return VBoxDbgStatsModel::getMinValueAsUInt(pLeft) < VBoxDbgStatsModel::getMinValueAsUInt(pRight); 3178 case 5: 3179 return VBoxDbgStatsModel::getAvgValueAsUInt(pLeft) < VBoxDbgStatsModel::getAvgValueAsUInt(pRight); 3180 case 6: 3181 return VBoxDbgStatsModel::getMaxValueAsUInt(pLeft) < VBoxDbgStatsModel::getMaxValueAsUInt(pRight); 3182 case 7: 3183 return VBoxDbgStatsModel::getTotalValueAsUInt(pLeft) < VBoxDbgStatsModel::getTotalValueAsUInt(pRight); 3184 case 8: 3185 if (pLeft->pDescStr == pRight->pDescStr) 3186 return false; 3187 if (!pLeft->pDescStr) 3188 return true; 3189 if (!pRight->pDescStr) 3190 return false; 3191 return *pLeft->pDescStr < *pRight->pDescStr; 3192 default: 3193 AssertCompile(DBGGUI_STATS_COLUMNS == 9); 3194 return true; 3195 } 3196 } 3197 return false; 3198 } 3199 return !pLeft; 3200 } 3201 3202 3203 void 3204 VBoxDbgStatsSortFileProxyModel::setShowUnusedRows(bool a_fHide) 3205 { 3206 if (a_fHide != m_fShowUnusedRows) 3207 { 3208 m_fShowUnusedRows = a_fHide; 3209 invalidateRowsFilter(); 3210 } 3211 } 3212 3213 3214 #endif /* VBOXDBG_WITH_SORTED_AND_FILTERED_STATS */ 3215 3216 3217 3218 /* 3219 * 2858 3220 * V B o x D b g S t a t s V i e w 2859 3221 * V B o x D b g S t a t s V i e w … … 2864 3226 2865 3227 2866 VBoxDbgStatsView::VBoxDbgStatsView(VBoxDbgGui *a_pDbgGui, VBoxDbgStatsModel *a_pModel, VBoxDbgStats *a_pParent/* = NULL*/) 2867 : QTreeView(a_pParent), VBoxDbgBase(a_pDbgGui), m_pModel(a_pModel), m_PatStr(), m_pParent(a_pParent), 2868 m_pLeafMenu(NULL), m_pBranchMenu(NULL), m_pViewMenu(NULL), m_pCurMenu(NULL), m_CurIndex() 2869 3228 VBoxDbgStatsView::VBoxDbgStatsView(VBoxDbgGui *a_pDbgGui, VBoxDbgStatsModel *a_pVBoxModel, 3229 VBoxDbgStatsSortFileProxyModel *a_pProxyModel, VBoxDbgStats *a_pParent/* = NULL*/) 3230 : QTreeView(a_pParent) 3231 , VBoxDbgBase(a_pDbgGui) 3232 , m_pVBoxModel(a_pVBoxModel) 3233 , m_pProxyModel(a_pProxyModel) 3234 , m_pModel(NULL) 3235 , m_PatStr() 3236 , m_pParent(a_pParent) 3237 , m_pLeafMenu(NULL) 3238 , m_pBranchMenu(NULL) 3239 , m_pViewMenu(NULL) 3240 , m_pCurMenu(NULL) 3241 , m_CurIndex() 2870 3242 { 2871 3243 /* … … 2873 3245 */ 2874 3246 setRootIsDecorated(true); 3247 if (a_pProxyModel) 3248 { 3249 m_pModel = a_pProxyModel; 3250 a_pProxyModel->setSourceModel(a_pVBoxModel); 3251 } 3252 else 3253 m_pModel = a_pVBoxModel; 2875 3254 setModel(m_pModel); 2876 QModelIndex RootIdx = m _pModel->getRootIndex(); /* This should really be QModelIndex(), but Qt on darwin does wrong things then. */3255 QModelIndex RootIdx = myGetRootIndex(); /* This should really be QModelIndex(), but Qt on darwin does wrong things then. */ 2877 3256 setRootIndex(RootIdx); 2878 3257 setItemsExpandable(true); … … 2880 3259 setSelectionBehavior(SelectRows); 2881 3260 setSelectionMode(SingleSelection); 2882 /// @todo sorting setSortingEnabled(true); 3261 if (a_pProxyModel) 3262 setSortingEnabled(true); 2883 3263 2884 3264 /* … … 2970 3350 2971 3351 #define DELETE_IT(m) if (m) { delete m; m = NULL; } else do {} while (0) 2972 DELETE_IT(m_pModel); 3352 DELETE_IT(m_pProxyModel); 3353 DELETE_IT(m_pVBoxModel); 2973 3354 2974 3355 DELETE_IT(m_pLeafMenu); … … 2992 3373 { 2993 3374 m_PatStr = rPatStr; 2994 if (m_pModel->updateStatsByPattern(rPatStr)) 2995 setRootIndex(m_pModel->getRootIndex()); /* hack */ 3375 if (m_pVBoxModel->updateStatsByPattern(rPatStr)) 3376 setRootIndex(myGetRootIndex()); /* hack */ 3377 } 3378 3379 3380 void 3381 VBoxDbgStatsView::setShowUnusedRows(bool a_fHide) 3382 { 3383 #ifdef VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 3384 if (m_pProxyModel) 3385 m_pProxyModel->setShowUnusedRows(a_fHide); 3386 #else 3387 RT_NOREF_PV(a_fHide); 3388 #endif 2996 3389 } 2997 3390 … … 3016 3409 VBoxDbgStatsView *pThis = (VBoxDbgStatsView *)pvUser; 3017 3410 3018 pThis->setExpanded(a_rIndex, true); 3019 3020 QModelIndex ParentIndex = pThis->m_pModel->parent(a_rIndex); 3411 QModelIndex ParentIndex; /* this isn't 100% optimal */ 3412 if (pThis->m_pProxyModel) 3413 { 3414 QModelIndex const ProxyIndex = pThis->m_pProxyModel->mapFromSource(a_rIndex); 3415 3416 ParentIndex = pThis->m_pModel->parent(ProxyIndex); 3417 } 3418 else 3419 { 3420 pThis->setExpanded(a_rIndex, true); 3421 3422 ParentIndex = pThis->m_pModel->parent(a_rIndex); 3423 } 3021 3424 while (ParentIndex.isValid() && !pThis->isExpanded(ParentIndex)) 3022 3425 { … … 3033 3436 VBoxDbgStatsView::expandMatching(const QString &rPatStr) 3034 3437 { 3035 m_p Model->iterateStatsByPattern(rPatStr, expandMatchingCallback, this);3438 m_pVBoxModel->iterateStatsByPattern(rPatStr, expandMatchingCallback, this); 3036 3439 } 3037 3440 … … 3081 3484 if (pMenu) 3082 3485 { 3083 m_pRefreshAct->setEnabled(!Idx.isValid() || Idx == m _pModel->getRootIndex());3486 m_pRefreshAct->setEnabled(!Idx.isValid() || Idx == myGetRootIndex()); 3084 3487 m_CurIndex = Idx; 3085 3488 m_pCurMenu = pMenu; … … 3096 3499 3097 3500 3501 QModelIndex 3502 VBoxDbgStatsView::myGetRootIndex(void) const 3503 { 3504 if (!m_pProxyModel) 3505 return m_pVBoxModel->getRootIndex(); 3506 return m_pProxyModel->mapFromSource(m_pVBoxModel->getRootIndex()); 3507 } 3508 3509 3098 3510 void 3099 3511 VBoxDbgStatsView::headerContextMenuRequested(const QPoint &a_rPos) … … 3105 3517 { 3106 3518 m_pRefreshAct->setEnabled(true); 3107 m_CurIndex = m _pModel->getRootIndex();3519 m_CurIndex = myGetRootIndex(); 3108 3520 m_pCurMenu = m_pViewMenu; 3109 3521 … … 3140 3552 { 3141 3553 QModelIndex Idx = m_pCurMenu ? m_CurIndex : currentIndex(); 3142 if (!Idx.isValid() || Idx == m _pModel->getRootIndex())3143 { 3144 if (m_p Model->updateStatsByPattern(m_PatStr))3145 setRootIndex(m _pModel->getRootIndex()); /* hack */3554 if (!Idx.isValid() || Idx == myGetRootIndex()) 3555 { 3556 if (m_pVBoxModel->updateStatsByPattern(m_PatStr)) 3557 setRootIndex(myGetRootIndex()); /* hack */ 3146 3558 } 3147 3559 else 3148 m_pModel->updateStatsByIndex(Idx); 3560 { 3561 if (m_pProxyModel) 3562 Idx = m_pProxyModel->mapToSource(Idx); 3563 m_pVBoxModel->updateStatsByIndex(Idx); 3564 } 3149 3565 } 3150 3566 … … 3154 3570 { 3155 3571 QModelIndex Idx = m_pCurMenu ? m_CurIndex : currentIndex(); 3156 if (!Idx.isValid() || Idx == m _pModel->getRootIndex())3157 m_p Model->resetStatsByPattern(m_PatStr);3572 if (!Idx.isValid() || Idx == myGetRootIndex()) 3573 m_pVBoxModel->resetStatsByPattern(m_PatStr); 3158 3574 else 3159 m_pModel->resetStatsByIndex(Idx); 3575 { 3576 if (m_pProxyModel) 3577 Idx = m_pProxyModel->mapToSource(Idx); 3578 m_pVBoxModel->resetStatsByIndex(Idx); 3579 } 3160 3580 } 3161 3581 … … 3165 3585 { 3166 3586 QModelIndex Idx = m_pCurMenu ? m_CurIndex : currentIndex(); 3167 m_pModel->copyTreeToClipboard(Idx); 3587 if (m_pProxyModel) 3588 Idx = m_pProxyModel->mapToSource(Idx); 3589 m_pVBoxModel->copyTreeToClipboard(Idx); 3168 3590 } 3169 3591 … … 3173 3595 { 3174 3596 QModelIndex Idx = m_pCurMenu ? m_CurIndex : currentIndex(); 3175 m_pModel->logTree(Idx, false /* a_fReleaseLog */); 3597 if (m_pProxyModel) 3598 Idx = m_pProxyModel->mapToSource(Idx); 3599 m_pVBoxModel->logTree(Idx, false /* a_fReleaseLog */); 3176 3600 } 3177 3601 … … 3181 3605 { 3182 3606 QModelIndex Idx = m_pCurMenu ? m_CurIndex : currentIndex(); 3183 m_pModel->logTree(Idx, true /* a_fReleaseLog */); 3607 if (m_pProxyModel) 3608 Idx = m_pProxyModel->mapToSource(Idx); 3609 m_pVBoxModel->logTree(Idx, true /* a_fReleaseLog */); 3184 3610 } 3185 3611 … … 3255 3681 connect(pSB, SIGNAL(valueChanged(int)), this, SLOT(setRefresh(int))); 3256 3682 3683 #ifdef VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 3684 QCheckBox *pCheckBox = new QCheckBox("Show unused"); 3685 pHLayout->addWidget(pCheckBox); 3686 pCheckBox->setMaximumSize(pCheckBox->sizeHint()); 3687 connect(pCheckBox, SIGNAL(stateChanged(int)), this, SLOT(sltShowUnusedRowsChanged(int))); 3688 #endif 3689 3257 3690 /* 3258 3691 * Create the tree view and setup the layout. 3259 3692 */ 3260 3693 VBoxDbgStatsModelVM *pModel = new VBoxDbgStatsModelVM(a_pDbgGui, m_PatStr, NULL, a_pDbgGui->getVMMFunctionTable()); 3261 m_pView = new VBoxDbgStatsView(a_pDbgGui, pModel, this); 3694 #ifdef VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 3695 VBoxDbgStatsSortFileProxyModel *pProxyModel = new VBoxDbgStatsSortFileProxyModel(this); 3696 m_pView = new VBoxDbgStatsView(a_pDbgGui, pModel, pProxyModel, this); 3697 #else 3698 m_pView = new VBoxDbgStatsView(a_pDbgGui, pModel, NULL, this); 3699 #endif 3262 3700 3263 3701 QWidget *pHBox = new QWidget; … … 3369 3807 m_pPatCB->setFocus(Qt::ShortcutFocusReason); 3370 3808 } 3809 3810 3811 void 3812 VBoxDbgStats::sltShowUnusedRowsChanged(int a_iState) 3813 { 3814 #ifdef VBOXDBG_WITH_SORTED_AND_FILTERED_STATS 3815 m_pView->setShowUnusedRows(a_iState != Qt::Unchecked); 3816 #else 3817 RT_NOREF_PV(a_iState); 3818 #endif 3819 } -
trunk/src/VBox/Debugger/VBoxDbgStatsQt.h
r98103 r103403 41 41 class VBoxDbgStats; 42 42 class VBoxDbgStatsModel; 43 class VBoxDbgStatsSortFileProxyModel; 43 44 44 45 /** Pointer to a statistics sample. */ … … 61 62 * Creates a VM statistics list view widget. 62 63 * 63 * @param a_pDbgGui Pointer to the debugger gui object. 64 * @param a_pModel The model. Will take ownership of this and delete it together 65 * with the view later 66 * @param a_pParent Parent widget. 67 */ 68 VBoxDbgStatsView(VBoxDbgGui *a_pDbgGui, VBoxDbgStatsModel *a_pModel, VBoxDbgStats *a_pParent = NULL); 64 * @param a_pDbgGui Pointer to the debugger gui object. 65 * @param a_pModel The model. Will take ownership of this and delete it 66 * together with the view later 67 * @param a_pProxyModel The proxy model object to use for sorting and 68 * filtering. 69 * @param a_pParent Parent widget. 70 */ 71 VBoxDbgStatsView(VBoxDbgGui *a_pDbgGui, VBoxDbgStatsModel *a_pModel, VBoxDbgStatsSortFileProxyModel *a_pProxyModel, 72 VBoxDbgStats *a_pParent = NULL); 69 73 70 74 /** Destructor. */ … … 73 77 /** 74 78 * Updates the view with current information from STAM. 79 * 75 80 * This will indirectly update the m_PatStr. 76 81 * … … 80 85 81 86 /** 87 * Shows or hides the unused rows. 88 * 89 * @param a_fShow Whether to show (@c true) or hide (@c false) unused 90 * rows. 91 */ 92 void setShowUnusedRows(bool a_fShow); 93 94 /** 82 95 * Resets the stats items matching the specified pattern. 96 * 83 97 * This pattern doesn't have to be the one used for update, thus m_PatStr isn't updated. 84 98 * … … 120 134 */ 121 135 virtual void contextMenuEvent(QContextMenuEvent *a_pEvt); 136 137 /** 138 * Gets the model index of the root node. 139 * 140 * This takes proxy / no-proxy into account. 141 * 142 * @returns root index for. 143 */ 144 QModelIndex myGetRootIndex(void) const; 122 145 123 146 protected slots: … … 143 166 protected: 144 167 /** Pointer to the data model. */ 145 VBoxDbgStatsModel *m_pModel; 168 VBoxDbgStatsModel *m_pVBoxModel; 169 /** Pointer to the proxy data model for sorting & filtering. */ 170 VBoxDbgStatsSortFileProxyModel *m_pProxyModel; 171 /** Either m_pVBoxModel or m_pProxyModel. */ 172 QAbstractItemModel *m_pModel; 146 173 /** The current selection pattern. */ 147 174 QString m_PatStr; … … 250 277 void actFocusToPat(); 251 278 279 /** The 'show unused rows' checkbox changed. */ 280 void sltShowUnusedRowsChanged(int a_iState); 281 252 282 protected: 253 283
Note:
See TracChangeset
for help on using the changeset viewer.