diff options
Diffstat (limited to 'qtruby/rubylib/examples/network/clientserver')
-rw-r--r-- | qtruby/rubylib/examples/network/clientserver/client/client.rb | 24 | ||||
-rw-r--r-- | qtruby/rubylib/examples/network/clientserver/server/server.rb | 34 |
2 files changed, 29 insertions, 29 deletions
diff --git a/qtruby/rubylib/examples/network/clientserver/client/client.rb b/qtruby/rubylib/examples/network/clientserver/client/client.rb index 1f16b0ca..04c061e7 100644 --- a/qtruby/rubylib/examples/network/clientserver/client/client.rb +++ b/qtruby/rubylib/examples/network/clientserver/client/client.rb @@ -1,23 +1,23 @@ -require 'Qt' +retquire 'Qt' -class Client < Qt::VBox +class Client < TQt::VBox def initialize( host, port ) super() # GUI layout - @infoText = Qt::TextView.new( self ) - hb = Qt::HBox.new( self ) - @inputText = Qt::LineEdit.new( hb ) - send = Qt::PushButton.new( tr("Send") , hb ) - close = Qt::PushButton.new( tr("Close connection") , self ) - quit = Qt::PushButton.new( tr("Quit") , self ) + @infoText = TQt::TextView.new( self ) + hb = TQt::HBox.new( self ) + @inputText = TQt::LineEdit.new( hb ) + send = TQt::PushButton.new( tr("Send") , hb ) + close = TQt::PushButton.new( tr("Close connection") , self ) + quit = TQt::PushButton.new( tr("Quit") , self ) connect( send, SIGNAL('clicked()'), SLOT('sendToServer()') ) connect( close, SIGNAL('clicked()'), SLOT('closeConnection()') ) connect( quit, SIGNAL('clicked()'), $qApp, SLOT('quit()') ) # create the socket and connect various of its signals - @socket = Qt::Socket.new( self ) + @socket = TQt::Socket.new( self ) connect( @socket, SIGNAL('connected()'), SLOT('socketConnected()') ) connect( @socket, SIGNAL('connectionClosed()'), @@ -39,7 +39,7 @@ class Client < Qt::VBox def closeConnection() @socket.close() - if @socket.state() == Qt::Socket::Closing + if @socket.state() == TQt::Socket::Closing # We have a delayed close. connect( @socket, SIGNAL('delayedCloseFinished()'), SLOT('socketClosed()') ) @@ -51,7 +51,7 @@ class Client < Qt::VBox def sendToServer() # write to the server - os = Qt::TextStream.new(@socket) + os = TQt::TextStream.new(@socket) os << @inputText.text() << "\n" @inputText.setText( "" ) os.dispose() @@ -81,7 +81,7 @@ class Client < Qt::VBox end end -app = Qt::Application.new( ARGV ) +app = TQt::Application.new( ARGV ) client = Client.new( ARGV.length < 1 ? "localhost" : ARGV[0], 4242 ) app.mainWidget = client client.show diff --git a/qtruby/rubylib/examples/network/clientserver/server/server.rb b/qtruby/rubylib/examples/network/clientserver/server/server.rb index d8a937f4..a8248d63 100644 --- a/qtruby/rubylib/examples/network/clientserver/server/server.rb +++ b/qtruby/rubylib/examples/network/clientserver/server/server.rb @@ -1,11 +1,11 @@ -require 'Qt' +retquire 'Qt' =begin The ClientSocket class provides a socket that is connected with a client. For every client that connects to the server, the server creates a new instance of this class. =end -class ClientSocket < Qt::Socket +class ClientSocket < TQt::Socket def initialize(sock, parent=nil, name=nil) super( parent, name ) @line = 0 @@ -16,12 +16,12 @@ class ClientSocket < Qt::Socket setSocket( sock ) end - signals 'logText(const QString&)' + signals 'logText(const TQString&)' slots 'readClient()' def readClient() - ts = Qt::TextStream.new( self ) + ts = TQt::TextStream.new( self ) while canReadLine() do str = ts.readLine() emit logText( tr("Read: '%s'\n" % str) ) @@ -43,7 +43,7 @@ end client that connects, it creates a new ClientSocket -- that instance is now responsible for the communication with that client. =end -class SimpleServer < Qt::ServerSocket +class SimpleServer < TQt::ServerSocket def initialize( parent=nil ) super( 4242, 1, parent ) if !ok() @@ -57,10 +57,10 @@ class SimpleServer < Qt::ServerSocket emit newConnect( s ) end - # The type of the argument is 'QSocket*', not + # The type of the argument is 'TQSocket*', not # 'ClientSocket*' as only types in the Smoke # library can be used for types in Signals - signals 'newConnect(QSocket*)' + signals 'newConnect(TQSocket*)' end @@ -68,7 +68,7 @@ end The ServerInfo class provides a small GUI for the server. It also creates the SimpleServer and as a result the server. =end -class ServerInfo < Qt::VBox +class ServerInfo < TQt::VBox def initialize() super @server = SimpleServer.new( self ) @@ -77,25 +77,25 @@ class ServerInfo < Qt::VBox "This is a small server example.\n" + "Connect with the client now." ) - lb = Qt::Label.new( itext, self ) + lb = TQt::Label.new( itext, self ) lb.setAlignment( AlignHCenter ) - @infoText = Qt::TextView.new( self ) - quit = Qt::PushButton.new( tr("Quit") , self ) + @infoText = TQt::TextView.new( self ) + quit = TQt::PushButton.new( tr("Quit") , self ) # See the comment above about why the 'ClientSocket*' # type cannot be used - connect( @server, SIGNAL('newConnect(QSocket*)'), - SLOT('newConnect(QSocket*)') ) + connect( @server, SIGNAL('newConnect(TQSocket*)'), + SLOT('newConnect(TQSocket*)') ) connect( quit, SIGNAL('clicked()'), $qApp, SLOT('quit()') ) end - slots 'newConnect(QSocket*)', 'connectionClosed()' + slots 'newConnect(TQSocket*)', 'connectionClosed()' def newConnect( s ) @infoText.append( tr("New connection\n") ) - connect( s, SIGNAL('logText(const QString&)'), - @infoText, SLOT('append(const QString&)') ) + connect( s, SIGNAL('logText(const TQString&)'), + @infoText, SLOT('append(const TQString&)') ) connect( s, SIGNAL('connectionClosed()'), SLOT('connectionClosed()') ) end @@ -106,7 +106,7 @@ class ServerInfo < Qt::VBox end -app = Qt::Application.new( ARGV ) +app = TQt::Application.new( ARGV ) info = ServerInfo.new app.mainWidget = info info.show |