[Ktutorial-commits] SF.net SVN: ktutorial:[265] trunk/ktutorial/ktutorial-library
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-09-28 21:32:19
|
Revision: 265 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=265&view=rev Author: danxuliu Date: 2010-09-28 21:32:13 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Fix not stopping the highlighting of a widget when the StepTextWidget is deleted. Modified Paths: -------------- trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.cpp trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.cpp 2010-09-28 20:55:26 UTC (rev 264) +++ trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.cpp 2010-09-28 21:32:13 UTC (rev 265) @@ -59,6 +59,12 @@ connect(this, SIGNAL(textChanged()), this, SLOT(updateText())); } +StepTextWidget::~StepTextWidget() { + if (mCurrentHighlightedWidget) { + stopHighlightingCurrentWidget(); + } +} + bool StepTextWidget::eventFilter(QObject* watched, QEvent* event) { if (watched != mCurrentHighlightedWidget) { return false; Modified: trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h 2010-09-28 20:55:26 UTC (rev 264) +++ trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h 2010-09-28 21:32:13 UTC (rev 265) @@ -59,6 +59,12 @@ explicit StepTextWidget(QWidget* parent = 0); /** + * Destroys this StepTextWidget. + * If there is a widget being highlighted, the highlighting is stopped. + */ + virtual ~StepTextWidget(); + + /** * Watches the widget currently being highlighted and stops the highlighting * when it is focused. * Modified: trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2010-09-28 20:55:26 UTC (rev 264) +++ trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2010-09-28 21:32:13 UTC (rev 265) @@ -58,6 +58,7 @@ void testStopHighlightingWidgetWhenFocused(); void testSetTextWhenWidgetIsBeingHighlighted(); + void testDeleteWhenWidgetIsBeingHighlighted(); private: @@ -321,6 +322,25 @@ QVERIFY(!widgetToHighlight->findChild<WidgetHighlighter*>("")); } +void StepTextWidgetTest::testDeleteWhenWidgetIsBeingHighlighted() { + KXmlGuiWindow mainWindow; + KTutorial::self()->setup(&mainWindow); + QWidget* widgetToHighlight = new QWidget(&mainWindow); + widgetToHighlight->setObjectName("widgetName"); + + StepTextWidget* widget = new StepTextWidget(); + widget->setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); + widget->show(); + + QPoint position = centerOfText(*widget, "widget to highlight"); + QTest::mouseClick(widget->viewport(), Qt::LeftButton, Qt::NoModifier, + position, 500); + + delete widget; + + QVERIFY(!widgetToHighlight->findChild<WidgetHighlighter*>("")); +} + /////////////////////////////////// Helpers //////////////////////////////////// void StepTextWidgetTest::selectFirstContextMenuOption() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |