| 82 | } |
| 83 | |
| 84 | QVariant TimeTraceModel::data(const QModelIndex &index, int role) const |
| 85 | { |
| 86 | auto it = time_calls_map.begin(); |
| 87 | std::advance(it, index.row()); |
| 88 | |
| 89 | if (role == Qt::BackgroundRole) { |
| 90 | QColor color = QGuiApplication::palette().window().color(); |
| 91 | int r, g, b; |
| 92 | color.getRgb(&r, &g, &b, nullptr); |
| 93 | if (color.lightness() > 128) { |
| 94 | /* Light theme */ |
| 95 | if (it->first == context->config.sc.busy_loop_hash) |
| 96 | color.setRgb(r - 0x30, g - 0x10, b); |
| 97 | else |
| 98 | color.setRgb(r, g, b - 0x18); |
| 99 | } |
| 100 | else { |
| 101 | /* Dark theme */ |
| 102 | if (it->first == context->config.sc.busy_loop_hash) |
| 103 | color.setRgb(r, g + 0x10, b + 0x20); |
| 104 | else |
| 105 | color.setRgb(r + 0x08, g + 0x08, b); |
| 106 | } |
| 107 | return QBrush(color); |
| 108 | } |
| 109 | else if (role == Qt::DisplayRole) { |
| 110 | if (index.column() == 0) { |
| 111 | switch (it->second.type) { |
| 112 | case SharedConfig::TIMETYPE_TIME: |
| 113 | return tr("time()"); |
| 114 | case SharedConfig::TIMETYPE_GETTIMEOFDAY: |
| 115 | return tr("gettimeofday()"); |
| 116 | case SharedConfig::TIMETYPE_CLOCK: |
| 117 | return tr("clock()"); |
| 118 | case SharedConfig::TIMETYPE_CLOCKGETTIME_REALTIME: |
| 119 | return tr("clock_gettime() realtime"); |
| 120 | case SharedConfig::TIMETYPE_CLOCKGETTIME_MONOTONIC: |
| 121 | return tr("clock_gettime() monotonic"); |
| 122 | case SharedConfig::TIMETYPE_SDLGETTICKS: |
| 123 | return tr("SDL_GetTicks()"); |
| 124 | case SharedConfig::TIMETYPE_SDLGETPERFORMANCECOUNTER: |
| 125 | return tr("SDL_GetPerformanceCounter()"); |
| 126 | case SharedConfig::TIMETYPE_GETTICKCOUNT: |
| 127 | return tr("GetTickCount()"); |
| 128 | case SharedConfig::TIMETYPE_GETTICKCOUNT64: |
| 129 | return tr("GetTickCount64()"); |
| 130 | case SharedConfig::TIMETYPE_QUERYPERFORMANCECOUNTER: |
| 131 | return tr("QueryPerformanceCounter()"); |
| 132 | default: |
| 133 | return tr("Unknown"); |
| 134 | } |
| 135 | } |
| 136 | else if (index.column() == 1) { |
| 137 | return QString("%1").arg(it->first, 0, 16); |
| 138 | } |
| 139 | else { |
| 140 | return it->second.count; |
| 141 | } |