def _lSlot(self, state): """Event when CheckBox changed""" self._param = QtXml.QDomElement() q = QtGui.QObject.sender().property("dom address").toString() ind = int(q.lastIndexOf( '/', -1)) ids = str(q.mid(ind,-1)) self._param = self.qhash[q].elem.firstChildElement("Activate") while(self._param.isNull() != False): q = str(self._param.text()).strip() + ids self.qhash[q].widget.setEnabled(state) widget_visible = self.qhash[q].elem.attribute("Visible","Unknown") if(state == False & widget_visible != "Unknown"): self.qhash[q].label.hide() self.qhash[q].widget.hide() else: self.qhash[q].label.show() self.qhash[q].widget.show() self._param = self._param.nextSiblingElement("Activate") self._param = self.qhash[q].elem.firstChildElement("Deactivate") while(self._param.isNull() != False): q = str(self._param.text()).strip() + ids self.qhash[q].widget.setEnabled(-state) widget_visible = self.qhash[q].elem.attribute("Visible","Unknown") if(state == True & widget_visible != "Unknown" ): self.qhash[q].label.hide() self.qhash[q].widget.hide() else: self.qhash[q].label.show() self.qhash[q].widget.show() self._param = self._param.nextSiblingElement("Deactivate")
def _textChangedSlot(self, text): """Event when TextBox changed Args: ----- text: str new contents of text box """ self._param = QtXml.QDomElement() if qt4: qs = str(self.sender().property("dom address").toPyObject()) else: qs = str(self.sender().property("dom address")) ind = qs.rfind('/') ids = qs[ind:] self._param = self.qhash[qs].elem.firstChildElement("Activate") while (self._param.isNull() is False): qs = str(self._param.text()).strip() + ids widget_visible = self.qhash[qs].elem.attribute("Visible", "Uknown") if (text != ""): self.qhash[qs].widget.setEnabled(True) self.qhash[qs].widget.show() self.qhash[qs].label.show() else: self.qhash[qs].widget.setEnabled(False) if (widget_visible != "Unknown"): self.qhash[qs].label.hide() self.qhash[qs].widget.hide() self._param = self._param.nextSiblingElement("Activate")
def _appendButtonClicked(self): """AppendButton clicked""" matFileName = QtGui.QFileDialog.getOpenFileName(self) if (matFileName == ""): return self._materialDoc = QtXml.QDomElement() self._appendDocument(matFileName)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'EasyImport_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = EasyImportDialog() # Declare instance attributes self.actions = [] self.menu = self.tr(u'&EasyImport') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'EasyImport') self.toolbar.setObjectName(u'EasyImport') # Root folder where shape files are stored self.shapeDirectory = QDir() # XML Config file self.configXML = QtXml.QDomDocument() # XML current Config self.currentConfigXML = QtXml.QDomElement() # XML Config path self.configFileName = 'config.xml' # Shape file dictionnary # shapeFiles[shape filename] = shapefile absolute path self.shapeFiles = {} # Shape file dictionnary # pointsLayersConfig[shape filename] = Import rules XML nodes self.pointsLayersConfig = {}
def _comboSlot(self, select): """Event when comboBox changend select: int index of the selection """ select = self.sender().itemText(select) if qt4: qs = str(self.sender().property("dom address").toPyObject()) else: qs = str(self.sender().property("dom address")) item = QtXml.QDomElement() ind = qs.rfind('/') ids = qs[ind:] item = self.qhash[qs].elem.firstChildElement("Item") while (item.isNull() is False): itemName = item.firstChildElement("Name") if (str(itemName.text()).strip() != select): activ = item.firstChildElement("Activate") while (activ.isNull() is False): s = str(activ.text()).strip() + ids h = self.qhash[s] widget_enabled = h.elem.attribute("Enabled", "True") widget_visible = h.elem.attribute("Visible", "Unknown") h.widget.setEnabled(False) if (widget_visible != "Unknown"): h.label.hide() h.widget.hide() activ = activ.nextSiblingElement("Activate") item = item.nextSiblingElement("Item") item = self.qhash[qs].elem.firstChildElement("Item") while (item.isNull() is False): itemName = item.firstChildElement("Name") if (str(itemName.text()).strip() == select): activ = item.firstChildElement("Activate") while (activ.isNull() is False): s = str(activ.text()).strip() + ids h = self.qhash[s] h.widget.setEnabled(True) h.label.show() h.widget.show() activ = activ.nextSiblingElement("Activate") item = item.nextSiblingElement("Item")
def _lSlot(self, state): """Event when CheckBox changed Args: ----- state: bool check state of the CheckBox """ self._param = QtXml.QDomElement() if qt4: qs = str(self.sender().property("dom address").toPyObject()) else: qs = str(self.sender().property("dom address")) ind = qs.rfind('/') ids = qs[ind:] self._param = self.qhash[qs].elem.firstChildElement("Activate") while (self._param.isNull() is False): qs = str(self._param.text()).strip() + ids self.qhash[qs].widget.setEnabled(state) widget_visible = self.qhash[qs].elem.attribute( "Visible", "Unknown") if (state is False & widget_visible != "Unknown"): self.qhash[qs].label.hide() self.qhash[qs].widget.hide() else: self.qhash[qs].label.show() self.qhash[qs].widget.show() self._param = self._param.nextSiblingElement("Activate") self._param = self.qhash[qs].elem.firstChildElement("Deactivate") while (self._param.isNull() is False): qs = str(self._param.text()).strip() + ids self.qhash[qs].widget.setEnabled(-state) widget_visible = self.qhash[qs].elem.attribute( "Visible", "Unknown") if (state is True & widget_visible != "Unknown"): self.qhash[qs].label.hide() self.qhash[qs].widget.hide() else: self.qhash[qs].label.show() self.qhash[qs].widget.show() self._param = self._param.nextSiblingElement("Deactivate")
def _comboSlot(self, select): """Event when comboBox changend""" q = QtGui.QObject.sender().property("dom address").toString() item = QtXml.QDomElement() ind = int(q.lastIndexOf( '/', -1)) ids= str(q.mid(ind,-1)) item = self.qhash[q].elem.firstChildElement("Item") while(item.isNull() != False): itemName = item.firstChildElement("Name") if(str(itemName.text()).strip() != select): activ = item.firstChildElement("Activate") while(activ.isNull() != False): activ=activ.nextSiblingElement("Activate") s=str(activ.text()).strip() + ids self.h = self.qhash[s] widget_enabled = self.h.elem.attribute("Enabled","True") widget_visible = self.h.elem.attribute("Visible","Unknown") self.h.widget.setEnabled(False) if(widget_visible != "Unknown"): self.h.label.hide() self.h.widget.hide() item = item.nextSiblingElement("Item") item = self.qhash[q].elem.firstChildElement("Item") while(item.isNull() != False): itemName = item.firstChildElement("Name") if(str(itemName.text()).strip() == select ): activ = item.firstChildElement("Activate") while(activ.isNull() != False): s = str(activ.text()).strip() + ids self.h = self.qhash[s] self.h.widget.setEnabled(True) self.h.label.show() self.h.widget.show() activ = activ.nextSiblingElement("Activate") item = item.nextSiblingElement("Item")