[Ktutorial-commits] SF.net SVN: ktutorial:[263] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-09-27 16:17:16
|
Revision: 263 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=263&view=rev Author: danxuliu Date: 2010-09-27 16:17:07 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Fix loading rich text markup as rich text instead of as plain text in the KTextEdits: in some places like code edition widgets rich text makes no sense, and in places like step description it must be loaded as plain text to be properly edited and saved (as there is no WYSIWYG edition yet). Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/view/LicenseWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/TutorialInformationWidget.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/LicenseWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialInformationWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/LicenseWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/LicenseWidget.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/src/view/LicenseWidget.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -30,7 +30,7 @@ ui = new Ui::LicenseWidget(); ui->setupUi(this); - ui->licenseTextEdit->setText(tutorial->licenseText()); + ui->licenseTextEdit->setPlainText(tutorial->licenseText()); } LicenseWidget::~LicenseWidget() { Modified: trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -66,7 +66,7 @@ } ui->triggerOptionLineEdit->setText(reaction->optionName()); - ui->responseCodeTextEdit->setText(reaction->customCode()); + ui->responseCodeTextEdit->setPlainText(reaction->customCode()); ui->responseStepLineEdit->setText(reaction->nextStepId()); } Modified: trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/src/view/StepCustomCodeWidget.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -36,7 +36,7 @@ ui->setupUi(this); if (type == Setup) { - ui->customCodeTextEdit->setText(step->customSetupCode()); + ui->customCodeTextEdit->setPlainText(step->customSetupCode()); ui->customCodeGroupBox->setTitle(i18nc("@title", "Step setup code")); setWindowTitle(i18nc("@title", "Set the step setup code")); setWhatsThis(i18nc("@info:whatsthis", "<para>Set the code to be " @@ -46,7 +46,7 @@ "must be written in the same programming language the tutorial will be " "exported to.</para>")); } else { - ui->customCodeTextEdit->setText(step->customTearDownCode()); + ui->customCodeTextEdit->setPlainText(step->customTearDownCode()); ui->customCodeGroupBox->setTitle(i18nc("@title", "Step tear down code")); setWindowTitle(i18nc("@title", "Set the step tear down code")); Modified: trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -31,7 +31,7 @@ ui->setupUi(this); ui->idLineEdit->setText(step->id()); - ui->textTextEdit->setText(step->text()); + ui->textTextEdit->setPlainText(step->text()); } StepDataWidget::~StepDataWidget() { Modified: trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/src/view/TutorialCustomCodeWidget.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -36,7 +36,7 @@ ui->setupUi(this); if (type == Setup) { - ui->customCodeTextEdit->setText(tutorial->customSetupCode()); + ui->customCodeTextEdit->setPlainText(tutorial->customSetupCode()); ui->customCodeGroupBox->setTitle(i18nc("@title", "Tutorial setup code")); setWindowTitle(i18nc("@title", "Set the tutorial setup code")); @@ -47,7 +47,7 @@ "must be written in the same programming language the tutorial will be " "exported to.</para>")); } else { - ui->customCodeTextEdit->setText(tutorial->customTearDownCode()); + ui->customCodeTextEdit->setPlainText(tutorial->customTearDownCode()); ui->customCodeGroupBox->setTitle(i18nc("@title", "Tutorial tear down code")); setWindowTitle(i18nc("@title", "Set the tutorial tear down code")); Modified: trunk/ktutorial/ktutorial-editor/src/view/TutorialInformationWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TutorialInformationWidget.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/src/view/TutorialInformationWidget.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -32,7 +32,7 @@ ui->setupUi(this); ui->nameLineEdit->setText(tutorial->name()); - ui->descriptionTextEdit->setText(tutorial->description()); + ui->descriptionTextEdit->setPlainText(tutorial->description()); } TutorialInformationWidget::~TutorialInformationWidget() { Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/LicenseWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/LicenseWidgetTest.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/LicenseWidgetTest.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -31,6 +31,7 @@ private slots: void testConstructor(); + void testConstructorWithRichText(); void testSaveChanges(); @@ -51,6 +52,18 @@ QCOMPARE(licenseTextEdit(widget)->toPlainText(), QString("The license")); } +void LicenseWidgetTest::testConstructorWithRichText() { + Tutorial tutorial; + tutorial.setLicenseText("<p>The license</p>"); + + QWidget parent; + LicenseWidget* widget = new LicenseWidget(&tutorial, &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(licenseTextEdit(widget)->toPlainText(), + QString("<p>The license</p>")); +} + void LicenseWidgetTest::testSaveChanges() { Tutorial tutorial; tutorial.setLicenseText("The license"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -41,6 +41,7 @@ private slots: void testConstructor(); + void testConstructorWithRichText(); void testSelectTriggerTypeOption(); void testSelectTriggerTypeCondition(); @@ -101,6 +102,36 @@ QString("The custom code")); } +void ReactionWidgetTest::testConstructorWithRichText() { + WaitFor* waitFor = new WaitForSignal(); + Reaction reaction; + reaction.setTriggerType(Reaction::ConditionMet); + reaction.setWaitFor(waitFor); + reaction.setOptionName("The option name"); + reaction.setResponseType(Reaction::CustomCode); + reaction.setCustomCode("<p>The custom code</p>"); + reaction.setNextStepId("The step id"); + + QWidget parent; + ReactionWidget* widget = new ReactionWidget(&reaction, &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QVERIFY(!triggerOptionRadioButton(widget)->isChecked()); + QVERIFY(!triggerOptionLineEdit(widget)->isEnabled()); + QCOMPARE(triggerOptionLineEdit(widget)->text(), QString("The option name")); + QVERIFY(triggerConditionRadioButton(widget)->isChecked()); + QVERIFY(triggerConditionWidget(widget)->isEnabled()); + QVERIFY(triggerConditionWidget(widget)->waitFor() != waitFor); + QVERIFY(*triggerConditionWidget(widget)->waitFor() == *waitFor); + QVERIFY(!responseStepRadioButton(widget)->isChecked()); + QVERIFY(!responseStepLineEdit(widget)->isEnabled()); + QCOMPARE(responseStepLineEdit(widget)->text(), QString("The step id")); + QVERIFY(responseCodeRadioButton(widget)->isChecked()); + QVERIFY(responseCodeTextEdit(widget)->isEnabled()); + QCOMPARE(responseCodeTextEdit(widget)->toPlainText(), + QString("<p>The custom code</p>")); +} + void ReactionWidgetTest::testSelectTriggerTypeOption() { Reaction reaction; reaction.setTriggerType(Reaction::ConditionMet); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/StepCustomCodeWidgetTest.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -31,7 +31,9 @@ private slots: void testConstructorSetup(); + void testConstructorSetupWithRichText(); void testConstructorTearDown(); + void testConstructorTearDownWithRichText(); void testSaveChangesSetup(); void testSaveChangesTearDown(); @@ -57,6 +59,21 @@ QString("The setup code")); } +void StepCustomCodeWidgetTest::testConstructorSetupWithRichText() { + Step step; + step.setCustomSetupCode("<p>The setup code</p>"); + + QWidget parent; + StepCustomCodeWidget* widget = + new StepCustomCodeWidget(&step, + StepCustomCodeWidget::Setup, + &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(customCodeTextEdit(widget)->toPlainText(), + QString("<p>The setup code</p>")); +} + void StepCustomCodeWidgetTest::testConstructorTearDown() { Step step; step.setCustomTearDownCode("The tear down code"); @@ -72,6 +89,21 @@ QString("The tear down code")); } +void StepCustomCodeWidgetTest::testConstructorTearDownWithRichText() { + Step step; + step.setCustomTearDownCode("<p>The tear down code</p>"); + + QWidget parent; + StepCustomCodeWidget* widget = + new StepCustomCodeWidget(&step, + StepCustomCodeWidget::TearDown, + &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(customCodeTextEdit(widget)->toPlainText(), + QString("<p>The tear down code</p>")); +} + void StepCustomCodeWidgetTest::testSaveChangesSetup() { Step step; step.setCustomSetupCode("The setup code"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -31,6 +31,7 @@ private slots: void testConstructor(); + void testConstructorWithRichText(); void testSaveChanges(); @@ -54,6 +55,19 @@ QCOMPARE(textTextEdit(widget)->toPlainText(), QString("The text")); } +void StepDataWidgetTest::testConstructorWithRichText() { + Step step; + step.setId("The id"); + step.setText("<p>The text</p>"); + + QWidget parent; + StepDataWidget* widget = new StepDataWidget(&step, &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(idLineEdit(widget)->text(), QString("The id")); + QCOMPARE(textTextEdit(widget)->toPlainText(), QString("<p>The text</p>")); +} + void StepDataWidgetTest::testSaveChanges() { Step step; step.setId("The id"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialCustomCodeWidgetTest.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -31,7 +31,9 @@ private slots: void testConstructorSetup(); + void testConstructorSetupWithRichText(); void testConstructorTearDown(); + void testConstructorTearDownWithRichText(); void testSaveChangesSetup(); void testSaveChangesTearDown(); @@ -57,6 +59,21 @@ QString("The setup code")); } +void TutorialCustomCodeWidgetTest::testConstructorSetupWithRichText() { + Tutorial tutorial; + tutorial.setCustomSetupCode("<p>The setup code</p>"); + + QWidget parent; + TutorialCustomCodeWidget* widget = + new TutorialCustomCodeWidget(&tutorial, + TutorialCustomCodeWidget::Setup, + &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(customCodeTextEdit(widget)->toPlainText(), + QString("<p>The setup code</p>")); +} + void TutorialCustomCodeWidgetTest::testConstructorTearDown() { Tutorial tutorial; tutorial.setCustomTearDownCode("The tear down code"); @@ -72,6 +89,21 @@ QString("The tear down code")); } +void TutorialCustomCodeWidgetTest::testConstructorTearDownWithRichText() { + Tutorial tutorial; + tutorial.setCustomTearDownCode("<p>The tear down code</p>"); + + QWidget parent; + TutorialCustomCodeWidget* widget = + new TutorialCustomCodeWidget(&tutorial, + TutorialCustomCodeWidget::TearDown, + &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(customCodeTextEdit(widget)->toPlainText(), + QString("<p>The tear down code</p>")); +} + void TutorialCustomCodeWidgetTest::testSaveChangesSetup() { Tutorial tutorial; tutorial.setCustomSetupCode("The setup code"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialInformationWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialInformationWidgetTest.cpp 2010-09-26 21:07:06 UTC (rev 262) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/TutorialInformationWidgetTest.cpp 2010-09-27 16:17:07 UTC (rev 263) @@ -31,6 +31,7 @@ private slots: void testConstructor(); + void testConstructorWithRichText(); void testSaveChanges(); @@ -56,6 +57,21 @@ QString("The description")); } +void TutorialInformationWidgetTest::testConstructorWithRichText() { + Tutorial tutorial; + tutorial.setName("The name"); + tutorial.setDescription("<p>The description</p>"); + + QWidget parent; + TutorialInformationWidget* widget = new TutorialInformationWidget(&tutorial, + &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(nameLineEdit(widget)->text(), QString("The name")); + QCOMPARE(descriptionTextEdit(widget)->toPlainText(), + QString("<p>The description</p>")); +} + void TutorialInformationWidgetTest::testSaveChanges() { Tutorial tutorial; tutorial.setName("The name"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |