| 296 | } |
| 297 | |
| 298 | QList<ActionBtuuonInfo> ItemDelegate::actionInfoList(const QStyleOptionViewItem &option, const QModelIndex &index) const |
| 299 | { |
| 300 | auto actList = index.data(kActionsRole).toStringList(); |
| 301 | if (actList.isEmpty()) |
| 302 | return {}; |
| 303 | |
| 304 | QList<ActionBtuuonInfo> actInfoList; |
| 305 | ActionBtuuonInfo info; |
| 306 | QRect tmpRect = option.rect; |
| 307 | for (int i = actList.size() - 1; i >= 0; --i) { |
| 308 | if (i % 2 == 0) { |
| 309 | info.id = actList[i]; |
| 310 | actInfoList.append(info); |
| 311 | } else { |
| 312 | info.text = actList[i]; |
| 313 | info.rect = tmpRect; |
| 314 | auto textRect = option.fontMetrics.boundingRect(0, 0, tmpRect.width(), 0, Qt::TextSingleLine, info.text); |
| 315 | textRect.adjust(-15, -5, 15, 5); |
| 316 | info.rect.setSize(textRect.size()); |
| 317 | info.rect.moveRight(tmpRect.right() - kNotificationSpacing); |
| 318 | info.rect.moveBottom(option.rect.bottom() - kNotificationSpacing); |
| 319 | tmpRect.moveRight(info.rect.left()); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | return actInfoList; |
| 324 | } |
| 325 | |
| 326 | QRect ItemDelegate::closeButtonRect(const QRect &itemRect) const |
| 327 | { |