| 148 | |
| 149 | |
| 150 | void ProcessItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& idx) const |
| 151 | { |
| 152 | bool selected = (option.state & QStyle::State_Selected) != 0; |
| 153 | if (selected) |
| 154 | painter->setBrush(getThemeColor(SelectionColor)); |
| 155 | else |
| 156 | painter->setBrush(option.backgroundBrush); |
| 157 | |
| 158 | painter->setPen(Qt::NoPen); |
| 159 | painter->setFont(m_font); |
| 160 | |
| 161 | QRect textRect = option.rect; |
| 162 | textRect.setBottom(textRect.top() + m_charHeight + 2); |
| 163 | painter->drawRect(textRect); |
| 164 | |
| 165 | auto data = idx.data(Qt::DisplayRole); |
| 166 | switch (idx.column()) |
| 167 | { |
| 168 | case ProcessListModel::PidColumn: |
| 169 | painter->setPen(getThemeColor(NumberColor).rgba()); |
| 170 | painter->drawText(textRect, data.toString()); |
| 171 | break; |
| 172 | case ProcessListModel::ProcessNameColumn: |
| 173 | painter->setPen(option.palette.color(QPalette::WindowText).rgba()); |
| 174 | painter->drawText(textRect, data.toString()); |
| 175 | break; |
| 176 | default: |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | |
| 182 | void ProcessItemDelegate::updateFonts() |