35 #include <QStyleOptionViewItem>
36 #include <QModelIndex>
38 #include <QApplication>
39 #include <QMouseEvent>
44 startPixmap(
":/icons/media-playback-start.ico"),
45 stopPixmap(
":/icons/process-stop-7.ico"),
46 restartPixmap(
":/icons/view-refresh-7.png")
52 QStyledItemDelegate::setEditorData(editor,
index);
57 QStyledItemDelegate::setModelData(editor, model,
index);
62 QStyleOptionButton button;
66 button.features = QStyleOptionButton::AutoDefaultButton;
68 int size = appIconSize;
69 if (!
index.parent().isValid())
71 size = scenarioIconSize;
73 if (
index.data().toString().compare(
"Start") == 0)
75 button.icon = startPixmap;
77 button.iconSize = QSize(size, size);
79 else if (
index.data().toString().compare(
"Stop") == 0)
81 button.icon = stopPixmap;
82 button.iconSize = QSize(size, size);
84 else if (
index.data().toString().compare(
"Restart") == 0)
86 button.icon = restartPixmap;
87 button.iconSize = QSize(size, size);
91 button.text =
index.data().toString();
94 if (
index.data().toString().compare(
"HIDE") == 0)
106 const_cast<ButtonDelegate*
>(
this)->buttonStates[
index] = QStyle::State_Raised | QStyle::State_Enabled;
110 QApplication::style()->drawControl(QStyle::CE_PushButton, &button, painter, 0);
116 if ((buttonStates[
index] & QStyle::State_Enabled) == 0)
121 if (event->type() == QEvent::MouseButtonPress)
123 buttonStates[
index] = QStyle::State_Sunken | QStyle::State_Enabled;
127 else if (event->type() == QEvent::MouseButtonRelease)
129 buttonStates[
index] = QStyle::State_Raised | QStyle::State_Enabled;
150 return scenarioIconSize;
155 scenarioIconSize =
value;
160 int size = appIconSize;
161 if (!
index.parent().isValid())
163 size = scenarioIconSize;
165 return QSize(
option.rect.width(),
option.rect.height() + size + 6);