[rkward-cvs] rkward/rkward/plugin rkstandardcomponent.cpp,NONE,1.1 rkstandardcomponent.h,NONE,1.1 Makefile.am,1.6,1.7 rkcomponent.cpp,1.2,1.3 rkcomponent.h,1.2,1.3 rkcomponentproperties.cpp,1.8,1.9 rkcomponentproperties.h,1.9,1.10
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Mon Feb 20 22:54:02 UTC 2006
Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21937
Modified Files:
Makefile.am rkcomponent.cpp rkcomponent.h
rkcomponentproperties.cpp rkcomponentproperties.h
Added Files:
rkstandardcomponent.cpp rkstandardcomponent.h
Log Message:
A few more implementation details for component infrastructre. And way to go...
Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkcomponent.h 17 Feb 2006 16:32:30 -0000 1.2
--- rkcomponent.h 20 Feb 2006 22:54:00 -0000 1.3
***************
*** 3,7 ****
-------------------
begin : Tue Dec 13 2005
! copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
--- 3,7 ----
-------------------
begin : Tue Dec 13 2005
! copyright : (C) 2005, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
***************
*** 29,33 ****
/** destructor */
virtual ~RKComponentBase ();
!
/** tries to locate a component (or property) described by identifier as a child (of any generation) of this RKComponentBase. If found, a pointer to this is returned. Also, the modifier parameter is set to hold any remaining modifier contained in the identifier.
@param identifier The identifier string to look for (including a potential modifier suffix).
--- 29,48 ----
/** destructor */
virtual ~RKComponentBase ();
! /** enum of types of properties. Used from RTTI. Don't change the values, as there are some range checks in the code (see isProperty ()) */
! enum RKComponentTypes {
! PropertyBase = 1,
! PropertyBool = 2,
! PropertyInt = 3,
! PropertyDouble = 4,
! PropertyRObjects = 5,
! PropertyCode = 6,
! PropertyUser = 1000, /**< for user expansion */
! PropertyEnd = 1999,
! ComponentBase = 2001,
! Component = 2002,
! ComponentUser = 3000 /**< for user expansion */
! };
! /** for RTTI. see RKComponentBase::RKComponentTypes */
! int type () { return ComponentBase; };
/** tries to locate a component (or property) described by identifier as a child (of any generation) of this RKComponentBase. If found, a pointer to this is returned. Also, the modifier parameter is set to hold any remaining modifier contained in the identifier.
@param identifier The identifier string to look for (including a potential modifier suffix).
***************
*** 37,40 ****
--- 52,57 ----
/** Locate the component.subcomponent.property.value described by identifier and return its value as a string. Especially useful as a callback in code templates! Recursively walks subcomponents/properties until the requested value is found. @See RKComponentBase::lookupComponent */
QString fetchStringValue (const QString &identifier);
+ /** returns true, if this is a property */
+ bool isProperty () { return (type () <= PropertyEnd); };
protected:
/** simple convenience function to add a child to the map of children */
***************
*** 54,57 ****
--- 71,75 ----
/** destructor */
virtual ~RKComponent ();
+ int type () { return Component; };
public slots:
/** generally the valueChanged () signal of all RKComponentPropertys directly owned by this component should be connected to this (Qt-)slot, so the component can update itself accordingly. Default implementation handles changes in visibilty, enabledness and requiredness properties. If you reimplement this, you will most likely still want to call the default implementation to handle these. */
--- NEW FILE: rkstandardcomponent.h ---
/***************************************************************************
rkstandardcomponent - description
-------------------
begin : Sun Feb 19 2006
copyright : (C) 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RKSTANDARDCOMPONENT_H
#define RKSTANDARDCOMPONENT_H
#include "rkcomponent.h"
/** The standard type of component (i.e. stand-alone), previously known as "plugin" */
class RKStandardComponent : public RKComponent {
public:
RKStandardComponent ();
~RKStandardComponent ();
};
/** A helper class used to build and initialize an RKComponent. Most importantly this will keep track of the properties yet to be connected. Used at least by RKStandardComponent. */
class RKComponentBuilder {
public:
RKComponentBuilder (RKComponent *parent);
~RKComponentBuilder ();
void buildElement (const QDomElement &element);
void makeConnections ();
private:
RKComponent *parent;
struct RKComponentPropertyConnection {
QString governor_property;
QString client_property;
bool reconcile;
};
QValueList <RKComponentPropertyConnection *> connection_list;
};
#endif
Index: rkcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkcomponent.cpp 17 Feb 2006 16:32:30 -0000 1.2
--- rkcomponent.cpp 20 Feb 2006 22:54:00 -0000 1.3
***************
*** 3,7 ****
-------------------
begin : Tue Dec 13 2005
! copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
--- 3,7 ----
-------------------
begin : Tue Dec 13 2005
! copyright : (C) 2005, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
***************
*** 25,32 ****
RK_TRACE (PLUGIN);
! if (identifier.isNull ()) return this;
RKComponentBase *child = child_map.find (identifier.section ("::", 0, 0));
! if (!child) { // if we do not have such a child, return 0 (RKComponentBase does not support modifiers)
RK_DO (qDebug ("Failed component lookup"), PLUGIN, DL_WARNING);
return 0;
--- 25,38 ----
RK_TRACE (PLUGIN);
! if (identifier.isEmpty ()) return this;
RKComponentBase *child = child_map.find (identifier.section ("::", 0, 0));
! if (!child) { // if we do not have such a child, return 0 unless this is a property
! if (isProperty ()) {
! if (modifier) {
! *modifier = identifier.section ("::", 1);
! }
! return this;
! }
RK_DO (qDebug ("Failed component lookup"), PLUGIN, DL_WARNING);
return 0;
***************
*** 42,46 ****
--- 48,64 ----
}
+ QString RKComponentBase::fetchStringValue (const QString &identifier) {
+ RK_TRACE (PLUGIN);
+ QString mod;
+ RKComponentBase *prop = lookupComponent (identifier, &mod);
+
+ if (prop && (prop->isProperty ())) {
+ return (static_cast<RKComponentPropertyBase *> (prop)->value (mod));
+ } else {
+ RK_DO (qDebug ("Failed lookup or not a property: '%s'", identifier.latin1 ()), PLUGIN, DL_WARNING);
+ return QString::null;
+ }
+ }
***************
*** 81,84 ****
--- 99,105 ----
bool RKComponent::isSatisfied () {
RK_TRACE (PLUGIN);
+
+ // TODO
+ return true;
}
***************
*** 86,93 ****
--- 107,118 ----
void RKComponent::setSatisfied (bool satisfied) {
RK_TRACE (PLUGIN);
+
+ // TODO
}
void RKComponent::setReady (bool ready) {
RK_TRACE (PLUGIN);
+
+ // TODO
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Makefile.am 13 Dec 2005 15:10:24 -0000 1.6
--- Makefile.am 20 Feb 2006 22:54:00 -0000 1.7
***************
*** 3,12 ****
noinst_LIBRARIES = libplugin.a
libplugin_a_SOURCES = rkcheckbox.cpp rkformula.cpp rkplugin.cpp \
! rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rkradio.cpp rktext.cpp \
! rkvarselector.cpp rkvarslot.cpp rkinput.cpp rknote.cpp \
! rkpluginbrowser.cpp rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp
noinst_HEADERS = rkcheckbox.h rkformula.h rkplugin.h rkpluginhandle.h \
! rkpluginspinbox.h rkpluginwidget.h rkradio.h rktext.h rkvarselector.h rkvarslot.h \
! rkcomponentmap.h rkcomponentproperties.h rkpluginbrowser.h rkinput.h rknote.h rkcomponent.h
--- 3,14 ----
noinst_LIBRARIES = libplugin.a
libplugin_a_SOURCES = rkcheckbox.cpp rkformula.cpp rkplugin.cpp \
! rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rkradio.cpp rktext.cpp \
! rkvarselector.cpp rkvarslot.cpp rkinput.cpp rknote.cpp \
! rkpluginbrowser.cpp rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp \
! rkstandardcomponent.cpp
noinst_HEADERS = rkcheckbox.h rkformula.h rkplugin.h rkpluginhandle.h \
! rkpluginspinbox.h rkpluginwidget.h rkradio.h rktext.h rkvarselector.h rkvarslot.h \
! rkcomponentmap.h rkcomponentproperties.h rkpluginbrowser.h rkinput.h rknote.h rkcomponent.h \
! rkstandardcomponent.h
--- NEW FILE: rkstandardcomponent.cpp ---
/***************************************************************************
rkstandardcomponent - description
-------------------
begin : Sun Feb 19 2006
copyright : (C) 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "rkstandardcomponent.h"
#include "../debug.h"
#include "rkstandardcomponent.moc"
Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkcomponentproperties.cpp 9 Dec 2005 18:18:13 -0000 1.8
--- rkcomponentproperties.cpp 20 Feb 2006 22:54:00 -0000 1.9
***************
*** 3,7 ****
-------------------
begin : Fri Nov 25 2005
! copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
--- 3,7 ----
-------------------
begin : Fri Nov 25 2005
! copyright : (C) 2005, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
Index: rkcomponentproperties.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rkcomponentproperties.h 13 Dec 2005 15:10:24 -0000 1.9
--- rkcomponentproperties.h 20 Feb 2006 22:54:00 -0000 1.10
***************
*** 3,7 ****
-------------------
begin : Fri Nov 25 2005
! copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
--- 3,7 ----
-------------------
begin : Fri Nov 25 2005
! copyright : (C) 2005, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
***************
*** 37,50 ****
/** destructor */
virtual ~RKComponentPropertyBase ();
- /** enum of types of properties. Used from RTTI */
- enum RKComponentPropertyTypes {
- PropertyBase = 1,
- PropertyBool = 2,
- PropertyInt = 3,
- PropertyDouble = 4,
- PropertyRObjects = 5,
- PropertyCode = 6,
- PropertyUser = 1000 /**< for user expansion */
- };
/** supplies the current value. Since more than one value may be supplied, modifier can be used to select a value. Default implementation only has a single string, however. */
virtual QString value (const QString &modifier=QString::null);
--- 37,40 ----
***************
*** 60,65 ****
/** see setRequired () */
virtual bool isSatisfied ();
! /** for RTTI. see RKComponentPropertyTypes */
! virtual int type () { return PropertyBase; };
/** connect this property to a governor property (given as argument). If reconcile_requirements, the requirements of both properties are reconciled to the least common denominator. The dependent property will be notified on all changes made in the governing property, so it can update its value.
Generally with few exceptions, you can only connect to properties that are either of the same class as this property, or of an extended class. Maybe in the future we will add some sophisticated converters allowing to connect vastly different types of properties in a meaningful way.
--- 50,55 ----
/** see setRequired () */
virtual bool isSatisfied ();
! /** for RTTI. see RKComponentBase::RKComponentTypes */
! int type () { return PropertyBase; };
/** connect this property to a governor property (given as argument). If reconcile_requirements, the requirements of both properties are reconciled to the least common denominator. The dependent property will be notified on all changes made in the governing property, so it can update its value.
Generally with few exceptions, you can only connect to properties that are either of the same class as this property, or of an extended class. Maybe in the future we will add some sophisticated converters allowing to connect vastly different types of properties in a meaningful way.
More information about the rkward-tracker
mailing list