Package Camelot :: Package camelot :: Package action :: Module refresh |
[frames] | no frames]

# Source Code for Module Camelot.camelot.action.refresh

     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  """The action module contains various QAction classes, representing commands that
    29  can be invoked via menus, toolbar buttons, and keyboard shortcuts."""
    30
    31  from PyQt4.QtCore import Qt
    32  from PyQt4 import QtGui, QtCore
    33
    34  from camelot.view.art import Icon
    35  from camelot.view.model_thread import post
    36
    37  import logging
    38  logger = logging.getLogger( 'camelot.action.refresh' )
    39
    40 -class SessionRefresh( QtGui.QAction ):
    41      """Session refresh expires all objects in the current session and sends
    42      a local entity update signal via the remote_signals mechanism"""
    43
    44 -    def __init__( self, parent ):
    45          super( SessionRefresh, self ).__init__( 'Refresh', parent )
    46          self.setShortcut( Qt.Key_F9 )
    47          self.setIcon( Icon( 'tango/16x16/actions/view-refresh.png' ).getQIcon() )
    48          self.connect( self, QtCore.SIGNAL( 'triggered(bool)' ), self.sessionRefresh )
    49          from camelot.view.remote_signals import get_signal_handler
    50          self.signal_handler = get_signal_handler()
    51
    52 -    def refreshed(self, refreshed_objects ):
    53          for o in refreshed_objects:
    54              self.signal_handler.sendEntityUpdate( self, o )
    55
    56 -    def sessionRefresh( self, checked ):
    57          logger.debug( 'session refresh requested' )
    58
    59          def refresh_objects():
    60              from elixir import session
    61              refreshed_objects = []
    62
    63              for _key, value in session.identity_map.items():
    64                  session.refresh( value )
    65                  refreshed_objects.append( value )
    66
    67              return refreshed_objects
    68
    69
    70          post( refresh_objects, self.refreshed)
    71