* add actions in the order they are added, not alphabetically by name (?!)
* remove actions if they get deleted BUG:30042 svn path=/branches/KDE/4.2/kdelibs/; revision=907995
This commit is contained in:
parent
9f03caaa18
commit
4f16460715
@ -331,9 +331,14 @@ bool ExtenderItem::isDetached() const
|
||||
void ExtenderItem::addAction(const QString &name, QAction *action)
|
||||
{
|
||||
Q_ASSERT(action);
|
||||
if (d->actionsInOrder.contains(action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->actions.insert(name, action);
|
||||
d->actionsInOrder.append(action);
|
||||
connect(action, SIGNAL(changed()), this, SLOT(updateToolBox()));
|
||||
connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(actionDestroyed(QObject*)));
|
||||
d->updateToolBox();
|
||||
}
|
||||
|
||||
@ -907,7 +912,7 @@ void ExtenderItemPrivate::updateToolBox()
|
||||
}
|
||||
|
||||
//add the actions that are actually set to visible.
|
||||
foreach (QAction *action, actions) {
|
||||
foreach (QAction *action, actionsInOrder) {
|
||||
if (action->isVisible()) {
|
||||
IconWidget *icon = new IconWidget(q);
|
||||
icon->setAction(action);
|
||||
@ -1105,10 +1110,29 @@ void ExtenderItemPrivate::resizeContent(const QSizeF &newSize)
|
||||
void ExtenderItemPrivate::previousTargetExtenderDestroyed(QObject *o)
|
||||
{
|
||||
Q_UNUSED(o)
|
||||
|
||||
previousTargetExtender = 0;
|
||||
}
|
||||
|
||||
void ExtenderItemPrivate::actionDestroyed(QObject *o)
|
||||
{
|
||||
QAction *action = static_cast<QAction *>(o);
|
||||
QMutableHashIterator<QString, QAction *> hit(actions);
|
||||
while (hit.hasNext()) {
|
||||
if (hit.next().value() == action) {
|
||||
hit.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QMutableListIterator<QAction *> lit(actionsInOrder);
|
||||
while (lit.hasNext()) {
|
||||
if (lit.next() == action) {
|
||||
lit.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint ExtenderItemPrivate::s_maxExtenderItemId = 0;
|
||||
|
||||
} // namespace Plasma
|
||||
|
@ -249,6 +249,7 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget
|
||||
Q_PRIVATE_SLOT(d, void themeChanged())
|
||||
Q_PRIVATE_SLOT(d, void sourceAppletRemoved())
|
||||
Q_PRIVATE_SLOT(d, void previousTargetExtenderDestroyed(QObject*))
|
||||
Q_PRIVATE_SLOT(d, void actionDestroyed(QObject*))
|
||||
|
||||
ExtenderItemPrivate * const d;
|
||||
|
||||
|
@ -59,6 +59,7 @@ class ExtenderItemPrivate
|
||||
qreal iconSize();
|
||||
void resizeContent(const QSizeF &newSize);
|
||||
void previousTargetExtenderDestroyed(QObject *o);
|
||||
void actionDestroyed(QObject *o);
|
||||
|
||||
ExtenderItem *q;
|
||||
|
||||
@ -78,7 +79,8 @@ class ExtenderItemPrivate
|
||||
|
||||
IconWidget *collapseIcon;
|
||||
|
||||
QMap<QString, QAction*> actions;
|
||||
QHash<QString, QAction*> actions;
|
||||
QList<QAction*> actionsInOrder;
|
||||
|
||||
QString title;
|
||||
QString name;
|
||||
|
Loading…
Reference in New Issue
Block a user