-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow reference to signals using 'on' handler syntax.
This will allow APIs like the following: trigger: mouseArea.onClicked However, signal handlers will not be callable from QML: mouseArea.onClicked() //throws exception Change-Id: I2ef5cb4e1f3ed4814ef590962391e1b14e3f0c43 Reviewed-on: http://codereview.qt.nokia.com/3683 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
- Loading branch information
Michael Brasser
authored and
Qt by Nokia
committed
Sep 1, 2011
1 parent
1dd8b50
commit d481f2f
Showing
8 changed files
with
185 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Qt.test 1.0 | ||
import QtQuick 2.0 | ||
|
||
QtObject { | ||
id: root | ||
|
||
property int count: 0 | ||
signal testSignal | ||
onTestSignal: count++ | ||
|
||
property int funcCount: 0 | ||
function testFunction() { | ||
funcCount++; | ||
} | ||
|
||
//should increment count | ||
function testSignalCall() { | ||
testSignal() | ||
} | ||
|
||
//should NOT increment count, and should throw an exception | ||
property string errorString | ||
function testSignalHandlerCall() { | ||
try { | ||
onTestSignal() | ||
} catch (error) { | ||
errorString = error.toString(); | ||
} | ||
} | ||
|
||
//should increment funcCount once | ||
function testSignalConnection() { | ||
testSignal.connect(testFunction) | ||
testSignal(); | ||
testSignal.disconnect(testFunction) | ||
testSignal(); | ||
} | ||
|
||
//should increment funcCount once | ||
function testSignalHandlerConnection() { | ||
onTestSignal.connect(testFunction) | ||
testSignal(); | ||
onTestSignal.disconnect(testFunction) | ||
testSignal(); | ||
} | ||
|
||
//should be defined | ||
property bool definedResult: false | ||
function testSignalDefined() { | ||
if (testSignal !== undefined) | ||
definedResult = true; | ||
} | ||
|
||
//should be defined | ||
property bool definedHandlerResult: false | ||
function testSignalHandlerDefined() { | ||
if (onTestSignal !== undefined) | ||
definedHandlerResult = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters