29 setLayoutDirection(Qt::LeftToRight);
30 setItemDelegate(m_delegate);
33void GM_SettingsListWidget::mousePressEvent(QMouseEvent* event)
35 if (containsRemoveIcon(event->position().toPoint())) {
40 if (containsUpdateIcon(event->position().toPoint())) {
45 QListWidget::mousePressEvent(event);
48void GM_SettingsListWidget::mouseDoubleClickEvent(QMouseEvent* event)
50 if (containsRemoveIcon(event->position().toPoint()) || containsUpdateIcon(event->position().toPoint()))
53 QListWidget::mouseDoubleClickEvent(event);
56bool GM_SettingsListWidget::containsRemoveIcon(
const QPoint &pos)
const
58 QListWidgetItem* item = itemAt(pos);
63 const QRect rect = visualItemRect(item);
64 const int removeIconPosition = rect.right() - m_delegate->
padding() - 16;
65 const int center = rect.height() / 2 + rect.top();
66 const int removeIconYPos = center - (16 / 2);
68 QRect removeIconRect(removeIconPosition, removeIconYPos, 16, 16);
70 return removeIconRect.contains(pos);
73bool GM_SettingsListWidget::containsUpdateIcon(
const QPoint &pos)
const
75 QListWidgetItem *item = itemAt(pos);
79 GM_Script *script =
static_cast<GM_Script*
>(item->data(Qt::UserRole + 10).value<
void*>());
83 const QRect rect = visualItemRect(item);
84 const int updateIconPosition = rect.right() - m_delegate->
padding() * 2 - 16 * 2;
85 const int center = rect.height() / 2 + rect.top();
86 const int updateIconYPos = center - (16 / 2);
88 QRect updateIconRect(updateIconPosition, updateIconYPos, 16, 16);
90 return updateIconRect.contains(pos);