[rkward-cvs] rkward/rkward/plugin rkcomponent.cpp,1.3,1.4 rkstandardcomponent.cpp,1.3,1.4 rkstandardcomponent.h,1.3,1.4

Thomas Friedrichsmeier tfry at users.sourceforge.net
Tue Mar 14 13:33:45 UTC 2006


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

Modified Files:
	rkcomponent.cpp rkstandardcomponent.cpp rkstandardcomponent.h 
Log Message:
Starting to move over old plugin code

Index: rkcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rkcomponent.cpp	20 Feb 2006 22:54:00 -0000	1.3
--- rkcomponent.cpp	14 Mar 2006 13:33:42 -0000	1.4
***************
*** 65,69 ****
  //############### RKComponent ########################
  
! RKComponent::RKComponent (RKComponent *parent) : QWidget (parent) {
  	RK_TRACE (PLUGIN);
  
--- 65,69 ----
  //############### RKComponent ########################
  
! RKComponent::RKComponent (RKComponent *parent_component, QWidget *parent_widget) : QWidget (parent_widget) {
  	RK_TRACE (PLUGIN);
  
***************
*** 75,79 ****
  	connect (requiredness_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyValueChanged (RKComponentPropertyBase *)));
  
! 	_parent = parent;
  }
  
--- 75,79 ----
  	connect (requiredness_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyValueChanged (RKComponentPropertyBase *)));
  
! 	_parent = parent_component;
  }
  

Index: rkstandardcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rkstandardcomponent.h	28 Feb 2006 23:15:46 -0000	1.3
--- rkstandardcomponent.h	14 Mar 2006 13:33:42 -0000	1.4
***************
*** 23,26 ****
--- 23,30 ----
  #include <qdom.h>
  
+ class RKErrorDialog;
+ class RKStandardComponentGUI;
+ class ScriptBackend;
+ 
  /** The standard type of component (i.e. stand-alone), previously known as "plugin". This is the type of component described by an XML-file */
  class RKStandardComponent : public RKComponent {
***************
*** 34,38 ****
  /** destructor */
  	~RKStandardComponent ();
! // TODO: should these be moved to a separate RKStandardComponentGUI-class?
  public slots:
  	void ok ();
--- 38,83 ----
  /** destructor */
  	~RKStandardComponent ();
! /** try to destruct the plugin */
! 	void tryDestruct ();
! public slots:
! 	void switchInterfaces ();
! 
! 
! /** this gets called by the script-backend, when it's done. Might enable the
! 	submit button or destruct the plugin. */
! 	void backendIdle ();
! 	void backendCommandDone (int flags);
! /** return result of given call (string vector) to the R-backend */	
! //	void getRVector (const QString &call);
! /** return result of given call to the R-backend */
! //	void doRCall (const QString &call);
! /** get a value for the backend */
! //	void getValue (const QString &id);
! private:
! /** The property holding the generated code. TODO: maybe, de facto, this property should be controlled (but not owned) by the scriptbackend. This way, we'd need less twisted logic inside this class. */
! 	RKComponentPropertyCode *code;
! 	QString filename;
! 	ScriptBackend *backend;
! 	RKErrorDialog *error_dialog;
! 	RKStandardComponentGUI *gui;
! /** sometimes the plugin can't be destroyed immediately, since, for example the script-backend is
! 	still busy cleaning stuff up. In that case this var is set and the plugin gets destroyed ASAP. */
! 	bool destroyed;
! };
! 
! #include <qwidget.h>
! 
! class RKCommandEditor;
! class QPushButton;
! 
! /** contains the standard GUI elements for a top-level RKStandardComponent
! TODO: differentiate into two classes for dialog and wizard interfaces. For now we ignore the wizard interface */
! class RKStandardComponentGUI : public QWidget {
! 	Q_OBJECT
! public:
! 	RKStandardComponentGUI (RKStandardComponent *component);
! 	~RKStandardComponentGUI ();
! 
! 	QWidget *mainWidget () { return main_widget; };
  public slots:
  	void ok ();
***************
*** 40,49 ****
  	void cancel ();
  	void toggleCode ();
- 	void switchInterfaces ();
  	void help ();
  private:
! /** The property holding the generated code. TODO: maybe, de facto, this property should be controlled (but not owned) by the scriptbackend. This way, we'd need less twisted logic inside this class. */
! 	RKComponentPropertyCode *code;
! 	QString filename;
  };
  
--- 85,108 ----
  	void cancel ();
  	void toggleCode ();
  	void help ();
  private:
! 	QWidget *main_widget;
! 
! 	// standard gui-elements
! 	RKCommandEditor *codeDisplay;
! 
! 	// common widgets
! 	QPushButton *okButton;
! 	QPushButton *cancelButton;
! 	QPushButton *helpButton;
! 	QPushButton *switchButton;
! 
! 	// widgets for dialog only
! 	QPushButton *toggleCodeButton;
! 
! private:
! 	RKStandardComponent *component;
! protected:
! 	void closeEvent (QCloseEvent *e);
  };
  
***************
*** 61,65 ****
  class RKComponentBuilder {
  public:
! 	RKComponentBuilder (RKComponent *parent_component, QWidget *parent_widget);
  	~RKComponentBuilder ();
  	void buildElement (QWidget *parent, const QDomElement &element);
--- 120,124 ----
  class RKComponentBuilder {
  public:
! 	RKComponentBuilder (RKComponent *parent_component);
  	~RKComponentBuilder ();
  	void buildElement (QWidget *parent, const QDomElement &element);

Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rkstandardcomponent.cpp	28 Feb 2006 23:15:46 -0000	1.3
--- rkstandardcomponent.cpp	14 Mar 2006 13:33:42 -0000	1.4
***************
*** 18,23 ****
--- 18,219 ----
  #include "rkstandardcomponent.h"
  
+ //#include <qdom.h>
+ //#include <qfile.h>
+ #include <qfileinfo.h>
+ //#include <qdialog.h>
+ #include <qlayout.h>
+ #include <qgroupbox.h>
+ //#include <qmap.h>
+ #include <qframe.h>
+ #include <qpushbutton.h>
+ //#include <qregexp.h>
+ //#include <qtabwidget.h>
+ #include <qsplitter.h>
+ //#include <qwidgetstack.h>
+ #include <qlabel.h>
+ //#include <qtimer.h>
+ #include <qapplication.h>
+ 
+ #include <klocale.h>
+ 
+ #include "../rkcommandeditor.h"
+ #include "../scriptbackends/phpbackend.h"
+ #include "../misc/rkerrordialog.h"
+ #include "../misc/xmlhelper.h"
+ /*#include "../rkward.h"
+ #include "../rkeditormanager.h"
+ #include "../rkcommandeditor.h"
+ #include "../settings/rksettingsmoduleplugins.h"
+ #include "../rbackend/rinterface.h"*/
+ 
+ // plugin-widgets
+ /*#include "rkpluginwidget.h"
+ #include "rkvarselector.h"
+ #include "rkvarslot.h"
+ #include "rktext.h"
+ #include "rkradio.h"
+ #include "rkcheckbox.h"
+ #include "rkpluginspinbox.h"
+ #include "rkformula.h"
+ #include "rknote.h"
+ #include "rkinput.h"
+ #include "rkpluginbrowser.h" */
+ 
+ #include "../rkglobals.h"
+ 
  #include "../debug.h"
  
  
+ RKStandardComponent::RKStandardComponent (RKComponent *parent_component, QWidget *parent_widget, const QString &filename) : RKComponent (parent_component, parent_widget) {
+ 	RKStandardComponent::filename = filename;
+ 	backend = 0;
+ 	gui = 0;
+ 
+ 	// create an error-dialog
+ 	error_dialog = new RKErrorDialog (i18n ("The R-backend has reported one or more error(s) while processing the plugin '%1'. This may lead to an incorrect ouput and is likely due to a bug in the plugin.\nA transcript of the error message(s) is shown below.").arg (filename), i18n ("R-Error"), false);
+ 	
+ 	// open the main description file for parsing
+ 	XMLHelper* xml = XMLHelper::getStaticHelper ();
+ 	QDomElement doc_element = xml->openXMLFile (filename, DL_ERROR);
+ 	if (xml->highestError () >= DL_ERROR) {
+ 		// TODO: inform user
+ 		return;
+ 	}
+ 
+ 	// initialize the PHP-backend with the code-template
+ 	QDomElement element = xml->getChildElement (doc_element, "code", DL_WARNING);
+ 	QString dummy = QFileInfo (filename).dirPath () + "/" + xml->getStringAttribute (element, "file", "code.php", DL_WARNING);
+ 	backend = new PHPBackend ();
+ 	connect (backend, SIGNAL (commandDone (int)), this, SLOT (backendCommandDone (int)));
+ 	connect (backend, SIGNAL (idle ()), this, SLOT (backendIdle ()));
+ 	connect (backend, SIGNAL (requestValue (const QString&)), this, SLOT (getValue (const QString&)));
+ //	connect (backend, SIGNAL (requestRCall (const QString&)), this, SLOT (doRCall (const QString&)));
+ //	connect (backend, SIGNAL (requestRVector (const QString&)), this, SLOT (getRVector (const QString&)));
+ 	connect (backend, SIGNAL (haveError ()), this, SLOT (tryDestruct ()));
+ 	if (!backend->initialize (dummy)) return;
+ 
+ 	connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (tryDestruct ()));
+ 	
+ /*	update_timer = new QTimer (this);
+ 	connect (update_timer, SIGNAL (timeout ()), this, SLOT (doChangeUpdate ())); */
+ 
+ // construct the GUI
+ 	// if top-level, construct standard elements
+ 	if (!parent_widget) {
+ 		parent_widget = gui = new RKStandardComponentGUI (this);
+ 	}
+ 
+ 	// create a builder
+ 	RKComponentBuilder *builder = new RKComponentBuilder (this);
+ 
+ 	// go
+ 	// TODO: this is wrong! wizard/dialog
+ 	builder->buildElement (parent_widget, doc_element);
+ }
+ 
+ RKStandardComponent::~RKStandardComponent () {
+ }
+ 
+ void RKStandardComponent::tryDestruct () {
+ 	if (gui) {
+ 		gui->hide ();
+ 	}
+ 	destroyed = true;
+ 
+ 	// TODO!
+ }
+ 
+ void RKStandardComponent::switchInterfaces () {
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ /////////////////////////////////////// RKStandardComponentGUI ////////////////////////////////////////////////
+ 
+ RKStandardComponentGUI::RKStandardComponentGUI (RKStandardComponent *component) {
+ 	RKStandardComponentGUI::component = component;
+ 
+ 	QGridLayout *main_grid = new QGridLayout (this, 1, 1);
+ 	QSplitter *splitter = new QSplitter (QSplitter::Vertical, this);
+ 	main_grid->addWidget (splitter, 0, 0);
+ 	QWidget *main_widget = new QWidget (splitter);
+ 	
+ 	QHBoxLayout *hbox = new QHBoxLayout (main_widget, RKGlobals::marginHint (), RKGlobals::spacingHint ());
+ 	QVBoxLayout *vbox = new QVBoxLayout (hbox, RKGlobals::spacingHint ());
+ 
+ 	// build standard elements
+ 	// lines
+ 	QFrame *line;
+ 	line = new QFrame (main_widget);
+ 	line->setFrameShape (QFrame::VLine);
+ 	line->setFrameShadow (QFrame::Plain);	
+ 	hbox->addWidget (line);
+ 
+ 	// buttons
+ 	vbox = new QVBoxLayout (hbox, RKGlobals::spacingHint ());
+ 	okButton = new QPushButton ("Submit", main_widget);
+ 	connect (okButton, SIGNAL (clicked ()), this, SLOT (ok ()));
+ 	vbox->addWidget (okButton);
+ 	
+ 	cancelButton = new QPushButton ("Close", main_widget);
+ 	connect (cancelButton, SIGNAL (clicked ()), this, SLOT (cancel ()));
+ 	vbox->addWidget (cancelButton);
+ 	vbox->addStretch (1);
+ 	
+ 	helpButton = new QPushButton ("Help", main_widget);
+ 	connect (helpButton, SIGNAL (clicked ()), this, SLOT (help ()));
+ 	vbox->addWidget (helpButton);
+ 	
+ /*	if (wizard_available) {
+ 		switchButton = new QPushButton ("Use Wizard", main_widget);
+ 		connect (switchButton, SIGNAL (clicked ()), this, SLOT (switchInterfaces ()));
+ 		vbox->addWidget (switchButton);
+ 	} */
+ 	vbox->addStretch (2);
+ 	
+ 	toggleCodeButton = new QPushButton ("Code", main_widget);
+ 	toggleCodeButton->setToggleButton (true);
+ 	toggleCodeButton->setOn (true);
+ 	connect (toggleCodeButton, SIGNAL (clicked ()), this, SLOT (toggleCode ()));
+ 	vbox->addWidget (toggleCodeButton);
+ 	
+ 	// text-fields
+ 	QWidget *lower_widget = new QWidget (splitter);
+ 	
+ 	vbox = new QVBoxLayout (lower_widget, RKGlobals::spacingHint ());
+ 	codeDisplay = new RKCommandEditor (lower_widget, true);
+ 	vbox->addWidget (codeDisplay);
+ }
+ 
+ RKStandardComponentGUI::~RKStandardComponentGUI () {
+ }
+ 
+ void RKStandardComponentGUI::ok () {
+ }
+ 
+ void RKStandardComponentGUI::back () {
+ }
+ 
+ void RKStandardComponentGUI::cancel () {
+ }
+ 
+ void RKStandardComponentGUI::toggleCode () {
+ }
+ 
+ void RKStandardComponentGUI::help () {
+ }
+ 
+ void RKStandardComponentGUI::closeEvent (QCloseEvent *e) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	e->accept ();
+ 	component->tryDestruct ();
+ }
+ 
+ 
+ 
  #include "rkstandardcomponent.moc"





More information about the rkward-tracker mailing list