[Ktutorial-commits] SF.net SVN: ktutorial:[165] trunk/ktutorial/ktutorial-editor/src/ serialization
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-03-19 07:12:28
|
Revision: 165
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=165&view=rev
Author: danxuliu
Date: 2010-03-19 07:12:21 +0000 (Fri, 19 Mar 2010)
Log Message:
-----------
Make arguments const, as a tutorial shouldn't be modified when exported.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp
trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h
Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2010-03-19 04:46:11 UTC (rev 164)
+++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2010-03-19 07:12:21 UTC (rev 165)
@@ -34,7 +34,7 @@
JavascriptExporter::JavascriptExporter(): mIndentationLevel(0) {
}
-QString JavascriptExporter::exportTutorial(Tutorial* tutorial) {
+QString JavascriptExporter::exportTutorial(const Tutorial* tutorial) {
QString code;
mOut.setString(&code);
@@ -54,7 +54,7 @@
//private:
-void JavascriptExporter::writeLicense(Tutorial* tutorial) {
+void JavascriptExporter::writeLicense(const Tutorial* tutorial) {
if (tutorial->licenseText().isEmpty()) {
return;
}
@@ -76,7 +76,7 @@
out() << " ****" << QString('*').repeated(maximumLineLength) << "****/\n\n";
}
-void JavascriptExporter::writeInformation(Tutorial* tutorial) {
+void JavascriptExporter::writeInformation(const Tutorial* tutorial) {
if (tutorial->name().isEmpty()) {
out() << "//Error: Tutorial without name!\n";
} else {
@@ -94,7 +94,7 @@
mOut << "\n";
}
-void JavascriptExporter::writeSetup(Tutorial* tutorial) {
+void JavascriptExporter::writeSetup(const Tutorial* tutorial) {
if (tutorial->customSetupCode().isEmpty()) {
return;
}
@@ -108,7 +108,7 @@
<< " this, \"tutorialSetup(QObject*)\");\n\n";
}
-void JavascriptExporter::writeTearDown(Tutorial* tutorial) {
+void JavascriptExporter::writeTearDown(const Tutorial* tutorial) {
if (tutorial->customTearDownCode().isEmpty()) {
return;
}
@@ -122,7 +122,7 @@
<< " this, \"tutorialTearDown(QObject*)\");\n\n";
}
-void JavascriptExporter::writeStep(Step* step) {
+void JavascriptExporter::writeStep(const Step* step) {
if (step->id().isEmpty()) {
out() << "//Error: Step without id!\n\n";
return;
@@ -148,7 +148,7 @@
out() << "tutorial.addStep(" << stepVariable << ");\n\n";
}
-void JavascriptExporter::writeSetup(Step* step) {
+void JavascriptExporter::writeSetup(const Step* step) {
if (step->customSetupCode().isEmpty() && step->reactions().count() == 0) {
return;
}
@@ -180,7 +180,7 @@
mVariables.clear();
}
-void JavascriptExporter::writeTearDown(Step* step) {
+void JavascriptExporter::writeTearDown(const Step* step) {
if (step->customTearDownCode().isEmpty()) {
return;
}
@@ -195,7 +195,8 @@
<< " this, \"" << stepVariable << "TearDown(QObject*)\");\n\n";
}
-void JavascriptExporter::writeReaction(Step* step, Reaction* reaction) {
+void JavascriptExporter::writeReaction(const Step* step,
+ const Reaction* reaction) {
if (reaction->triggerType() == Reaction::ConditionMet &&
!reaction->waitFor()) {
out() << "//Error: WaitFor not set!\n";
@@ -252,24 +253,24 @@
addFunction(functionName, reaction->customCode());
}
-QString JavascriptExporter::writeWaitFor(WaitFor* waitFor) {
- if (qobject_cast<WaitForComposed*>(waitFor)) {
- return writeWaitFor(static_cast<WaitForComposed*>(waitFor));
+QString JavascriptExporter::writeWaitFor(const WaitFor* waitFor) {
+ if (qobject_cast<const WaitForComposed*>(waitFor)) {
+ return writeWaitFor(static_cast<const WaitForComposed*>(waitFor));
}
- if (qobject_cast<WaitForEvent*>(waitFor)) {
- return writeWaitFor(static_cast<WaitForEvent*>(waitFor));
+ if (qobject_cast<const WaitForEvent*>(waitFor)) {
+ return writeWaitFor(static_cast<const WaitForEvent*>(waitFor));
}
- if (qobject_cast<WaitForNot*>(waitFor)) {
- return writeWaitFor(static_cast<WaitForNot*>(waitFor));
+ if (qobject_cast<const WaitForNot*>(waitFor)) {
+ return writeWaitFor(static_cast<const WaitForNot*>(waitFor));
}
- if (qobject_cast<WaitForSignal*>(waitFor)) {
- return writeWaitFor(static_cast<WaitForSignal*>(waitFor));
+ if (qobject_cast<const WaitForSignal*>(waitFor)) {
+ return writeWaitFor(static_cast<const WaitForSignal*>(waitFor));
}
return "";
}
-QString JavascriptExporter::writeWaitFor(WaitForComposed* waitForComposed) {
+QString JavascriptExporter::writeWaitFor(const WaitForComposed* waitForComposed) {
QString type;
if (waitForComposed->compositionType() == WaitForComposed::And) {
type = "And";
@@ -295,7 +296,7 @@
return variable;
}
-QString JavascriptExporter::writeWaitFor(WaitForEvent* waitForEvent) {
+QString JavascriptExporter::writeWaitFor(const WaitForEvent* waitForEvent) {
if (waitForEvent->receiverName().isEmpty()) {
out() << "//Error: WaitForEvent without receiver name!\n";
return "";
@@ -318,7 +319,7 @@
return variable;
}
-QString JavascriptExporter::writeWaitFor(WaitForNot* waitForNot) {
+QString JavascriptExporter::writeWaitFor(const WaitForNot* waitForNot) {
if (!waitForNot->negatedWaitFor()) {
out() << "//Error: WaitForNot without negated WaitFor!\n";
return "";
@@ -336,7 +337,7 @@
return variable;
}
-QString JavascriptExporter::writeWaitFor(WaitForSignal* waitForSignal) {
+QString JavascriptExporter::writeWaitFor(const WaitForSignal* waitForSignal) {
if (waitForSignal->emitterName().isEmpty()) {
out() << "//Error: WaitForSignal without emitter name!\n";
return "";
Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2010-03-19 04:46:11 UTC (rev 164)
+++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2010-03-19 07:12:21 UTC (rev 165)
@@ -69,7 +69,7 @@
* @param tutorial The tutorial to export.
* @return The Javascript code.
*/
- QString exportTutorial(Tutorial* tutorial);
+ QString exportTutorial(const Tutorial* tutorial);
private:
@@ -100,7 +100,7 @@
*
* @param tutorial The tutorial to write its license.
*/
- void writeLicense(Tutorial* tutorial);
+ void writeLicense(const Tutorial* tutorial);
/**
* Writes the name and description code of a tutorial.
@@ -108,7 +108,7 @@
*
* @param tutorial The tutorial to write its name and description code.
*/
- void writeInformation(Tutorial* tutorial);
+ void writeInformation(const Tutorial* tutorial);
/**
* Writes the setup function of a tutorial and its custom code.
@@ -116,7 +116,7 @@
*
* @param tutorial The tutorial to write its setup function.
*/
- void writeSetup(Tutorial* tutorial);
+ void writeSetup(const Tutorial* tutorial);
/**
* Writes the tear down function of a tutorial and its custom code.
@@ -124,7 +124,7 @@
*
* @param tutorial The tutorial to write its tear down function.
*/
- void writeTearDown(Tutorial* tutorial);
+ void writeTearDown(const Tutorial* tutorial);
/**
* Writes the full code (step creation, setup, tear down and adding to the
@@ -133,7 +133,7 @@
*
* @param step The step to write its code.
*/
- void writeStep(Step* step);
+ void writeStep(const Step* step);
/**
* Writes the setup code (including setting up reactions) of a Step.
@@ -144,7 +144,7 @@
*
* @param step The step to write its setup code.
*/
- void writeSetup(Step* step);
+ void writeSetup(const Step* step);
/**
* Writes the tear down code of a Step.
@@ -152,7 +152,7 @@
*
* @param step The step to write its tear down code.
*/
- void writeTearDown(Step* step);
+ void writeTearDown(const Step* step);
/**
* Writes the reaction code.
@@ -162,7 +162,7 @@
* @param step The step that the reaction is part of.
* @param reaction The reaction to write its code.
*/
- void writeReaction(Step* step, Reaction* reaction);
+ void writeReaction(const Step* step, const Reaction* reaction);
/**
* Writes the code to create and set a WaitFor.
@@ -171,7 +171,7 @@
* @return The name of the variable that holds the WaitFor, or an empty
* string if the WaitFor data is invalid.
*/
- QString writeWaitFor(WaitFor* waitFor);
+ QString writeWaitFor(const WaitFor* waitFor);
/**
* Writes the code to create and set a WaitForComposed.
@@ -181,7 +181,7 @@
* @param waitForComposed The WaitForComposed.
* @return The name of the variable that holds the WaitFor.
*/
- QString writeWaitFor(WaitForComposed* waitForComposed);
+ QString writeWaitFor(const WaitForComposed* waitForComposed);
/**
* Writes the code to create and set a WaitForEvent.
@@ -191,7 +191,7 @@
* @param waitForEvent The WaitForEvent.
* @return The name of the variable that holds the WaitFor.
*/
- QString writeWaitFor(WaitForEvent* waitForEvent);
+ QString writeWaitFor(const WaitForEvent* waitForEvent);
/**
* Writes the code to create and set a WaitForNot.
@@ -201,7 +201,7 @@
* @param waitForNot The WaitForNot.
* @return The name of the variable that holds the WaitFor.
*/
- QString writeWaitFor(WaitForNot* waitForNot);
+ QString writeWaitFor(const WaitForNot* waitForNot);
/**
* Writes the code to create and set a WaitForSignal.
@@ -211,7 +211,7 @@
* @param waitForSignal The WaitForSignal.
* @return The name of the variable that holds the WaitFor.
*/
- QString writeWaitFor(WaitForSignal* waitForSignal);
+ QString writeWaitFor(const WaitForSignal* waitForSignal);
/**
* Returns the output stream after adding the identation text.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|