def _add_simple_query_item(self, field_name: str, operator: str = '=', value=None): """ Adds a simple query item """ combo = QComboBox() combo.addItem('=') combo.addItem('<') combo.addItem('<=') combo.addItem('>') combo.addItem('>=') combo.addItem('<>') combo.setCurrentIndex(combo.findText(operator)) button = QToolButton() button.setIcon(GuiUtils.get_icon('remove.svg')) button.setAutoRaise(True) filter_item = QTreeWidgetItem() filter_item.setText(0, field_name) filter_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable) filter_item.setText(2, value) self.simple_query_list.addTopLevelItem(filter_item) self.simple_query_list.setItemWidget(filter_item, 1, combo) self.simple_query_list.setItemWidget(filter_item, 3, button) button.clicked.connect(partial(self._remove_simple_item, filter_item))
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" self.menu = QMenu(self.tr('&QQuake')) self.iface.pluginMenu().addMenu(self.menu) show_dialog_action = QAction(self.tr('QQuake')) show_dialog_action.setIcon(GuiUtils.get_icon('icon.svg')) show_dialog_action.triggered.connect(self.show_dialog) self.iface.addToolBarIcon(show_dialog_action) self.menu.addAction(show_dialog_action) self.actions.append(show_dialog_action) show_options_action = QAction(self.tr('Options…')) show_options_action.setIcon(GuiUtils.get_icon('options.svg')) show_options_action.triggered.connect(self.show_options) self.menu.addAction(show_options_action) self.actions.append(show_options_action) # will be set False in run() self.first_start = True self.options_factory = QQuakeOptionsFactory() self.options_factory.setTitle(self.tr('QQuake')) self.iface.registerOptionsWidgetFactory(self.options_factory)
def icon(self): # pylint: disable=missing-function-docstring return GuiUtils.get_icon('icon.svg')
def testGetIcon(self): """ Tests get_icon """ self.assertFalse(GuiUtils.get_icon('icon.svg').isNull()) self.assertTrue(GuiUtils.get_icon('not_an_icon.svg').isNull())