Exemple #1
0
 def setUp(self): 
     testlog.debug('Instantiate null address, address.setter list')
     #self.QI = QgisInterface(_Dummy_Canvas())
     qi = ASM.getMock(ASM.ASMenum.QI)()
     controller = Controller(qi)
     self._layermanager = LayerManager(qi,controller)
     self._layermanager.addressLayerAdded = ASM.getMock(ASM.ASMenum.SIGNAL)()
     Database.setup(DCONF)
Exemple #2
0
 def test20_layerManagerTest(self):
     #assertIsNotNone added in 3.1        
     testlog.debug('Test_0.20 LayerManager instantiation test')
     qi = ASM.getMock(ASM.ASMenum.QI)()
     controller = Controller(qi)
     layermanager = LayerManager(qi,controller)
     self.assertNotEqual(layermanager,None,'LayerManager not instantiated')
Exemple #3
0
class Test_1_LayerManagerSetters(unittest.TestCase):

    def setUp(self): 
        testlog.debug('Instantiate null address, address.setter list')
        #self.QI = QgisInterface(_Dummy_Canvas())
        qi = ASM.getMock(ASM.ASMenum.QI)()
        controller = Controller(qi)
        self._layermanager = LayerManager(qi,controller)
        
    def tearDown(self):
        testlog.debug('Destroy null layermanager')
        self._layermanager = None        
        
    def test10_instLayerID(self):
        '''Test the layer id setter'''
        testval = 't10'
        testlog.debug('Test_1.10 Instantiate layer ID')
        testlayer = ASM.getMock(ASM.ASMenum.LAYER)(cprv=testval,vlrv=True)

        self._layermanager.setLayerId(testlayer,testval)
        self.assertEqual(self._layermanager.layerId(testlayer),testval, 'Unable to set layer ID {}'.format(testval))

    def test11_instLayerIdRange(self):
        '''Example of success/fail test cases over range of input values'''
        testlog.debug('Test_1.11 Test range of layer ID values')

        testsuccesses = ('A','Z','#$%^&_)_#@)','māori','   ')
        for ts in testsuccesses:
            testlayer = ASM.getMock(ASM.ASMenum.LAYER)(cprv=ts,vlrv=True)
            self._layermanager.setLayerId(testlayer,ts)
            self.assertEqual(self._layermanager.layerId(testlayer),ts, 'Unable to set layer ID {}'.format(ts))
            
        #NB Can't set None as on Mock property since it is interpreted as no value so must be caught
        testfailures = (None,'',0,float('nan'),float('inf'),object,self)
        for tf in testfailures:
            testlayer = ASM.getMock(ASM.ASMenum.LAYER)(cprv=tf)
            #testlayer.customProperty.return_value = tf
            self.assertRaises(InvalidParameterException, self._layermanager.setLayerId, testlayer, tf)
    def initGui(self):
        """ 
        Set up UI within QGIS 
        """
        
        # set srs
        self._displayCrs = QgsCoordinateReferenceSystem()
        self._displayCrs.createFromOgcWmsCrs('EPSG:4167') 
        self.iface.mapCanvas().mapSettings().setDestinationCrs(self._displayCrs)
        
        # init layerManager
        self._layerManager = LayerManager(self.iface, self)
        # init Highlighter
        self.highlighter = FeatureHighlighter(self.iface, self._layerManager, self)
        
        # Build an action list from QGIS navigation toolbar
        actionList = self.iface.mapNavToolToolBar().actions()
        self.actions = self.iface.mapNavToolToolBar().actions()
        
        # Main address editing window
        self._loadaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/loadaddress.png'), 
            'QGIS-AIMS-Plugin', self.iface.mainWindow())
        self._loadaction.setWhatsThis('Open the QGIS-AIMS-Plugin')
        self._loadaction.setStatusTip('Open the QGIS-AIMS-Plugin')
        self._loadaction.triggered.connect(self.loadQueues)
        self._loadaction.triggered.connect(self.loadLayers)
        self._loadaction.triggered.connect(self.enableAddressLayer)
        self._loadaction.triggered.connect(self.startDM)
        
        # Create new address tool
        self._createnewaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/newaddresspoint.png'), 
            'Create AIMS Feature', self.iface.mainWindow())
        self._createnewaddressaction.setWhatsThis('Create AIMS Feature')
        self._createnewaddressaction.setStatusTip('Create AIMS Feature')
        self._createnewaddressaction.setEnabled(False)
        self._createnewaddressaction.setCheckable(True)
        self._createnewaddressaction.triggered.connect( self.startNewAddressTool )
        self._createnewaddresstool = CreateNewAddressTool( self.iface, self._layerManager, self)
        self._createnewaddresstool.setAction( self._createnewaddressaction )
        self.actions.append(self._createnewaddressaction)

        # Delete address point
        self._deladdressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/deleteaddress.png'), 
            'Delete AIMS Feature', self.iface.mainWindow())
        self._deladdressaction.setWhatsThis('Delete AIMS Feature')
        self._deladdressaction.setStatusTip('Delete AIMS Feature')
        self._deladdressaction.setEnabled(False)
        self._deladdressaction.setCheckable(True)
        self._deladdressaction.triggered.connect( self.startDelAddressTool )
        self._deladdtool = DelAddressTool( self.iface, self._layerManager, self)
        self._deladdtool.setAction( self._deladdressaction )        
        self.actions.append(self._deladdressaction)

        # Move address
        self._moveaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/moveaddress.png'), 
            'Move AIMS Feature(s)', self.iface.mainWindow())
        self._moveaddressaction.setWhatsThis('Move AIMS Feature(s)')
        self._moveaddressaction.setStatusTip('Move AIMS Feature(s)')
        self._moveaddressaction.setEnabled(False)
        self._moveaddressaction.setCheckable(True)
        self._moveaddressaction.triggered.connect( self.startMoveAddressTool )
        self._moveaddtool = MoveAddressTool( self.iface, self._layerManager, self)
        self._moveaddtool.setAction( self._moveaddressaction )      
        self.actions.append(self._moveaddressaction)
        
        # Update address
        self._updateaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/updateaddress.png'), 
            'Update AIMS Feature', self.iface.mainWindow())
        self._updateaddressaction.setWhatsThis('Update AIMS Feature')
        self._updateaddressaction.setStatusTip('Update AIMS Feature')
        self._updateaddressaction.setEnabled(False)
        self._updateaddressaction.setCheckable(True)
        self._updateaddressaction.triggered.connect( self.startUpdateAddressTool )
        self._updateaddtool = UpdateAddressTool( self.iface, self._layerManager, self)
        self._updateaddtool.setAction( self._updateaddressaction )  
        self.actions.append(self._updateaddressaction)
                    
        # RCL tool -- Not a QAction as triggered from many palaces but not the toolbar
        self._rcltool = GetRcl(self.iface, self._layerManager, self)
        
        # UpdateReview Position tool -- Not a QAction as triggered initiated from review queue form
        self._updateReviewPos = UpdateReviewPosition(self.iface, self._layerManager, self)
       
        # Address lineage
        """
        self._lineageaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/lineage.png'), 
            'Build Lineage Relationships Between Features', self.iface.mainWindow())
        self._lineageaction.setWhatsThis('Build Lineage Relationships Between Features')
        self._lineageaction.setStatusTip('Build Lineage Relationships Between Features')
        self._lineageaction.setEnabled(False)
        self._lineageaction.setCheckable(True)
        self._lineagetool = LineageTool( self.iface, self._layerManager, self)
        self._lineageaction.triggered.connect(self._lineagetool.setEnabled)
        self.actions.append(self._lineageaction)
        """
        
        # Address highlighter
        self._highlightaction = QAction(QIcon(":/plugins/QGIS-AIMS-Plugin/resources/addresshighlight.png"), 
            "Electoral address highlighter", self.iface.mainWindow())
        self._highlightaction.setWhatsThis("Turn the electoral address highlighter on or off")
        self._highlightaction.setStatusTip("Turn the electoral address highlighter on or off")     
        self._highlightaction.setText('Highlightaction')
        self._highlightaction.setEnabled(False)
        self._highlightaction.setCheckable(True)
        self._highlightaction.toggled.connect( self.highlighter.setEnabled )
        
        # Add to own toolbar
        self._toolbar = self.iface.addToolBar('QGIS-AIMS-Plugin')
        self._toolbar.addAction(self._createnewaddressaction)
        self._toolbar.addAction(self._deladdressaction)
        self._toolbar.addAction(self._updateaddressaction)
        self._toolbar.addAction(self._moveaddressaction)
        #self._toolbar.addAction(self._lineageaction)
        self._toolbar.addAction(self._highlightaction)
        
        # Add actions to menu
        self.iface.addToolBarIcon(self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._createnewaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._updateaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._moveaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._highlightaction)

        # capture maptool selection changes
        QObject.connect(self.iface.mapCanvas(), SIGNAL( "mapToolSet(QgsMapTool *)" ), self.mapToolChanged)

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self.iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend( action.defaultWidget().actions() )
            else:
                actionList.append( action )
        # ... could add other toolbars' action lists...

        # Build a group with actions from actionList
        group = QActionGroup( self.iface.mainWindow() )
        group.setExclusive(True)
        for qgisAction in actionList:
            group.addAction( qgisAction )

        # Add our own actions
        for action in self.actions:
            if action.text() == 'Highlightaction': continue
            group.addAction( action )
Exemple #5
0
class Test_2_LayerManagerConnection(unittest.TestCase):
    '''installreflayer->installlayer->findlayer->layers'''
    
    MLAYERS = (('rcl','_rclLayer'),('par','_parLayer'),('loc','_locLayer'),('adr','_adrLayer'))
    
    def setUp(self): 
        testlog.debug('Instantiate null address, address.setter list')
        #self.QI = QgisInterface(_Dummy_Canvas())
        qi = ASM.getMock(ASM.ASMenum.QI)()
        controller = Controller(qi)
        self._layermanager = LayerManager(qi,controller)
        self._layermanager.addressLayerAdded = ASM.getMock(ASM.ASMenum.SIGNAL)()
        Database.setup(DCONF)

        
    def tearDown(self):
        testlog.debug('Destroy null layermanager')
        self._layermanager = None
        Database.setup({name:None for name in DCONF})                 

    def test10_layers_m(self):
        '''tests whether a layer generator is returned and it contains valid mock layers'''
        test_layers = 3*(ASM.getMock(ASM.ASMenum.LAYER)(vlrv=True),)
        with patch(LM_QMLR) as qmlr_mock:
            qmlr_mock.instance.return_value.mapLayers.return_value.values.return_value = test_layers
            for glayer in self._layermanager.layers():
                testlog.debug('T10 - testing layer (fetch) for {}'.format(glayer))
                self.assertEqual(isinstance(glayer, ASM.getMock(ASM.ASMenum.LAYER)().__class__), True,'Object returned not a layer type')    
                
    def test11_layers(self):
        '''tests whether a layer generator is returned and it contains valid layers'''
        #TODO install test layers even though installlayer functionality is untested. in the meantime returns none
        for glayer in self._layermanager.layers():
            testlog.debug('testing layer (fetch) for {}'.format(glayer))
            self.assertEqual(isinstance(glayer, QgsVectorLayer), True,'Object returned not a layer type')
            
            
    def test20_findLayer(self):
        '''tests whether the find layer fiunction returns a named layer, uses layers() gen'''
        test_layerdict = {test_layerid:ASM.getMock(ASM.ASMenum.LAYER)(cprv=test_layerid,vlrv=True) for test_layerid in ('rcl','par','loc','adr')}
        #test_layerlist = len(test_layeridlist)*(ASM.getMock(ASM.ASMenum.LAYER)(vlrv=True),)
        #test_layerdict = {x[0]:x[1] for x in zip(test_layeridlist,test_layerlist)}
        with patch(LM_QMLR) as qmlr_mock:
            qmlr_mock.instance.return_value.mapLayers.return_value.values.return_value = test_layerdict.values()
            for test_layerid in test_layerdict:
                testlog.debug('T20 testing findlayer for layer type {}'.format(test_layerid))
                #test_layerdict[test_layerid].customProperty.return_value = test_layerid
                test_layer = self._layermanager.findLayer(test_layerid)
                self.assertEqual(isinstance(test_layer, ASM.getMock(ASM.ASMenum.LAYER)(vlrv=True).__class__), True,'Object returned not a layer type with name'.format(test_layerid))
    

    def test30_installLayers_find(self):
        '''tests install layer when layer is already installed in Qgis'''
        for test_id in [l[0] for l in self.MLAYERS]:
            test_layer = ASM.getMock(ASM.ASMenum.LAYER)(cprv=test_id,vlrv=True)
            #set up legendinterface to return legend mock!!!
            qlgd_mock =  ASM.getMock(ASM.ASMenum.QLGD)()
            self._layermanager._iface.legendInterface.return_value = qlgd_mock
    
            for lyr_vis in (True,False):
                #set legend visibility
                qlgd_mock.isLayerVisible.return_value = lyr_vis
                with patch(LM_QMLR) as qmlr_mock:
                    testlog.debug('T30 - testing installlayer 1 on layer with name {} and lgd visibility={}'.format(test_id,lyr_vis))
                    #set up findlayer to return test_layer
                    qmlr_mock.instance.return_value.mapLayers.return_value.values.return_value = [test_layer,]
                    res_layer = self._layermanager.installLayer(**getLConf(replace={'id':test_id}))
        
                    self.assertEqual(test_layer,res_layer, 'installlayers and set layers dont match on layer with name {} and lgd visibility={}'.format(test_id,lyr_vis))
                        
    def test31_installLayers_db(self):
        '''tests installlayer's fetch from database if layer not available'''
        #This doesn't test the Database fetch part of the function and just internal logic. It isn't as useful as it could be
        test_layer = ASM.getMock(ASM.ASMenum.LAYER)() 
        for test_id in [l[0] for l in self.MLAYERS]:
            #set layerid to none to bypass active fetch
            with patch(LM_QMLR) as qmlr_mock:
                qmlr_mock.instance.return_value.mapLayers.return_value.values.return_value = ()
                with patch(LM_QVL) as qvl_mock:
                    testlog.debug('T40 - testing installlayer 2 on layer with name {}'.format(test_id))
                    qvl_mock.return_value = test_layer
                    res_layer = self._layermanager.installLayer(**getLConf(replace={'displayname':test_id}))
                    self.assertEqual(test_layer, res_layer, 'installlayers and set layers dont match on fetched layer with name {}'.format(test_id))


    #now that installlayers is tested we can use this to generate test layers
        
    def test32_installLayers_tst(self):
        '''tests whether fake layers have been installed following execution of the installlayers method'''
        test_layer_id = 't32'
        test_layer = self._layermanager.installLayer(**getLConf(replace={'displayname':test_layer_id}))
        #test_layer = ASM.getMock(ASM.ASMenum.LAYER)(cprv=test_layer_id) 
        with patch(LM_QMLR) as qmlr_mock:
            testlog.debug('T32 - testing installlayers on fake layer {}'.format(test_layer_id))
            self._layermanager.setLayerId(test_layer,test_layer_id)
            qmlr_mock.instance.return_value.mapLayers.return_value.values.return_value = (test_layer,)
            found_layer = self._layermanager.findLayer(test_layer_id)
            self.assertEqual(found_layer, test_layer,'returned layer does not match set layer using name {}'.format(test_layer_id))
    
    
    def test40_installRefLayers(self):
        '''tests whether ref layers have been installed following execution of the installreflayers method'''
        ref_layers = {a:b for a,b in zip([l[0] for l in self.MLAYERS][:2], self._layermanager.installRefLayers())}
        
        with patch(LM_QMLR) as qmlr_mock:
            qmlr_mock.instance.return_value.mapLayers.return_value.values.return_value = ref_layers.values()
            for test_layerid in ref_layers:
                testlog.debug('T40 - testing installreflayers for layer type {}'.format(test_layerid))
                self._layermanager.setLayerId(ref_layers[test_layerid],test_layerid)
                found_layer = self._layermanager.findLayer(test_layerid)
                self.assertEqual(found_layer, ref_layers[test_layerid],'returned layer does not match set layer using name {}'.format(test_layerid))
    
        

    def test50_checkNewLayer(self):
        '''tests whether layer is assigned to correct attribute'''
        #NB ('adr','_adrLayer'),#can't easily test adr since it emits a signal and fails with mock parameters
        for ltype in self.MLAYERS:
            testlog.debug('T50 - testing checknewlayer layer type {}'.format(ltype[0]))
            testlayer = ASM.getMock(ASM.ASMenum.LAYER)(cprv=ltype[0])
            #TODO. consider moving id setting to local scope
            self._layermanager.setLayerId(testlayer,ltype[0])
            #testlayer.customProperty.return_value = ltype[0]
            self._layermanager.checkNewLayer(testlayer)
            self.assertEqual(self._layermanager.__getattribute__(ltype[1]),testlayer)
        
    def test60_checkRemovedLayer(self):
        '''checks layers get null'd by first installing a layer then removing it'''
        test_layerdict = {test_layerpair:ASM.getMock(ASM.ASMenum.LAYER)(idrv=test_layerpair[0],cprv=test_layerpair[0],vlrv=True) for test_layerpair in self.MLAYERS}

        for test_layerpair in test_layerdict:
            #test_layerdict[test_layerpair].id.return_value = test_layerpair[0]
            self._layermanager.setLayerId(test_layerdict[test_layerpair],test_layerpair[0])
            self._layermanager.checkNewLayer(test_layerdict[test_layerpair])
            testlog.debug('T60a - testing checkremovelayer is added, layer type {}'.format(test_layerpair[0]))
            self.assertEqual(self._layermanager.__getattribute__(test_layerpair[1]),test_layerdict[test_layerpair],'Layer not initialised')
            
            self._layermanager.checkRemovedLayer(test_layerpair[0])
            testlog.debug('T60b - testing checkremovelayer is removed, layer type {}'.format(test_layerpair[0]))
            self.assertEqual(self._layermanager.__getattribute__(test_layerpair[1]),None,'Layer not removed')
            

    def test70_createFeaturesLayers(self):
        r = {'entities':[{'properties':{'version':1,'components':{},'addressedObject':{'addressPosition':{'coordinates':(0,0)}},'codes':{}}}]}
        #pqvl = patch(LM_QVL)
        #mock_qvl = pqvl.start()
        with patch(LM_QVL) as mock_qvl:
            mock_qvl.customProperty = 'adr'
            with patch(LM_QDP) as mock_qdp:
                with patch(LM_QF) as mock_qf:
                    #with patch(LM_QG) as mock_qg:
                        #mock_qg.fromPoint.return_value = ASM.getMock(ASM.ASMenum.GEOMETRY)()
                        #with patch(LM_QP) as mock_qp:
                            #mock_qp.return_value = ASM.getMock(ASM.ASMenum.POINT)()
                    with patch(LM_QMLR) as mock_qmlr:
                        self._layermanager.createFeaturesLayers(r)
                        #this method doesn't return anything testable so this test method just makes sure it runs without error given minimal input
                        self.assertEqual(True,True,'this cant be false')
                        
    
    def test_80_getAimsFeatures(self):
        self._layermanager._iface.mapCanvas.return_value.extent.return_value = 1000#ext?
        
    def test90_loadAimsFeatures(self):
        self._layermanager._iface.mapCanvas.return_value.mapSettings.return_value.scale.return_value = 9999999
        self._layermanager.loadAimsFeatures()
        self.assertEqual(1,1,'1')
class Controller( QObject ):
    ''' 
    Managers all UI Components and Plugins Tools as well as 
    initialisation and dessimnation of Singleton Instances  
        
     '''
    # log
    global uilog
    uilog = Logger.setup(lf='uiLog')
    
    _instance = None
    
    def __init__(self, iface):
        """ 
        Initialise UI Data Manager and Response Handler 
        
        @param iface: QgisInterface Abstract base class defining interfaces exposed by QgisApp  
        @type iface: Qgisinterface Object
        """
        
        QObject.__init__(self)
        self.iface = iface
        self._queues = None
        self._dockWindow = None
        self._currentMapTool = None
        self.rclParent = None
        self.currentRevItem = None
        self.actions = []
        if Controller._instance == None:
            Controller._instance = self
        self.uidm = UiDataManager(self.iface, self)
        self.RespHandler = ResponseHandler(self.iface, self.uidm)
        
        self.refLayer = None
        self.adrlayer = None
        self.revLayer = None
        
    def initGui(self):
        """ 
        Set up UI within QGIS 
        """
        
        # set srs
        self._displayCrs = QgsCoordinateReferenceSystem()
        self._displayCrs.createFromOgcWmsCrs('EPSG:4167') 
        self.iface.mapCanvas().mapSettings().setDestinationCrs(self._displayCrs)
        
        # init layerManager
        self._layerManager = LayerManager(self.iface, self)
        # init Highlighter
        self.highlighter = FeatureHighlighter(self.iface, self._layerManager, self)
        
        # Build an action list from QGIS navigation toolbar
        actionList = self.iface.mapNavToolToolBar().actions()
        self.actions = self.iface.mapNavToolToolBar().actions()
        
        # Main address editing window
        self._loadaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/loadaddress.png'), 
            'QGIS-AIMS-Plugin', self.iface.mainWindow())
        self._loadaction.setWhatsThis('Open the QGIS-AIMS-Plugin')
        self._loadaction.setStatusTip('Open the QGIS-AIMS-Plugin')
        self._loadaction.triggered.connect(self.loadQueues)
        self._loadaction.triggered.connect(self.loadLayers)
        self._loadaction.triggered.connect(self.enableAddressLayer)
        self._loadaction.triggered.connect(self.startDM)
        
        # Create new address tool
        self._createnewaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/newaddresspoint.png'), 
            'Create AIMS Feature', self.iface.mainWindow())
        self._createnewaddressaction.setWhatsThis('Create AIMS Feature')
        self._createnewaddressaction.setStatusTip('Create AIMS Feature')
        self._createnewaddressaction.setEnabled(False)
        self._createnewaddressaction.setCheckable(True)
        self._createnewaddressaction.triggered.connect( self.startNewAddressTool )
        self._createnewaddresstool = CreateNewAddressTool( self.iface, self._layerManager, self)
        self._createnewaddresstool.setAction( self._createnewaddressaction )
        self.actions.append(self._createnewaddressaction)

        # Delete address point
        self._deladdressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/deleteaddress.png'), 
            'Delete AIMS Feature', self.iface.mainWindow())
        self._deladdressaction.setWhatsThis('Delete AIMS Feature')
        self._deladdressaction.setStatusTip('Delete AIMS Feature')
        self._deladdressaction.setEnabled(False)
        self._deladdressaction.setCheckable(True)
        self._deladdressaction.triggered.connect( self.startDelAddressTool )
        self._deladdtool = DelAddressTool( self.iface, self._layerManager, self)
        self._deladdtool.setAction( self._deladdressaction )        
        self.actions.append(self._deladdressaction)

        # Move address
        self._moveaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/moveaddress.png'), 
            'Move AIMS Feature(s)', self.iface.mainWindow())
        self._moveaddressaction.setWhatsThis('Move AIMS Feature(s)')
        self._moveaddressaction.setStatusTip('Move AIMS Feature(s)')
        self._moveaddressaction.setEnabled(False)
        self._moveaddressaction.setCheckable(True)
        self._moveaddressaction.triggered.connect( self.startMoveAddressTool )
        self._moveaddtool = MoveAddressTool( self.iface, self._layerManager, self)
        self._moveaddtool.setAction( self._moveaddressaction )      
        self.actions.append(self._moveaddressaction)
        
        # Update address
        self._updateaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/updateaddress.png'), 
            'Update AIMS Feature', self.iface.mainWindow())
        self._updateaddressaction.setWhatsThis('Update AIMS Feature')
        self._updateaddressaction.setStatusTip('Update AIMS Feature')
        self._updateaddressaction.setEnabled(False)
        self._updateaddressaction.setCheckable(True)
        self._updateaddressaction.triggered.connect( self.startUpdateAddressTool )
        self._updateaddtool = UpdateAddressTool( self.iface, self._layerManager, self)
        self._updateaddtool.setAction( self._updateaddressaction )  
        self.actions.append(self._updateaddressaction)
                    
        # RCL tool -- Not a QAction as triggered from many palaces but not the toolbar
        self._rcltool = GetRcl(self.iface, self._layerManager, self)
        
        # UpdateReview Position tool -- Not a QAction as triggered initiated from review queue form
        self._updateReviewPos = UpdateReviewPosition(self.iface, self._layerManager, self)
       
        # Address lineage
        """
        self._lineageaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/lineage.png'), 
            'Build Lineage Relationships Between Features', self.iface.mainWindow())
        self._lineageaction.setWhatsThis('Build Lineage Relationships Between Features')
        self._lineageaction.setStatusTip('Build Lineage Relationships Between Features')
        self._lineageaction.setEnabled(False)
        self._lineageaction.setCheckable(True)
        self._lineagetool = LineageTool( self.iface, self._layerManager, self)
        self._lineageaction.triggered.connect(self._lineagetool.setEnabled)
        self.actions.append(self._lineageaction)
        """
        
        # Address highlighter
        self._highlightaction = QAction(QIcon(":/plugins/QGIS-AIMS-Plugin/resources/addresshighlight.png"), 
            "Electoral address highlighter", self.iface.mainWindow())
        self._highlightaction.setWhatsThis("Turn the electoral address highlighter on or off")
        self._highlightaction.setStatusTip("Turn the electoral address highlighter on or off")     
        self._highlightaction.setText('Highlightaction')
        self._highlightaction.setEnabled(False)
        self._highlightaction.setCheckable(True)
        self._highlightaction.toggled.connect( self.highlighter.setEnabled )
        
        # Add to own toolbar
        self._toolbar = self.iface.addToolBar('QGIS-AIMS-Plugin')
        self._toolbar.addAction(self._createnewaddressaction)
        self._toolbar.addAction(self._deladdressaction)
        self._toolbar.addAction(self._updateaddressaction)
        self._toolbar.addAction(self._moveaddressaction)
        #self._toolbar.addAction(self._lineageaction)
        self._toolbar.addAction(self._highlightaction)
        
        # Add actions to menu
        self.iface.addToolBarIcon(self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._createnewaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._updateaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._moveaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._highlightaction)

        # capture maptool selection changes
        QObject.connect(self.iface.mapCanvas(), SIGNAL( "mapToolSet(QgsMapTool *)" ), self.mapToolChanged)

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self.iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend( action.defaultWidget().actions() )
            else:
                actionList.append( action )
        # ... could add other toolbars' action lists...

        # Build a group with actions from actionList
        group = QActionGroup( self.iface.mainWindow() )
        group.setExclusive(True)
        for qgisAction in actionList:
            group.addAction( qgisAction )

        # Add our own actions
        for action in self.actions:
            if action.text() == 'Highlightaction': continue
            group.addAction( action )
   
    # Plugin Management 
    def loadQueues( self ):
        """ 
        Initialise Loading of the queue widgets into QGIS 
        """
        queues = self.Queues()
        if not queues.isVisible():
            queues.parent().show()
               
    def Queues(self):
        """ 
        Load of the queue widgets into QGIS
        @rtype: QtGui.QTabWidget  
        @return: Docked QTabWidget with UI compinets for displaying and
                 editing AIMS features
        """
        if not self._queues:
            queues = AimsQueueWidget(self.iface.mainWindow())
            self._dockWindow = DockWindow(self.iface.mainWindow(),queues,"AimsQueues","Aims Queues")
            self._queues = queues
            self._dockWindow.unloadPlugin.connect(self.unload)
        return self._queues
    
    def startDM(self):
        """
        Start the Data Manager only once the user enables the Plugin
        """         
        self.uidm.startDM()
    
    def enableAddressLayer(self):
        """ 
        enable tools that are dependent on the Address Layer
        only when the address layer exists 
        """
        
        self._deladdressaction.setEnabled(True)
        self._createnewaddressaction.setEnabled(True)
        self._moveaddressaction.setEnabled(True)
        self._updateaddressaction.setEnabled(True)
        self._highlightaction.setEnabled(True)
        
    def loadLayers(self):
        """ 
        Install map layers
        """
        
        if not self.refLayer:
            self.refLayer = self._layerManager.installRefLayers()
        if not self.adrlayer:
            self._layerManager.installAimsLayer('adr', 'AIMS Features')
        if not self.revLayer:
            self._layerManager.installAimsLayer('rev', 'AIMS Review')
        self._layerManager.initialiseExtentEvent()
    
    def mapToolChanged(self):
        """ 
        Track the current maptool (excluding rcl tool) to allow 
        for rollback to previous tool when the Rcltool is deactivated 
        """
            
        if (isinstance(self.iface.mapCanvas().mapTool(), GetRcl) == False and
                isinstance(self.iface.mapCanvas().mapTool(), UpdateReviewPosition) == False):          
            self._currentMapTool = self.iface.mapCanvas().mapTool()
            #self.highlighter.hideAll()
            # logging 
            uilog.info('*** TOOL CHANGE ***    {0} started'.format(self.iface.mapCanvas().mapTool())) 
        
    def setPreviousMapTool(self):
        """ 
        Roll back to the previous maptool
        """
        if self.iface.mapCanvas().mapTool() != self._currentMapTool:
            self.iface.mapCanvas().setMapTool(self._currentMapTool)
    
    def startNewAddressTool(self):
        """
        Enable the 'create new address' map tool 
        """
        self.iface.mapCanvas().setMapTool(self._createnewaddresstool)
        self._createnewaddresstool.setEnabled(True)
    
    def startRclTool(self, parent = None):
        """
        Enable the 'get rcl tool' map tool 
        
        @param parent: Map that enabled the RCL tool. Based on the RCL tools
                        parent, different highlighting of features is performed
        @type  parent: string     
        """
        
        self.rclParent = parent
        self.iface.mapCanvas().setMapTool(self._rcltool)
        self._rcltool.setEnabled(True)
    
    def startUpdateReviewPosTool(self, revItem = None):
        """ 
        Enable the 'get update Review position tool' map tool
        @param revItem: The current Review Item that is assigned to self.currentRevItem 
        @type  revItem: AIMSDataManager.Address.AddressResolution() Object 
        """
        
        self.currentRevItem = revItem
        self.iface.mapCanvas().setMapTool(self._updateReviewPos)
        self._rcltool.setEnabled(True)
    
    def startMoveAddressTool(self):
        """ 
        Enable the 'move address' map tool 
        """
        
        self.iface.mapCanvas().setMapTool(self._moveaddtool)
        self._moveaddtool.setEnabled(True)
    
    def startUpdateAddressTool(self):
        """ 
        Enable the "update address" map tool 
        """
        
        self.iface.mapCanvas().setMapTool(self._updateaddtool)
        self._updateaddtool.setEnabled(True)
        
    def startDelAddressTool(self):
        """
        Enable the "delete address" map tool 
        """
        
        self.iface.mapCanvas().setMapTool(self._deladdtool)
        self._deladdtool.setEnabled(True)
    
    '''
    def startLineageTool(self):
        """ 
        Enable the "lineage" map tool 
        """
        self.iface.mapCanvas().setMapTool(self._lineagetool)
        self._deladdtool.setEnabled(True) 
    '''
        
    def unload(self):
        """
        Remove Plugins UI Elements From QGIS
        """
        
        self._layerManager.disconnectExtentEvent()
        if self._queues:
            self._queues.close()
            self._queues = None 
        self.uidm.killDm()
        self.iface.mainWindow().removeToolBar(self._toolbar)
        self.iface.removeToolBarIcon(self._loadaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin',self._loadaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._createnewaddressaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._updateaddressaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._moveaddressaction)
        #self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._lineageaction)
        self.iface.removePluginMenu("&QGIS-AIMS-Plugin'", self._highlightaction)
    
    @pyqtSlot()
    def rDataChanged(self):
        """ 
        Review data changed, update review layer and table 
        """
        
        self._queues.uResolutionTab.refreshData()
        self._layerManager.updateReviewLayer()
    
    @pyqtSlot()
    def fDataChanged(self):
        """
        Feature data changed, update review layer and table 
        """
        
        self._layerManager.getAimsFeatures()
    def initGui(self):
        self._layers = LayerManager(self._iface, self)
                
        # Build an action list from QGIS navigation toolbar
        actionList = self._iface.mapNavToolToolBar().actions()
        self.actions = self._iface.mapNavToolToolBar().actions()
        # Main address editing window
        self._loadaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/loadaddress.png'), 
            'QGIS-AIMS-Plugin', self._iface.mainWindow())
        self._loadaction.setWhatsThis('Open the QGIS-AIMS-Plugin')
        self._loadaction.setStatusTip('Open the QGIS-AIMS-Plugin')
        self._loadaction.triggered.connect(self.loadQueues)
        self._loadaction.triggered.connect( self.loadLayers )
        
        # Create new address tool
        self._createnewaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/newaddresspoint.png'), 
            'Create AIMS Feature', self._iface.mainWindow())
        self._createnewaddressaction.setWhatsThis('Create AIMS Feature')
        self._createnewaddressaction.setStatusTip('Create AIMS Feature')
        self._createnewaddressaction.setEnabled(False)
        self._createnewaddressaction.setCheckable(True)
        self._createnewaddressaction.triggered.connect( self.startNewAddressTool )
        self._createnewaddresstool = CreateNewAddressTool( self._iface, self._layers, self)
        self._createnewaddresstool.setAction( self._createnewaddressaction )
        self.actions.append(self._createnewaddressaction)
        
        # Delete address point
        self._deladdressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/deleteaddress.png'), 
            'Delete AIMS Feature', self._iface.mainWindow())
        self._deladdressaction.setWhatsThis('Delete AIMS Feature')
        self._deladdressaction.setStatusTip('Delete AIMS Feature')
        self._deladdressaction.setEnabled(False)
        self._deladdressaction.setCheckable(True)
        self._deladdressaction.triggered.connect( self.startDelAddressTool )
        self._deladdtool = DelAddressTool( self._iface, self._layers, self)
        self._deladdtool.setAction( self._deladdressaction )        
        self.actions.append(self._deladdressaction)
        
        # Move address
        self._moveaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/moveaddress.png'), 
            'Move AIMS Feature(s)', self._iface.mainWindow())
        self._moveaddressaction.setWhatsThis('Move AIMS Feature(s)')
        self._moveaddressaction.setStatusTip('Move AIMS Feature(s)')
        self._moveaddressaction.setEnabled(False)
        self._moveaddressaction.setCheckable(True)
        self._moveaddressaction.triggered.connect( self.startMoveAddressTool )
        self._moveaddtool = MoveAddressTool( self._iface, self._layers, self)
        self._moveaddtool.setAction( self._moveaddressaction )      
        self.actions.append(self._moveaddressaction)
        
        # Update address
        self._updateaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/updateaddress.png'), 
            'Update AIMS Feature', self._iface.mainWindow())
        self._updateaddressaction.setWhatsThis('Update AIMS Feature')
        self._updateaddressaction.setStatusTip('Update AIMS Feature')
        self._updateaddressaction.setEnabled(False)
        self._updateaddressaction.setCheckable(True)
        self._updateaddressaction.triggered.connect( self.startUpdateAddressTool )
        self._updateaddtool = UpdateAddressTool( self._iface, self._layers, self)
        self._updateaddtool.setAction( self._updateaddressaction )  
        self.actions.append(self._updateaddressaction)
                    
        # RCL tools -- Not a QAction as triggered from many palaces but not the toolbar
        self._rcltool = GetRcl(self._iface, self._layers, self, parent = None)
       
        # Address lineage
        self._lineageaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/lineage.png'), 
            'Build Lineage Relationships Between Features', self._iface.mainWindow())
        self._lineageaction.setWhatsThis('Build Lineage Relationships Between Features')
        self._lineageaction.setStatusTip('Build Lineage Relationships Between Features')
        self._lineageaction.setEnabled(False)
        self._lineageaction.setCheckable(True)
        self._lineagetool = LineageTool( self._iface, self._layers, self)
        self._lineageaction.triggered.connect(self._lineagetool.setEnabled)
        self.actions.append(self._lineageaction)
        
        # Add to own toolbar
        self._toolbar = self._iface.addToolBar('QGIS-AIMS-Plugin')
        self._toolbar.addAction(self._createnewaddressaction)
        self._toolbar.addAction(self._deladdressaction)
        self._toolbar.addAction(self._updateaddressaction)
        self._toolbar.addAction(self._moveaddressaction)
        self._toolbar.addAction(self._lineageaction)
        
        # Add actions to menu and toolbar icon
        self._iface.addToolBarIcon(self._loadaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._createnewaddressaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._updateaddressaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._moveaddressaction)
        
        # Make useful connections
        self._layers.addressLayerAdded.connect(self.enableAddressLayer)
        self._layers.addressLayerRemoved.connect(self.disableAddressLayer)
        # capture maptool selection changes
        QObject.connect( self._iface.mapCanvas(), SIGNAL( "mapToolSet(QgsMapTool *)" ), self.mapToolChanged)

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self._iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend( action.defaultWidget().actions() )
            else:
                actionList.append( action )
        # ... could add other toolbars' action lists...

        # Build a group with actions from actionList
        group = QActionGroup( self._iface.mainWindow() )
        group.setExclusive(True)
        for qgisAction in actionList:
            group.addAction( qgisAction )

        # Add our own actions
        for action in self.actions:
            group.addAction( action )
class Controller(QObject):
    '''For future use with multiple objects requesting address/layers etc'''
    _instance = None
    
    def __init__(self, iface):
        QObject.__init__(self)
        self._iface = iface
        self.api = AimsApi()
        self.user = self.api.user
        self._alist = AddressList()
        self._currentAddress = None
        self._queues = None
        self._currentMapTool = None
        self.actions = []
        if Controller._instance == None:
            Controller._instance = self
      
        aimslog.debug(iface)
        
        # set srs
        self._displayCrs = QgsCoordinateReferenceSystem()
        self._displayCrs.createFromOgcWmsCrs('EPSG:4167') 
        iface.mapCanvas().mapSettings().setDestinationCrs(self._displayCrs)

    def initGui(self):
        self._layers = LayerManager(self._iface, self)
                
        # Build an action list from QGIS navigation toolbar
        actionList = self._iface.mapNavToolToolBar().actions()
        self.actions = self._iface.mapNavToolToolBar().actions()
        # Main address editing window
        self._loadaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/loadaddress.png'), 
            'QGIS-AIMS-Plugin', self._iface.mainWindow())
        self._loadaction.setWhatsThis('Open the QGIS-AIMS-Plugin')
        self._loadaction.setStatusTip('Open the QGIS-AIMS-Plugin')
        self._loadaction.triggered.connect(self.loadQueues)
        self._loadaction.triggered.connect( self.loadLayers )
        
        # Create new address tool
        self._createnewaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/newaddresspoint.png'), 
            'Create AIMS Feature', self._iface.mainWindow())
        self._createnewaddressaction.setWhatsThis('Create AIMS Feature')
        self._createnewaddressaction.setStatusTip('Create AIMS Feature')
        self._createnewaddressaction.setEnabled(False)
        self._createnewaddressaction.setCheckable(True)
        self._createnewaddressaction.triggered.connect( self.startNewAddressTool )
        self._createnewaddresstool = CreateNewAddressTool( self._iface, self._layers, self)
        self._createnewaddresstool.setAction( self._createnewaddressaction )
        self.actions.append(self._createnewaddressaction)
        
        # Delete address point
        self._deladdressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/deleteaddress.png'), 
            'Delete AIMS Feature', self._iface.mainWindow())
        self._deladdressaction.setWhatsThis('Delete AIMS Feature')
        self._deladdressaction.setStatusTip('Delete AIMS Feature')
        self._deladdressaction.setEnabled(False)
        self._deladdressaction.setCheckable(True)
        self._deladdressaction.triggered.connect( self.startDelAddressTool )
        self._deladdtool = DelAddressTool( self._iface, self._layers, self)
        self._deladdtool.setAction( self._deladdressaction )        
        self.actions.append(self._deladdressaction)
        
        # Move address
        self._moveaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/moveaddress.png'), 
            'Move AIMS Feature(s)', self._iface.mainWindow())
        self._moveaddressaction.setWhatsThis('Move AIMS Feature(s)')
        self._moveaddressaction.setStatusTip('Move AIMS Feature(s)')
        self._moveaddressaction.setEnabled(False)
        self._moveaddressaction.setCheckable(True)
        self._moveaddressaction.triggered.connect( self.startMoveAddressTool )
        self._moveaddtool = MoveAddressTool( self._iface, self._layers, self)
        self._moveaddtool.setAction( self._moveaddressaction )      
        self.actions.append(self._moveaddressaction)
        
        # Update address
        self._updateaddressaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/updateaddress.png'), 
            'Update AIMS Feature', self._iface.mainWindow())
        self._updateaddressaction.setWhatsThis('Update AIMS Feature')
        self._updateaddressaction.setStatusTip('Update AIMS Feature')
        self._updateaddressaction.setEnabled(False)
        self._updateaddressaction.setCheckable(True)
        self._updateaddressaction.triggered.connect( self.startUpdateAddressTool )
        self._updateaddtool = UpdateAddressTool( self._iface, self._layers, self)
        self._updateaddtool.setAction( self._updateaddressaction )  
        self.actions.append(self._updateaddressaction)
                    
        # RCL tools -- Not a QAction as triggered from many palaces but not the toolbar
        self._rcltool = GetRcl(self._iface, self._layers, self, parent = None)
       
        # Address lineage
        self._lineageaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/lineage.png'), 
            'Build Lineage Relationships Between Features', self._iface.mainWindow())
        self._lineageaction.setWhatsThis('Build Lineage Relationships Between Features')
        self._lineageaction.setStatusTip('Build Lineage Relationships Between Features')
        self._lineageaction.setEnabled(False)
        self._lineageaction.setCheckable(True)
        self._lineagetool = LineageTool( self._iface, self._layers, self)
        self._lineageaction.triggered.connect(self._lineagetool.setEnabled)
        self.actions.append(self._lineageaction)
        
        # Add to own toolbar
        self._toolbar = self._iface.addToolBar('QGIS-AIMS-Plugin')
        self._toolbar.addAction(self._createnewaddressaction)
        self._toolbar.addAction(self._deladdressaction)
        self._toolbar.addAction(self._updateaddressaction)
        self._toolbar.addAction(self._moveaddressaction)
        self._toolbar.addAction(self._lineageaction)
        
        # Add actions to menu and toolbar icon
        self._iface.addToolBarIcon(self._loadaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._createnewaddressaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._updateaddressaction)
        self._iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._moveaddressaction)
        
        # Make useful connections
        self._layers.addressLayerAdded.connect(self.enableAddressLayer)
        self._layers.addressLayerRemoved.connect(self.disableAddressLayer)
        # capture maptool selection changes
        QObject.connect( self._iface.mapCanvas(), SIGNAL( "mapToolSet(QgsMapTool *)" ), self.mapToolChanged)

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self._iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend( action.defaultWidget().actions() )
            else:
                actionList.append( action )
        # ... could add other toolbars' action lists...

        # Build a group with actions from actionList
        group = QActionGroup( self._iface.mainWindow() )
        group.setExclusive(True)
        for qgisAction in actionList:
            group.addAction( qgisAction )

        # Add our own actions
        for action in self.actions:
            group.addAction( action )
    
    def mapToolChanged(self):
        if isinstance(self._iface.mapCanvas().mapTool(), GetRcl) == False:          
            self._currentMapTool = self._iface.mapCanvas().mapTool()

    # Plugin Management 
    def enableAddressLayer(self, layer):
        ''' enable tools that are dependent on the Address Layer
            only when the address layer exists '''
        self._deladdressaction.setEnabled(True)
        self._createnewaddressaction.setEnabled(True)
        self._moveaddressaction.setEnabled(True)
        self._updateaddressaction.setEnabled(True)
        self._lineageaction.setEnabled(True)
        
    def disableAddressLayer(self):
        ''' disable tools that are dependent on the Address Layer
            when the address does not exists '''
        self._deladdressaction.setEnabled(False)
        self._createnewaddressaction.setEnabled(False)
        self._moveaddressaction.setEnabled(False)
        self._updateaddressaction.setEnabled(False)
        self._lineageaction.setEnabled(False)

    def unload(self):
        if self._queues:
            self._queues.close()
            self._queues = None 
        self._iface.mainWindow().removeToolBar(self._toolbar)
        self._iface.removeToolBarIcon(self._loadaction)
        self._iface.removePluginMenu('&QGIS-AIMS-Plugin',self._loadaction)
        self._iface.removePluginMenu('&QGIS-AIMS-Plugin', self._createnewaddressaction)
        self._iface.removePluginMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self._iface.removePluginMenu('&QGIS-AIMS-Plugin', self._updateaddressaction)
        self._iface.removePluginMenu('&QGIS-AIMS-Plugin', self._moveaddressaction)
        self._iface.removePluginMenu('&QGIS-AIMS-Plugin', self._lineageaction)

    def loadQueues( self ):
        ''' load the queue widgets '''
        queues = self.Queues()
        if not queues.isVisible():
            queues.parent().show()
               
    def Queues(self):
        if not self._queues:
            queues = AimsQueueWidget( self._iface.mainWindow(), self )
            DockWindow(self._iface.mainWindow(),queues,"AimsQueues","Aims Queues")
            self._queues = queues
        return self._queues
    
    def loadLayers(self):
        self._layers.initialiseExtentEvent()
        self._layers.installRefLayers()
    
    def setPreviousMapTool(self):
        ''' this allows for roll back to the maptool that called get rcl
        for a better ux'''
        self._iface.mapCanvas().setMapTool(self._currentMapTool)
        
    def startNewAddressTool(self):
        self._iface.mapCanvas().setMapTool(self._createnewaddresstool)
        self._createnewaddresstool.setEnabled(True)
    
    def startRclTool(self, parent = None):
        self._rcltool = GetRcl(self._iface, self._layers, self, parent)
        self._iface.mapCanvas().setMapTool(self._rcltool)
        self._rcltool.setEnabled(True)
    
    def startMoveAddressTool(self):
        self._iface.mapCanvas().setMapTool(self._moveaddtool)
        self._moveaddtool.setEnabled(True)
    
    def startUpdateAddressTool(self):
        self._iface.mapCanvas().setMapTool(self._updateaddtool)
        self._updateaddtool.setEnabled(True)
        
    def startDelAddressTool(self):
        self._iface.mapCanvas().setMapTool(self._deladdtool)
        self._deladdtool.setEnabled(True)
    
    def startLineageTool(self):
        self._iface.mapCanvas().setMapTool(self._lineagetool)
        self._deladdtool.setEnabled(True) 
             
    def initialiseAddressObj(self): 
        return Address(self.user)
  
    # API Methods
    def newAddress(self, payload):   
        return self.api.changefeedAdd(payload)
    
    def retireAddress(self, retireFeatures):
        return self.api.changefeedRetire(retireFeatures) 
    
    def getFeatures(self, xMaximum, yMaximum, xMinimum, yMinimum):
        return self.api.getFeatures(xMaximum, yMaximum, xMinimum, yMinimum)
    
    def updateFeature(self, payload):
        return self.api.updateFeature(payload)
    
    def newGroup(self, payload):
        return self.api.newGroup(payload)
    
    def addToGroup(self, groupId, payload):
        return self.api.addToGroup(groupId, payload)

    def submitGroup(self, groupId, payload):
        return self.api.submitGroup(groupId, payload)
    
    def groupVersion(self, groupId):
        return self.api.groupVersion(groupId)
    
    def refreshlayer(self):
        pass
    
    def getResData(self):
        return self.api.getResData()
Exemple #9
0
    def initGui(self):
        """ 
        Set up UI within QGIS 
        """

        # set srs
        self._displayCrs = QgsCoordinateReferenceSystem()
        self._displayCrs.createFromOgcWmsCrs('EPSG:4167')
        self.iface.mapCanvas().mapSettings().setDestinationCrs(
            self._displayCrs)

        # init layerManager
        self._layerManager = LayerManager(self.iface, self)
        self._layerManager.registerFunctions()
        # init Highlighter
        self.highlighter = FeatureHighlighter(self.iface, self._layerManager,
                                              self)

        # Build an action list from QGIS navigation toolbar
        actionList = self.iface.mapNavToolToolBar().actions()
        self.actions = self.iface.mapNavToolToolBar().actions()

        # Main address editing window
        self._loadaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/loadaddress.png'),
            'QGIS-AIMS-Plugin', self.iface.mainWindow())
        self._loadaction.setWhatsThis('Open the QGIS-AIMS-Plugin')
        self._loadaction.setStatusTip('Open the QGIS-AIMS-Plugin')
        self._loadaction.triggered.connect(self.loadQueues)
        self._loadaction.triggered.connect(self.loadLayers)
        self._loadaction.triggered.connect(self.enableAddressLayer)
        self._loadaction.triggered.connect(self.startDM)

        # Create new address tool
        self._createnewaddressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/newaddresspoint.png'),
            'Create AIMS Feature', self.iface.mainWindow())
        self._createnewaddressaction.setWhatsThis('Create AIMS Feature')
        self._createnewaddressaction.setStatusTip('Create AIMS Feature')
        self._createnewaddressaction.setEnabled(False)
        self._createnewaddressaction.setCheckable(True)
        self._createnewaddressaction.triggered.connect(
            self.startNewAddressTool)
        self._createnewaddresstool = CreateNewAddressTool(
            self.iface, self._layerManager, self)
        self._createnewaddresstool.setAction(self._createnewaddressaction)
        self.actions.append(self._createnewaddressaction)

        # Delete address point
        self._deladdressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/deleteaddress.png'),
            'Delete AIMS Feature', self.iface.mainWindow())
        self._deladdressaction.setWhatsThis('Delete AIMS Feature')
        self._deladdressaction.setStatusTip('Delete AIMS Feature')
        self._deladdressaction.setEnabled(False)
        self._deladdressaction.setCheckable(True)
        self._deladdressaction.triggered.connect(self.startDelAddressTool)
        self._deladdtool = DelAddressTool(self.iface, self._layerManager, self)
        self._deladdtool.setAction(self._deladdressaction)
        self.actions.append(self._deladdressaction)

        # Move address
        self._moveaddressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/moveaddress.png'),
            'Move AIMS Feature(s)', self.iface.mainWindow())
        self._moveaddressaction.setWhatsThis('Move AIMS Feature(s)')
        self._moveaddressaction.setStatusTip('Move AIMS Feature(s)')
        self._moveaddressaction.setEnabled(False)
        self._moveaddressaction.setCheckable(True)
        self._moveaddressaction.triggered.connect(self.startMoveAddressTool)
        self._moveaddtool = MoveAddressTool(self.iface, self._layerManager,
                                            self)
        self._moveaddtool.setAction(self._moveaddressaction)
        self.actions.append(self._moveaddressaction)

        # Update address
        self._updateaddressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/updateaddress.png'),
            'Update AIMS Feature', self.iface.mainWindow())
        self._updateaddressaction.setWhatsThis('Update AIMS Feature')
        self._updateaddressaction.setStatusTip('Update AIMS Feature')
        self._updateaddressaction.setEnabled(False)
        self._updateaddressaction.setCheckable(True)
        self._updateaddressaction.triggered.connect(
            self.startUpdateAddressTool)
        self._updateaddtool = UpdateAddressTool(self.iface, self._layerManager,
                                                self)
        self._updateaddtool.setAction(self._updateaddressaction)
        self.actions.append(self._updateaddressaction)

        # RCL tool -- Not a QAction as triggered from many palaces but not the toolbar
        self._rcltool = GetRcl(self.iface, self._layerManager, self)

        # UpdateReview Position tool -- Not a QAction as triggered initiated from review queue form
        self._updateReviewPos = UpdateReviewPosition(self.iface,
                                                     self._layerManager, self)

        # Address lineage
        """
        self._lineageaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/lineage.png'), 
            'Build Lineage Relationships Between Features', self.iface.mainWindow())
        self._lineageaction.setWhatsThis('Build Lineage Relationships Between Features')
        self._lineageaction.setStatusTip('Build Lineage Relationships Between Features')
        self._lineageaction.setEnabled(False)
        self._lineageaction.setCheckable(True)
        self._lineagetool = LineageTool( self.iface, self._layerManager, self)
        self._lineageaction.triggered.connect(self._lineagetool.setEnabled)
        self.actions.append(self._lineageaction)
        """

        # Address highlighter
        self._highlightaction = QAction(
            QIcon(":/plugins/QGIS-AIMS-Plugin/resources/addresshighlight.png"),
            "Electoral address highlighter", self.iface.mainWindow())
        self._highlightaction.setWhatsThis(
            "Turn the electoral address highlighter on or off")
        self._highlightaction.setStatusTip(
            "Turn the electoral address highlighter on or off")
        self._highlightaction.setText('Highlightaction')
        self._highlightaction.setEnabled(False)
        self._highlightaction.setCheckable(True)
        self._highlightaction.toggled.connect(self.highlighter.setEnabled)

        # Add to own toolbar
        self._toolbar = self.iface.addToolBar('QGIS-AIMS-Plugin')
        self._toolbar.addAction(self._createnewaddressaction)
        self._toolbar.addAction(self._deladdressaction)
        self._toolbar.addAction(self._updateaddressaction)
        self._toolbar.addAction(self._moveaddressaction)
        #self._toolbar.addAction(self._lineageaction)
        self._toolbar.addAction(self._highlightaction)

        # Add actions to menu
        self.iface.addToolBarIcon(self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin',
                                   self._createnewaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin',
                                   self._updateaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin',
                                   self._moveaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._highlightaction)

        # capture maptool selection changes
        QObject.connect(self.iface.mapCanvas(),
                        SIGNAL("mapToolSet(QgsMapTool *)"),
                        self.mapToolChanged)

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self.iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend(action.defaultWidget().actions())
            else:
                actionList.append(action)
        # ... could add other toolbars' action lists...

        # Build a group with actions from actionList
        group = QActionGroup(self.iface.mainWindow())
        group.setExclusive(True)
        for qgisAction in actionList:
            group.addAction(qgisAction)

        # Add our own actions
        for action in self.actions:
            if action.text() == 'Highlightaction': continue
            group.addAction(action)
Exemple #10
0
class Controller(QObject):
    ''' 
    Managers all UI Components and Plugins Tools as well as 
    initialisation and dessimnation of Singleton Instances  
        
     '''
    # log
    global uilog
    uilog = Logger.setup(lf='uiLog')

    _instance = None

    def __init__(self, iface):
        """ 
        Initialise UI Data Manager and Response Handler 
        
        @param iface: QgisInterface Abstract base class defining interfaces exposed by QgisApp  
        @type iface: Qgisinterface Object
        """

        QObject.__init__(self)
        self.iface = iface
        self._queues = None
        self._dockWindow = None
        self._currentMapTool = None
        self.rclParent = None
        self.currentRevItem = None
        self.actions = []
        if Controller._instance == None:
            Controller._instance = self
        self.uidm = UiDataManager(self.iface, self)
        self.RespHandler = ResponseHandler(self.iface, self.uidm)

        self.refLayer = None
        self.adrlayer = None
        self.revLayer = None

    def initGui(self):
        """ 
        Set up UI within QGIS 
        """

        # set srs
        self._displayCrs = QgsCoordinateReferenceSystem()
        self._displayCrs.createFromOgcWmsCrs('EPSG:4167')
        self.iface.mapCanvas().mapSettings().setDestinationCrs(
            self._displayCrs)

        # init layerManager
        self._layerManager = LayerManager(self.iface, self)
        self._layerManager.registerFunctions()
        # init Highlighter
        self.highlighter = FeatureHighlighter(self.iface, self._layerManager,
                                              self)

        # Build an action list from QGIS navigation toolbar
        actionList = self.iface.mapNavToolToolBar().actions()
        self.actions = self.iface.mapNavToolToolBar().actions()

        # Main address editing window
        self._loadaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/loadaddress.png'),
            'QGIS-AIMS-Plugin', self.iface.mainWindow())
        self._loadaction.setWhatsThis('Open the QGIS-AIMS-Plugin')
        self._loadaction.setStatusTip('Open the QGIS-AIMS-Plugin')
        self._loadaction.triggered.connect(self.loadQueues)
        self._loadaction.triggered.connect(self.loadLayers)
        self._loadaction.triggered.connect(self.enableAddressLayer)
        self._loadaction.triggered.connect(self.startDM)

        # Create new address tool
        self._createnewaddressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/newaddresspoint.png'),
            'Create AIMS Feature', self.iface.mainWindow())
        self._createnewaddressaction.setWhatsThis('Create AIMS Feature')
        self._createnewaddressaction.setStatusTip('Create AIMS Feature')
        self._createnewaddressaction.setEnabled(False)
        self._createnewaddressaction.setCheckable(True)
        self._createnewaddressaction.triggered.connect(
            self.startNewAddressTool)
        self._createnewaddresstool = CreateNewAddressTool(
            self.iface, self._layerManager, self)
        self._createnewaddresstool.setAction(self._createnewaddressaction)
        self.actions.append(self._createnewaddressaction)

        # Delete address point
        self._deladdressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/deleteaddress.png'),
            'Delete AIMS Feature', self.iface.mainWindow())
        self._deladdressaction.setWhatsThis('Delete AIMS Feature')
        self._deladdressaction.setStatusTip('Delete AIMS Feature')
        self._deladdressaction.setEnabled(False)
        self._deladdressaction.setCheckable(True)
        self._deladdressaction.triggered.connect(self.startDelAddressTool)
        self._deladdtool = DelAddressTool(self.iface, self._layerManager, self)
        self._deladdtool.setAction(self._deladdressaction)
        self.actions.append(self._deladdressaction)

        # Move address
        self._moveaddressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/moveaddress.png'),
            'Move AIMS Feature(s)', self.iface.mainWindow())
        self._moveaddressaction.setWhatsThis('Move AIMS Feature(s)')
        self._moveaddressaction.setStatusTip('Move AIMS Feature(s)')
        self._moveaddressaction.setEnabled(False)
        self._moveaddressaction.setCheckable(True)
        self._moveaddressaction.triggered.connect(self.startMoveAddressTool)
        self._moveaddtool = MoveAddressTool(self.iface, self._layerManager,
                                            self)
        self._moveaddtool.setAction(self._moveaddressaction)
        self.actions.append(self._moveaddressaction)

        # Update address
        self._updateaddressaction = QAction(
            QIcon(':/plugins/QGIS-AIMS-Plugin/resources/updateaddress.png'),
            'Update AIMS Feature', self.iface.mainWindow())
        self._updateaddressaction.setWhatsThis('Update AIMS Feature')
        self._updateaddressaction.setStatusTip('Update AIMS Feature')
        self._updateaddressaction.setEnabled(False)
        self._updateaddressaction.setCheckable(True)
        self._updateaddressaction.triggered.connect(
            self.startUpdateAddressTool)
        self._updateaddtool = UpdateAddressTool(self.iface, self._layerManager,
                                                self)
        self._updateaddtool.setAction(self._updateaddressaction)
        self.actions.append(self._updateaddressaction)

        # RCL tool -- Not a QAction as triggered from many palaces but not the toolbar
        self._rcltool = GetRcl(self.iface, self._layerManager, self)

        # UpdateReview Position tool -- Not a QAction as triggered initiated from review queue form
        self._updateReviewPos = UpdateReviewPosition(self.iface,
                                                     self._layerManager, self)

        # Address lineage
        """
        self._lineageaction = QAction(QIcon(':/plugins/QGIS-AIMS-Plugin/resources/lineage.png'), 
            'Build Lineage Relationships Between Features', self.iface.mainWindow())
        self._lineageaction.setWhatsThis('Build Lineage Relationships Between Features')
        self._lineageaction.setStatusTip('Build Lineage Relationships Between Features')
        self._lineageaction.setEnabled(False)
        self._lineageaction.setCheckable(True)
        self._lineagetool = LineageTool( self.iface, self._layerManager, self)
        self._lineageaction.triggered.connect(self._lineagetool.setEnabled)
        self.actions.append(self._lineageaction)
        """

        # Address highlighter
        self._highlightaction = QAction(
            QIcon(":/plugins/QGIS-AIMS-Plugin/resources/addresshighlight.png"),
            "Electoral address highlighter", self.iface.mainWindow())
        self._highlightaction.setWhatsThis(
            "Turn the electoral address highlighter on or off")
        self._highlightaction.setStatusTip(
            "Turn the electoral address highlighter on or off")
        self._highlightaction.setText('Highlightaction')
        self._highlightaction.setEnabled(False)
        self._highlightaction.setCheckable(True)
        self._highlightaction.toggled.connect(self.highlighter.setEnabled)

        # Add to own toolbar
        self._toolbar = self.iface.addToolBar('QGIS-AIMS-Plugin')
        self._toolbar.addAction(self._createnewaddressaction)
        self._toolbar.addAction(self._deladdressaction)
        self._toolbar.addAction(self._updateaddressaction)
        self._toolbar.addAction(self._moveaddressaction)
        #self._toolbar.addAction(self._lineageaction)
        self._toolbar.addAction(self._highlightaction)

        # Add actions to menu
        self.iface.addToolBarIcon(self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin',
                                   self._createnewaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._deladdressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin',
                                   self._updateaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin',
                                   self._moveaddressaction)
        self.iface.addPluginToMenu('&QGIS-AIMS-Plugin', self._highlightaction)

        # capture maptool selection changes
        QObject.connect(self.iface.mapCanvas(),
                        SIGNAL("mapToolSet(QgsMapTool *)"),
                        self.mapToolChanged)

        # Add actions from QGIS attributes toolbar (handling QWidgetActions)
        tmpActionList = self.iface.attributesToolBar().actions()
        for action in tmpActionList:
            if isinstance(action, QWidgetAction):
                actionList.extend(action.defaultWidget().actions())
            else:
                actionList.append(action)
        # ... could add other toolbars' action lists...

        # Build a group with actions from actionList
        group = QActionGroup(self.iface.mainWindow())
        group.setExclusive(True)
        for qgisAction in actionList:
            group.addAction(qgisAction)

        # Add our own actions
        for action in self.actions:
            if action.text() == 'Highlightaction': continue
            group.addAction(action)

    # Plugin Management
    def loadQueues(self):
        """ 
        Initialise Loading of the queue widgets into QGIS 
        """
        queues = self.Queues()
        if not queues.isVisible():
            queues.parent().show()

    def Queues(self):
        """ 
        Load of the queue widgets into QGIS
        @rtype: QtGui.QTabWidget  
        @return: Docked QTabWidget with UI compinets for displaying and
                 editing AIMS features
        """
        if not self._queues:
            queues = AimsQueueWidget(self.iface.mainWindow())
            self._dockWindow = DockWindow(self.iface.mainWindow(), queues,
                                          "AimsQueues", "Aims Queues")
            self._queues = queues
            self._dockWindow.unloadPlugin.connect(self.unload)
        return self._queues

    def startDM(self):
        """
        Start the Data Manager only once the user enables the Plugin
        """
        self.uidm.startDM()

    def enableAddressLayer(self):
        """ 
        enable tools that are dependent on the Address Layer
        only when the address layer exists 
        """

        self._deladdressaction.setEnabled(True)
        self._createnewaddressaction.setEnabled(True)
        self._moveaddressaction.setEnabled(True)
        self._updateaddressaction.setEnabled(True)
        self._highlightaction.setEnabled(True)

    def loadLayers(self):
        """ 
        Install map layers
        """

        if not self.refLayer:
            self.refLayer = self._layerManager.installRefLayers()
        if not self.adrlayer:
            self._layerManager.installAimsLayer('adr', 'AIMS Features')
        if not self.revLayer:
            self._layerManager.installAimsLayer('rev', 'AIMS Review')
        self._layerManager.initialiseExtentEvent()

    def mapToolChanged(self):
        """ 
        Track the current maptool (excluding rcl tool) to allow 
        for rollback to previous tool when the Rcltool is deactivated 
        """

        if (isinstance(self.iface.mapCanvas().mapTool(), GetRcl) == False
                and isinstance(self.iface.mapCanvas().mapTool(),
                               UpdateReviewPosition) == False):
            self._currentMapTool = self.iface.mapCanvas().mapTool()
            #self.highlighter.hideAll()
            # logging
            uilog.info('*** TOOL CHANGE ***    {0} started'.format(
                self.iface.mapCanvas().mapTool()))

    def setPreviousMapTool(self):
        """ 
        Roll back to the previous maptool
        """
        if self.iface.mapCanvas().mapTool() != self._currentMapTool:
            self.iface.mapCanvas().setMapTool(self._currentMapTool)

    def startNewAddressTool(self):
        """
        Enable the 'create new address' map tool 
        """
        self.iface.mapCanvas().setMapTool(self._createnewaddresstool)
        self._createnewaddresstool.setEnabled(True)

    def startRclTool(self, parent=None):
        """
        Enable the 'get rcl tool' map tool 
        
        @param parent: Map that enabled the RCL tool. Based on the RCL tools
                        parent, different highlighting of features is performed
        @type  parent: string     
        """

        self.rclParent = parent
        self.iface.mapCanvas().setMapTool(self._rcltool)
        self._rcltool.setEnabled(True)

    def startUpdateReviewPosTool(self, revItem=None):
        """ 
        Enable the 'get update Review position tool' map tool
        @param revItem: The current Review Item that is assigned to self.currentRevItem 
        @type  revItem: AIMSDataManager.Address.AddressResolution() Object 
        """

        self.currentRevItem = revItem
        self.iface.mapCanvas().setMapTool(self._updateReviewPos)
        self._rcltool.setEnabled(True)

    def startMoveAddressTool(self):
        """ 
        Enable the 'move address' map tool 
        """

        self.iface.mapCanvas().setMapTool(self._moveaddtool)
        self._moveaddtool.setEnabled(True)

    def startUpdateAddressTool(self):
        """ 
        Enable the "update address" map tool 
        """

        self.iface.mapCanvas().setMapTool(self._updateaddtool)
        self._updateaddtool.setEnabled(True)

    def startDelAddressTool(self):
        """
        Enable the "delete address" map tool 
        """

        self.iface.mapCanvas().setMapTool(self._deladdtool)
        self._deladdtool.setEnabled(True)

    '''
    def startLineageTool(self):
        """ 
        Enable the "lineage" map tool 
        """
        self.iface.mapCanvas().setMapTool(self._lineagetool)
        self._deladdtool.setEnabled(True) 
    '''

    def unload(self):
        """
        Remove Plugins UI Elements From QGIS
        """

        self._layerManager.disconnectExtentEvent()
        if self._queues:
            self._queues.close()
            self._queues = None
        self.uidm.killDm()
        self.iface.mainWindow().removeToolBar(self._toolbar)
        self.iface.removeToolBarIcon(self._loadaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._loadaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin',
                                    self._createnewaddressaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin',
                                    self._deladdressaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin',
                                    self._updateaddressaction)
        self.iface.removePluginMenu('&QGIS-AIMS-Plugin',
                                    self._moveaddressaction)
        #self.iface.removePluginMenu('&QGIS-AIMS-Plugin', self._lineageaction)
        self.iface.removePluginMenu("&QGIS-AIMS-Plugin'",
                                    self._highlightaction)
        self._layerManager

    @pyqtSlot()
    def rDataChanged(self):
        """ 
        Review data changed, update review layer and table 
        """

        self._queues.uResolutionTab.refreshData()
        self._layerManager.updateReviewLayer()

    @pyqtSlot()
    def fDataChanged(self):
        """
        Feature data changed, update review layer and table 
        """

        self._layerManager.getAimsFeatures()