Class: QSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/QWebChannel/QSignal.rb

Instance Method Summary collapse

Constructor Details

#initialize(signalName, signalIndex, object, isPropertyNotifySignal) ⇒ QSignal

Returns a new instance of QSignal.



2
3
4
5
6
7
8
# File 'lib/QWebChannel/QSignal.rb', line 2

def initialize(signalName, signalIndex, object, isPropertyNotifySignal)
    @signalName=signalName
    @signalIndex=signalIndex
    @object=object
    @webChannel=@object.webChannel
    @isPropertyNotifySignal=isPropertyNotifySignal
end

Instance Method Details

#connect(callback) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/QWebChannel/QSignal.rb', line 10

def connect(callback)
    @object.__objectSignals__[@signalIndex]=@object.__objectSignals__[@signalIndex] || []
    @object.__objectSignals__[@signalIndex] << callback
    
    if (!@isPropertyNotifySignal && @signalName!= "destroyed")
        @webChannel.exec( { "type" => QWebChannelMessageTypes::CONNECTTOSIGNAL, "object" => @object.__id__, "signal" => @signalIndex  } )
    end
end

#disconnect(callback) ⇒ Object

def connect(callback)



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/QWebChannel/QSignal.rb', line 19

def disconnect(callback)
    @object.__objectSignals__[signalIndex]=@object.__objectSignals__[signalIndex] || []
    idx=@object.__objectSignals__[signalIndex].indexOf(callback)


    @object.__objectSignals__[signalIndex].delete_at(idx) 
    
    if (!isPropertyNotifySignal && @object.__objectSignals__[signalIndex].length == 0)
        @webChannel.exec( { "type" => QWebChannelMessageTypes::DISCONNECTFROMSIGNAL, "object" => @object.__id__, "signal" => signalIndex } )
    end #if (!isPropertyNotifySignal && @object.__objectSignals__[signalIndex].length == 0)
end