| 135 | } |
| 136 | |
| 137 | void ProjectModelItemDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem& option, |
| 138 | const QRect& rect, const QString& text) const |
| 139 | { |
| 140 | QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) |
| 141 | ? QPalette::Normal : QPalette::Disabled; |
| 142 | if (option.state & QStyle::State_Editing) { |
| 143 | painter->save(); |
| 144 | painter->setPen(option.palette.color(cg, QPalette::Text)); |
| 145 | painter->drawRect(rect.adjusted(0, 0, -1, -1)); |
| 146 | painter->restore(); |
| 147 | } |
| 148 | |
| 149 | if(text.isEmpty()) { |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) { |
| 154 | cg = QPalette::Inactive; |
| 155 | } |
| 156 | if (option.state & QStyle::State_Selected) { |
| 157 | painter->setPen(option.palette.color(cg, QPalette::HighlightedText)); |
| 158 | } else { |
| 159 | painter->setPen(option.palette.color(cg, QPalette::Text)); |
| 160 | } |
| 161 | |
| 162 | QFontMetrics fm(painter->fontMetrics()); |
| 163 | painter->drawText(rect, fm.elidedText(text, Qt::ElideRight, rect.width())); |
| 164 | } |
| 165 | |
| 166 | bool ProjectModelItemDelegate::helpEvent(QHelpEvent* event, |
| 167 | QAbstractItemView* view, const QStyleOptionViewItem& option, |