[Ktutorial-commits] SF.net SVN: ktutorial:[162] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-03-16 05:43:03
|
Revision: 162 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=162&view=rev Author: danxuliu Date: 2010-03-16 05:42:56 +0000 (Tue, 16 Mar 2010) Log Message: ----------- Add WaitForEvent to store the data of conditions to wait for events. The classes and changes needed to make them work at application level are also included. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp Added Paths: ----------- trunk/ktutorial/ktutorial-editor/src/WaitForEvent.cpp trunk/ktutorial/ktutorial-editor/src/WaitForEvent.h trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.h trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui trunk/ktutorial/ktutorial-editor/tests/unit/WaitForEventTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventTreeItemTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt 2010-03-16 05:42:56 UTC (rev 162) @@ -13,6 +13,7 @@ Tutorial.cpp WaitFor.cpp WaitForComposed.cpp + WaitForEvent.cpp WaitForNot.cpp WaitForSignal.cpp ) Added: trunk/ktutorial/ktutorial-editor/src/WaitForEvent.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForEvent.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/WaitForEvent.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include "WaitForEvent.h" + +//public: + +WaitForEvent::WaitForEvent(QObject* parent): WaitFor(parent) { +} + +WaitFor* WaitForEvent::clone() const { + WaitForEvent* cloned = new WaitForEvent(); + cloned->setReceiverName(mReceiverName); + cloned->setEventName(mEventName); + + return cloned; +} + +bool WaitForEvent::equals(const WaitFor& waitFor) const { + if (!qobject_cast<const WaitForEvent*>(&waitFor)) { + return false; + } + + const WaitForEvent* waitForEvent = + static_cast<const WaitForEvent*>(&waitFor); + if (waitForEvent->receiverName() != mReceiverName) { + return false; + } + + if (waitForEvent->eventName() != mEventName) { + return false; + } + + return true; +} + +QString WaitForEvent::receiverName() const { + return mReceiverName; +} + +void WaitForEvent::setReceiverName(const QString& receiverName) { + mReceiverName = receiverName; + + emit dataChanged(this); +} + +QString WaitForEvent::eventName() const { + return mEventName; +} + +void WaitForEvent::setEventName(const QString& eventName) { + mEventName = eventName; + + emit dataChanged(this); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/WaitForEvent.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/WaitForEvent.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForEvent.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/WaitForEvent.h 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#ifndef WAITFOREVENT_H +#define WAITFOREVENT_H + +#include "WaitFor.h" + +/** + * Container for conditions that wait for an event to be received data. + * It stores the data used in KTutorial WaitForEvent, but it has nothing to do + * with it (they don't even know each other). Its purpose is store the data + * needed to generate the code to initialize a true KTutorial::WaitForEvent + * object. + * + * When any attribute is modified, dataChanged(WaitFor*) signal is emitted. + */ +class WaitForEvent: public WaitFor { +Q_OBJECT +public: + + /** + * Creates a new WaitForEvent. + * + * @param parent The parent QObject. + */ + WaitForEvent(QObject* parent = 0); + + virtual WaitFor* clone() const; + virtual bool equals(const WaitFor& waitFor) const; + + QString receiverName() const; + void setReceiverName(const QString& receiverName); + + QString eventName() const; + void setEventName(const QString& eventName); + +private: + + QString mReceiverName; + QString mEventName; + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/WaitForEvent.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-03-16 05:42:56 UTC (rev 162) @@ -20,6 +20,8 @@ TutorialTreeItem.cpp TutorialTreeSelectionManager.cpp WaitForComposedTreeItem.cpp + WaitForEventTreeItem.cpp + WaitForEventWidget.cpp WaitForNotTreeItem.cpp WaitForSignalTreeItem.cpp WaitForSignalWidget.cpp @@ -34,6 +36,7 @@ ReactionWidget.ui StepDataWidget.ui TutorialInformationWidget.ui + WaitForEventWidget.ui WaitForSignalWidget.ui WaitForWidget.ui ) Modified: trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -20,6 +20,7 @@ #include "ui_NewWaitForWidget.h" #include "../WaitForComposed.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForSignal.h" @@ -49,6 +50,8 @@ return new WaitForNot(); } else if (index == 3) { return new WaitForSignal(); + } else if (index == 4) { + return new WaitForEvent(); } return 0; Modified: trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui 2010-03-16 05:42:56 UTC (rev 162) @@ -61,6 +61,11 @@ <string comment="@item:inlistbox">The specified signal is emitted</string> </property> </item> + <item> + <property name="text"> + <string comment="@item:inlistbox">The specified event is received</string> + </property> + </item> </widget> </item> </layout> Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include "WaitForEventTreeItem.h" + +#include <KLocalizedString> + +#include "../WaitForEvent.h" + +//public: + +WaitForEventTreeItem::WaitForEventTreeItem(WaitForEvent* waitForEvent, + TreeItem* parent): + WaitForTreeItem(waitForEvent, parent) { + mReceiverName = waitForEvent->receiverName(); + mEventName = waitForEvent->eventName(); + + connect(waitForEvent, SIGNAL(dataChanged(WaitFor*)), + this, SLOT(update(WaitFor*))); +} + +QString WaitForEventTreeItem::text() const { + QString receiverName; + if (mReceiverName.isEmpty()) { + receiverName = i18nc("@item", "(object not set)"); + } else { + receiverName = "\"" + mReceiverName + "\""; + } + + QString eventName; + if (mEventName.isEmpty()) { + eventName = i18nc("@item", "(event not set)"); + } else { + eventName = "\"" + mEventName + "\""; + } + + return i18nc("@item", "When the event %1 is received by object %2", + eventName, receiverName); +} + +//private: + +void WaitForEventTreeItem::update(WaitFor* waitFor) { + WaitForEvent* waitForEvent = static_cast<WaitForEvent*>(waitFor); + mReceiverName = waitForEvent->receiverName(); + mEventName = waitForEvent->eventName(); + + emit dataChanged(this); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.h 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#ifndef WAITFOREVENTTREEITEM_H +#define WAITFOREVENTTREEITEM_H + +#include "WaitForTreeItem.h" + +class WaitForEvent; + +/** + * A TreeItem that represents a WaitForEvent. + * The tree representation of a WaitForEvent is a plain text: + * When the event "event name" is received by the object "object name" + * + * If the event or the receiver name aren't set yet, a placeholder is put + * instead. Event placeholder is "(event not set)", and the receiver name + * placeholder is "(object name not set)" (without quotes, but with + * parenthesis). + * + * Whenever the WaitForEvent data changes, the WaitForEventTreeItem text is + * updated as needed. + */ +class WaitForEventTreeItem: public WaitForTreeItem { +Q_OBJECT +public: + + /** + * Creates a new WaitForEventTreeItem for the given WaitForEvent and with + * the given parent. + * + * @param waitForEvent The WaitForEvent to represent. + * @param parent The parent TreeItem. + */ + explicit WaitForEventTreeItem(WaitForEvent* waitForEvent, + TreeItem* parent = 0); + + /** + * Returns the description of the WaitForEvent. + * + * @return The text for this TreeItem. + */ + virtual QString text() const; + +private: + + /** + * The receiver name of the WaitForEvent. + */ + QString mReceiverName; + + /** + * The event name of the WaitForEvent. + */ + QString mEventName; + +private Q_SLOTS: + + /** + * Updates this WaitForEventTreeItem when the data of its WaitForEvent + * changed. + * + * @param waitFor The WaitForEvent. + */ + void update(WaitFor* waitFor); + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventTreeItem.h ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include "WaitForEventWidget.h" + +#include "ui_WaitForEventWidget.h" +#include "../WaitForEvent.h" + +//public: + +WaitForEventWidget::WaitForEventWidget(WaitForEvent* waitForEvent, + QWidget* parent): + EditionWidget(parent), + mWaitForEvent(waitForEvent) { + + ui = new Ui::WaitForEventWidget(); + ui->setupUi(this); + + ui->receiverNameLineEdit->setText(waitForEvent->receiverName()); + ui->eventNameLineEdit->setText(waitForEvent->eventName()); +} + +WaitForEventWidget::~WaitForEventWidget() { + delete ui; +} + +void WaitForEventWidget::saveChanges() { + QString receiverName = ui->receiverNameLineEdit->text(); + if (mWaitForEvent->receiverName() != receiverName) { + mWaitForEvent->setReceiverName(receiverName); + } + + QString eventName = ui->eventNameLineEdit->text(); + if (mWaitForEvent->eventName() != eventName) { + mWaitForEvent->setEventName(eventName); + } +} Property changes on: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#ifndef WAITFOREVENTWIDGET_H +#define WAITFOREVENTWIDGET_H + +#include "EditionWidget.h" + +class WaitForEvent; + +namespace Ui { +class WaitForEventWidget; +} + +/** + * Edition widget for the condition to wait for an event. + */ +class WaitForEventWidget: public EditionWidget { +Q_OBJECT +public: + + /** + * Creates a new WaitForEventWidget for the given WaitForEvent. + * + * @param waitForEvent The WaitForEvent to set its data. + * @param parent The parent QWidget. + */ + explicit WaitForEventWidget(WaitForEvent* waitForEvent, + QWidget* parent = 0); + + /** + * Destroys this widget. + */ + virtual ~WaitForEventWidget(); + + /** + * Saves the receiver name and the event name in the WaitForEvent. + */ + virtual void saveChanges(); + +private: + + /** + * The WaitForEvent to edit. + */ + WaitForEvent* mWaitForEvent; + + /** + * The Ui Designer generated class. + */ + Ui::WaitForEventWidget* ui; + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>WaitForEventWidget</class> + <widget class="QWidget" name="WaitForEventWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string comment="@title">Edit event to wait for</string> + </property> + <property name="whatsThis"> + <string comment="@info:whatsthis"><para>Set the receiver name and the event to wait for.</para></string> + </property> + <layout class="QVBoxLayout" name="WaitForEventlVerticalLayout"> + <item> + <widget class="QGroupBox" name="waitForEventGroupBox"> + <property name="title"> + <string comment="@title:group">Wait for event</string> + </property> + <layout class="QHBoxLayout" name="waitForEventGroupBoxHorizontalLayout"> + <item> + <layout class="QVBoxLayout" name="labelVerticalLayout"> + <item> + <widget class="QLabel" name="receiverNameLabel"> + <property name="text"> + <string comment="@label:textbox">Receiver name:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="buddy"> + <cstring>receiverNameLineEdit</cstring> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="eventNameLabel"> + <property name="text"> + <string comment="@label:textbox">Event name:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="buddy"> + <cstring>eventNameLineEdit</cstring> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="lineEditVerticalLayout"> + <item> + <widget class="KLineEdit" name="receiverNameLineEdit"> + <property name="whatsThis"> + <string comment="@info:whatsthis"><para>The name of the QObject that receives the event.</para> +<para>Note that the name is not the class of the object, but the string returned by its objectName() method.</para></string> + </property> + </widget> + </item> + <item> + <widget class="KLineEdit" name="eventNameLineEdit"> + <property name="whatsThis"> + <string comment="@info:whatsthis"><para>The name of the event.</para> +<para>The name must not contain the "QEvent::" prefix, only the pure name of the event.</para></string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="waitForEventWidgetSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>182</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>KLineEdit</class> + <extends>QLineEdit</extends> + <header>klineedit.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -18,9 +18,11 @@ #include "WaitForTreeItem.h" #include "WaitForComposedTreeItem.h" +#include "WaitForEventTreeItem.h" #include "WaitForNotTreeItem.h" #include "WaitForSignalTreeItem.h" #include "../WaitForComposed.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForSignal.h" @@ -33,6 +35,11 @@ static_cast<WaitForComposed*>(waitFor), parent); } + if (qobject_cast<WaitForEvent*>(waitFor)) { + return new WaitForEventTreeItem(static_cast<WaitForEvent*>(waitFor), + parent); + } + if (qobject_cast<WaitForNot*>(waitFor)) { return new WaitForNotTreeItem(static_cast<WaitForNot*>(waitFor), parent); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -23,9 +23,11 @@ #include "NewWaitForWidget.h" #include "TextTreeItem.h" #include "TreeModel.h" +#include "WaitForEventWidget.h" #include "WaitForSignalWidget.h" #include "WaitForTreeItem.h" #include "../WaitForComposed.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForSignal.h" @@ -107,6 +109,14 @@ return; } + if (qobject_cast<WaitForEvent*>(selectedWaitFor)) { + ui->addButton->setEnabled(false); + ui->editButton->setEnabled(true); + ui->removeButton->setEnabled(true); + + return; + } + if (qobject_cast<WaitForNot*>(selectedWaitFor)) { if (static_cast<WaitForNot*>(selectedWaitFor)->negatedWaitFor()) { ui->addButton->setEnabled(false); @@ -200,6 +210,12 @@ void WaitForWidget::editWaitFor() { EditionWidget* editionWidget = 0; + if (qobject_cast<WaitForEvent*>(mCurrentWaitFor)) { + WaitForEvent* waitForEvent = + static_cast<WaitForEvent*>(mCurrentWaitFor); + editionWidget = new WaitForEventWidget(waitForEvent, this); + } + if (qobject_cast<WaitForSignal*>(mCurrentWaitFor)) { WaitForSignal* waitForSignal = static_cast<WaitForSignal*>(mCurrentWaitFor); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt 2010-03-16 05:42:56 UTC (rev 162) @@ -20,6 +20,7 @@ Tutorial WaitFor WaitForComposed + WaitForEvent WaitForNot WaitForSignal ) @@ -36,6 +37,7 @@ Tutorial WaitFor WaitForComposed + WaitForEvent WaitForNot WaitForSignal ) Added: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForEventTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/WaitForEventTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/WaitForEventTest.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,154 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include <QtTest> + +#include "WaitForEvent.h" + +class WaitForEventTest: public QObject { +Q_OBJECT + +private slots: + + void initTestCase(); + + void testConstructor(); + + void testClone(); + + void testEquals(); + + void testSetReceiverName(); + + void testSetEventName(); + +private: + + int mWaitForStarType; + + void assertWaitForEvent(const QSignalSpy& spy, int index, + WaitFor* waitFor); + +}; + +class StubWaitFor: public WaitFor { +Q_OBJECT +public: + + int mValue; + + StubWaitFor(int value = 0): mValue(value) { + } + + virtual WaitFor* clone() const { + return new StubWaitFor(mValue); + } + + virtual bool equals(const WaitFor& waitFor) const { + if (!qobject_cast<const StubWaitFor*>(&waitFor)) { + return false; + } + + return mValue == static_cast<const StubWaitFor*>(&waitFor)->mValue; + } +}; + +void WaitForEventTest::initTestCase() { + //WaitFor* must be registered in order to be used with QSignalSpy + mWaitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*"); +} + +void WaitForEventTest::testConstructor() { + QObject parent; + WaitForEvent* waitForEvent = new WaitForEvent(&parent); + + QCOMPARE(waitForEvent->parent(), &parent); +} + +void WaitForEventTest::testClone() { + WaitForEvent waitForEvent; + + WaitForEvent* cloned = static_cast<WaitForEvent*>(waitForEvent.clone()); + + QVERIFY(cloned != &waitForEvent); + QCOMPARE(cloned->receiverName(), waitForEvent.receiverName()); + QCOMPARE(cloned->eventName(), waitForEvent.eventName()); + delete cloned; +} + +void WaitForEventTest::testEquals() { + WaitForEvent waitForEvent1; + waitForEvent1.setReceiverName("The receiver name"); + waitForEvent1.setEventName("The event name"); + WaitForEvent waitForEvent2; + + QCOMPARE(waitForEvent1 == waitForEvent2, false); + QCOMPARE(waitForEvent2 == waitForEvent1, false); + + waitForEvent2.setReceiverName("The receiver name"); + waitForEvent2.setEventName("The event name"); + + QCOMPARE(waitForEvent1 == waitForEvent2, true); + QCOMPARE(waitForEvent2 == waitForEvent1, true); + + StubWaitFor stubWaitFor; + + QCOMPARE(waitForEvent1 == stubWaitFor, false); +} + +void WaitForEventTest::testSetReceiverName() { + WaitForEvent waitForEvent; + + QSignalSpy dataChangedSpy(&waitForEvent, SIGNAL(dataChanged(WaitFor*))); + + waitForEvent.setReceiverName("The receiver name"); + + QCOMPARE(waitForEvent.receiverName(), QString("The receiver name")); + QCOMPARE(dataChangedSpy.count(), 1); + assertWaitForEvent(dataChangedSpy, 0, &waitForEvent); +} + +void WaitForEventTest::testSetEventName() { + WaitForEvent waitForEvent; + + QSignalSpy dataChangedSpy(&waitForEvent, SIGNAL(dataChanged(WaitFor*))); + + waitForEvent.setEventName("The event name"); + + QCOMPARE(waitForEvent.eventName(), QString("The event name")); + QCOMPARE(dataChangedSpy.count(), 1); + assertWaitForEvent(dataChangedSpy, 0, &waitForEvent); +} + +//WaitFor* must be declared as a metatype to be used in qvariant_cast +Q_DECLARE_METATYPE(WaitFor*); + +/////////////////////////////////// Helpers //////////////////////////////////// + +void WaitForEventTest::assertWaitForEvent(const QSignalSpy& spy, int index, + WaitFor* waitFor) { + QCOMPARE(spy.at(index).count(), 1); + + QVariant argument = spy.at(index).at(0); + QCOMPARE(argument.userType(), mWaitForStarType); + QCOMPARE(qvariant_cast<WaitFor*>(argument), waitFor); +} + +QTEST_MAIN(WaitForEventTest) + +#include "WaitForEventTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForEventTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-16 05:42:56 UTC (rev 162) @@ -35,6 +35,8 @@ TutorialTreeItem TutorialTreeSelectionManager WaitForComposedTreeItem + WaitForEventTreeItem + WaitForEventWidget WaitForNotTreeItem WaitForSignalTreeItem WaitForSignalWidget @@ -67,6 +69,8 @@ TutorialTreeItem TutorialTreeSelectionManager WaitForComposedTreeItem + WaitForEventTreeItem + WaitForEventWidget WaitForNotTreeItem WaitForSignalTreeItem WaitForSignalWidget Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -23,6 +23,7 @@ #include <KComboBox> #include "../WaitForComposed.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForSignal.h" @@ -37,6 +38,7 @@ void testWaitForWhenOrConditionIsSelected(); void testWaitForWhenNotConditionIsSelected(); void testWaitForWhenSignalConditionIsSelected(); + void testWaitForWhenEventConditionIsSelected(); private: @@ -93,6 +95,16 @@ delete waitFor; } +void NewWaitForWidgetTest::testWaitForWhenEventConditionIsSelected() { + NewWaitForWidget widget; + + selectOption(&widget, 4); + + WaitForEvent* waitFor = qobject_cast<WaitForEvent*>(widget.waitFor()); + QVERIFY(waitFor); + delete waitFor; +} + /////////////////////////////////// Helpers //////////////////////////////////// void NewWaitForWidgetTest::selectOption(NewWaitForWidget* widget, Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventTreeItemTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventTreeItemTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventTreeItemTest.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,164 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include <QtTest> + +#include "WaitForEventTreeItem.h" + +#include <KLocalizedString> + +#include "../WaitForEvent.h" + +class WaitForEventTreeItemTest: public QObject { +Q_OBJECT + +private slots: + + void initTestCase(); + + void testConstructor(); + void testConstructorFull(); + + void testWaitForEventSetReceiverName(); + void testWaitForEventSetReceiverNameChange(); + + void testWaitForEventSetEventName(); + void testWaitForEventSetEventNameChange(); + +private: + + int mTreeItemStarType; + + void assertDataChanged(const QSignalSpy& spy, int index, + TreeItem* item) const; + +}; + +class StubTreeItem: public TreeItem { +public: + virtual QString text() const { + return ""; + } +}; + +void WaitForEventTreeItemTest::initTestCase() { + //TreeItem* must be registered in order to be used with QSignalSpy + mTreeItemStarType = qRegisterMetaType<TreeItem*>("TreeItem*"); +} + +void WaitForEventTreeItemTest::testConstructor() { + WaitForEvent waitForEvent; + + StubTreeItem parent; + WaitForEventTreeItem item(&waitForEvent, &parent); + + QCOMPARE(item.parent(), &parent); + QCOMPARE(item.waitFor(), &waitForEvent); + QCOMPARE(item.text(), i18nc("@item", "When the event (event not set) is " + "received by object (object not " + "set)")); +} + +void WaitForEventTreeItemTest::testConstructorFull() { + WaitForEvent waitForEvent; + waitForEvent.setReceiverName("receiverName"); + waitForEvent.setEventName("eventName"); + + StubTreeItem parent; + WaitForEventTreeItem item(&waitForEvent, &parent); + + QCOMPARE(item.parent(), &parent); + QCOMPARE(item.waitFor(), &waitForEvent); + QCOMPARE(item.text(), i18nc("@item", "When the event \"eventName\" is " + "received by object " + "\"receiverName\"")); +} + +void WaitForEventTreeItemTest::testWaitForEventSetReceiverName() { + WaitForEvent waitForEvent; + waitForEvent.setReceiverName("receiverName"); + + WaitForEventTreeItem item(&waitForEvent); + + QCOMPARE(item.text(), i18nc("@item", "When the event (event not set) is " + "received by object \"receiverName\"")); +} + +void WaitForEventTreeItemTest::testWaitForEventSetReceiverNameChange() { + WaitForEvent waitForEvent; + WaitForEventTreeItem item(&waitForEvent); + + waitForEvent.setReceiverName("receiverName"); + + QSignalSpy dataChangedSpy(&item, SIGNAL(dataChanged(TreeItem*))); + + waitForEvent.setReceiverName("receiverNameChanged"); + + QCOMPARE(item.text(), i18nc("@item", "When the event (event not set) is " + "received by object " + "\"receiverNameChanged\"")); + QCOMPARE(dataChangedSpy.count(), 1); + assertDataChanged(dataChangedSpy, 0, &item); +} + +void WaitForEventTreeItemTest::testWaitForEventSetEventName() { + WaitForEvent waitForEvent; + waitForEvent.setEventName("eventName"); + + WaitForEventTreeItem item(&waitForEvent); + + QCOMPARE(item.text(), i18nc("@item", "When the event \"eventName\" is " + "received by object (object not " + "set)")); +} + +void WaitForEventTreeItemTest::testWaitForEventSetEventNameChange() { + WaitForEvent waitForEvent; + WaitForEventTreeItem item(&waitForEvent); + + waitForEvent.setEventName("eventName"); + + QSignalSpy dataChangedSpy(&item, SIGNAL(dataChanged(TreeItem*))); + + waitForEvent.setEventName("eventNameChanged"); + + QCOMPARE(item.text(), i18nc("@item", "When the event " + "\"eventNameChanged\" is received by " + "object (object not set)")); + QCOMPARE(dataChangedSpy.count(), 1); + assertDataChanged(dataChangedSpy, 0, &item); +} + +/////////////////////////////////// Helpers //////////////////////////////////// + +//TreeItem* must be declared as a metatype to be used in qvariant_cast +Q_DECLARE_METATYPE(TreeItem*); + +void WaitForEventTreeItemTest::assertDataChanged(const QSignalSpy& spy, + int index, + TreeItem* item) const { + QCOMPARE(spy.at(index).count(), 1); + + QVariant argument = spy.at(index).at(0); + QCOMPARE(argument.userType(), mTreeItemStarType); + QCOMPARE(qvariant_cast<TreeItem*>(argument), item); +} + +QTEST_MAIN(WaitForEventTreeItemTest) + +#include "WaitForEventTreeItemTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventTreeItemTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -0,0 +1,86 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include <QtTest> + +#include "WaitForEventWidget.h" + +#include <KLineEdit> + +#include "../WaitForEvent.h" + +class WaitForEventWidgetTest: public QObject { +Q_OBJECT + +private slots: + + void testConstructor(); + + void testSaveChanges(); + +private: + + KLineEdit* receiverNameLineEdit(WaitForEventWidget* widget) const; + KLineEdit* eventNameLineEdit(WaitForEventWidget* widget) const; + +}; + +void WaitForEventWidgetTest::testConstructor() { + WaitForEvent waitFor; + waitFor.setReceiverName("The receiver name"); + waitFor.setEventName("The event name"); + + QWidget parent; + WaitForEventWidget* widget = new WaitForEventWidget(&waitFor, &parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(receiverNameLineEdit(widget)->text(), + QString("The receiver name")); + QCOMPARE(eventNameLineEdit(widget)->text(), QString("The event name")); +} + +void WaitForEventWidgetTest::testSaveChanges() { + WaitForEvent waitFor; + waitFor.setReceiverName("The receiver name"); + waitFor.setEventName("The event name"); + + WaitForEventWidget widget(&waitFor); + receiverNameLineEdit(&widget)->setText("The new receiver name"); + eventNameLineEdit(&widget)->setText("The new event name"); + + widget.saveChanges(); + + QCOMPARE(waitFor.receiverName(), QString("The new receiver name")); + QCOMPARE(waitFor.eventName(), QString("The new event name")); +} + +/////////////////////////////////// Helpers //////////////////////////////////// + +KLineEdit* WaitForEventWidgetTest::receiverNameLineEdit( + WaitForEventWidget* widget) const { + return widget->findChild<KLineEdit*>("receiverNameLineEdit"); +} + +KLineEdit* WaitForEventWidgetTest::eventNameLineEdit( + WaitForEventWidget* widget) const { + return widget->findChild<KLineEdit*>("eventNameLineEdit"); +} + +QTEST_MAIN(WaitForEventWidgetTest) + +#include "WaitForEventWidgetTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -21,10 +21,12 @@ #include "WaitForTreeItem.h" #include "WaitForComposedTreeItem.h" +#include "WaitForEventTreeItem.h" #include "WaitForNotTreeItem.h" #include "WaitForSignalTreeItem.h" #include "../WaitFor.h" #include "../WaitForComposed.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForSignal.h" @@ -36,6 +38,7 @@ void testConstructor(); void testTreeItemForWaitForComposed(); + void testTreeItemForWaitForEvent(); void testTreeItemForWaitForNot(); void testTreeItemForWaitForSignal(); @@ -99,6 +102,20 @@ delete item; } +void WaitForTreeItemTest::testTreeItemForWaitForEvent() { + WaitForEvent waitFor; + StubTreeItem parent; + + WaitForTreeItem* item = WaitForTreeItem::treeItemForWaitFor(&waitFor, + &parent); + + QVERIFY(qobject_cast<WaitForEventTreeItem*>(item)); + QCOMPARE(item->parent(), &parent); + QCOMPARE(item->waitFor(), &waitFor); + + delete item; +} + void WaitForTreeItemTest::testTreeItemForWaitForNot() { WaitForNot waitFor; StubTreeItem parent; Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp 2010-03-16 03:00:35 UTC (rev 161) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp 2010-03-16 05:42:56 UTC (rev 162) @@ -28,6 +28,7 @@ #include "EditionDialog.h" #include "../WaitForComposed.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForSignal.h" @@ -38,6 +39,7 @@ void addWaitForSignal() const; void cancelAddWaitForDialog() const; + void setEventData() const; void setSignalData() const; private slots: @@ -52,6 +54,7 @@ void testSelectWaitForOr(); void testSelectWaitForNot(); void testSelectWaitForNotEmpty(); + void testSelectWaitForEvent(); void testSelectWaitForSignal(); void testClearSelection(); @@ -60,6 +63,7 @@ void testAddWaitForToWaitForNot(); void testAddWaitForCancellingDialog(); + void testEditWaitForEvent(); void testEditWaitForSignal(); void testRemoveWaitForFromRoot(); @@ -71,6 +75,7 @@ WaitForComposed* mWaitFor; WaitForSignal* mWaitFor1; WaitForComposed* mWaitFor2; + WaitForEvent* mWaitFor2_1; WaitForNot* mWaitFor3; WaitForSignal* mWaitFor3_1; WaitForNot* mWaitFor4; @@ -104,6 +109,11 @@ mWaitFor2->setCompositionType(WaitForComposed::Or); mWaitFor->addWaitFor(mWaitFor2); + mWaitFor2_1 = new WaitForEvent(); + mWaitFor2_1->setReceiverName("receiver"); + mWaitFor2_1->setEventName("event"); + mWaitFor2->addWaitFor(mWaitFor2_1); + mWaitFor3 = new WaitForNot(); mWaitFor->addWaitFor(mWaitFor3); @@ -165,6 +175,12 @@ assertButtonEnabled(true, false, true); } +void WaitForWidgetTest::testSelectWaitForEvent() { + selectItem(getIndex(0, getIndex(1, getIndex(0)))); + + assertButtonEnabled(false, true, true); +} + void WaitForWidgetTest::testSelectWaitForSignal() { selectItem(getIndex(0, getIndex(0))); @@ -219,9 +235,10 @@ QCOMPARE(mWaitFor->waitFors()[2], mWaitFor3); QCOMPARE(mWaitFor->waitFors()[3], mWaitFor4); QVERIFY(qobject_cast<WaitForSignal*>(mWaitFor->waitFors()[4])); - QCOMPARE(mWaitFor2->waitFors().count(), 1); - QVERIFY(qobject_cast<WaitForSignal*>(mWaitFor2->waitFors()[0])); - QVERIFY(mWaitFor->waitFors()[4] != mWaitFor2->waitFors()[0]); + QCOMPARE(mWaitFor2->waitFors().count(), 2); + QCOMPARE(mWaitFor2->waitFors()[0], mWaitFor2_1); + QVERIFY(qobject_cast<WaitForSignal*>(mWaitFor2->waitFors()[1])); + QVERIFY(mWaitFor->waitFors()[4] != mWaitFor2->waitFors()[1]); } void WaitForWidgetTest::testAddWaitForToWaitForNot() { @@ -262,6 +279,20 @@ assertButtonEnabled(true, false, false); } +void WaitForWidgetTest::testEditWaitForEvent() { + selectItem(getIndex(0, getIndex(1, getIndex(0)))); + + //The dialog is modal, so it won't return to the test code until it is + //closed. Thus, the commands to execute on the dialog must be "queued", + //as calling setEventData after the button click won't work. + QTimer::singleShot(500, this, SLOT(setEventData())); + + button("editButton")->click(); + + QCOMPARE(mWaitFor2_1->receiverName(), QString("The new receiver name")); + QCOMPARE(mWaitFor2_1->eventName(), QString("The new event name")); +} + void WaitForWidgetTest::testEditWaitForSignal() { selectItem(getIndex(0, getIndex(0))); @@ -329,6 +360,22 @@ dialog->button(KDialog::Cancel)->click(); } +void WaitForWidgetTest::setEventData() const { + KLineEdit* receiverNameLineEdit = + mWidget->findChild<KLineEdit*>("receiverNameLineEdit"); + QVERIFY(receiverNameLineEdit); + receiverNameLineEdit->setText("The new receiver name"); + + KLineEdit* eventNameLineEdit = + mWidget->findChild<KLineEdit*>("eventNameLineEdit"); + QVERIFY(eventNameLineEdit); + eventNameLineEdit->setText("The new event name"); + + EditionDialog* dialog = mWidget->findChild<EditionDialog*>("editionDialog"); + QVERIFY(dialog); + dialog->button(KDialog::Ok)->click(); +} + void WaitForWidgetTest::setSignalData() const { KLineEdit* emitterNameLineEdit = mWidget->findChild<KLineEdit*>("emitterNameLineEdit"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |