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