[Ktutorial-commits] SF.net SVN: ktutorial:[313] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2011-05-24 21:36:49
|
Revision: 313 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=313&view=rev Author: danxuliu Date: 2011-05-24 21:36:42 +0000 (Tue, 24 May 2011) Log Message: ----------- Set the buddy for object name labels. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -111,6 +111,9 @@ ui = new Ui::RemoteObjectNameWidget(); ui->setupUi(this); + setFocusPolicy(Qt::StrongFocus); + setFocusProxy(ui->objectNameLineEdit); + connect(ui->objectNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(handleNameChanged(QString))); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -50,6 +50,7 @@ delete ui->receiverNameLineEdit; ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->receiverNameLabel->setBuddy(mRemoteObjectNameWidget); mRemoteObjectNameWidget->setName(waitForEvent->receiverName()); #else Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>receiverNameLineEdit</cstring> + </property> </widget> </item> <item> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -51,6 +51,7 @@ delete ui->objectNameLineEdit; ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->objectNameLabel->setBuddy(mRemoteObjectNameWidget); connect(mRemoteObjectNameWidget, SIGNAL(remoteObjectChosen(RemoteObject*)), this, SLOT(setChosenRemoteObject(RemoteObject*))); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>objectNameLineEdit</cstring> + </property> </widget> </item> <item> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -53,6 +53,7 @@ delete ui->emitterNameLineEdit; ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->emitterNameLabel->setBuddy(mRemoteObjectNameWidget); connect(mRemoteObjectNameWidget, SIGNAL(remoteObjectChosen(RemoteObject*)), this, SLOT(setChosenRemoteObject(RemoteObject*))); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>emitterNameLineEdit</cstring> + </property> </widget> </item> <item> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -42,6 +42,7 @@ mRemoteObjectNameWidget = new RemoteObjectNameWidget(this); ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->windowObjectNameLabel->setBuddy(mRemoteObjectNameWidget); mRemoteObjectNameWidget->setName(waitForWindow->windowObjectName()); #else Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>windowObjectNameLineEdit</cstring> + </property> </widget> </item> </layout> Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -25,6 +25,7 @@ #undef private #undef protected +#include <QLabel> #include <QtDBus/QtDBus> #include <KCompletionBox> @@ -65,6 +66,10 @@ void testAddingOrRemovingRemoteObjects(); + void testSetFocus(); + + void testWidgetAsBuddyOfLabel(); + private: QString mPath; @@ -338,6 +343,56 @@ "burdensome so the test must be done manually", SkipAll); } +void RemoteObjectNameWidgetTest::testSetFocus() { + QWidget parent; + QLineEdit* otherLineEdit = new QLineEdit(&parent); + + RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); + + //Focus is not set in hidden widgets until they are shown + parent.show(); + + //Give the parent widget time to be shown + QTest::qWait(500); + + otherLineEdit->setFocus(); + + QVERIFY(!widget->hasFocus()); + QVERIFY(!objectNameLineEdit(widget)->hasFocus()); + + widget->setFocus(); + + QVERIFY(widget->hasFocus()); + QVERIFY(objectNameLineEdit(widget)->hasFocus()); +} + +void RemoteObjectNameWidgetTest::testWidgetAsBuddyOfLabel() { + QWidget parent; + QLineEdit* otherLineEdit = new QLineEdit(&parent); + + RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); + + QLabel* widgetLabel = new QLabel(&parent); + widgetLabel->setText("&Widget label:"); + widgetLabel->setBuddy(widget); + + //Focus is not set in hidden widgets until they are shown + parent.show(); + + //Give the parent widget time to be shown + QTest::qWait(500); + + otherLineEdit->setFocus(); + + QVERIFY(!widget->hasFocus()); + QVERIFY(!objectNameLineEdit(widget)->hasFocus()); + + QTest::keyClick(&parent, Qt::Key_W, Qt::AltModifier); + + QVERIFY(widget->hasFocus()); + QVERIFY(objectNameLineEdit(widget)->hasFocus()); +} + /////////////////////////////////// Helpers //////////////////////////////////// KLineEdit* RemoteObjectNameWidgetTest::objectNameLineEdit( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |