Ejemplo n.º 1
0
    def __init__(self, iface):
        QObject.__init__(self)

        # Save reference to the QGIS interface
        self.iface = iface

        # this will hold the combinations list
        self.manager = LcManager(self.iface)

        # Create the dock widget and keep reference
        if QSettings().value('plugins/LayerCombinations/WidgetType',
                             self.DOCKWIDGET) == self.TOOLBAR:
            self.widget = LcCanvasToolBar(self.manager)
        else:
            self.widget = LcCanvasDockWidget(self.manager)

        # This will hold the composers dock widgets
        self.compDockWidgets = []

        # Create the GUI in the map composer window when a Composer is added (also works for composers that are loaded at project opening)
        self.iface.composerAdded.connect(self.initComposerGui)

        # we have to reload the list when a project is opened/closed
        self.iface.projectRead.connect(
            self.manager.loadCombinations
        )  #we have to reload the list when a project is opened/closed
        self.iface.newProjectCreated.connect(
            self.manager.loadCombinations
        )  #we have to reload the list when a project is opened/closed

        #and we start by reloading the list
        self.manager.loadCombinations()

        #and by loading the GUI for already loaded composers (should be usefull only when the plugin is loaded while composers are already existing)
        composers = self.iface.activeComposers()
        for composer in composers:
            self.initComposerGui(composer)