[rkward-cvs] SF.net SVN: rkward-code:[4925] trunk/rkward
tfry at users.sf.net
tfry at users.sf.net
Fri Oct 17 16:55:49 UTC 2014
Revision: 4925
http://sourceforge.net/p/rkward/code/4925
Author: tfry
Date: 2014-10-17 16:55:48 +0000 (Fri, 17 Oct 2014)
Log Message:
-----------
Instead of using one global XMLHelper object, for most things, use separate instances for each (standard-)component.
This is somewhat less messy, but importantly, it will allow to keep information on which message catalog to use
in the XMLHelper instance.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/misc/xmlhelper.cpp
trunk/rkward/rkward/misc/xmlhelper.h
trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
trunk/rkward/rkward/plugin/rkcheckbox.cpp
trunk/rkward/rkward/plugin/rkcomponent.cpp
trunk/rkward/rkward/plugin/rkcomponent.h
trunk/rkward/rkward/plugin/rkcomponentcontext.cpp
trunk/rkward/rkward/plugin/rkcomponentcontext.h
trunk/rkward/rkward/plugin/rkcomponentmap.cpp
trunk/rkward/rkward/plugin/rkcomponentmap.h
trunk/rkward/rkward/plugin/rkcomponentmeta.cpp
trunk/rkward/rkward/plugin/rkcomponentmeta.h
trunk/rkward/rkward/plugin/rkdropdown.cpp
trunk/rkward/rkward/plugin/rkformula.cpp
trunk/rkward/rkward/plugin/rkinput.cpp
trunk/rkward/rkward/plugin/rkmatrixinput.cpp
trunk/rkward/rkward/plugin/rkoptionset.cpp
trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
trunk/rkward/rkward/plugin/rkpluginframe.cpp
trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp
trunk/rkward/rkward/plugin/rkpluginspinbox.cpp
trunk/rkward/rkward/plugin/rkpreviewbox.cpp
trunk/rkward/rkward/plugin/rkradio.cpp
trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
trunk/rkward/rkward/plugin/rkstandardcomponent.h
trunk/rkward/rkward/plugin/rktabpage.cpp
trunk/rkward/rkward/plugin/rktext.cpp
trunk/rkward/rkward/plugin/rkvalueselector.cpp
trunk/rkward/rkward/plugin/rkvarslot.cpp
trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
Property Changed:
----------------
trunk/rkward/
Index: trunk/rkward
===================================================================
--- trunk/rkward 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward 2014-10-17 16:55:48 UTC (rev 4925)
Property changes on: trunk/rkward
___________________________________________________________________
Modified: svn:mergeinfo
## -3,4 +3,4 ##
/branches/release_branch_0.5.4:3098-3102,3127
/branches/release_branch_0.5.7:3913,3979-3980,3998
/branches/release_branches/rkward_0.6.1:4649-4650
-/branches/release_branches/rkward_0.6.2:4914
+/branches/release_branches/rkward_0.6.2:4914,4921
\ No newline at end of property
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/ChangeLog 2014-10-17 16:55:48 UTC (rev 4925)
@@ -1,3 +1,4 @@
+- Fixed some erroneous plugin debug messages
- IN PROGESS: Allow plugins to be translated
--- Version 0.6.2 - Oct-20-2014
Modified: trunk/rkward/rkward/misc/xmlhelper.cpp
===================================================================
--- trunk/rkward/rkward/misc/xmlhelper.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/misc/xmlhelper.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -27,27 +27,15 @@
#include "../debug.h"
-//static
-XMLHelper *XMLHelper::static_xml_helper=0;
-
-XMLHelper::XMLHelper () {
+XMLHelper::XMLHelper (const QString &filename) {
RK_TRACE (XML);
+ XMLHelper::filename = filename;
}
XMLHelper::~XMLHelper () {
RK_TRACE (XML);
}
-//static
-XMLHelper *XMLHelper::getStaticHelper () {
- RK_TRACE (XML);
-
- if (!static_xml_helper) {
- static_xml_helper = new XMLHelper ();
- }
- return static_xml_helper;
-}
-
QDomElement XMLHelper::openXMLFile (const QString &filename, int debug_level, bool with_includes, bool with_snippets) {
RK_TRACE (XML);
Modified: trunk/rkward/rkward/misc/xmlhelper.h
===================================================================
--- trunk/rkward/rkward/misc/xmlhelper.h 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/misc/xmlhelper.h 2014-10-17 16:55:48 UTC (rev 4925)
@@ -37,8 +37,8 @@
*/
class XMLHelper {
public:
-/** create an instance of XMLHelper. Usually you will use the instance returned by getStaticHelper () instead of creating a new instance. */
- XMLHelper ();
+/** create an instance of XMLHelper. */
+ XMLHelper (const QString &filename=QString ());
/** destrcutor */
~XMLHelper ();
@@ -46,8 +46,8 @@
When calling this function, highestError () will be reset to 0.
@param filename the name of the file to parse
@param debug_level level of debug message to generate if opening/parsing fails
- at param with_includes should be helper take care of resolving "include" elements?
- at param with_snippets should be helper take care of resolving "insert" elements?
+ at param with_includes should the helper take care of resolving "include" elements?
+ at param with_snippets should the helper take care of resolving "insert" elements?
@returns the document-element of the file. */
QDomElement openXMLFile (const QString &filename, int debug_level, bool with_includes=true, bool with_snippets=true);
@@ -141,13 +141,10 @@
@param message_level sometime you may want to make sure your message is being shown even if it is not very important to your code. For instance, if there is a typo/illegal value in an optional setting, your code can continue using a reasonable default, but the user should still be notified of this error. If you omit this parameter or set it to something smaller that debug_level, debug_level will be used instead. */
void displayError (const QDomNode *in_node, const QString &message, int debug_level, int message_level=-1);
-/** @returns a pointer to the default instance of XMLHelper (if none has been created so far, this will happen automatically. */
- static XMLHelper *getStaticHelper ();
private:
/** copy the node list into a child list. The main effect is that a child list is not updated according to document changes */
XMLChildList nodeListToChildList (const QDomNodeList &from);
void replaceWithChildren (QDomNode *replaced, const QDomElement &replacement_parent);
- static XMLHelper *static_xml_helper;
QString filename;
};
Modified: trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -45,7 +45,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parentComponent ()->xmlHelper ();
// create all the options
XMLChildList option_elements = xml->getChildElements (element, "option", DL_ERROR);
@@ -119,6 +119,11 @@
}
if (new_id < 0) {
RK_DEBUG (PLUGIN, DL_ERROR, "option selector '%s' has no such option:", qPrintable (getIdInParent ()));
+/* RKComponent *p = this;
+ while (p) {
+ qDebug ("p: %s", qPrintable (p->getIdInParent ()));
+ p = p->parentComponent();
+ } */
if (property == string) {
RK_DEBUG (PLUGIN, DL_ERROR, "'%s'", qPrintable (fetchStringValue (string)));
} else {
Modified: trunk/rkward/rkward/plugin/rkcheckbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcheckbox.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcheckbox.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -27,7 +27,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create and add property
addChild ("state", state = new RKComponentPropertyBool (this, true, xml->getBoolAttribute (element, "checked", false, DL_INFO), xml->getStringAttribute (element, "value", "1", DL_INFO), xml->getStringAttribute (element, "value_unchecked", QString::null, DL_INFO)));
Modified: trunk/rkward/rkward/plugin/rkcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponent.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -369,10 +369,10 @@
emit (componentChanged (this));
}
-RKStandardComponent *RKComponent::standardComponent (QString *id_adjust) {
+RKStandardComponent *RKComponent::standardComponent (QString *id_adjust) const {
RK_TRACE (PLUGIN);
- RKComponent *p = this;
+ RKComponent *p = const_cast<RKComponent*> (this);
while (p) {
if (p->type () == RKComponent::ComponentStandard) return static_cast<RKStandardComponent*> (p);
if (id_adjust) id_adjust->prepend (p->getIdInParent () + '.');
@@ -393,6 +393,13 @@
return 0;
}
+XMLHelper* RKComponent::xmlHelper () const {
+ RK_TRACE (PLUGIN);
+
+ RKStandardComponent *sc = standardComponent ();
+ return sc->getXmlHelper ();
+}
+
void RKComponent::removeFromParent () {
RK_TRACE (PLUGIN);
Modified: trunk/rkward/rkward/plugin/rkcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.h 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponent.h 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkcomponent - description
-------------------
begin : Tue Dec 13 2005
- copyright : (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -154,6 +154,7 @@
#include "rkcomponentproperties.h"
+class XMLHelper;
/** abstract base class of all RKComponents, including component widgets */
class RKComponent : public QWidget, public RKComponentBase {
Q_OBJECT
@@ -203,9 +204,11 @@
/** The parent of this component. Should be notified, whenever isSatisfied () or recursiveStatus () changed. */
RKComponent *parentComponent () const { return _parent; };
/** The standard component containing this component (if any). If @param id_adjust is given, it will be set to a relative path to the standard component. */
- RKStandardComponent *standardComponent (QString *id_adjust=0);
+ RKStandardComponent *standardComponent (QString *id_adjust=0) const;
/** Like standardcomponent, but will return the topmost component in case of embedding. */
RKStandardComponent *topmostStandardComponent ();
+/** Return a properly initialize helper for parsing XML in this component. */
+ XMLHelper *xmlHelper () const;
/** Find the id of this component. NOTE: this is slow. Better to store the id in the first place, if needed */
QString getIdInParent () const;
Modified: trunk/rkward/rkward/plugin/rkcomponentcontext.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentcontext.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponentcontext.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkcomponentcontext - description
-------------------
begin : Mon Jan 22 2007
- copyright : (C) 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -35,12 +35,11 @@
RK_TRACE (PLUGIN);
}
-int RKContextMap::create (const QDomElement &context_element, const QString &component_namespace) {
+int RKContextMap::create (const QDomElement &context_element, XMLHelper &xml, const QString &component_namespace) {
RK_TRACE (PLUGIN);
- XMLHelper *xml = XMLHelper::getStaticHelper ();
- QDomElement element = xml->getChildElement (gui_xml.documentElement (), "MenuBar", DL_ERROR);
- return (createMenus (element, context_element, component_namespace));
+ QDomElement element = xml.getChildElement (gui_xml.documentElement (), "MenuBar", DL_ERROR);
+ return (createMenus (element, xml, context_element, component_namespace));
}
RKContextHandler *RKContextMap::makeContextHandler (QObject *parent, bool create_actions) {
Modified: trunk/rkward/rkward/plugin/rkcomponentcontext.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentcontext.h 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponentcontext.h 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkcomponentcontext - description
-------------------
begin : Mon Jan 22 2007
- copyright : (C) 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -25,6 +25,7 @@
class QDomElement;
class RKContextHandler;
+class XMLHelper;
/** This class keeps a list of components that are useable in a certain context (e.g. x11 device). It also keeps a description of the menu structure(s) that should be used for that context. Note that in order to use the XML-GUI, you should create an RKContextHandler using makeContextHandler().
@@ -38,7 +39,7 @@
/** destructor */
~RKContextMap ();
/** A menu entries to the context map from a .pluginmap file */
- int create (const QDomElement &context_element, const QString &component_namespace);
+ int create (const QDomElement &context_element, XMLHelper &xml, const QString &component_namespace);
/** Create a context handler for this context. */
RKContextHandler *makeContextHandler (QObject *parent, bool create_actions=true);
QStringList components () { return component_ids; };
Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -40,11 +40,10 @@
return QDir::cleanPath (QDir (basedir).filePath (filename));
}
-QString RKPluginMapFile::parseId (const QDomElement& e) {
+QString RKPluginMapFile::parseId (const QDomElement& e, XMLHelper &xml) {
RK_TRACE (PLUGIN);
- XMLHelper *xml = XMLHelper::getStaticHelper ();
- return (xml->getStringAttribute (e, "namespace", "rkward", DL_WARNING) + "::" + xml->getStringAttribute (e, "id", QString (), DL_INFO));
+ return (xml.getStringAttribute (e, "namespace", "rkward", DL_WARNING) + "::" + xml.getStringAttribute (e, "id", QString (), DL_INFO));
}
@@ -64,30 +63,28 @@
gui_xml.setContent (QString ("<!DOCTYPE kpartgui>\n<kpartgui name=\"rkwardcomponents\" version=\"0.3.4\">\n<MenuBar>\n\n</MenuBar>\n</kpartgui>"));
}
-int RKComponentGUIXML::createMenus (QDomElement& parent, const QDomElement& hierarchy_description, const QString& cnamespace) {
+int RKComponentGUIXML::createMenus (QDomElement& parent, XMLHelper &xml, const QDomElement& hierarchy_description, const QString& cnamespace) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
- XMLChildList list = xml->getChildElements (hierarchy_description, "menu", DL_INFO);
+ XMLChildList list = xml.getChildElements (hierarchy_description, "menu", DL_INFO);
int counter = 0;
for (XMLChildList::const_iterator it=list.begin (); it != list.end (); ++it) {
- counter += addSubMenu (parent, (*it), cnamespace);
+ counter += addSubMenu (parent, xml, (*it), cnamespace);
}
return counter;
}
-QDomElement RKComponentGUIXML::findOrCreateElement (QDomElement& parent, const QString& tagname, const QString& name, const QString& label, int index) {
+QDomElement RKComponentGUIXML::findOrCreateElement (QDomElement& parent, XMLHelper &xml, const QString& tagname, const QString& name, const QString& label, int index) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
- XMLChildList list = xml->getChildElements (parent, QString::null, DL_INFO); // we need to look at all children, so we get the order right
+ XMLChildList list = xml.getChildElements (parent, QString::null, DL_INFO); // we need to look at all children, so we get the order right
QDomElement insert_after_element;
for (XMLChildList::const_iterator it=list.begin (); it != list.end (); ++it) {
- if ((tagname == (*it).tagName ()) && (name == xml->getStringAttribute ((*it), "name", "", DL_ERROR))) {
+ if ((tagname == (*it).tagName ()) && (name == xml.getStringAttribute ((*it), "name", "", DL_ERROR))) {
return (*it);
} else {
if (index >= 0) {
- if (index > xml->getIntAttribute ((*it), "index", -1, DL_INFO)) {
+ if (index > xml.getIntAttribute ((*it), "index", -1, DL_INFO)) {
insert_after_element = *it;
}
}
@@ -108,31 +105,30 @@
return ret;
}
-int RKComponentGUIXML::addSubMenu (QDomElement& parent, const QDomElement& description, const QString& cnamespace) {
+int RKComponentGUIXML::addSubMenu (QDomElement& parent, XMLHelper &xml, const QDomElement& description, const QString& cnamespace) {
RK_TRACE (PLUGIN);
int counter = 0;
- XMLHelper* xml = XMLHelper::getStaticHelper ();
// 1: check whether menu already exists, and create new menu otherwise
- QDomElement menu_element = findOrCreateElement (parent, "Menu", xml->getStringAttribute (description, "id", "none", DL_ERROR), xml->getStringAttribute (description, "label", i18n ("(no label)"), DL_WARNING), xml->getIntAttribute (description, "index", -1, DL_INFO));
+ QDomElement menu_element = findOrCreateElement (parent, xml, "Menu", xml.getStringAttribute (description, "id", "none", DL_ERROR), xml.getStringAttribute (description, "label", i18n ("(no label)"), DL_WARNING), xml.getIntAttribute (description, "index", -1, DL_INFO));
// 2: recurse into submenus (of element to add!)
- XMLChildList list = xml->getChildElements (description, "menu", DL_INFO);
+ XMLChildList list = xml.getChildElements (description, "menu", DL_INFO);
for (XMLChildList::const_iterator it=list.begin (); it != list.end (); ++it) {
- counter += addSubMenu (menu_element, (*it), cnamespace);
+ counter += addSubMenu (menu_element, xml, (*it), cnamespace);
}
// 3: add entries
- list = xml->getChildElements (description, "entry", DL_INFO);
+ list = xml.getChildElements (description, "entry", DL_INFO);
for (XMLChildList::const_iterator it=list.begin (); it != list.end (); ++it) {
- QString id = cnamespace + xml->getStringAttribute ((*it), "component", "#invalid#", DL_ERROR);
+ QString id = cnamespace + xml.getStringAttribute ((*it), "component", "#invalid#", DL_ERROR);
RKComponentHandle* handle = RKComponentMap::getComponentHandle (id);
if ((!handle) || (!handle->isPlugin ())) {
RK_DEBUG (PLUGIN, DL_ERROR, "No such component found while creating menu-entries or component is not a standalone plugin: \"%s\". No entry created.", id.toLatin1 ().data ());
} else {
- findOrCreateElement (menu_element, "Action", id, QString::null, xml->getIntAttribute ((*it), "index", -1, DL_INFO));
+ findOrCreateElement (menu_element, xml, "Action", id, QString::null, xml.getIntAttribute ((*it), "index", -1, DL_INFO));
addedEntry (id, handle);
counter++;
}
@@ -349,41 +345,41 @@
return ret;
}
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper xml (plugin_map_file_abs);
QDomElement element;
XMLChildList list;
- QDomElement document_element = xml->openXMLFile (plugin_map_file_abs, DL_ERROR);
+ QDomElement document_element = xml.openXMLFile (plugin_map_file_abs, DL_ERROR);
if (document_element.isNull ()) {
ret.addAndPrintError (DL_ERROR, i18n ("Could not open plugin map file %1. (Is not readble, or failed to parse)", plugin_map_file_abs));
return ret;
}
- QString prefix = QFileInfo (plugin_map_file_abs).absolutePath() + '/' + xml->getStringAttribute (document_element, "base_prefix", QString::null, DL_INFO);
- QString cnamespace = xml->getStringAttribute (document_element, "namespace", "rkward", DL_INFO) + "::";
+ QString prefix = QFileInfo (plugin_map_file_abs).absolutePath() + '/' + xml.getStringAttribute (document_element, "base_prefix", QString::null, DL_INFO);
+ QString cnamespace = xml.getStringAttribute (document_element, "namespace", "rkward", DL_INFO) + "::";
RKPluginMapFile *pluginmap_file_desc = new RKPluginMapFile (prefix);
- pluginmap_file_desc->id = RKPluginMapFile::parseId (document_element);
+ pluginmap_file_desc->id = RKPluginMapFile::parseId (document_element, xml);
pluginmapfiles.insert (QFileInfo (plugin_map_file).absoluteFilePath (), pluginmap_file_desc);
// step 0: check dependencies, parse about, and initialize
- QDomElement dependencies = xml->getChildElement (document_element, "dependencies", DL_INFO);
+ QDomElement dependencies = xml.getChildElement (document_element, "dependencies", DL_INFO);
if (!dependencies.isNull ()) {
if (!RKComponentDependency::isRKWardVersionCompatible (dependencies)) {
ret.addAndPrintError (DL_WARNING, i18n ("Skipping plugin map file '%1': Not compatible with this version of RKWard", plugin_map_file_abs));
return ret;
}
- pluginmap_file_desc->dependencies = RKComponentDependency::parseDependencies (dependencies);
+ pluginmap_file_desc->dependencies = RKComponentDependency::parseDependencies (dependencies, xml);
}
// step 1: include required files
QStringList includelist;
- list = xml->getChildElements (document_element, "require", DL_INFO);
+ list = xml.getChildElements (document_element, "require", DL_INFO);
for (XMLChildList::const_iterator it=list.constBegin (); it != list.constEnd (); ++it) {
if ((*it).hasAttribute ("file")) {
- QString file = pluginmap_file_desc->makeFileName (xml->getStringAttribute (*it, "file", QString (), DL_ERROR));
+ QString file = pluginmap_file_desc->makeFileName (xml.getStringAttribute (*it, "file", QString (), DL_ERROR));
/// EXPERIMENTAL: Look for localized version of required pluginmap
- if (xml->getBoolAttribute (*it, "localized", false, DL_INFO)) {
+ if (xml.getBoolAttribute (*it, "localized", false, DL_INFO)) {
QFileInfo fi(file);
QDir dir = fi.absoluteDir ();
QString fn = fi.fileName ();
@@ -423,7 +419,7 @@
ret.addAndPrintError (DL_ERROR, i18n ("Specified required file '%1' does not exist or is not readable. Ignoring.", file));
}
} else {
- QString map_id = xml->getStringAttribute (*it, "map", QString (), DL_ERROR);
+ QString map_id = xml.getStringAttribute (*it, "map", QString (), DL_ERROR);
// Try to locate the map among the already loaded files, first
QString file;
for (PluginMapFileMap::const_iterator pmit = pluginmapfiles.constBegin (); pmit != pluginmapfiles.constEnd (); ++pmit) {
@@ -447,18 +443,18 @@
}
// step 2: create (list of) components
- element = xml->getChildElement (document_element, "components", DL_INFO);
- list = xml->getChildElements (element, "component", DL_INFO);
+ element = xml.getChildElement (document_element, "components", DL_INFO);
+ list = xml.getChildElements (element, "component", DL_INFO);
// Plugins that depend on a specific version of RKWard can be specified in several alternative version.
// It is not an error, unless *none* of the specified alternatives can be loaded.
QSet<QString> local_components;
QSet<QString> depfailed_local_components;
for (XMLChildList::const_iterator it=list.begin (); it != list.end (); ++it) {
- QString id = cnamespace + xml->getStringAttribute((*it), "id", QString::null, DL_WARNING);
+ QString id = cnamespace + xml.getStringAttribute((*it), "id", QString::null, DL_WARNING);
// check dependencies, first
- QDomElement cdependencies = xml->getChildElement (*it, "dependencies", DL_INFO);
+ QDomElement cdependencies = xml.getChildElement (*it, "dependencies", DL_INFO);
if (!cdependencies.isNull ()) {
if (!RKComponentDependency::isRKWardVersionCompatible (cdependencies)) {
RK_DEBUG (PLUGIN, DL_INFO, "Skipping component '%1': Not compatible with this version of RKWard", qPrintable (id));
@@ -467,9 +463,9 @@
}
}
- QString filename = xml->getStringAttribute((*it), "file", QString::null, DL_WARNING);
- int type = xml->getMultiChoiceAttribute ((*it), "type", "standard", 0, DL_WARNING);
- QString label = xml->getStringAttribute ((*it), "label", i18n ("(no label)"), DL_WARNING);
+ QString filename = xml.getStringAttribute((*it), "file", QString (), DL_WARNING);
+ int type = xml.getMultiChoiceAttribute ((*it), "type", "standard", 0, DL_WARNING);
+ QString label = xml.getStringAttribute ((*it), "label", i18n ("(no label)"), DL_WARNING);
if (components.contains (id)) {
ret.addAndPrintError (DL_WARNING, i18n ("RKComponentMap already contains a component with id \"%1\". Ignoring second entry.", id));
@@ -478,11 +474,11 @@
} else {
// create and initialize component handle
RKComponentHandle *handle = new RKComponentHandle (pluginmap_file_desc, filename, label, (RKComponentType) type);
- XMLChildList attributes_list = xml->getChildElements (*it, "attribute", DL_DEBUG);
+ XMLChildList attributes_list = xml.getChildElements (*it, "attribute", DL_DEBUG);
for (XMLChildList::const_iterator ait=attributes_list.begin (); ait != attributes_list.end (); ++ait) {
- handle->addAttribute (xml->getStringAttribute (*ait, "id", "noid", DL_WARNING), xml->getStringAttribute (*ait, "value", QString::null, DL_ERROR), xml->getStringAttribute (*ait, "label", QString::null, DL_ERROR));
+ handle->addAttribute (xml.getStringAttribute (*ait, "id", "noid", DL_WARNING), xml.getStringAttribute (*ait, "value", QString (), DL_ERROR), xml.getStringAttribute (*ait, "label", QString (), DL_ERROR));
}
- if (!cdependencies.isNull ()) handle->addDependencies (RKComponentDependency::parseDependencies (cdependencies));
+ if (!cdependencies.isNull ()) handle->addDependencies (RKComponentDependency::parseDependencies (cdependencies, xml));
components.insert (id, handle);
local_components.insert (id);
}
@@ -494,20 +490,20 @@
}
// step 3: create / insert into menus
- QDomElement xmlgui_menubar_element = xml->getChildElement (gui_xml.documentElement (), "MenuBar", DL_ERROR);
- ret.valid_plugins += createMenus (xmlgui_menubar_element, xml->getChildElement (document_element, "hierarchy", DL_INFO), cnamespace);
+ QDomElement xmlgui_menubar_element = xml.getChildElement (gui_xml.documentElement (), "MenuBar", DL_ERROR);
+ ret.valid_plugins += createMenus (xmlgui_menubar_element, xml, xml.getChildElement (document_element, "hierarchy", DL_INFO), cnamespace);
// step 4: create and register contexts
- list = xml->getChildElements (document_element, "context", DL_INFO);
+ list = xml.getChildElements (document_element, "context", DL_INFO);
for (XMLChildList::const_iterator it=list.constBegin (); it != list.constEnd (); ++it) {
- QString id = xml->getStringAttribute (*it, "id", QString::null, DL_ERROR);
+ QString id = xml.getStringAttribute (*it, "id", QString::null, DL_ERROR);
RKContextMap *context = getContextLocal (id);
if (!context) {
context = new RKContextMap (id);
contexts.insert (id, context);
}
- ret.valid_plugins += context->create (*it, cnamespace);
+ ret.valid_plugins += context->create (*it, xml, cnamespace);
}
setXMLGUIBuildDocument (gui_xml); // TODO: Should be called only once, not for each pluginmap!
Modified: trunk/rkward/rkward/plugin/rkcomponentmap.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.h 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.h 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkcomponentmap.h - description
-------------------
begin : Thu May 12 2005
- copyright : (C) 2005-2013 by Thomas Friedrichsmeier
+ copyright : (C) 2005-2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -22,6 +22,7 @@
#include "rkcomponentmeta.h"
+class XMLHelper;
/** very simple helper class to keep track of .pluginmap files */
class RKPluginMapFile {
public:
@@ -31,7 +32,7 @@
QString getBaseDir () { return basedir; };
QString makeFileName (const QString &filename);
QList<RKComponentDependency> getDependencies () { return dependencies; };
- static QString parseId (const QDomElement &e);
+ static QString parseId (const QDomElement &e, XMLHelper &xml);
private:
friend class RKComponentMap;
QString basedir;
@@ -104,6 +105,7 @@
#include <kxmlguiclient.h>
class QDomElement;
+class XMLHelper;
/** This class keeps a QDomDocument that is a represenation of the GUI using KDEs XML-GUI format (a ui.rc). Use createMenus () to have it parse the menu descriptions from a .pluginmap file. It will adjust the XML description accordingly. When done, you can use to generated gui_xml to set it as the xmlGUIBuildDocument of a KXMLGUIClient.
@@ -123,13 +125,13 @@
@param parent the parent menu (or tag) (in the KXMLGUI)
@param hierarchy_description the QDomElement containing the description for the new menu hierarchy
@returns number of plugins/menu-entries added successfully */
- int createMenus (QDomElement& parent, const QDomElement& hierarchy_description, const QString& cnamespace);
+ int createMenus (QDomElement& parent, XMLHelper &xml, const QDomElement& hierarchy_description, const QString& cnamespace);
/** recurse into a lower menu-level
@param parent the parent menu (in the KXMLGUI)
@param description the QDomElement containing the description for the new submenu
@returns number of plugins/menu-entries added successfully */
- int addSubMenu (QDomElement& parent, const QDomElement& description, const QString& cnamespace);
+ int addSubMenu (QDomElement& parent, XMLHelper &xml, const QDomElement& description, const QString& cnamespace);
/** helper function: Find a specified element, and return it. If the element could not be found, it is created instead. The first three parameters are used as search parameters (all have to match). The additional two parameters only take effect, if a new element is created.
@param parent the QDomElement whose children to search through
@@ -137,7 +139,7 @@
@param name value of the "name"-attribute to look for
@param label the label to assign to the new element (if no existing match could be found)
@param index the index position where to insert the new element in the list of children (if no existing match could be found). -1 means insert at the end of the list. */
- QDomElement findOrCreateElement (QDomElement& parent, const QString& tagname, const QString& name, const QString& label, int index);
+ QDomElement findOrCreateElement (QDomElement& parent, XMLHelper &xml, const QString& tagname, const QString& name, const QString& label, int index);
/** an entry was added to the menu(s) somewhere. Reimplement, if you want to e.g. create a KAction for this */
virtual void addedEntry (const QString & /* id */, RKComponentHandle * /* handle */) {};
Modified: trunk/rkward/rkward/plugin/rkcomponentmeta.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmeta.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponentmeta.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkcomponentmeta - description
-------------------
begin : Wed Jan 09 2013
- copyright : (C) 2013 by Thomas Friedrichsmeier
+ copyright : (C) 2013, 2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -31,33 +31,32 @@
QLatin1String any_min_version_tag ("min_version");
QLatin1String any_max_version_tag ("max_version");
-RKComponentAboutData::RKComponentAboutData (const QDomElement& e) {
+RKComponentAboutData::RKComponentAboutData (const QDomElement& e, XMLHelper &xml) {
RK_TRACE (PLUGIN);
if (e.isNull ()) return;
- XMLHelper *xml = XMLHelper::getStaticHelper ();
- name = xml->getStringAttribute (e, "name", QString (), DL_INFO);
- version = xml->getStringAttribute (e, "version", QString (), DL_INFO);
- releasedate = xml->getStringAttribute (e, "releasedate", QString (), DL_INFO);
- shortinfo = xml->getStringAttribute (e, "shortinfo", QString (), DL_INFO);
- copyright = xml->getStringAttribute (e, "copyright", QString (), DL_INFO);
- license = xml->getStringAttribute (e, "license", QString (), DL_INFO);
- url = xml->getStringAttribute (e, "url", QString (), DL_INFO);
- category = xml->getStringAttribute (e, "category", i18n ("Unspecified"), DL_INFO);
+ name = xml.getStringAttribute (e, "name", QString (), DL_INFO);
+ version = xml.getStringAttribute (e, "version", QString (), DL_INFO);
+ releasedate = xml.getStringAttribute (e, "releasedate", QString (), DL_INFO);
+ shortinfo = xml.getStringAttribute (e, "shortinfo", QString (), DL_INFO);
+ copyright = xml.getStringAttribute (e, "copyright", QString (), DL_INFO);
+ license = xml.getStringAttribute (e, "license", QString (), DL_INFO);
+ url = xml.getStringAttribute (e, "url", QString (), DL_INFO);
+ category = xml.getStringAttribute (e, "category", i18n ("Unspecified"), DL_INFO);
- XMLChildList aes = xml->getChildElements (e, "author", DL_INFO);
+ XMLChildList aes = xml.getChildElements (e, "author", DL_INFO);
for (int i = 0; i < aes.size (); ++i) {
QDomElement ae = aes[i];
RKComponentAuthor author;
- author.name = xml->getStringAttribute (ae, "name", QString (), DL_INFO);
+ author.name = xml.getStringAttribute (ae, "name", QString (), DL_INFO);
if (author.name.isEmpty ()) {
- author.name = xml->getStringAttribute (ae, "given", QString (), DL_WARNING) + " " + xml->getStringAttribute (ae, "family", QString (), DL_WARNING);
+ author.name = xml.getStringAttribute (ae, "given", QString (), DL_WARNING) + " " + xml.getStringAttribute (ae, "family", QString (), DL_WARNING);
}
- if (author.name.isEmpty ()) xml->displayError (&ae, "No author name specified", DL_WARNING);
- author.roles = xml->getStringAttribute (ae, "role", QString (), DL_INFO);
- author.email = xml->getStringAttribute (ae, "email", QString (), DL_WARNING);
- author.url = xml->getStringAttribute (ae, "url", QString (), DL_INFO);
+ if (author.name.isEmpty ()) xml.displayError (&ae, "No author name specified", DL_WARNING);
+ author.roles = xml.getStringAttribute (ae, "role", QString (), DL_INFO);
+ author.email = xml.getStringAttribute (ae, "email", QString (), DL_WARNING);
+ author.url = xml.getStringAttribute (ae, "url", QString (), DL_INFO);
authors.append (author);
}
}
@@ -120,12 +119,11 @@
return true;
}
-QList <RKComponentDependency> RKComponentDependency::parseDependencies (const QDomElement& e) {
+QList <RKComponentDependency> RKComponentDependency::parseDependencies (const QDomElement& e, XMLHelper &xml) {
RK_TRACE (PLUGIN);
QList<RKComponentDependency> ret;
if (e.isNull ()) return ret;
- XMLHelper *xml = XMLHelper::getStaticHelper ();
RKComponentDependency dep;
// Check for R dependency, first.
@@ -134,20 +132,20 @@
if (e.hasAttribute (R_max_version_tag)) dep.max_version = RKSessionVars::parseVersionString (e.attribute (R_max_version_tag), 0);
if ((dep.min_version > 0) || (dep.max_version < 0xFFFFFFFF)) ret.append (dep);
- XMLChildList deps = xml->getChildElements (e, QString (), DL_INFO);
+ XMLChildList deps = xml.getChildElements (e, QString (), DL_INFO);
for (int i = 0; i < deps.size (); ++i) {
QDomElement dep_e = deps[i];
if (dep_e.tagName () == "package") {
dep.type = RKComponentDependency::RPackage;
- dep.source_info = xml->getStringAttribute (e, "repository", QString (), DL_INFO);
+ dep.source_info = xml.getStringAttribute (e, "repository", QString (), DL_INFO);
} else if (dep_e.tagName () == "pluginmap") {
dep.type = RKComponentDependency::RKWardPluginmap;
- dep.source_info = xml->getStringAttribute (e, "url", QString ("http://rkward.sf.net"), DL_WARNING);
+ dep.source_info = xml.getStringAttribute (e, "url", QString ("http://rkward.sf.net"), DL_WARNING);
} else {
RK_DEBUG (PLUGIN, DL_ERROR, "Tag <%s> is not allowed, here.", qPrintable (dep_e.tagName ()));
continue;
}
- dep.package = xml->getStringAttribute (dep_e, "name", QString (), DL_ERROR);
+ dep.package = xml.getStringAttribute (dep_e, "name", QString (), DL_ERROR);
dep.min_version = 0;
dep.max_version = 0xFFFFFFFF;
Modified: trunk/rkward/rkward/plugin/rkcomponentmeta.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmeta.h 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkcomponentmeta.h 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkcomponentmeta - description
-------------------
begin : Wed Jan 09 2013
- copyright : (C) 2013 by Thomas Friedrichsmeier
+ copyright : (C) 2013, 2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -21,6 +21,7 @@
#include <QDomElement>
#include <QList>
+class XMLHelper;
struct RKComponentDependency {
RKComponentDependency () : type (RBaseInstallation), min_version (0), max_version (0xFFFFFFFF) {};
QString toHtml () const;
@@ -37,7 +38,7 @@
quint32 min_version;
quint32 max_version;
- static QList<RKComponentDependency> parseDependencies (const QDomElement &e);
+ static QList<RKComponentDependency> parseDependencies (const QDomElement &e, XMLHelper &xml);
static bool isRKWardVersionCompatible (const QDomElement &e);
static bool isRVersionCompatible (const QDomElement &e);
};
@@ -51,7 +52,7 @@
class RKComponentAboutData {
public:
- RKComponentAboutData (const QDomElement &e);
+ RKComponentAboutData (const QDomElement &e, XMLHelper &xml);
~RKComponentAboutData ();
QString toHtml () const;
Modified: trunk/rkward/rkward/plugin/rkdropdown.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkdropdown.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkdropdown.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -33,7 +33,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create layout
QVBoxLayout *vbox = new QVBoxLayout (this);
Modified: trunk/rkward/rkward/plugin/rkformula.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkformula.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkformula.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -59,7 +59,7 @@
labels->setInternal (true);
// get xmlHelper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create layout
QVBoxLayout *vbox = new QVBoxLayout (this);
Modified: trunk/rkward/rkward/plugin/rkinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkinput.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkinput.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -35,7 +35,7 @@
lineedit = 0;
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create and add property
addChild ("text", text = new RKComponentPropertyBase (this, false));
Modified: trunk/rkward/rkward/plugin/rkmatrixinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -35,7 +35,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create layout
QVBoxLayout *vbox = new QVBoxLayout (this);
Modified: trunk/rkward/rkward/plugin/rkoptionset.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkoptionset.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -39,7 +39,7 @@
RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
updating = false;
last_known_status = Processing;
n_invalid_rows = n_unfinished_rows = 0;
@@ -80,8 +80,8 @@
contents_container = new RKComponent (this, user_area);
QDomElement content_element = xml->getChildElement (element, "content", DL_ERROR);
RKComponentBuilder *builder = new RKComponentBuilder (contents_container, content_element);
- builder->buildElement (content_element, user_area, false); // NOTE that parent widget != parent component, here, by intention. The point is that the display should not be disabled along with the contents
- builder->parseLogic (xml->getChildElement (element, "logic", DL_INFO), false);
+ builder->buildElement (content_element, *xml, user_area, false); // NOTE that parent widget != parent component, here, by intention. The point is that the display should not be disabled along with the contents
+ builder->parseLogic (xml->getChildElement (element, "logic", DL_INFO), *xml, false);
builder->makeConnections ();
addChild ("contents", contents_container);
connect (standardComponent (), SIGNAL (standardInitializationComplete()), this, SLOT (fetchDefaults()));
Modified: trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginbrowser.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkpluginbrowser.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -30,7 +30,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create and add property
addChild ("selection", selection = new RKComponentPropertyBase (this, true));
Modified: trunk/rkward/rkward/plugin/rkpluginframe.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginframe.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkpluginframe.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -29,7 +29,7 @@
RKPluginFrame::RKPluginFrame (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper* xml = parent_component->xmlHelper ();
QVBoxLayout *layout = new QVBoxLayout (this);
layout->setContentsMargins (0, 0, 0, 0);
Modified: trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -31,7 +31,7 @@
RK_TRACE (PLUGIN);
// read settings
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
bool checkable = xml->getBoolAttribute (element, "checkable", false, DL_INFO);
bool checked = xml->getBoolAttribute (element, "checked", false, DL_INFO);
Modified: trunk/rkward/rkward/plugin/rkpluginspinbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginspinbox.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkpluginspinbox.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -29,7 +29,7 @@
RKPluginSpinBox::RKPluginSpinBox (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// first question: int or real
intmode = (xml->getMultiChoiceAttribute (element, "type", "integer;real", 1, DL_INFO) == 0);
Modified: trunk/rkward/rkward/plugin/rkpreviewbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpreviewbox.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkpreviewbox.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -42,7 +42,7 @@
dev_num = 0;
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create and add property
addChild ("state", state = new RKComponentPropertyBool (this, true, preview_active, "active", "inactive"));
Modified: trunk/rkward/rkward/plugin/rkradio.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkradio.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkradio.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -34,7 +34,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create layout
QVBoxLayout *vbox = new QVBoxLayout (this);
Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -73,6 +73,7 @@
scripting = 0;
gui = 0;
wizard = 0;
+ xml = 0;
created = false;
killed = false;
addChild ("code", code = new RKComponentPropertyCode (this, true)); // do not change this name!
@@ -89,7 +90,7 @@
addChild ("current_dataframe", current_dataframe_property);
// open the main description file for parsing
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper* xml = getXmlHelper ();
QDomElement doc_element = xml->openXMLFile (filename, DL_ERROR);
if (doc_element.isNull ()) {
KMessageBox::error (this, i18n ("There has been an error while trying to parse the description of this plugin ('%1'). Please refer to stdout for details.", filename), i18n ("Could not create plugin"));
@@ -171,6 +172,7 @@
if (gui) delete gui; // NOTE: *NOT* using gui->deleteLater (). Destructing the GUI immediately is necessary to get rid of child components, immediately. Otherwise these could try to access their (destroyed) parent, e.g. if they have a timer running that gets triggered before the deletion event arrives.
if (backend) backend->destroy (); // it will self-destruct, when it has closed the process.
+ delete xml;
}
void RKStandardComponent::kill () {
@@ -219,10 +221,17 @@
gui->setWindowTitle (caption);
}
+XMLHelper* RKStandardComponent::getXmlHelper () {
+ RK_TRACE (PLUGIN);
+
+ if (!xml) xml = new XMLHelper (filename);
+ return xml;
+}
+
bool RKStandardComponent::createTopLevel (const QDomElement &doc_element, int force_mode, bool enslaved) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper* xml = getXmlHelper ();
bool build_wizard = false;
QDomElement dialog_element;
QDomElement wizard_element;
@@ -277,7 +286,7 @@
RK_ASSERT (gui); // this should only ever happen on top level
// open the main description file for parsing (again)
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper* xml = getXmlHelper ();
QDomElement doc_element = xml->openXMLFile (filename, DL_ERROR);
int force_mode = 2;
if (isWizardish ()) force_mode = 1;
@@ -324,14 +333,14 @@
void RKStandardComponent::buildAndInitialize (const QDomElement &doc_element, const QDomElement &gui_element, QWidget *parent_widget, bool build_wizard, bool enslaved) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper* xml = getXmlHelper ();
// create a builder
RKComponentBuilder *builder = new RKComponentBuilder (this, doc_element);
// go
- builder->buildElement (gui_element, parent_widget, build_wizard);
- builder->parseLogic (xml->getChildElement (doc_element, "logic", DL_INFO));
+ builder->buildElement (gui_element, *xml, parent_widget, build_wizard);
+ builder->parseLogic (xml->getChildElement (doc_element, "logic", DL_INFO), *xml);
setCaption (xml->getStringAttribute (gui_element, "label", QString::null, DL_WARNING));
// initialize
@@ -515,19 +524,18 @@
RK_TRACE (PLUGIN);
}
-QDomElement RKComponentBuilder::doElementCopy (const QString id, const QDomElement ©) {
+QDomElement RKComponentBuilder::doElementCopy (const QString id, XMLHelper &xml, const QDomElement ©) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
QDomElement res;
if (id.isEmpty ()) {
- xml->displayError (©, "no id given for copy element", DL_ERROR, DL_ERROR);
+ xml.displayError (©, "no id given for copy element", DL_ERROR, DL_ERROR);
return res; // null
}
// find matching element to copy from
- XMLChildList candidates = xml->findElementsWithAttribute (doc_elem, "id", id, true, DL_ERROR);
+ XMLChildList candidates = xml.findElementsWithAttribute (doc_elem, "id", id, true, DL_ERROR);
XMLChildList::const_iterator it;
for (it = candidates.constBegin (); it != candidates.constEnd (); ++it) {
if ((*it).tagName () == QLatin1String ("copy")) continue;
@@ -535,7 +543,7 @@
break;
}
if (res.isNull ()) {
- xml->displayError (©, "no matching element found to copy from", DL_ERROR, DL_ERROR);
+ xml.displayError (©, "no matching element found to copy from", DL_ERROR, DL_ERROR);
return res;
}
@@ -551,20 +559,19 @@
return res;
}
-void RKComponentBuilder::buildElement (const QDomElement &element, QWidget *parent_widget, bool allow_pages) {
+void RKComponentBuilder::buildElement (const QDomElement &element, XMLHelper &xml, QWidget *parent_widget, bool allow_pages) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
- XMLChildList children = xml->getChildElements (element, QString::null, DL_ERROR);
+ XMLChildList children = xml.getChildElements (element, QString::null, DL_ERROR);
XMLChildList::const_iterator it;
for (it = children.constBegin (); it != children.constEnd (); ++it) {
RKComponent *widget = 0;
QDomElement e = *it; // shorthand
- QString id = xml->getStringAttribute (e, "id", QString::null, DL_INFO);
+ QString id = xml.getStringAttribute (e, "id", QString::null, DL_INFO);
if (e.tagName () == QLatin1String ("copy")) {
- e = doElementCopy (id, e);
+ e = doElementCopy (id, xml, e);
} // no else, here. e may be changed to some entirely different element, now.
if (allow_pages && (e.tagName () == QLatin1String ("page"))) {
@@ -572,14 +579,14 @@
QVBoxLayout *layout = new QVBoxLayout (widget);
KVBox *box = new KVBox (widget);
layout->addWidget (box);
- buildElement (e, box, false);
+ buildElement (e, xml, box, false);
} else if (e.tagName () == QLatin1String ("row")) {
widget = new RKComponent (component (), parent_widget); // wrapping this (and column, below) inside an RKComponent has the benefit, that it can have an id, and hence can be set to visibile/hidden, enabled/disabled
QVBoxLayout *layout = new QVBoxLayout (widget);
layout->setContentsMargins (0, 0, 0, 0);
KHBox *box = new KHBox (widget);
layout->addWidget (box);
- buildElement (e, box, false);
+ buildElement (e, xml, box, false);
} else if (e.tagName () == QLatin1String ("stretch")) {
QWidget *stretch = new QWidget (parent_widget);
stretch->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
@@ -592,11 +599,11 @@
layout->setContentsMargins (0, 0, 0, 0);
KVBox *box = new KVBox (widget);
layout->addWidget (box);
- buildElement (e, box, false);
+ buildElement (e, xml, box, false);
} else if (e.tagName () == QLatin1String ("frame")) {
RKPluginFrame *frame = new RKPluginFrame (e, component (), parent_widget);
widget = frame;
- buildElement (e, frame->getPage (), false);
+ buildElement (e, xml, frame->getPage (), false);
} else if (e.tagName () == QLatin1String ("tabbook")) {
QTabWidget *tabbook = new QTabWidget (parent_widget);
QDomNodeList tabs = e.childNodes ();
@@ -604,8 +611,8 @@
QDomElement tab_e = tabs.item (t).toElement ();
if (tab_e.tagName () == QLatin1String ("tab")) {
RKTabPage *tabpage = new RKTabPage (tab_e, component (), tabbook);
- buildElement (tab_e, tabpage->getPage (), false);
- QString tab_id = xml->getStringAttribute (tab_e, "id", QString::null, DL_INFO);
+ buildElement (tab_e, xml, tabpage->getPage (), false);
+ QString tab_id = xml.getStringAttribute (tab_e, "id", QString::null, DL_INFO);
if (!tab_id.isNull ()) {
parent->addChild (tab_id, tabpage);
}
@@ -615,15 +622,15 @@
widget = new RKVarSelector (e, component (), parent_widget);
} else if ((e.tagName () == QLatin1String ("varslot")) || (e.tagName () == QLatin1String ("valueslot"))) {
widget = new RKVarSlot (e, component (), parent_widget);
- QString source = xml->getStringAttribute (e, "source_property", QString (), DL_INFO);
- if (source.isEmpty ()) source = xml->getStringAttribute (e, "source", "#noid#", DL_WARNING) + ".selected";
+ QString source = xml.getStringAttribute (e, "source_property", QString (), DL_INFO);
+ if (source.isEmpty ()) source = xml.getStringAttribute (e, "source", "#noid#", DL_WARNING) + ".selected";
addConnection (id, "source", source, QString (), false, e);
} else if ((e.tagName () == QLatin1String ("valueselector")) || (e.tagName () == QLatin1String ("select"))) {
widget = new RKValueSelector (e, component (), parent_widget);
} else if (e.tagName () == QLatin1String ("formula")) {
widget = new RKFormula (e, component (), parent_widget);
- addConnection (id, "dependent", xml->getStringAttribute (e, "dependent", "#noid#", DL_INFO), "available", false, e);
- addConnection (id, "fixed_factors", xml->getStringAttribute (e, "fixed_factors", "#noid#", DL_INFO), "available", false, e);
+ addConnection (id, "dependent", xml.getStringAttribute (e, "dependent", "#noid#", DL_INFO), "available", false, e);
+ addConnection (id, "fixed_factors", xml.getStringAttribute (e, "fixed_factors", "#noid#", DL_INFO), "available", false, e);
} else if (e.tagName () == QLatin1String ("radio")) {
widget = new RKRadio (e, component (), parent_widget);
} else if (e.tagName () == QLatin1String ("dropdown")) {
@@ -645,13 +652,13 @@
} else if (e.tagName () == QLatin1String ("saveobject")) {
widget = new RKPluginSaveObject (e, component (), parent_widget);
} else if (e.tagName () == QLatin1String ("embed")) {
- QString component_id = xml->getStringAttribute (e, "component", QString::null, DL_ERROR);
+ QString component_id = xml.getStringAttribute (e, "component", QString::null, DL_ERROR);
RKComponentHandle *handle = RKComponentMap::getComponentHandle (component_id);
if (handle) {
- if (xml->getBoolAttribute (e, "as_button", false, DL_INFO)) {
+ if (xml.getBoolAttribute (e, "as_button", false, DL_INFO)) {
RKStandardComponent* swidget = handle->invoke (component (), 0);
widget = swidget;
- QString dummy = xml->getStringAttribute (e, "label", "Options", DL_WARNING);
+ QString dummy = xml.getStringAttribute (e, "label", "Options", DL_WARNING);
swidget->setCaption (dummy);
// TODO we should use a specialized pushbutton, that changes color if the corresponding component is dissatisfied!
QPushButton *button = new QPushButton (dummy, parent_widget);
@@ -660,16 +667,16 @@
widget = handle->invoke (component (), parent_widget);
}
} else {
- xml->displayError (&e, QString ("Could not embed component '%1'. Not found").arg (component_id), DL_ERROR);
+ xml.displayError (&e, QString ("Could not embed component '%1'. Not found").arg (component_id), DL_ERROR);
}
} else if (e.tagName () == QLatin1String ("optionset")) {
widget = new RKOptionSet (e, component (), parent_widget);
} else if (e.tagName () == QLatin1String ("optiondisplay")) {
RKComponent *set = component ()->parentComponent ();
if (set->type () == RKComponentBase::ComponentOptionSet) {
- widget = static_cast<RKOptionSet *> (set)->createDisplay (xml->getBoolAttribute (e, "index", true, DL_INFO), parent_widget);
+ widget = static_cast<RKOptionSet *> (set)->createDisplay (xml.getBoolAttribute (e, "index", true, DL_INFO), parent_widget);
} else {
- xml->displayError (&e, QString ("optiondisplay element is not allowed outside of an optionset"), DL_ERROR);
+ xml.displayError (&e, QString ("optiondisplay element is not allowed outside of an optionset"), DL_ERROR);
}
} else if (e.tagName () == QLatin1String ("scriptable")) {
widget = new RKComponent (component (), parent_widget);
@@ -680,7 +687,7 @@
QString id_adjust;
parent->standardComponent (&id_adjust)->scriptingProxy ()->addScriptableWidget (id_adjust + id, widget);
} else {
- xml->displayError (&e, QString ("Invalid tagname '%1'").arg (e.tagName ()), DL_ERROR);
+ xml.displayError (&e, QString ("Invalid tagname '%1'").arg (e.tagName ()), DL_ERROR);
}
if (widget && (!(id.isNull ()))) {
@@ -689,43 +696,42 @@
}
}
-void RKComponentBuilder::parseLogic (const QDomElement &element, bool allow_script_tag) {
+void RKComponentBuilder::parseLogic (const QDomElement &element, XMLHelper &xml, bool allow_script_tag) {
RK_TRACE (PLUGIN);
if (element.isNull ()) return;
// find connect elements
- XMLHelper* xml = XMLHelper::getStaticHelper ();
- XMLChildList children = xml->getChildElements (element, "connect", DL_INFO);
+ XMLChildList children = xml.getChildElements (element, "connect", DL_INFO);
XMLChildList::const_iterator it;
for (it = children.constBegin (); it != children.constEnd (); ++it) {
- addConnection (xml->getStringAttribute (*it, "client", "#noid#", DL_WARNING), QString::null, xml->getStringAttribute (*it, "governor", "#noid#", DL_WARNING), QString::null, xml->getBoolAttribute (*it, "reconcile", false, DL_INFO), element);
+ addConnection (xml.getStringAttribute (*it, "client", "#noid#", DL_WARNING), QString::null, xml.getStringAttribute (*it, "governor", "#noid#", DL_WARNING), QString::null, xml.getBoolAttribute (*it, "reconcile", false, DL_INFO), element);
}
// find initialize elements
- children = xml->getChildElements (element, "set", DL_INFO);
+ children = xml.getChildElements (element, "set", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
- initial_values.insert (xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING), xml->getStringAttribute (*it, "to", "false", DL_WARNING));
+ initial_values.insert (xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING), xml.getStringAttribute (*it, "to", "false", DL_WARNING));
}
- children = xml->getChildElements (element, "dependency_check", DL_INFO);
+ children = xml.getChildElements (element, "dependency_check", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
RKComponentPropertyBool *dep = new RKComponentPropertyBool (component (), false);
dep->setInternal (true);
dep->setBoolValue (RKComponentDependency::isRKWardVersionCompatible (*it) && RKComponentDependency::isRVersionCompatible (*it));
- component ()->addChild (xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING), dep);
+ component ()->addChild (xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING), dep);
}
// find outside elements
- children = xml->getChildElements (element, "external", DL_INFO);
+ children = xml.getChildElements (element, "external", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
- QString id = xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING);
- RKComponentPropertyBase *prop = new RKComponentPropertyBase (component (), xml->getBoolAttribute (*it, "required", false, DL_INFO));
+ QString id = xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING);
+ RKComponentPropertyBase *prop = new RKComponentPropertyBase (component (), xml.getBoolAttribute (*it, "required", false, DL_INFO));
component ()->addChild (id, prop);
prop->setInternal (true);
component ()->connect (prop, SIGNAL (valueChanged (RKComponentPropertyBase *)), component (), SLOT (outsideValueChanged (RKComponentPropertyBase *)));
- QString dummy = xml->getStringAttribute (*it, "default", QString::null, DL_INFO);
+ QString dummy = xml.getStringAttribute (*it, "default", QString::null, DL_INFO);
if (!dummy.isNull ()) {
initial_values.insert (id, dummy);
}
@@ -734,45 +740,45 @@
// find convert elements
QMap<RKComponentPropertyBase*, QStringList> switch_convert_sources;
- children = xml->getChildElements (element, "convert", DL_INFO);
+ children = xml.getChildElements (element, "convert", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
RKComponentPropertyConvert *convert = new RKComponentPropertyConvert (component ());
convert->setInternal (true);
- QString id = xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING);
- int mode = xml->getMultiChoiceAttribute (*it, "mode", convert->convertModeOptionString (), 0, DL_WARNING);
+ QString id = xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING);
+ int mode = xml.getMultiChoiceAttribute (*it, "mode", convert->convertModeOptionString (), 0, DL_WARNING);
convert->setMode ((RKComponentPropertyConvert::ConvertMode) mode);
if ((mode == RKComponentPropertyConvert::Equals) || (mode == RKComponentPropertyConvert::NotEquals)) {
- convert->setStandard (xml->getStringAttribute (*it, "standard", QString::null, DL_WARNING));
+ convert->setStandard (xml.getStringAttribute (*it, "standard", QString::null, DL_WARNING));
} else if (mode == RKComponentPropertyConvert::Range) {
- convert->setRange (xml->getDoubleAttribute (*it, "min", -FLT_MAX, DL_INFO), xml->getDoubleAttribute (*it, "max", FLT_MAX, DL_INFO));
+ convert->setRange (xml.getDoubleAttribute (*it, "min", -FLT_MAX, DL_INFO), xml.getDoubleAttribute (*it, "max", FLT_MAX, DL_INFO));
}
- switch_convert_sources.insert (convert, xml->getStringAttribute (*it, "sources", QString::null, DL_WARNING).split (';'));
- convert->setRequireTrue (xml->getBoolAttribute (*it, "require_true", false, DL_INFO));
+ switch_convert_sources.insert (convert, xml.getStringAttribute (*it, "sources", QString::null, DL_WARNING).split (';'));
+ convert->setRequireTrue (xml.getBoolAttribute (*it, "require_true", false, DL_INFO));
component ()->addChild (id, convert);
}
// find switch elements
- children = xml->getChildElements (element, "switch", DL_INFO);
+ children = xml.getChildElements (element, "switch", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
- QDomElement t = xml->getChildElement (*it, "true", DL_INFO);
- QDomElement f = xml->getChildElement (*it, "false", DL_INFO);
+ QDomElement t = xml.getChildElement (*it, "true", DL_INFO);
+ QDomElement f = xml.getChildElement (*it, "false", DL_INFO);
if (t.isNull () != f.isNull ()) {
- xml->displayError (&(*it), "One of <true> / <false> was provided for boolean <switch>, but not the other. Skipping switch.", DL_ERROR);
+ xml.displayError (&(*it), "One of <true> / <false> was provided for boolean <switch>, but not the other. Skipping switch.", DL_ERROR);
continue;
}
- XMLChildList case_elems = xml->getChildElements (*it, "case", DL_INFO);
- QDomElement default_elem = xml->getChildElement (*it, "default", DL_INFO);
+ XMLChildList case_elems = xml.getChildElements (*it, "case", DL_INFO);
+ QDomElement default_elem = xml.getChildElement (*it, "default", DL_INFO);
if (!default_elem.isNull ()) case_elems.append (default_elem);
if (t.isNull ()) {
if (case_elems.isEmpty ()) {
- xml->displayError (&(*it), "Neither <true> / <false> nor <case> / <default> were provided. Skipping switch.", DL_ERROR);
+ xml.displayError (&(*it), "Neither <true> / <false> nor <case> / <default> were provided. Skipping switch.", DL_ERROR);
continue;
}
} else {
if (!case_elems.isEmpty ()) {
- xml->displayError (&(*it), "One <true> / <false> *or* <case> / <default> may be provided a <switch>. Proceeding with boolean switch.", DL_ERROR);
+ xml.displayError (&(*it), "One <true> / <false> *or* <case> / <default> may be provided a <switch>. Proceeding with boolean switch.", DL_ERROR);
case_elems.clear ();
}
case_elems.append (f);
@@ -782,15 +788,15 @@
QStringList def_strings;
QStringList standards;
QStringList sources;
- sources.append (xml->getStringAttribute (*it, "condition", QString (), DL_ERROR)); // store condition prop as first "source"
+ sources.append (xml.getStringAttribute (*it, "condition", QString (), DL_ERROR)); // store condition prop as first "source"
for (XMLChildList::const_iterator cit = case_elems.constBegin (); cit != case_elems.constEnd (); ++cit) {
- def_strings.append (xml->getStringAttribute (*cit, "fixed_value", QString (), DL_INFO));
- sources.append (xml->getStringAttribute (*cit, "dynamic_value", QString (), DL_INFO));
- if ((*cit).tagName () == "case") standards.append (xml->getStringAttribute (*cit, "standard", QString (), DL_WARNING));
+ def_strings.append (xml.getStringAttribute (*cit, "fixed_value", QString (), DL_INFO));
+ sources.append (xml.getStringAttribute (*cit, "dynamic_value", QString (), DL_INFO));
+ if ((*cit).tagName () == "case") standards.append (xml.getStringAttribute (*cit, "standard", QString (), DL_WARNING));
}
- QString id = xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING);
+ QString id = xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING);
RKComponentPropertySwitch *switchel = new RKComponentPropertySwitch (component (), def_strings, standards);
switchel->setInternal (true);
switch_convert_sources.insert (switchel, sources);
@@ -812,13 +818,13 @@
}
}
- QDomElement e = xml->getChildElement (element, "script", DL_INFO);
+ QDomElement e = xml.getChildElement (element, "script", DL_INFO);
if (!e.isNull () && allow_script_tag) {
- QString file = xml->getStringAttribute (e, "file", QString (), DL_INFO);
+ QString file = xml.getStringAttribute (e, "file", QString (), DL_INFO);
QString inline_command = e.text ();
parent->standardComponent ()->scriptingProxy ()->initialize (file, inline_command);
} else if (!e.isNull ()) {
- xml->displayError (&e, "<script> element is not allowed inside this <logic> section.", DL_ERROR);
+ xml.displayError (&e, "<script> element is not allowed inside this <logic> section.", DL_ERROR);
}
}
@@ -840,7 +846,7 @@
component ()->setPropertyValues (&initial_values);
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = component ()->xmlHelper ();
for (ConnectionList::const_iterator it = connection_list.constBegin (); it != connection_list.constEnd (); ++it) {
RK_DEBUG (PLUGIN, DL_DEBUG, "Connecting '%s' to '%s'", (*it).client_property.toLatin1 ().data (), (*it).governor_property.toLatin1 ().data ());
Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.h 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.h 2014-10-17 16:55:48 UTC (rev 4925)
@@ -2,7 +2,7 @@
rkstandardcomponent - description
-------------------
begin : Sun Feb 19 2006
- copyright : (C) 2006, 2007, 2009, 2010, 2012 by Thomas Friedrichsmeier
+ copyright : (C) 2006, 2007, 2009, 2010, 2012, 2014 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -66,6 +66,7 @@
void setCaption (const QString &caption);
/** return the filename of the xml file */
QString getFilename () { return filename; };
+ XMLHelper *getXmlHelper ();
RKComponentHandle *getHandle () { return handle; };
bool haveHelp () { return have_help; };
/** Submits the current code (by simulating a click on the ok button).
@@ -118,6 +119,7 @@
void buildAndInitialize (const QDomElement &doc_element, const QDomElement &gui_element, QWidget *parent_widget, bool build_wizard, bool enslaved=false);
/** used during switchInterfaces () to discard child components, and delete gui if applicable */
void discard ();
+ XMLHelper *xml;
protected:
friend class RKComponentBuilder;
/** reimplemented for technical reasons. Additionally registers component children with the component stack if in wizard mode */
@@ -142,14 +144,14 @@
public:
RKComponentBuilder (RKComponent *parent_component, const QDomElement &document_element);
~RKComponentBuilder ();
- void buildElement (const QDomElement &element, QWidget *parent_widget, bool allow_pages);
- void parseLogic (const QDomElement &element, bool allow_script_tag=true);
+ void buildElement (const QDomElement &element, XMLHelper &xml, QWidget *parent_widget, bool allow_pages);
+ void parseLogic (const QDomElement &element, XMLHelper &xml, bool allow_script_tag=true);
void makeConnections ();
RKComponent *component () const { return parent; };
private:
/** internal convenience function to schedule a property connection */
void addConnection (const QString &client_id, const QString &client_property, const QString &governor_id, const QString &governor_property, bool reconcile, const QDomElement &origin);
- QDomElement doElementCopy (const QString id, const QDomElement ©);
+ QDomElement doElementCopy (const QString id, XMLHelper &xml, const QDomElement ©);
QDomElement doc_elem;
RKComponent *parent;
struct RKComponentPropertyConnection {
Modified: trunk/rkward/rkward/plugin/rktabpage.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rktabpage.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rktabpage.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -30,7 +30,7 @@
RKTabPage::RKTabPage (const QDomElement &element, RKComponent *parent_component, QTabWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
- XMLHelper* xml = XMLHelper::getStaticHelper ();
+ XMLHelper* xml = parent_component->xmlHelper ();
label = xml->getStringAttribute (element, "label", QString::null, DL_WARNING);
QVBoxLayout *layout = new QVBoxLayout (this);
Modified: trunk/rkward/rkward/plugin/rktext.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rktext.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rktext.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -31,7 +31,7 @@
RK_TRACE (PLUGIN);
// get xml-helper
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
// create layout and label
QVBoxLayout *vbox = new QVBoxLayout (this);
Modified: trunk/rkward/rkward/plugin/rkvalueselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvalueselector.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkvalueselector.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -31,7 +31,7 @@
RK_TRACE (PLUGIN);
updating = false;
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
standalone = element.tagName () == "select";
addChild ("selected", selected = new RKComponentPropertyStringList (this, false));
Modified: trunk/rkward/rkward/plugin/rkvarslot.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvarslot.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/plugin/rkvarslot.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -36,7 +36,7 @@
RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
RK_TRACE (PLUGIN);
- XMLHelper *xml = XMLHelper::getStaticHelper ();
+ XMLHelper *xml = parent_component->xmlHelper ();
updating = false;
// basic layout
Modified: trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -352,9 +352,10 @@
}
if (inf.id.isEmpty ()) {
- QDomElement de = XMLHelper::getStaticHelper ()->openXMLFile (inf.filename, DL_WARNING);
- inf.id = RKPluginMapFile::parseId (de);
- inf.priority = XMLHelper::getStaticHelper ()->getMultiChoiceAttribute (de, "priority", "hidden;low;medium;high", (int) PriorityMedium, DL_WARNING);
+ XMLHelper xml = XMLHelper ();
+ QDomElement de = xml.openXMLFile (inf.filename, DL_WARNING);
+ inf.id = RKPluginMapFile::parseId (de, xml);
+ inf.priority = xml.getMultiChoiceAttribute (de, "priority", "hidden;low;medium;high", (int) PriorityMedium, DL_WARNING);
}
}
@@ -621,10 +622,10 @@
if (!plugin_map_dynamic_info.contains (pluginmapfile)) {
// TODO
PluginMapMetaInfo inf;
- XMLHelper *xml = XMLHelper::getStaticHelper ();
- QDomElement doc_elem = xml->openXMLFile (pluginmapfile, DL_WARNING);
- inf.about = new RKComponentAboutData (xml->getChildElement (doc_elem, "about", DL_INFO));
- inf.dependencies = RKComponentDependency::parseDependencies (xml->getChildElement (doc_elem, "dependencies", DL_INFO));
+ XMLHelper xml;
+ QDomElement doc_elem = xml.openXMLFile (pluginmapfile, DL_WARNING);
+ inf.about = new RKComponentAboutData (xml.getChildElement (doc_elem, "about", DL_INFO), xml);
+ inf.dependencies = RKComponentDependency::parseDependencies (xml.getChildElement (doc_elem, "dependencies", DL_INFO), xml);
plugin_map_dynamic_info.insert (pluginmapfile, inf);
}
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2014-10-17 14:42:59 UTC (rev 4924)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2014-10-17 16:55:48 UTC (rev 4925)
@@ -646,7 +646,7 @@
element = help_xml.getChildElement (help_doc_element, "about", DL_INFO);
}
if (!element.isNull ()) {
- RKComponentAboutData about (element);
+ RKComponentAboutData about (element, for_component ? component_xml : help_xml);
writeHTML (startSection ("about", i18n ("About"), QString (), &anchors, &anchornames));
writeHTML (about.toHtml ());
}
@@ -718,14 +718,11 @@
} else if (url.host () == "page") {
QString help_base_dir = RKCommonFunctions::getRKWardDataDir () + "pages/";
+ XMLHelper xml;
QString help_file_name = help_base_dir + url.path () + ".rkh";
- XMLHelper *xml = new XMLHelper ();
-
- QDomElement doc_element = xml->openXMLFile (help_file_name, DL_WARNING);
- QDomElement title_element = xml->getChildElement (doc_element, "title", DL_WARNING);
+ QDomElement doc_element = xml.openXMLFile (help_file_name, DL_WARNING);
+ QDomElement title_element = xml.getChildElement (doc_element, "title", DL_WARNING);
text = title_element.text ();
-
- delete xml;
}
if (text.isEmpty ()) {
More information about the rkward-tracker
mailing list