[rkward-cvs] rkward/rkward/plugin rkcomponent.cpp,NONE,1.1 rkcomponent.h,NONE,1.1 Makefile.am,1.5,1.6 rkcomponentproperties.h,1.8,1.9
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Tue Dec 13 15:10:26 UTC 2005
Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3929
Modified Files:
Makefile.am rkcomponentproperties.h
Added Files:
rkcomponent.cpp rkcomponent.h
Log Message:
Started working on RKComponent
--- NEW FILE: rkcomponent.cpp ---
/***************************************************************************
rkcomponent - description
-------------------
begin : Tue Dec 13 2005
copyright : (C) 2005 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 "rkcomponent.h"
#include "../debug.h"
RKComponent::RKComponent (RKComponent *parent) : QWidget (parent) {
RK_TRACE (PLUGIN);
addChild ("enabled", enabledness_property = new RKComponentPropertyBool (this, false));
connect (enabledness_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyValueChanged (RKComponentPropertyBase *)));
addChild ("visible", visibility_property = new RKComponentPropertyBool (this, false));
connect (visibility_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyValueChanged (RKComponentPropertyBase *)));
addChild ("required", requiredness_property = new RKComponentPropertyBool (this, false));
connect (requiredness_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyValueChanged (RKComponentPropertyBase *)));
_parent = parent;
}
RKComponent::~RKComponent () {
RK_TRACE (PLUGIN);
// properties are QObjects, and hence deleted automatically
}
/** 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. */
void RKComponent::propertyValueChanged (RKComponentPropertyBase *property) {
RK_TRACE (PLUGIN);
if (property == visibility_property) {
setShown (visibility_property->boolValue ());
} else if (property == enabledness_property) {
setEnabled (enabledness_property->boolValue ());
} else if (property == requiredness_property) {
checkSatisfied ();
}
}
bool RKComponent::isSatisfied () {
RK_TRACE (PLUGIN);
}
/** also notifies the parent, if applicable */
void RKComponent::setSatisfied (bool satisfied) {
RK_TRACE (PLUGIN);
}
void RKComponent::setReady (bool ready) {
RK_TRACE (PLUGIN);
}
#include "rkcomponent.moc"
--- NEW FILE: rkcomponent.h ---
/***************************************************************************
rkcomponent - description
-------------------
begin : Tue Dec 13 2005
copyright : (C) 2005 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 RKCOMPONENT_H
#define RKCOMPONENT_H
#include <qdict.h>
#include <qwidget.h>
/** a very low level base for RKComponent and RKComponentProperty. Not sure, we really need it, yet, but here it is. */
class RKComponentBase {
public:
/** constructor */
RKComponentBase ();
/** 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.
@param modifier If a non null pointer to QString is given, this will be set to the value of the remaining modifier (only if successful)
@returns a pointer to the RKComponentBase, if found, or 0, if no such RKComponentBase exists as a child of this RKComponentBase. */
virtual RKComponentBase* lookupComponent (const QString &identifier, QString *modifier);
/** 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);
protected:
/** simple convenience function to add a child to the map of children */
void addChild (const QString &id, RKComponentBase *child);
QDict<RKComponentBase> child_map;
};
#include "rkcomponentproperties.h"
/** abstract base class of all RKComponents, including component widgets */
class RKComponent : public QWidget, public RKComponentBase {
Q_OBJECT
public:
/** constructor
@param parent The parent RKComponent (also used as the parent widget). If 0, this RKComponent will be a top-level component/widget */
RKComponent (RKComponent *parent);
/** destructor */
virtual ~RKComponent ();
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. */
virtual void propertyValueChanged (RKComponentPropertyBase *property);
public:
/** standard property controlling visibility */
RKComponentPropertyBool *visibilityProperty () { return visibility_property; };
/** standard property controlling enabledness */
RKComponentPropertyBool *enablednessProperty () { return enabledness_property; };
/** standard property controlling requiredness */
RKComponentPropertyBool *requirednessProperty () { return requiredness_property; };
/** convenience call to set visibilty property (and hence visibility of this component) */
void setVisible (bool visible) { visibilityProperty ()->setBoolValue (visible); };
/** convenience call to set visibilty property (and hence visibility of this component) */
void setEnabled (bool enabled) { enablednessProperty ()->setBoolValue (enabled); };
/** convenience call to set visibilty property (and hence visibility of this component) */
void setRequired (bool required) { requirednessProperty ()->setBoolValue (required); };
/** The parent of this component. Should be notified, whenever isSatisfied () or isReady ()-state changed. */
RKComponent *parent () { return _parent; };
/** check whether the component is satisfied (such as after a value change or requireness change). If statisfied state has changed, and silent==false, notfies parent. TODO: maybe statisfaction-state should be made a property as well! */
virtual void checkSatisfied (bool silent=false);
bool isSatisfied ();
/** Is the component "ready"? I.e. it is up to date according to current settings. Does not imply it is also satisfied. Default implementation always returns true. TODO: maybe ready-state should be made a property as well! */
virtual bool isReady () { return true; };
protected:
RKComponentPropertyBool *visibility_property;
RKComponentPropertyBool *enabledness_property;
RKComponentPropertyBool *requiredness_property;
RKComponent *_parent;
private:
/** also notifies the parent, if applicable */
void setSatisfied (bool satisfied);
void setReady (bool ready);
};
#endif
Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.am 25 Nov 2005 14:58:48 -0000 1.5
--- Makefile.am 13 Dec 2005 15:10:24 -0000 1.6
***************
*** 5,12 ****
rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rkradio.cpp rktext.cpp \
rkvarselector.cpp rkvarslot.cpp rkinput.cpp rknote.cpp \
! rkpluginbrowser.cpp rkcomponentmap.cpp rkcomponentproperties.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
--- 5,12 ----
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
Index: rkcomponentproperties.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkcomponentproperties.h 9 Dec 2005 16:06:32 -0000 1.8
--- rkcomponentproperties.h 13 Dec 2005 15:10:24 -0000 1.9
***************
*** 21,29 ****
#include <qobject.h>
/** Base class for all RKComponentProperties. The base class can handle only a string-property. See derived classes for special types of properties.
see \ref RKComponentProperties
*/
! class RKComponentPropertyBase : public QObject {
Q_OBJECT
public:
--- 21,34 ----
#include <qobject.h>
+ /* we need these foward declarations for now, due to cylcic includes. TODO: fix this */
+ class RKComponentPropertyBase;
+ class RKComponentPropertyBool;
+ #include "rkcomponent.h"
+
/** Base class for all RKComponentProperties. The base class can handle only a string-property. See derived classes for special types of properties.
see \ref RKComponentProperties
*/
! class RKComponentPropertyBase : public QObject, public RKComponentBase {
Q_OBJECT
public:
***************
*** 87,91 ****
@param value_false string value if false/off
@param default_state value to use, if invalid string value was set */
! RKComponentPropertyBool (QObject *parent, bool required, const QString &value_true, const QString &value_false, bool default_state);
/** destructor */
~RKComponentPropertyBool ();
--- 92,96 ----
@param value_false string value if false/off
@param default_state value to use, if invalid string value was set */
! RKComponentPropertyBool (QObject *parent, bool required, const QString &value_true="TRUE", const QString &value_false="FALSE", bool default_state=true);
/** destructor */
~RKComponentPropertyBool ();
More information about the rkward-tracker
mailing list