[rkward-cvs] SF.net SVN: rkward: [1340] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Feb 6 00:21:11 UTC 2007


Revision: 1340
          http://svn.sourceforge.net/rkward/?rev=1340&view=rev
Author:   tfry
Date:     2007-02-05 16:21:10 -0800 (Mon, 05 Feb 2007)

Log Message:
-----------
Prevent updating code (and preview) too often

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkpreviewbox.cpp
    trunk/rkward/rkward/plugin/rkpreviewbox.h
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugin/rkstandardcomponent.h
    trunk/rkward/rkward/scriptbackends/phpbackend.cpp

Modified: trunk/rkward/rkward/plugin/rkpreviewbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpreviewbox.cpp	2007-02-05 21:11:43 UTC (rev 1339)
+++ trunk/rkward/rkward/plugin/rkpreviewbox.cpp	2007-02-06 00:21:10 UTC (rev 1340)
@@ -65,6 +65,8 @@
 	}
 
 	// initialize
+	update_timer = new QTimer (this);
+	connect (update_timer, SIGNAL (timeout ()), this, SLOT (tryPreviewNow ()));
 	updating = false;
 	changedState (0);
 }
@@ -102,7 +104,7 @@
 void RKPreviewBox::tryPreview () {
 	RK_TRACE (PLUGIN);
 
-	if (toggle_preview_box->isChecked ()) QTimer::singleShot (0, this, SLOT (tryPreviewNow ()));
+	if (toggle_preview_box->isChecked ()) update_timer->start (10, true);
 	else killPreview ();
 
 	updateStatusLabel ();

Modified: trunk/rkward/rkward/plugin/rkpreviewbox.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpreviewbox.h	2007-02-05 21:11:43 UTC (rev 1339)
+++ trunk/rkward/rkward/plugin/rkpreviewbox.h	2007-02-06 00:21:10 UTC (rev 1340)
@@ -27,6 +27,7 @@
 class QCheckBox;
 class QDomElement;
 class QLabel;
+class QTimer;
 
 /**
 This RKComponent provides a (togglable) automatic graphical preview. WARNING: This component violates some standards of "good component behavior", esp. by assuming several things about the nature of the parent component. So please do not take this as an example for basing other components on.
@@ -56,6 +57,7 @@
 	void tryPreview ();
 	void killPreview ();
 	void updateStatusLabel ();
+	QTimer *update_timer;
 	QCheckBox *toggle_preview_box;
 	QLabel *status_label;
 	RKComponentPropertyCode *code_property;

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2007-02-05 21:11:43 UTC (rev 1339)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2007-02-06 00:21:10 UTC (rev 1340)
@@ -26,6 +26,7 @@
 #include <qtabwidget.h>
 #include <qlabel.h>
 #include <qapplication.h>
+#include <qtimer.h>
 
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -93,6 +94,8 @@
 	have_help = QFileInfo (dummy).exists ();
 
 	connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (deleteLater ()));
+	handle_change_timer = new QTimer (this);
+	connect (handle_change_timer, SIGNAL (timeout ()), this, SLOT (handleChange ()));
 
 // construct the GUI
 	if (!parent_component) {					// top-level
@@ -298,7 +301,15 @@
 	RK_TRACE (PLUGIN);
 
 	if (!created) return;
+	if (gui) gui->enableSubmit (false);
 
+	// delay actual handling, until all changes have run up
+	handle_change_timer->start (10, true);
+}
+
+void RKStandardComponent::handleChange () {
+	RK_TRACE (PLUGIN);
+
 	backend->preprocess (0);
 	backend->calculate (0);
 	backend->printout (0);
@@ -306,8 +317,7 @@
 	backend->preview (0);
 
 	if (gui) {
-		gui->updateCode ();
-		gui->enableSubmit (isSatisfied ());
+		gui->updateCode ();	// will read "processing, please wait", or similar
 	}
 
 	RKComponent::changed ();
@@ -318,7 +328,7 @@
 	RK_ASSERT (backend);
 
 	return (!(backend->isBusy ()));
-};
+}
 
 void RKStandardComponent::backendIdle () {
 	RK_TRACE (PLUGIN);

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.h	2007-02-05 21:11:43 UTC (rev 1339)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.h	2007-02-06 00:21:10 UTC (rev 1340)
@@ -26,6 +26,7 @@
 class RKComponentHandle;
 class RKStandardComponentStack;
 class ScriptBackend;
+class QTimer;
 
 /** The standard type of component (i.e. stand-alone), previously known as "plugin". This is the type of component described by an XML-file
 
@@ -80,6 +81,7 @@
 	void hide ();
 /** for enslaved components */
 	void showGUI ();
+	void handleChange ();
 private:
 /** The property holding the generated code. Note that this member is tightly controlled by the ScriptBackend */
 	RKComponentPropertyCode *code;
@@ -89,6 +91,7 @@
 	RKStandardComponentGUI *gui;
 	RKComponentHandle *handle;
 	RKStandardComponentStack *wizard;
+	QTimer *handle_change_timer;
 /** Avoid updating code-display, etc. until the component is fully created */
 	bool created;
 	bool createTopLevel (const QDomElement &doc_element, int force_mode=0, bool enslaved=false);

Modified: trunk/rkward/rkward/scriptbackends/phpbackend.cpp
===================================================================
--- trunk/rkward/rkward/scriptbackends/phpbackend.cpp	2007-02-05 21:11:43 UTC (rev 1339)
+++ trunk/rkward/rkward/scriptbackends/phpbackend.cpp	2007-02-06 00:21:10 UTC (rev 1340)
@@ -110,16 +110,16 @@
 	if (code_property) {
 		if (type == Preprocess) {
 			code_property->setPreprocess (QString::null);
-			invalidateCalls (Preprocess);
 		} else if (type == Calculate) {
 			code_property->setCalculate (QString::null);
-			invalidateCalls (Calculate);
 		} else if (type == Printout) {
 			code_property->setPrintout (QString::null);
-			invalidateCalls (Printout);
 		} else if (type == Cleanup) {
 			code_property->setCleanup (QString::null);
+		} else if (type == Preview) {
+			code_property->setPreview (QString::null);
 		}
+		invalidateCalls (type);
 	}
 
 	command_stack.append (command);
@@ -278,12 +278,12 @@
 			busy = true;
 //			writeData (res + eot_string);
 		} else if (request.startsWith ("PHP-Error")) {
-				QString error = request.remove ("PHP-Error");
-				php_process->detach ();
-				KMessageBox::error (0, i18n ("The PHP-backend has reported an error\n(\"%1\")\nand has been shut down. This is most likely due to a bug in the plugin. But of course you may want to try to close and restart the plugin to see whether it works with different settings.").arg (error.stripWhiteSpace ()), i18n ("PHP-Error"));
-				emit (haveError ());
-				destroy ();
-				return;
+			QString error = request.remove ("PHP-Error");
+			php_process->detach ();
+			KMessageBox::error (0, i18n ("The PHP-backend has reported an error\n(\"%1\")\nand has been shut down. This is most likely due to a bug in the plugin. But of course you may want to try to close and restart the plugin to see whether it works with different settings.").arg (error.stripWhiteSpace ()), i18n ("PHP-Error"));
+			emit (haveError ());
+			destroy ();
+			return;
 		}
 		return;
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list