[rkward-cvs] rkward/rkward/plugin rktabpage.cpp,NONE,1.1 rktabpage.h,NONE,1.1 Makefile.am,1.16,1.17 rkcomponent.h,1.16,1.17 rkstandardcomponent.cpp,1.27,1.28 rkstandardcomponent.h,1.15,1.16

Thomas Friedrichsmeier tfry at users.sourceforge.net
Wed Apr 5 14:30:30 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3268

Modified Files:
	Makefile.am rkcomponent.h rkstandardcomponent.cpp 
	rkstandardcomponent.h 
Added Files:
	rktabpage.cpp rktabpage.h 
Log Message:
Allow to specify default/initial values for properties. Make visibility work for tab pages

Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** rkcomponent.h	29 Mar 2006 16:21:51 -0000	1.16
--- rkcomponent.h	5 Apr 2006 14:30:27 -0000	1.17
***************
*** 54,57 ****
--- 54,58 ----
  		ComponentBrowser = 2010,
  		ComponentText = 2011,
+ 		ComponentTab = 2012,
  		ComponentStandard = 2100,
  		ComponentUser = 3000	/**< for user expansion */

Index: rkstandardcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** rkstandardcomponent.h	5 Apr 2006 10:09:18 -0000	1.15
--- rkstandardcomponent.h	5 Apr 2006 14:30:27 -0000	1.16
***************
*** 97,101 ****
  };
  
! 
  
  /** 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.
--- 97,101 ----
  };
  
! #include <qmap.h>
  
  /** 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.
***************
*** 131,134 ****
--- 131,135 ----
  	typedef QValueList <RKComponentPropertyConnection> ConnectionList;
  	ConnectionList connection_list;
+ 	QMap<QString, QString> initial_values;
  };
  

--- NEW FILE: rktabpage.cpp ---
/***************************************************************************
                          rktabpage.cpp  -  description
                             -------------------
    begin                : Wed Apr 5 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 "rktabpage.h"

#include <qstring.h>
#include <qlayout.h>
#include <qtabwidget.h>

#include "../rkglobals.h"
#include "../misc/xmlhelper.h"
#include "../debug.h"

RKTabPage::RKTabPage (const QDomElement &element, RKComponent *parent_component, QTabWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
	RK_TRACE (PLUGIN);

	XMLHelper* xml = XMLHelper::getStaticHelper ();
	label = xml->getStringAttribute (element, "label", QString::null, DL_WARNING);

	QVBoxLayout *layout = new QVBoxLayout (this);
	page = new QVBox (this);
	page->setSpacing (RKGlobals::spacingHint ());
	layout->addWidget (page);

	tabbook = parent_widget;
	tabbook->addTab (this, label);
	index = tabbook->indexOf (this);

	inserted = true;
	connect (visibility_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (visibleEnabledChanged (RKComponentPropertyBase *)));
	connect (enabledness_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (visibleEnabledChanged (RKComponentPropertyBase *)));
}

RKTabPage::~RKTabPage () {
	RK_TRACE (PLUGIN);
}

void RKTabPage::visibleEnabledChanged (RKComponentPropertyBase *property) {
	RK_TRACE (PLUGIN);

	if (property == visibility_property) {
		if (visibility_property->boolValue ()) {
			if (!inserted) {
				tabbook->insertTab (this, label, index);
				inserted = true;
			}
		} else {
			if (inserted) {
				tabbook->removePage (this);
				inserted = false;
			}
		}
	} else if (property == enabledness_property) {
		tabbook->setTabEnabled (this, enabledness_property->boolValue ());
	}
}

#include "rktabpage.moc"

--- NEW FILE: rktabpage.h ---
/***************************************************************************
                          rktabpage.cpp  -  description
                             -------------------
    begin                : Wed Apr 5 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 RKTABPAGE_H
#define RKTABPAGE_H

#include "rkcomponent.h"

#include <qstring.h>
#include <qvbox.h>

class QDomElement;
class QTabWidget;

/** A passive component acting as a page in a tabbook. The only function is, that if the component is hidden, the corresponding tab in the tabbook is also hidden.

@author Thomas Friedrichsmeier
*/
class RKTabPage : public RKComponent {
	Q_OBJECT
public:
	RKTabPage (const QDomElement &element, RKComponent *parent_component, QTabWidget *parent_widget);

	~RKTabPage ();

	// returns the page child elements should be drawn in
	QVBox *getPage () { return page; };

	int type () { return ComponentTab; };

public slots:
/** called when visibile or enabled properties change */
	void visibleEnabledChanged (RKComponentPropertyBase *property);
private:
	QVBox *page;
	QTabWidget *tabbook;
	int index;
	QString label;
	bool inserted;
};

#endif

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/Makefile.am,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Makefile.am	20 Mar 2006 22:13:23 -0000	1.16
--- Makefile.am	5 Apr 2006 14:30:27 -0000	1.17
***************
*** 5,14 ****
  	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp rkradio.cpp \
  	rkcheckbox.cpp rkpluginspinbox.cpp rkinput.cpp rkpluginbrowser.cpp rktext.cpp \
! 	rkstandardcomponentgui.cpp
  
  noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
  	rkstandardcomponent.h rkvarselector.h rkvarslot.h rkformula.h rkradio.h \
  	rkcheckbox.h rkpluginspinbox.h rkinput.h rkpluginbrowser.h rktext.h \
! 	rkstandardcomponentgui.h
  
  
--- 5,14 ----
  	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp rkradio.cpp \
  	rkcheckbox.cpp rkpluginspinbox.cpp rkinput.cpp rkpluginbrowser.cpp rktext.cpp \
! 	rktabpage.cpp rkstandardcomponentgui.cpp
  
  noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
  	rkstandardcomponent.h rkvarselector.h rkvarslot.h rkformula.h rkradio.h \
  	rkcheckbox.h rkpluginspinbox.h rkinput.h rkpluginbrowser.h rktext.h \
! 	rktabpage.h rkstandardcomponentgui.h
  
  

Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** rkstandardcomponent.cpp	5 Apr 2006 10:09:18 -0000	1.27
--- rkstandardcomponent.cpp	5 Apr 2006 14:30:27 -0000	1.28
***************
*** 46,49 ****
--- 46,50 ----
  #include "rkpluginbrowser.h"
  #include "rktext.h"
+ #include "rktabpage.h"
  
  #include "../rkglobals.h"
***************
*** 423,427 ****
  		RKComponent *widget = 0;
  		QDomElement e = *it;		// shorthand
! 		QString id = xml->getStringAttribute (e, "id", "#noid#", DL_INFO);
  
  		if (allow_pages && (e.tagName () == "page")) {
--- 424,428 ----
  		RKComponent *widget = 0;
  		QDomElement e = *it;		// shorthand
! 		QString id = xml->getStringAttribute (e, "id", QString::null, DL_INFO);
  
  		if (allow_pages && (e.tagName () == "page")) {
***************
*** 462,469 ****
  				QDomElement tab_e = tabs.item (t).toElement ();
  				if (tab_e.tagName () == "tab") {
! 					QVBox *tabpage = new QVBox (tabbook);
! 					tabpage->setSpacing (RKGlobals::spacingHint ());
! 					buildElement (tab_e, tabpage, false);
! 					tabbook->addTab (tabpage, tab_e.attribute ("label"));
  				}
  			}
--- 463,472 ----
  				QDomElement tab_e = tabs.item (t).toElement ();
  				if (tab_e.tagName () == "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);
! 					if (!tab_id.isNull ()) {
! 						parent->addChild (tab_id, tabpage);
! 					}
  				}
  			}
***************
*** 510,514 ****
  		}
  
! 		if (widget) {
  			parent->addChild (id, widget);
  		}
--- 513,517 ----
  		}
  
! 		if (widget && (!(id.isNull ()))) {
  			parent->addChild (id, widget);
  		}
***************
*** 530,539 ****
  	}
  
  	// find outside elements
  	children = xml->getChildElements (element, "external", DL_INFO);
  	for (it = children.constBegin (); it != children.constEnd (); ++it) {
  		RKComponentPropertyBase *prop = new RKComponentPropertyBase (component (), xml->getBoolAttribute (*it, "required", false, DL_INFO));
! 		component ()->addChild (xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING), prop);
  		component ()->connect (prop, SIGNAL (valueChanged (RKComponentPropertyBase *)), component (), SLOT (outsideValueChanged (RKComponentPropertyBase *)));
  		// TODO add more options
  	}
--- 533,554 ----
  	}
  
+ 	// find initialize elements
+ 	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));
+ 	}
+ 
  	// find outside elements
  	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));
! 		component ()->addChild (id, prop);
  		component ()->connect (prop, SIGNAL (valueChanged (RKComponentPropertyBase *)), component (), SLOT (outsideValueChanged (RKComponentPropertyBase *)));
+ 
+ 		QString dummy = xml->getStringAttribute (*it, "default", QString::null, DL_INFO);
+ 		if (!dummy.isNull ()) {
+ 			initial_values.insert (id, dummy);
+ 		}
  		// TODO add more options
  	}
***************
*** 573,576 ****
--- 588,594 ----
  void RKComponentBuilder::makeConnections () {
  	RK_TRACE (PLUGIN);
+ 
+ 	component ()->setPropertyValues (&initial_values);
+ 
  	XMLHelper *xml = XMLHelper::getStaticHelper ();
  
***************
*** 592,595 ****
--- 610,617 ----
  		static_cast<RKComponentPropertyBase *> (client)->connectToGovernor (static_cast<RKComponentPropertyBase *> (governor), dummy, (*it).reconcile);
  	}
+ 
+ 	// save some RAM
+ 	connection_list.clear ();
+ 	initial_values.clear ();
  }
  





More information about the rkward-tracker mailing list