Commit 13a4a2ea authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Handle action signals from RKComponentMap, instead of RKComponentHandle's.

- No need to have create QObject for every single handle.
- Will allow better handling of conflicting components (such as resolving to the latest available version on activation).
parent 32c21fe7
......@@ -213,7 +213,6 @@ QVariant RKComponentBase::fetchValue (const QString &id, const int hint) {
if (ret.isEmpty ()) {
ret << "-" << "-";
}
RK_DEBUG (PLUGIN, DL_WARNING, "Labels for %s: %s", qPrintable (id), qPrintable (ret.join (":")));
return QVariant (ret);
}
QVariant val = prop->value (mod);
......
......@@ -223,7 +223,7 @@ void RKComponentMap::initialize () {
component_map = new RKComponentMap ();
}
RKComponentMap::RKComponentMap () : RKComponentGUIXML (), KXMLGUIClient () {
RKComponentMap::RKComponentMap () : QObject (), RKComponentGUIXML (), KXMLGUIClient () {
RK_TRACE (PLUGIN);
setComponentData (KGlobal::mainComponent ());
......@@ -558,12 +558,27 @@ RKPluginMapParseResult RKComponentMap::addPluginMapLocal (const QString& plugin_
return ret;
}
void RKComponentMap::activateComponent () {
RK_TRACE (PLUGIN);
if (!sender ()) {
RK_ASSERT (sender ());
return;
}
RKComponentHandle *handle = getComponentHandleLocal (sender ()->objectName ());
if (!handle) {
RK_ASSERT (handle);
return;
}
handle->invoke (0, 0);
}
void RKComponentMap::addedEntry (const QString &id, RKComponentHandle *handle) {
RK_TRACE (PLUGIN);
if (handle->isPlugin ()) {
handle->setAccessible (true);
KAction *action = actionCollection ()->addAction (id, handle, SLOT (activated()));
KAction *action = actionCollection ()->addAction (id, this, SLOT (activateComponent()));
action->setText (handle->getLabel ());
action->setShortcutConfigurable (true);
}
......@@ -574,7 +589,7 @@ void RKComponentMap::addedEntry (const QString &id, RKComponentHandle *handle) {
#include "rkstandardcomponent.h"
RKComponentHandle::RKComponentHandle (RKPluginMapFile *pluginmap, const QString &rel_filename, const QString &label, RKComponentType type) : QObject (RKWardMainWindow::getMain ()) {
RKComponentHandle::RKComponentHandle (RKPluginMapFile *pluginmap, const QString &rel_filename, const QString &label, RKComponentType type) {
RK_TRACE (PLUGIN);
RKComponentHandle::type = type;
......@@ -603,12 +618,6 @@ RKStandardComponent *RKComponentHandle::invoke (RKComponent *parent_component, Q
return (new RKStandardComponent (parent_component, parent_widget, getFilename (), this));
}
void RKComponentHandle::activated () {
RK_TRACE (PLUGIN);
invoke (0, 0);
}
QString RKComponentHandle::getAttributeValue (const QString &attribute_id) {
RK_TRACE (PLUGIN);
......
......@@ -63,8 +63,7 @@ class KActionCollection;
@author Thomas Friedrichsmeier
*/
class RKComponentHandle : public QObject {
Q_OBJECT
class RKComponentHandle {
public:
RKComponentHandle (RKPluginMapFile *pluginmap, const QString &rel_filename, const QString &label, RKComponentType type);
virtual ~RKComponentHandle ();
......@@ -89,9 +88,6 @@ public:
/** Returns whether this component is accessible from the menu, somewhere (else it might be in a context) */
bool isAccessible () const { return is_accessible; };
const RKMessageCatalog *messageCatalog () const { return plugin_map->messageCatalog (); };
public slots:
/** Slot called, when the menu-item for this component is selected. Responsible for creating the GUI. */
void activated ();
protected:
/** The plugin map where this component was declared */
RKPluginMapFile *plugin_map;
......@@ -175,10 +171,10 @@ The RKComponentMap provides convenience functions for adding or removing a .plug
@author Thomas Friedrichsmeier
*/
class RKComponentMap : public RKComponentGUIXML, public KXMLGUIClient {
class RKComponentMap : public QObject, public RKComponentGUIXML, public KXMLGUIClient {
Q_OBJECT
public:
RKComponentMap ();
~RKComponentMap ();
/** adds all Plugins / components in a .pluginmap-file. Also takes care of creating the menu-items, etc.
......@@ -209,6 +205,9 @@ public:
/** @returns a list of all currently registered component ids */
QStringList allComponentIds () { return components.keys(); };
bool isPluginMapLoaded (const QString& abs_filename) { return pluginmapfiles.contains (abs_filename); };
public slots:
/** Slot called, when a menu-item for a component is selected. Responsible for creating the GUI. */
void activateComponent ();
private:
/** typedef for easy reference to iterator */
typedef QMap<QString, RKComponentHandle*> ComponentMap;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment