[rkward-cvs] [rkward] rkward: Change RKComponentMap API a bit so that we can create temporary instances (for showing the menu-structure of plugins contained in a .pluginmap)
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Dec 9 18:45:05 UTC 2014
Git commit d42907dd6f3a81f80aa0c3e05b668319b44bd592 by Thomas Friedrichsmeier.
Committed on 09/12/2014 at 18:10.
Pushed by tfry into branch 'master'.
Change RKComponentMap API a bit so that we can create temporary instances (for showing the menu-structure of plugins contained in a .pluginmap)
M +4 -16 rkward/plugin/rkcomponentmap.cpp
M +6 -6 rkward/plugin/rkcomponentmap.h
M +2 -2 rkward/rkward.cpp
http://commits.kde.org/rkward/d42907dd6f3a81f80aa0c3e05b668319b44bd592
diff --git a/rkward/plugin/rkcomponentmap.cpp b/rkward/plugin/rkcomponentmap.cpp
index bbb5cd0..fd70859 100644
--- a/rkward/plugin/rkcomponentmap.cpp
+++ b/rkward/plugin/rkcomponentmap.cpp
@@ -234,10 +234,10 @@ RKComponentMap::RKComponentMap () : QObject (), RKComponentGUIXML (), KXMLGUICli
RKComponentMap::~RKComponentMap () {
RK_TRACE (PLUGIN);
- clearLocal ();
+ clearAll ();
}
-void RKComponentMap::clearLocal () {
+void RKComponentMap::clearAll () {
RK_TRACE (PLUGIN);
actionCollection ()->clear ();
@@ -260,12 +260,6 @@ void RKComponentMap::clearLocal () {
setXMLGUIBuildDocument (gui_xml);
}
-void RKComponentMap::clearAll () {
- RK_TRACE (PLUGIN);
-
- getMap ()->clearLocal ();
-}
-
RKContextMap *RKComponentMap::getContext (const QString &id) {
RK_TRACE (PLUGIN);
@@ -403,12 +397,6 @@ void RKPluginMapParseResult::addAndPrintError (int level, const QString message)
RK_DEBUG (PLUGIN, level, qPrintable (message));
}
-RKPluginMapParseResult RKComponentMap::addPluginMap (const QString& plugin_map_file) {
- RK_TRACE (PLUGIN);
-
- return getMap()->addPluginMapLocal (plugin_map_file);
-}
-
void RKComponentMap::finalizeAll () {
RK_TRACE (PLUGIN);
@@ -420,7 +408,7 @@ void RKComponentMap::finalizeAll () {
}
}
-RKPluginMapParseResult RKComponentMap::addPluginMapLocal (const QString& plugin_map_file) {
+RKPluginMapParseResult RKComponentMap::addPluginMap (const QString& plugin_map_file) {
RK_TRACE (PLUGIN);
RKPluginMapParseResult ret;
@@ -490,7 +478,7 @@ RKPluginMapParseResult RKComponentMap::addPluginMapLocal (const QString& plugin_
}
}
for (QStringList::const_iterator it = includelist.constBegin (); it != includelist.constEnd (); ++it) {
- ret.add (addPluginMapLocal (*it));
+ ret.add (addPluginMap (*it));
}
// step 2: create (list of) components
diff --git a/rkward/plugin/rkcomponentmap.h b/rkward/plugin/rkcomponentmap.h
index 79181d7..ab2054d 100644
--- a/rkward/plugin/rkcomponentmap.h
+++ b/rkward/plugin/rkcomponentmap.h
@@ -163,12 +163,15 @@ public:
int valid_plugins;
};
-/** This class (only a single instance should ever be needed) keeps a list of named components, which can be made accessible via the menu-structure
+/** This class keeps a list of named components, which can be made accessible via the menu-structure
or included in other plugins. What this class does is rather simple: It basically maps a two piece name (namespace, component name) to a short description of the component (RKComponentHandle). The most important part of that description is the filename where a more elaborate definition of
the component can be retrieved.
The RKComponentMap provides convenience functions for adding or removing a .pluginmap-file to/from the list of components, and looking up RKComponentHandle for a given component name.
+Usually there is exactly one instance of this class, accessible with RKComonentMap::getMain(), and some other static functions. However, temporary instances can be created for parsing
+individual .pluginmap files in order to list / display the plugins contained in these.
+
@author Thomas Friedrichsmeier
*/
class RKComponentMap : public QObject, public RKComponentGUIXML, public KXMLGUIClient {
@@ -179,11 +182,11 @@ public:
/** adds all Plugins / components in a .pluginmap-file. Also takes care of creating the menu-items, etc.
@returns status info of number of plugins (i.e. stand-alone components/menu-entries) added successfully / failed */
- static RKPluginMapParseResult addPluginMap (const QString& plugin_map_file);
+ RKPluginMapParseResult addPluginMap (const QString& plugin_map_file);
void finalizeAll ();
/** clears out (and deletes) all components / plugins */
- static void clearAll ();
+ void clearAll ();
/** returns the component identified by id, 0 if not found */
static RKComponentHandle* getComponentHandle (const QString &id);
@@ -217,9 +220,6 @@ private:
RKComponentHandle* getComponentHandleLocal (const QString &id);
QString getComponentIdLocal (RKComponentHandle* component);
RKContextMap *getContextLocal (const QString &id);
- RKPluginMapParseResult addPluginMapLocal (const QString& plugin_map_file);
-
- void clearLocal ();
typedef QMap<QString, RKContextMap*> RKComponentContextMap;
RKComponentContextMap contexts;
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 7d901d0..fc6f567 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -289,7 +289,7 @@ void RKWardMainWindow::initPlugins (const QStringList &automatically_added) {
}
factory ()->removeClient (RKComponentMap::getMap ());
- RKComponentMap::clearAll ();
+ RKComponentMap::getMap ()->clearAll ();
QStringList completely_broken_maps;
QStringList completely_broken_maps_details;
@@ -297,7 +297,7 @@ void RKWardMainWindow::initPlugins (const QStringList &automatically_added) {
QStringList somewhat_broken_maps_details;
for (int i = 0; i < all_maps.size (); ++i) {
const QString &map = all_maps[i];
- RKPluginMapParseResult result = RKComponentMap::addPluginMap (map);
+ RKPluginMapParseResult result = RKComponentMap::getMap ()->addPluginMap (map);
if (!result.valid_plugins) {
RKSettingsModulePlugins::markPluginMapAsBroken (map);
completely_broken_maps.append (map);
More information about the rkward-tracker
mailing list