QVariant model::DbContainerModel::data(const QModelIndex& index, int role) const { TreeNode* node = Index2Node(index); if (node != nullptr) { switch (role) { case Qt::DisplayRole: case ItemNameRole: return GetDisplayData(node, index.row()); case ItemTypeRole: return QVariant::fromValue(node->GetElement()->Type()); case ItemSizeRole: return GetSizeData(node); default: return QVariant(); } } return QVariant(); }
void CPageDisplay::Update() { int max_rate[NUM_STATUS_BARS]; CString max_range_text; double stat_double; CString stat_string; // Setting ranges on status bar display based on selections. for ( int i = 0; i < NUM_STATUS_BARS; i++ ) { max_rate[i] = GetMaxRange( &(barcharts[i].results[GetWhichPerf()]), barcharts[i].result_to_display ); } // If the results to display are the same, giving them the same ranges for easier comparisons. for ( i = 0; i < NUM_STATUS_BARS - 1; i++) { for ( int j = i; j < NUM_STATUS_BARS; j++ ) { if ( barcharts[i].result_to_display == barcharts[j].result_to_display ) { if ( max_rate[i] > max_rate[j] ) max_rate[j] = max_rate[i]; else max_rate[i] = max_rate[j]; } } } // Setting ranges on status bar and displaying range value. for ( i = 0; i < NUM_STATUS_BARS; i++ ) { ( (CProgressCtrl*)GetDlgItem( PRate1 + i ) )->SetRange( 0, max_rate[i] ); // See if results are displaying a percentage. if ( ( barcharts[i].result_to_display >= CPU_UTILIZATION_RESULT ) && ( barcharts[i].result_to_display <= IRQ_UTILIZATION_RESULT ) ) { max_range_text.Format( "%d %%", max_rate[i] ); // display % sign ( (CStatic*)GetDlgItem( TRate1MAX + i ) )->SetWindowText( max_range_text ); } else { max_range_text.Format( "%d", max_rate[i] ); // displaying a rate ( (CStatic*)GetDlgItem( TRate1MAX + i ) )->SetWindowText( max_range_text ); } // Update the name. SetDlgItemText( TWorker1 + i, barcharts[i].name ); // Get the performance data to display (a number and a string) GetDisplayData( &(barcharts[i].results[GetWhichPerf()]), barcharts[i].result_to_display, &stat_double, &stat_string ); // Update the appropriate progress bar ((CProgressCtrl *) GetDlgItem( PRate1 + i ))->SetPos( (int) stat_double ); // Display the new value to the user ((CStatic *) GetDlgItem( TRate1 + i ))->SetWindowText( stat_string ); } // Update the data. UpdateWindow(); // Update the big meter dialog, if it exists. if ( m_dlgBigMeter.is_displayed ) m_dlgBigMeter.UpdateDisplay(); }