def configure(self):
        d = ConfigureDialog(self._state)
        d.setModal(True)
        if d.exec_():
            self.serialize(self._location)
            self._state = d.getState()
            # When a PMR location is given we need to translate that into a
            # local path for passing into the ImageSourceData class
            local_dir = self._state.location()
            pmr_location = self._state.pmrLocation()
            if pmr_location and not len(local_dir):
                # Get login details:
                local_dir = os.path.join(self._location, self._state.identifier())
                if not os.path.exists(local_dir):
                    os.mkdir(local_dir)

                self._state.setLocation(local_dir)
                d.setState(self._state)

            if pmr_location and os.path.exists(local_dir):
                pmr_tool = PMRTool()
                pmr_tool.cloneWorkspace(pmr_location, local_dir)

            self._configured = d.validate()
            if self._configuredObserver is not None:
                self._configuredObserver()
        def testConfigureDialog(self):
            if self.pixmap_unavailable:
                return

            from mapclientplugins.imagesourcestep.widgets.configuredialog import ConfigureDialog, ConfigureDialogState

            state = ConfigureDialogState()
            d = ConfigureDialog(state)

            self.assertEqual(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(), False)
            QTest.keyClicks(d._ui.identifierLineEdit, 'hello')
            QTest.keyClicks(d._ui.localLineEdit, 'here')
            self.assertEqual(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(), True)
            # QTest.mouseClick(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok), QtCore.Qt.LeftButton)
            newstate = d.getState()
            self.assertEqual(newstate.identifier(), 'hello')
            self.assertEqual(newstate.location(), 'here')
Esempio n. 3
0
        def testConfigureDialog(self):
            if self.pixmap_unavailable:
                return

            from mapclientplugins.imagesourcestep.widgets.configuredialog import ConfigureDialog, ConfigureDialogState

            state = ConfigureDialogState()
            d = ConfigureDialog(state)

            self.assertEqual(
                d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(),
                False)
            QTest.keyClicks(d._ui.identifierLineEdit, 'hello')
            QTest.keyClicks(d._ui.localLineEdit, 'here')
            self.assertEqual(
                d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok).isEnabled(),
                True)
            # QTest.mouseClick(d._ui.buttonBox.button(QtGui.QDialogButtonBox.Ok), QtCore.Qt.LeftButton)
            newstate = d.getState()
            self.assertEqual(newstate.identifier(), 'hello')
            self.assertEqual(newstate.location(), 'here')
 def deserialize(self, string):
     self._state.deserialize(string)
     d = ConfigureDialog(self._state)
     d.setWorkflowLocation(self._location)
     self._configured = d.validate()
    def configure(self):
        d = ConfigureDialog(self._state, QtGui.QApplication.activeWindow().currentWidget())
        d.setWorkflowLocation(self._location)
        d.setModal(True)
        if d.exec_():
            self._state = d.getState()
            # When a PMR location is given we need to translate that into a
            # local path for passing into the ImageSourceData class
            local_dir = self._state.location()
            pmr_location = self._state.pmrLocation()
            if pmr_location and not len(local_dir):
                # Get login details:
                local_dir = self._location
                if not os.path.exists(local_dir):
                    os.mkdir(local_dir)

                self._state.setLocation(local_dir)
                d.setState(self._state)

            if pmr_location and os.path.exists(local_dir):
                pmr_info = PMR()
                pmr_tool = PMRTool(pmr_info)
                pmr_tool.cloneWorkspace(pmr_location, local_dir)

            self._configured = d.validate()
            if self._configuredObserver is not None:
                self._configuredObserver()
 def deserialize(self, location):
     configuration_file = os.path.join(location, getConfigFilename(self._state.identifier()))
     s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat)
     self._state.load(s)
     d = ConfigureDialog(self._state)
     self._configured = d.validate()