equal
deleted
inserted
replaced
75 static inline QAction *actionOfItem(const QStandardItem* item) |
75 static inline QAction *actionOfItem(const QStandardItem* item) |
76 { |
76 { |
77 return qvariant_cast<QAction*>(item->data(qdesigner_internal::ActionModel::ActionRole)); |
77 return qvariant_cast<QAction*>(item->data(qdesigner_internal::ActionModel::ActionRole)); |
78 } |
78 } |
79 |
79 |
80 static QIcon fixActionIcon(const QIcon &icon) |
|
81 { |
|
82 if (icon.isNull()) |
|
83 return qdesigner_internal::emptyIcon(); |
|
84 return icon; |
|
85 } |
|
86 |
|
87 namespace qdesigner_internal { |
80 namespace qdesigner_internal { |
88 |
81 |
89 // ----------- ActionModel |
82 // ----------- ActionModel |
90 ActionModel::ActionModel(QWidget *parent ) : |
83 ActionModel::ActionModel(QWidget *parent ) : |
91 QStandardItemModel(parent), |
84 QStandardItemModel(parent), |
|
85 m_emptyIcon(emptyIcon()), |
92 m_core(0) |
86 m_core(0) |
93 { |
87 { |
94 QStringList headers; |
88 QStringList headers; |
95 headers += tr("Name"); |
89 headers += tr("Name"); |
96 headers += tr("Used"); |
90 headers += tr("Used"); |
125 |
119 |
126 QStandardItemList list; |
120 QStandardItemList list; |
127 for (int i = 0; i < NumColumns; i++) |
121 for (int i = 0; i < NumColumns; i++) |
128 list += item(row, i); |
122 list += item(row, i); |
129 |
123 |
130 setItems(m_core, actionOfItem(list.front()), list); |
124 setItems(m_core, actionOfItem(list.front()), m_emptyIcon, list); |
131 } |
125 } |
132 |
126 |
133 void ActionModel::remove(int row) |
127 void ActionModel::remove(int row) |
134 { |
128 { |
135 qDeleteAll(takeRow(row)); |
129 qDeleteAll(takeRow(row)); |
148 QStandardItem *item = new QStandardItem; |
142 QStandardItem *item = new QStandardItem; |
149 item->setData(itemData, ActionRole); |
143 item->setData(itemData, ActionRole); |
150 item->setFlags(flags); |
144 item->setFlags(flags); |
151 items.push_back(item); |
145 items.push_back(item); |
152 } |
146 } |
153 setItems(m_core, action, items); |
147 setItems(m_core, action, m_emptyIcon, items); |
154 appendRow(items); |
148 appendRow(items); |
155 return indexFromItem(items.front()); |
149 return indexFromItem(items.front()); |
156 } |
150 } |
157 |
151 |
158 // Find the associated menus and toolbars, ignore toolbuttons |
152 // Find the associated menus and toolbars, ignore toolbuttons |
183 if (index == -1) |
177 if (index == -1) |
184 return PropertySheetKeySequenceValue(); |
178 return PropertySheetKeySequenceValue(); |
185 return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index)); |
179 return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index)); |
186 } |
180 } |
187 |
181 |
188 void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QStandardItemList &sl) |
182 void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, |
|
183 const QIcon &defaultIcon, |
|
184 QStandardItemList &sl) |
189 { |
185 { |
190 |
186 |
191 // Tooltip, mostly for icon view mode |
187 // Tooltip, mostly for icon view mode |
192 QString firstTooltip = action->objectName(); |
188 QString firstTooltip = action->objectName(); |
193 const QString text = action->text(); |
189 const QString text = action->text(); |
198 |
194 |
199 Q_ASSERT(sl.size() == NumColumns); |
195 Q_ASSERT(sl.size() == NumColumns); |
200 |
196 |
201 QStandardItem *item = sl[NameColumn]; |
197 QStandardItem *item = sl[NameColumn]; |
202 item->setText(action->objectName()); |
198 item->setText(action->objectName()); |
203 item->setIcon(fixActionIcon(action->icon())); |
199 QIcon icon = action->icon(); |
|
200 if (icon.isNull()) |
|
201 icon = defaultIcon; |
|
202 item->setIcon(icon); |
204 item->setToolTip(firstTooltip); |
203 item->setToolTip(firstTooltip); |
205 item->setWhatsThis(firstTooltip); |
204 item->setWhatsThis(firstTooltip); |
206 // Used |
205 // Used |
207 const QWidgetList associatedDesignerWidgets = associatedWidgets(action); |
206 const QWidgetList associatedDesignerWidgets = associatedWidgets(action); |
208 const bool used = !associatedDesignerWidgets.empty(); |
207 const bool used = !associatedDesignerWidgets.empty(); |