camelot.camelot.view.response_handler

Package camelot :: Package camelot :: Package view :: Module response_handler |
[hide private]
[frames] | no frames]

# Source Code for Module camelot.camelot.view.response_handler

     1  #  ==================================================================================
     2  #
     3  #  Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved.
     4  #  www.conceptive.be / project-camelot@conceptive.be
     5  #
     6  #  This file is part of the Camelot Library.
     7  #
     8  #  This file may be used under the terms of the GNU General Public
     9  #  License version 2.0 as published by the Free Software Foundation
    10  #  and appearing in the file LICENSE.GPL included in the packaging of
    11  #  this file.  Please review the following information to ensure GNU
    12  #  General Public Licensing requirements will be met:
    13  #  http://www.trolltech.com/products/qt/opensource.html
    14  #
    15  #  If you are unsure which license is appropriate for your use, please
    16  #  review the following information:
    17  #  http://www.trolltech.com/products/qt/licensing.html or contact
    18  #  project-camelot@conceptive.be.
    19  #
    20  #  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    21  #  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    22  #
    23  #  For use of this library in commercial applications, please contact
    24  #  project-camelot@conceptive.be
    25  #
    26  #  ==================================================================================
    27
    28  """QT Response handler class to be used when constructing
    29  a model thread. Construct this response handler within the
    30  GUI thread to have all responses being handled within the
    31  event loop of the GUI thread."""
    32
    33  import threading
    34  import logging
    35
    36  logger = logging.getLogger('response_handler')
    37  logger.setLevel(logging.INFO)
    38
    39  from PyQt4.QtCore import *
    40
    41  from model_thread import get_model_thread
    42
    43 -class ResponseHandler(QObject):
    44 -  def __init__(self):
    45      QObject.__init__(self)
    46      self.response_signal = SIGNAL("responseAvailable()")
    47      self.start_signal = SIGNAL("startProcessingRequest()")
    48      self.stop_signal = SIGNAL("stopProcessingRequest()")
    49      self.connect(self, self.response_signal, self.handleResponse)
    50 -  def handleResponse(self):
    51      logger.debug('handle responses in thread %s'%str(threading.currentThread()))
    52      get_model_thread().process_responses()
    53 -  def responseAvailable(self):
    54      logger.debug('response available in thread %s'%str(threading.currentThread()))
    55      self.emit(self.response_signal)
    56 -  def startProcessingRequest(self):
    57      self.emit(self.start_signal)
    58 -  def stopProcessingRequest(self):
    59      self.emit(self.stop_signal)
    60