[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/actions
From: Michael Jansen <kde () michael-jansen ! biz>
Date: 2008-09-15 21:45:39
Message-ID: 1221515139.402089.16368.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 861361 by mjansen:
Remove action from categories if removed from the collection.
M +18 -0 kactioncategory.cpp
M +15 -2 kactioncategory.h
M +14 -2 kactioncollection.cpp
--- trunk/KDE/kdelibs/kdeui/actions/kactioncategory.cpp #861360:861361
@@ -128,6 +128,24 @@
}
+void KActionCategory::unlistAction(QAction *action)
+ {
+ // ATTENTION:
+ // This method is called from KActionCollection with an QObject formerly
+ // known as a QAction during _k_actionDestroyed(). So don't do fancy stuff
+ // here that needs a real QAction!
+
+ // Get the index for the action
+ int index = d->actions.indexOf(action);
+
+ // Action not found.
+ if (index==-1) return;
+
+ // Remove the action
+ d->actions.takeAt(index);
+ }
+
+
KActionCategoryPrivate::KActionCategoryPrivate( KActionCategory *host )
: q(host)
{}
--- trunk/KDE/kdelibs/kdeui/actions/kactioncategory.h #861360:861361
@@ -66,6 +66,11 @@
* The usage is analog to action collections. Just create a category and use
* it instead of the collection to create the actions.
*
+ * The synchronization between KActionCollection and KActionCategory is done
+ * internally. There is for example no need to remove actions from a category.
+ * It is done implicitely if the action is removed from the associated
+ * collection.
+ *
* \code
*
* KActionCategory *file = KActionCategory(i18n("File"), actionCollection())
@@ -105,9 +110,9 @@
virtual ~KActionCategory();
/**
- * \group Adding Actions
+ * \name Adding Actions
*
- * Add a actions to the category.
+ * Add a action to the category.
*
* This methods are provided for your convenience. They call the
* corresponding method of KActionCollection.
@@ -168,6 +173,14 @@
private:
+ /**
+ * Remove \action from this category if found.
+ */
+ void unlistAction(QAction *action);
+
+ //! KActionCollection needs access to some of our helper methods
+ friend class KActionCollectionPrivate;
+
//! Implementation details
KActionCategoryPrivate *d;
};
--- trunk/KDE/kdelibs/kdeui/actions/kactioncollection.cpp #861360:861361
@@ -25,6 +25,7 @@
*/
#include "kactioncollection.h"
+#include "kactioncategory.h"
#include <kauthorized.h>
#include "kxmlguiclient.h"
#include "kxmlguifactory.h"
@@ -243,16 +244,21 @@
action->blockSignals(true);
}
+ // Check if we have another action under this name
if (QAction *oldAction = d->actionByName.value(index_name)) {
takeAction(oldAction);
}
+
+ // Check if we have this action under a different name.
takeAction(action);
- // really insert action
+
+ // Add action to our lists.
d->actionByName.insert(index_name, action);
d->actions.append(action);
- foreach (QWidget* widget, d->associatedWidgets)
+ foreach (QWidget* widget, d->associatedWidgets) {
widget->addAction(action);
+ }
connect(action, SIGNAL(destroyed(QObject*)), SLOT(_k_actionDestroyed(QObject*)));
@@ -676,6 +682,12 @@
actionByName.remove(name);
actions.takeAt(index);
+ // Remove the action from the categories. Should be only one
+ QList<KActionCategory*> categories = q->findChildren<KActionCategory*>();
+ foreach (KActionCategory *category, categories) {
+ category->unlistAction(action);
+ }
+
return action;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic