[Ktutorial-commits] SF.net SVN: ktutorial:[244] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-05-21 23:36:39
|
Revision: 244 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=244&view=rev Author: danxuliu Date: 2010-05-21 23:36:29 +0000 (Fri, 21 May 2010) Log Message: ----------- Add RemoteObjectNameWidget to select the name of a remote object. It encapsulates the current KLineEdit and RemoteObjectChooser button in WaitForSignalWidget and WaitForEventWidget, also providing remote object name completion. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 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/src/view/WaitForSignalWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.h trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForSignalWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp Added Paths: ----------- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -32,7 +32,8 @@ "org.kde.ktutorial.EditorSupport", QDBusConnection::sessionBus(), 0), mMapper(mapper), - mRemoteEventSpy(0) { + mRemoteEventSpy(0), + mNumberOfPendingEnableEventSpyCalls(0) { } RemoteEditorSupport::~RemoteEditorSupport() { @@ -66,6 +67,7 @@ RemoteEventSpy* RemoteEditorSupport::enableEventSpy() throw (DBusException) { if (mRemoteEventSpy) { + mNumberOfPendingEnableEventSpyCalls++; return mRemoteEventSpy; } @@ -75,6 +77,7 @@ } mRemoteEventSpy = new RemoteEventSpy(service(), mMapper); + mNumberOfPendingEnableEventSpyCalls = 1; return mRemoteEventSpy; } @@ -83,6 +86,11 @@ return; } + mNumberOfPendingEnableEventSpyCalls--; + if (mNumberOfPendingEnableEventSpyCalls > 0) { + return; + } + QDBusReply<void> reply = call("disableEventSpy"); if (!reply.isValid()) { throw DBusException(reply.error().message()); Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h 2010-05-21 23:36:29 UTC (rev 244) @@ -103,6 +103,12 @@ /** * Disables the EventSpy in the remote EditorSupport and destroys the proxy * for it. + * The EventSpy is not disabled until the same number of calls to the + * enableEventSpy() method are made to this method. It makes possible to + * share the same RemoteEventSpy between objects that know nothing one of + * each other: each object enable and disable the RemoteEventSpy as they + * need, but it is not actually disabled until it is disabled by the last + * object using it. * * @throws DBusException If a DBus error happens. */ @@ -120,6 +126,12 @@ */ RemoteEventSpy* mRemoteEventSpy; + /** + * The number of enableEventSpy calls that didn't get a disableEventSpy + * counterpart yet. + */ + int mNumberOfPendingEnableEventSpyCalls; + }; #endif Modified: trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-05-21 23:36:29 UTC (rev 244) @@ -35,6 +35,7 @@ set(ktutorial_editor_view_SRCS ${ktutorial_editor_view_SRCS} RemoteObjectChooser.cpp + RemoteObjectNameWidget.cpp RemoteObjectTreeItem.cpp RemoteObjectTreeItemUpdater.cpp RemoteObjectTreeSelectionManager.cpp @@ -47,6 +48,7 @@ LicenseWidget.ui NewWaitForWidget.ui ReactionWidget.ui + RemoteObjectNameWidget.ui StepDataWidget.ui TutorialInformationWidget.ui WaitForEventWidget.ui Added: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -0,0 +1,195 @@ +/*************************************************************************** + * 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 "RemoteObjectNameWidget.h" +#include "ui_RemoteObjectNameWidget.h" + +#include <KDebug> +#include <KMessageBox> + +#include "RemoteObjectChooser.h" +#include "../targetapplication/RemoteEditorSupport.h" +#include "../targetapplication/RemoteEventSpy.h" +#include "../targetapplication/RemoteObject.h" +#include "../targetapplication/TargetApplication.h" + +//public: + +RemoteObjectNameWidget::RemoteObjectNameWidget(QWidget* parent): + QWidget(parent) { + + ui = new Ui::RemoteObjectNameWidget(); + ui->setupUi(this); + + ui->objectNameLineEdit->completionObject()->setOrder(KCompletion::Sorted); + connect(ui->objectNameLineEdit, SIGNAL(textChanged(QString)), + this, SLOT(handleNameChanged(QString))); + + connect(ui->objectNamePushButton, SIGNAL(clicked(bool)), + this, SLOT(showRemoteObjectChooser())); + + if (TargetApplication::self()->remoteEditorSupport()) { + registerRemoteObjects(); + } + + connect(TargetApplication::self(), SIGNAL(started()), + this, SLOT(registerRemoteObjects())); + connect(TargetApplication::self(), SIGNAL(finished()), + this, SLOT(deregisterRemoteObjects())); +} + +RemoteObjectNameWidget::~RemoteObjectNameWidget() { + if (TargetApplication::self()->remoteEditorSupport()) { + TargetApplication::self()->remoteEditorSupport()->disableEventSpy(); + } + + delete ui; +} + +QString RemoteObjectNameWidget::name() const { + return ui->objectNameLineEdit->text(); +} + +void RemoteObjectNameWidget::setName(const QString& name) { + ui->objectNameLineEdit->setText(name); +} + +//private: + +void RemoteObjectNameWidget::registerRemoteObject(RemoteObject* remoteObject, + RemoteObject* parent) +throw (DBusException) { + Q_ASSERT(remoteObject); + + if (!remoteObject->name().isEmpty()) { + KCompletion* completion = ui->objectNameLineEdit->completionObject(); + completion->addItem(remoteObject->name()); + + mRemoteObjectForName.insert(remoteObject->name(), remoteObject); + mRemoteObjectForParent.insert(parent, remoteObject); + } + + foreach (RemoteObject* child, remoteObject->children()) { + registerRemoteObject(child, remoteObject); + } +} + +void RemoteObjectNameWidget::deregisterRemoteObject(RemoteObject* remoteObject, + RemoteObject* parent) +throw (DBusException) { + Q_ASSERT(remoteObject); + + //The remote object is no longer accesible, so name() can't be called + QString name = mRemoteObjectForName.key(remoteObject); + + KCompletion* completion = ui->objectNameLineEdit->completionObject(); + completion->removeItem(name); + + mRemoteObjectForName.remove(name); + mRemoteObjectForParent.remove(parent, remoteObject); + + foreach (RemoteObject* child, remoteObject->children()) { + deregisterRemoteObject(child, remoteObject); + } +} + +//private slots: + +void RemoteObjectNameWidget::showRemoteObjectChooser() { + RemoteObjectChooser* chooser = new RemoteObjectChooser(this); + connect(chooser, SIGNAL(remoteObjectChosen(RemoteObject*)), + this, SLOT(setChosenRemoteObject(RemoteObject*))); + + chooser->show(); +} + +void RemoteObjectNameWidget::setChosenRemoteObject(RemoteObject* remoteObject) { + try { + ui->objectNameLineEdit->setText(remoteObject->name()); + } catch (DBusException e) { + QString text = i18nc("@label", "The object name can not be set, there " +"was a problem getting the name from the target application: %1", e.message()); + QString title = i18nc("@title", "Can't communicate with the target " +"application"); + KMessageBox::sorry(this, text, title); + } +} + +void RemoteObjectNameWidget::registerRemoteObjects() { + try { + registerRemoteObject(TargetApplication::self()-> + remoteEditorSupport()->mainWindow(), 0); + } catch (DBusException e) { + kWarning() << "The remote objects could not be registered to provide " + << "name completion (" << e.message() << ")."; + } + + try { + RemoteEventSpy* remoteEventSpy = + TargetApplication::self()->remoteEditorSupport()->enableEventSpy(); + connect(remoteEventSpy, SIGNAL(eventReceived(RemoteObject*,QString)), + this, SLOT(updateRemoteObjects(RemoteObject*,QString))); + } catch (DBusException e) { + kWarning() << "The remote event spy could not be connected to provide " + << "name completion updates (" << e.message() << ")."; + } +} + +void RemoteObjectNameWidget::deregisterRemoteObjects() { + ui->objectNameLineEdit->completionObject()->clear(); + mRemoteObjectForName.clear(); + mRemoteObjectForParent.clear(); +} + +void RemoteObjectNameWidget::updateRemoteObjects(RemoteObject* remoteObject, + const QString& eventType) { + if (eventType != "ChildAdded" && eventType != "ChildRemoved") { + return; + } + + try { + QList<RemoteObject*> children = remoteObject->children(); + + QList<RemoteObject*> knownChildren = + mRemoteObjectForParent.values(remoteObject); + + if (eventType == "ChildAdded") { + foreach (RemoteObject* child, children) { + if (!knownChildren.contains(child)) { + registerRemoteObject(child, remoteObject); + } + } + } + + if (eventType == "ChildRemoved") { + foreach (RemoteObject* child, knownChildren) { + if (!children.contains(child)) { + deregisterRemoteObject(child, remoteObject); + } + } + } + } catch (DBusException e) { + kWarning() << "There was a problem querying the remote objects, the " + << "name completion could not be updated (" + << e.message() << ")."; + } +} + +void RemoteObjectNameWidget::handleNameChanged(const QString& name) { + emit remoteObjectChosen(mRemoteObjectForName.value(name)); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h 2010-05-21 23:36:29 UTC (rev 244) @@ -0,0 +1,175 @@ +/*************************************************************************** + * 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 REMOTEOBJECTNAMEWIDGET_H +#define REMOTEOBJECTNAMEWIDGET_H + +#include <QHash> +#include <QWidget> + +#include "../targetapplication/DBusException.h" + +class RemoteObject; + +namespace Ui { +class RemoteObjectNameWidget; +} + +/** + * Widget to choose the name of a RemoteObject. + * The widget is composed by a line edit and a button to show a + * RemoteObjectChooser. The name can be set directly in the line edit or with + * the aid of the RemoteObjectChooser. + * + * The line edit provides text completion for the names of the remote objects + * in the target application. If there is no target application running, no + * completion is provided. As soon as it starts, the completion is enabled. + * + * When a name is set in the line edit the signal + * remoteObjectChosen(RemoteObject*) is emitted. + */ +class RemoteObjectNameWidget: public QWidget { +Q_OBJECT +public: + + /** + * Creates a new RemoteObjectNameWidget. + * + * @param parent The parent QWidget. + */ + explicit RemoteObjectNameWidget(QWidget* parent = 0); + + /** + * Destroys this widget. + */ + virtual ~RemoteObjectNameWidget(); + + /** + * Returns the chosen remote object name. + * + * @return The chosen remote object name. + */ + QString name() const; + + /** + * Sets the chosen remote object name. + * + * @param name The chosen remote object name. + */ + void setName(const QString& name); + +Q_SIGNALS: + + /** + * Emitted when the name of a remote object is set. + * It does not matter how the name was set (using setName(QString), written + * by the user or chosen from the RemoteObjectChooser). + * If there is no remote object with the name set or the target application + * is not running, the parameter of this signal is a null pointer. + * + * @param remoteObject The RemoteObject with the name set. + */ + void remoteObjectChosen(RemoteObject* remoteObject); + +private: + + /** + * The RemoteObjects with a name indexed by their name. + */ + QHash<QString, RemoteObject*> mRemoteObjectForName; + + /** + * The known RemoteObjects with a name indexed by their parent + */ + QMultiHash<RemoteObject*, RemoteObject*> mRemoteObjectForParent; + + /** + * The Ui Designer generated class. + */ + Ui::RemoteObjectNameWidget* ui; + + /** + * Registers the given RemoteObject and all its children. + * The objects are only registered if they have a name. In that case, it is + * added to the completion of the name line edit. + * + * @param remoteObject The RemoteObject to register. + * @param parent The parent of the RemoteObject to register. + * @throws DBusException If a DBus error happens. + */ + void registerRemoteObject(RemoteObject* remoteObject, RemoteObject* parent) + throw (DBusException); + + /** + * Deregisters the given RemoteObject and all its children. + * + * @param remoteObject The RemoteObject to deregister. + * @param parent The parent of the RemoteObject to deregister. + * @throws DBusException If a DBus error happens. + */ + void deregisterRemoteObject(RemoteObject* remoteObject, + RemoteObject* parent) + throw (DBusException); + +private Q_SLOTS: + + /** + * Creates and shows a new RemoteObjectChooser. + */ + void showRemoteObjectChooser(); + + /** + * Sets the object name based in the chosen remote object. + * + * @param remoteObject The chosen RemoteObject. + */ + void setChosenRemoteObject(RemoteObject* remoteObject); + + /** + * Registers the remote objects and add their names to the line edit + * completion object. + */ + void registerRemoteObjects(); + + /** + * Deregisters the remote objects and removes their names from the line edit + * completion object. + */ + void deregisterRemoteObjects(); + + /** + * Updates the registered remote objects if they received a ChildAdded or + * ChildRemoved event. + * + * @param remoteObject The RemoteObject that received the event. + * @param eventType The type of the event received. + */ + void updateRemoteObjects(RemoteObject* remoteObject, + const QString& eventType); + + /** + * Emits remoteObjectChosen(RemoteObject*) with the remote object with the + * given name. + * + * @param name The name set. + */ + void handleNameChanged(const QString& name); + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui 2010-05-21 23:36:29 UTC (rev 244) @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>RemoteObjectNameWidget</class> + <widget class="QWidget" name="RemoteObjectNameWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="RemoteObjectNameWidgetHorizontalLayout"> + <property name="margin"> + <number>0</number> + </property> + <item> + <widget class="KLineEdit" name="objectNameLineEdit"/> + </item> + <item> + <widget class="KPushButton" name="objectNamePushButton"> + <property name="toolTip"> + <string comment="@info:tooltip">Choose the object name from a list with all the objects in the target application</string> + </property> + <property name="whatsThis"> + <string comment="@info:whatsthis"><p>Opens the list with all the objects in the target application to select the object from them.</p> +<p>The object list must be gotten from a running application. The first time that you try to choose the object name you will be asked for the target application of the tutorial. A new instance of the application will then be started to know the available objects.</p> +<p>The next time that you try to choose the object name the already running application will be used. If it is quitted, a new instance will be started again.</p> +<p>When the target application is started all the KTutorial editor windows, except the one with the list, will be hidden. When the list is closed, the windows will be shown again.</p></string> + </property> + <property name="text"> + <string comment="@action:button">Choose...</string> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>KPushButton</class> + <extends>QPushButton</extends> + <header>kpushbutton.h</header> + </customwidget> + <customwidget> + <class>KLineEdit</class> + <extends>QLineEdit</extends> + <header>klineedit.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -24,9 +24,7 @@ #include "../data/WaitForEvent.h" #ifdef QT_QTDBUS_FOUND -#include <KMessageBox> - -#include "RemoteObjectChooser.h" +#include "RemoteObjectNameWidget.h" #include "../targetapplication/RemoteObject.h" #endif @@ -38,16 +36,26 @@ mWaitForEvent(waitForEvent) { ui = new Ui::WaitForEventWidget(); +#ifdef QT_QTDBUS_FOUND + //Hack: RemoteObjectNameWidget is created before the other widgets to be + //the first widget in the tab order. I feel dumb, but I tried using + //setTabOrder and got nothing... + mRemoteObjectNameWidget = new RemoteObjectNameWidget(this); +#endif ui->setupUi(this); #ifdef QT_QTDBUS_FOUND - connect(ui->receiverNamePushButton, SIGNAL(clicked(bool)), - this, SLOT(showRemoteObjectChooser())); + //Replace ui->receiverNameLineEdit with mRemoteObjectNameWidget + ui->valueVerticalLayout->removeWidget(ui->receiverNameLineEdit); + delete ui->receiverNameLineEdit; + + ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + + mRemoteObjectNameWidget->setName(waitForEvent->receiverName()); #else - ui->receiverNamePushButton->hide(); + ui->receiverNameLineEdit->setText(waitForEvent->receiverName()); #endif - ui->receiverNameLineEdit->setText(waitForEvent->receiverName()); ui->eventNameLineEdit->setText(waitForEvent->eventName()); addItemsToEventNameCompletion(); @@ -58,7 +66,11 @@ } void WaitForEventWidget::saveChanges() { +#ifdef QT_QTDBUS_FOUND + QString receiverName = mRemoteObjectNameWidget->name(); +#else QString receiverName = ui->receiverNameLineEdit->text(); +#endif if (mWaitForEvent->receiverName() != receiverName) { mWaitForEvent->setReceiverName(receiverName); } @@ -80,28 +92,3 @@ completion->addItem(eventTypeEnumerator.key(i)); } } - -//private slots: - -#ifdef QT_QTDBUS_FOUND -void WaitForEventWidget::showRemoteObjectChooser() { - RemoteObjectChooser* chooser = new RemoteObjectChooser(this); - connect(chooser, SIGNAL(remoteObjectChosen(RemoteObject*)), - this, SLOT(setChosenRemoteObject(RemoteObject*))); - - chooser->show(); -} - -void WaitForEventWidget::setChosenRemoteObject(RemoteObject* remoteObject) { - try { - ui->receiverNameLineEdit->setText(remoteObject->name()); - } catch (DBusException e) { - QString text = i18nc("@label", "The receiver name can not be set, " -"there was a problem getting the name from the target application: %1", -e.message()); - QString title = i18nc("@title", "Can't communicate with the target " -"application"); - KMessageBox::sorry(this, text, title); - } -} -#endif Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.h 2010-05-21 23:36:29 UTC (rev 244) @@ -21,7 +21,11 @@ #include "EditionWidget.h" +#ifdef QT_QTDBUS_FOUND class RemoteObject; +class RemoteObjectNameWidget; +#endif + class WaitForEvent; namespace Ui { @@ -66,27 +70,18 @@ */ Ui::WaitForEventWidget* ui; - /** - * Adds all the event names to the completion object of the event name line - * edit. - */ - void addItemsToEventNameCompletion(); - -private Q_SLOTS: - #ifdef QT_QTDBUS_FOUND /** - * Creates and shows a new RemoteObjectChooser. + * The widget to get the name of a remote object. */ - void showRemoteObjectChooser(); + RemoteObjectNameWidget* mRemoteObjectNameWidget; +#endif /** - * Sets the receiver name based in the chosen remote object. - * - * @param remoteObject The chosen RemoteObject. + * Adds all the event names to the completion object of the event name line + * edit. */ - void setChosenRemoteObject(RemoteObject* remoteObject); -#endif + void addItemsToEventNameCompletion(); }; Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2010-05-21 23:36:29 UTC (rev 244) @@ -33,9 +33,6 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> - <property name="buddy"> - <cstring>receiverNameLineEdit</cstring> - </property> </widget> </item> <item> @@ -56,32 +53,12 @@ <item> <layout class="QVBoxLayout" name="valueVerticalLayout"> <item> - <layout class="QHBoxLayout" name="receiverNameValueHorizontalLayout"> - <item> - <widget class="KLineEdit" name="receiverNameLineEdit"> - <property name="whatsThis"> - <string comment="@info:whatsthis"><para>The name of the QObject that receives the event.</para> + <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="KPushButton" name="receiverNamePushButton"> - <property name="toolTip"> - <string comment="@info:tooltip">Choose the emitter name from a list with all the objects in the target application</string> - </property> - <property name="whatsThis"> - <string comment="@info:whatsthis"><p>Opens the list with all the objects in the target application to select the receiver from them.</p> -<p>The object list must be gotten from a running application. The first time that you try to choose the receiver name you will be asked for the target application of the tutorial. A new instance of the application will then be started to know the available objects.</p> -<p>The next time that you try to choose the receiver name the already running application will be used. If it is quitted, a new instance will be started again.</p> -<p>When the target application is started all the KTutorial editor windows, except the one with the list, will be hidden. When the list is closed, the windows will be shown again.</p></string> - </property> - <property name="text"> - <string comment="@action:button">Choose...</string> - </property> - </widget> - </item> - </layout> + </property> + </widget> </item> <item> <widget class="KLineEdit" name="eventNameLineEdit"> @@ -113,11 +90,6 @@ </widget> <customwidgets> <customwidget> - <class>KPushButton</class> - <extends>QPushButton</extends> - <header>kpushbutton.h</header> - </customwidget> - <customwidget> <class>KLineEdit</class> <extends>QLineEdit</extends> <header>klineedit.h</header> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -22,9 +22,9 @@ #include "../data/WaitForSignal.h" #ifdef QT_QTDBUS_FOUND -#include <KMessageBox> +#include <KDebug> -#include "RemoteObjectChooser.h" +#include "RemoteObjectNameWidget.h" #include "../targetapplication/RemoteClass.h" #include "../targetapplication/RemoteObject.h" #endif @@ -39,16 +39,29 @@ mWaitForSignal(waitForSignal) { ui = new Ui::WaitForSignalWidget(); +#ifdef QT_QTDBUS_FOUND + //Hack: RemoteObjectNameWidget is created before the other widgets to be + //the first widget in the tab order. I feel dumb, but I tried using + //setTabOrder and got nothing... + mRemoteObjectNameWidget = new RemoteObjectNameWidget(this); +#endif ui->setupUi(this); #ifdef QT_QTDBUS_FOUND - connect(ui->emitterNamePushButton, SIGNAL(clicked(bool)), - this, SLOT(showRemoteObjectChooser())); + //Replace ui->emitterNameLineEdit with mRemoteObjectNameWidget + ui->valueVerticalLayout->removeWidget(ui->emitterNameLineEdit); + delete ui->emitterNameLineEdit; + + ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + + connect(mRemoteObjectNameWidget, SIGNAL(remoteObjectChosen(RemoteObject*)), + this, SLOT(setChosenRemoteObject(RemoteObject*))); + + mRemoteObjectNameWidget->setName(waitForSignal->emitterName()); #else - ui->emitterNamePushButton->hide(); + ui->emitterNameLineEdit->setText(waitForSignal->emitterName()); #endif - ui->emitterNameLineEdit->setText(waitForSignal->emitterName()); ui->signalNameLineEdit->setText(waitForSignal->signalName()); } @@ -57,7 +70,11 @@ } void WaitForSignalWidget::saveChanges() { +#ifdef QT_QTDBUS_FOUND + QString emitterName = mRemoteObjectNameWidget->name(); +#else QString emitterName = ui->emitterNameLineEdit->text(); +#endif if (mWaitForSignal->emitterName() != emitterName) { mWaitForSignal->setEmitterName(emitterName); } @@ -71,7 +88,8 @@ //private: #ifdef QT_QTDBUS_FOUND -void WaitForSignalWidget::setSignalCompletion(RemoteClass* remoteClass) { +void WaitForSignalWidget::setSignalCompletion(RemoteClass* remoteClass) +throw (DBusException) { KCompletion* completion = ui->signalNameLineEdit->completionObject(); completion->clear(); completion->setOrder(KCompletion::Sorted); @@ -89,24 +107,18 @@ //private slots: #ifdef QT_QTDBUS_FOUND -void WaitForSignalWidget::showRemoteObjectChooser() { - RemoteObjectChooser* chooser = new RemoteObjectChooser(this); - connect(chooser, SIGNAL(remoteObjectChosen(RemoteObject*)), - this, SLOT(setChosenRemoteObject(RemoteObject*))); +void WaitForSignalWidget::setChosenRemoteObject(RemoteObject* remoteObject) { + if (!remoteObject) { + setSignalCompletion(0); + return; + } - chooser->show(); -} - -void WaitForSignalWidget::setChosenRemoteObject(RemoteObject* remoteObject) { try { - ui->emitterNameLineEdit->setText(remoteObject->name()); setSignalCompletion(remoteObject->remoteClass()); } catch (DBusException e) { - QString text = i18nc("@label", "The emitter name can not be set, there " -"was a problem getting the name from the target application: %1", e.message()); - QString title = i18nc("@title", "Can't communicate with the target " -"application"); - KMessageBox::sorry(this, text, title); + kWarning() << "The signal completion could not be set, there was a " + << "problem getting the class of the remote object (" + << e.message() << ")."; } } #endif Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.h 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.h 2010-05-21 23:36:29 UTC (rev 244) @@ -21,8 +21,14 @@ #include "EditionWidget.h" +#ifdef QT_QTDBUS_FOUND +#include "../targetapplication/DBusException.h" + class RemoteClass; class RemoteObject; +class RemoteObjectNameWidget; +#endif + class WaitForSignal; namespace Ui { @@ -69,23 +75,23 @@ #ifdef QT_QTDBUS_FOUND /** + * The widget to get the name of a remote object. + */ + RemoteObjectNameWidget* mRemoteObjectNameWidget; + + /** * Sets the completion of the signal line edit to the signals emitted by the * given remote class and its super classes. * * @param remoteClass The class to get its signal list. */ - void setSignalCompletion(RemoteClass* remoteClass); + void setSignalCompletion(RemoteClass* remoteClass) throw (DBusException); #endif private Q_SLOTS: #ifdef QT_QTDBUS_FOUND /** - * Creates and shows a new RemoteObjectChooser. - */ - void showRemoteObjectChooser(); - - /** * Sets the emitter name based in the chosen remote object. * * @param remoteObject The chosen RemoteObject. Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui 2010-05-21 23:36:29 UTC (rev 244) @@ -33,9 +33,6 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> - <property name="buddy"> - <cstring>emitterNameLineEdit</cstring> - </property> </widget> </item> <item> @@ -56,32 +53,12 @@ <item> <layout class="QVBoxLayout" name="valueVerticalLayout"> <item> - <layout class="QHBoxLayout" name="emitterNameValueHorizontalLayout"> - <item> - <widget class="KLineEdit" name="emitterNameLineEdit"> - <property name="whatsThis"> - <string comment="@info:whatsthis"><para>The name of the QObject that emits the signal.</para> + <widget class="KLineEdit" name="emitterNameLineEdit"> + <property name="whatsThis"> + <string comment="@info:whatsthis"><para>The name of the QObject that emits the signal.</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="KPushButton" name="emitterNamePushButton"> - <property name="toolTip"> - <string comment="@info:tooltip">Choose the emitter name from a list with all the objects in the target application</string> - </property> - <property name="whatsThis"> - <string comment="@info:whatsthis"><p>Opens the list with all the objects in the target application to select the emitter from them.</p> -<p>The object list must be gotten from a running application. The first time that you try to choose the emitter name you will be asked for the target application of the tutorial. A new instance of the application will then be started to know the available objects.</p> -<p>The next time that you try to choose the emitter name the already running application will be used. If it is quitted, a new instance will be started again.</p> -<p>When the target application is started all the KTutorial editor windows, except the one with the list, will be hidden. When the list is closed, the windows will be shown again.</p></string> - </property> - <property name="text"> - <string comment="@action:button">Choose...</string> - </property> - </widget> - </item> - </layout> + </property> + </widget> </item> <item> <widget class="KLineEdit" name="signalNameLineEdit"> @@ -113,11 +90,6 @@ </widget> <customwidgets> <customwidget> - <class>KPushButton</class> - <extends>QPushButton</extends> - <header>kpushbutton.h</header> - </customwidget> - <customwidget> <class>KLineEdit</class> <extends>QLineEdit</extends> <header>klineedit.h</header> Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2010-05-21 23:36:29 UTC (rev 244) @@ -81,7 +81,7 @@ QString objectName(int objectId) { - if (objectId > 100) { + if (objectId > 1000) { return ""; } @@ -89,7 +89,7 @@ } QString className(int objectId) { - if (objectId > 100) { + if (objectId > 1000) { return ""; } Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -61,6 +61,7 @@ void testEnableEventSpyWhenRemoteEditorSupportIsNotAvailable(); void testDisableEventSpy(); + void testDisableEventSpyAfterSeveralEnableEventSpyCalls(); void testDisableEventSpyTwice(); void testDisableEventSpyWhenRemoteEditorSupportIsNotAvailable(); @@ -267,6 +268,33 @@ QCOMPARE(eventReceivedSpy.count(), 0); } +void RemoteEditorSupportTest:: + testDisableEventSpyAfterSeveralEnableEventSpyCalls() { + RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); + RemoteEditorSupport remoteEditorSupport( + QDBusConnection::sessionBus().baseService(), &mapper); + + RemoteEventSpy* remoteEventSpy = remoteEditorSupport.enableEventSpy(); + remoteEditorSupport.enableEventSpy(); + remoteEditorSupport.enableEventSpy(); + + QVERIFY(remoteEventSpy); + + remoteEditorSupport.disableEventSpy(); + remoteEditorSupport.disableEventSpy(); + + QCOMPARE(mEditorSupport->mDisableEventSpyCount, 0); + + remoteEditorSupport.enableEventSpy(); + remoteEditorSupport.disableEventSpy(); + + QCOMPARE(mEditorSupport->mDisableEventSpyCount, 0); + + remoteEditorSupport.disableEventSpy(); + + QCOMPARE(mEditorSupport->mDisableEventSpyCount, 1); +} + void RemoteEditorSupportTest::testDisableEventSpyTwice() { RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); RemoteEditorSupport remoteEditorSupport( @@ -277,9 +305,14 @@ QVERIFY(remoteEventSpy); remoteEditorSupport.disableEventSpy(); + + QCOMPARE(mEditorSupport->mDisableEventSpyCount, 1); + remoteEditorSupport.disableEventSpy(); QCOMPARE(mEditorSupport->mDisableEventSpyCount, 1); + + QVERIFY(remoteEditorSupport.enableEventSpy()); } void RemoteEditorSupportTest:: Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-05-21 23:36:29 UTC (rev 244) @@ -52,6 +52,7 @@ unit_tests( RemoteObjectChooser + RemoteObjectNameWidget RemoteObjectTreeItem RemoteObjectTreeItemUpdater RemoteObjectTreeSelectionManager Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -0,0 +1,245 @@ +/*************************************************************************** + * 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 "RemoteObjectNameWidget.h" + +#include <QtDBus/QtDBus> + +#include <KLineEdit> +#include <KProcess> + +#include "../targetapplication/RemoteClassStubs.h" +#include "../targetapplication/RemoteEditorSupport.h" +#include "../targetapplication/RemoteObject.h" +#define protected public +#define private public +#include "../targetapplication/TargetApplication.h" +#undef private +#undef protected + +class RemoteObjectNameWidgetTest: public QObject { +Q_OBJECT + +private slots: + + void initTestCase(); + void init(); + void cleanup(); + + void testConstructor(); + + void testSetName(); + void testSetNameWithUnknownRemoteObjectName(); + + void testTargetApplicationStartedAfterWidget(); + void testTargetApplicationStopped(); + + void testAddingOrRemovingRemoteObjects(); + +private: + + QString mPath; + + int mRemoteObjectStarType; + + StubEditorSupport* mEditorSupport; + StubObjectRegister* mObjectRegister; + + KLineEdit* objectNameLineEdit(RemoteObjectNameWidget* widget) const; + + void assertRemoteObjectSignal(const QSignalSpy& spy, int index, + const RemoteObject* remoteObject) const; + +}; + +void RemoteObjectNameWidgetTest::initTestCase() { + //RemoteObject* must be registered in order to be used with QSignalSpy + mRemoteObjectStarType = qRegisterMetaType<RemoteObject*>("RemoteObject*"); +} + +void RemoteObjectNameWidgetTest::init() { + mPath = QApplication::applicationDirPath() + + "/../targetapplication/TargetApplicationStub"; + + //Avoid signals from previews tests to be delivered to the next ones + //setting a new TargetApplication + delete TargetApplication::sSelf; + TargetApplication::sSelf = new TargetApplication(); +} + +void RemoteObjectNameWidgetTest::cleanup() { + delete TargetApplication::sSelf; + TargetApplication::sSelf = 0; +} + +void RemoteObjectNameWidgetTest::testConstructor() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + QWidget parent; + RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); + + QCOMPARE(widget->parentWidget(), &parent); + QCOMPARE(widget->name(), QString("")); + QStringList items = objectNameLineEdit(widget)->completionObject()->items(); + QCOMPARE(items.count(), 5); + QVERIFY(items.contains("The object name 42")); + QVERIFY(items.contains("The object name 420")); + QVERIFY(items.contains("The object name 421")); + QVERIFY(items.contains("The object name 422")); + QVERIFY(items.contains("The object name 423")); +} + +void RemoteObjectNameWidgetTest::testSetName() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + RemoteObjectNameWidget widget; + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + widget.setName("The object name 423"); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + + QCOMPARE(widget.name(), QString("The object name 423")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); + assertRemoteObjectSignal(remoteObjectChosenSpy, 0, + mainWindow->children()[3]); +} + +void RemoteObjectNameWidgetTest::testSetNameWithUnknownRemoteObjectName() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + RemoteObjectNameWidget widget; + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + widget.setName("The object name 108"); + + QCOMPARE(widget.name(), QString("The object name 108")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); + assertRemoteObjectSignal(remoteObjectChosenSpy, 0, 0); +} + +void RemoteObjectNameWidgetTest::testTargetApplicationStartedAfterWidget() { + RemoteObjectNameWidget widget; + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + QStringList items = objectNameLineEdit(&widget)->completionObject()-> + items(); + QCOMPARE(items.count(), 0); + + widget.setName("The object name 42"); + + QCOMPARE(widget.name(), QString("The object name 42")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); + assertRemoteObjectSignal(remoteObjectChosenSpy, 0, 0); + + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + items = objectNameLineEdit(&widget)->completionObject()->items(); + QCOMPARE(items.count(), 5); + QVERIFY(items.contains("The object name 42")); + QVERIFY(items.contains("The object name 420")); + QVERIFY(items.contains("The object name 421")); + QVERIFY(items.contains("The object name 422")); + QVERIFY(items.contains("The object name 423")); + + widget.setName("The object name 423"); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + + QCOMPARE(widget.name(), QString("The object name 423")); + QCOMPARE(remoteObjectChosenSpy.count(), 2); + assertRemoteObjectSignal(remoteObjectChosenSpy, 1, + mainWindow->children()[3]); +} + +void RemoteObjectNameWidgetTest::testTargetApplicationStopped() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + RemoteObjectNameWidget widget; + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + TargetApplication::self()->mProcess->kill(); + + //Give the target application time to stop + QTest::qWait(1000); + + QStringList items = objectNameLineEdit(&widget)->completionObject()-> + items(); + QCOMPARE(items.count(), 0); + + widget.setName("The object name 42"); + + QCOMPARE(widget.name(), QString("The object name 42")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); + assertRemoteObjectSignal(remoteObjectChosenSpy, 0, 0); +} + +void RemoteObjectNameWidgetTest::testAddingOrRemovingRemoteObjects() { + QSKIP("Unfortunately, testing if the completion list is updated when an " + "object is added or removed in the target application is too " + "burdensome so the test must be done manually", SkipAll); +} + +/////////////////////////////////// Helpers //////////////////////////////////// + +KLineEdit* RemoteObjectNameWidgetTest::objectNameLineEdit( + RemoteObjectNameWidget* widget) const { + return widget->findChild<KLineEdit*>("objectNameLineEdit"); +} + +//RemoteObject* must be declared as a metatype to be used in qvariant_cast +Q_DECLARE_METATYPE(RemoteObject*); + +void RemoteObjectNameWidgetTest::assertRemoteObjectSignal(const QSignalSpy& spy, + int index, const RemoteObject* remoteObject) const { + QVariant argument = spy.at(index).at(0); + QCOMPARE(argument.userType(), mRemoteObjectStarType); + QCOMPARE(qvariant_cast<RemoteObject*>(argument), remoteObject); +} + +QTEST_MAIN(RemoteObjectNameWidgetTest) + +#include "RemoteObjectNameWidgetTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForEventWidgetTest.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -85,7 +85,11 @@ KLineEdit* WaitForEventWidgetTest::receiverNameLineEdit( WaitForEventWidget* widget) const { +#ifdef QT_QTDBUS_FOUND + return widget->findChild<KLineEdit*>("objectNameLineEdit"); +#else return widget->findChild<KLineEdit*>("receiverNameLineEdit"); +#endif } KLineEdit* WaitForEventWidgetTest::eventNameLineEdit( Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForSignalWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForSignalWidgetTest.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForSignalWidgetTest.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -72,7 +72,11 @@ KLineEdit* WaitForSignalWidgetTest::emitterNameLineEdit( WaitForSignalWidget* widget) const { +#ifdef QT_QTDBUS_FOUND + return widget->findChild<KLineEdit*>("objectNameLineEdit"); +#else return widget->findChild<KLineEdit*>("emitterNameLineEdit"); +#endif } KLineEdit* WaitForSignalWidgetTest::signalNameLineEdit( Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp 2010-05-18 16:42:44 UTC (rev 243) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp 2010-05-21 23:36:29 UTC (rev 244) @@ -362,7 +362,11 @@ void WaitForWidgetTest::setEventData() const { KLineEdit* receiverNameLineEdit = +#ifdef QT_QTDBUS_FOUND + mWidget->findChild<KLineEdit*>("objectNameLineEdit"); +#else mWidget->findChild<KLineEdit*>("receiverNameLineEdit"); +#endif QVERIFY(receiverNameLineEdit); receiverNameLineEdit->setText("The new receiver name"); @@ -378,7 +382,11 @@ void WaitForWidgetTest::setSignalData() const { KLineEdit* emitterNameLineEdit = +#ifdef QT_QTDBUS_FOUND + mWidget->findChild<KLineEdit*>("objectNameLineEdit"); +#else mWidget->findChild<KLineEdit*>("emitterNameLineEdit"); +#endif QVERIFY(emitterNameLineEdit); emitterNameLineEdit->setText("The new emitter name"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |