def _removeDevice(self): ''' Removes the currently selected device. ''' items = self._deviceList.selectedItems() if not items: return dev = devices.get(items[0].text(0)) if not dialogs.runQuestion("Do you want to remove " "'%s' device permanently?" % dev.name): return log.debug("Removing device: %s" % dev) self._updateConnectionState(False, dev) devices.remove(dev.name) self._removeDeviceItem(dev) log.info("Device removed: %s" % dev)
def _deviceDisconnected(self, device, error): ''' Removes a tab representing the disconnected device. The error parameter can be set to True to indicate that the device was disconnected due to an error. ''' tab = self._tabs.get(device) if not tab: return if error and not dialogs.runQuestion("Do you want to close '%s' tab?" % (device.name)): tab.setActive(False) if self._tabWidget.currentWidget() == tab.tab: self._setInfoActive(tab) else: self._removeDeviceTab(device) tab.searchingStopped.emit()
def removeLocation(self): ''' Removes selected items from locations tree and refreshes the tests tree. ''' items = self._locsTree.selectedItems() if not (items and runQuestion( "Are you sure you want to remove %s?\n\n %s" % ("these locations" if len(items) > 1 else "this location", "\n".join(item.text(0) for item in items)))): return for item in items: path = item.text(0) log.debug("Removing test path '%s'" % path) location.remove(path) self._locsTree.takeTopLevelItem( self._locsTree.indexOfTopLevelItem(item)) self._locItems.pop(path) self.refresh()
def _close(self, index=None): ''' Disconnects a dump tab or a device tab of given index. ''' if index is None: index = self._tabWidget.currentIndex() tab = self.deviceTabAtIndex(index) if tab is None: return if not tab.isActive(): self._removeDeviceTab(tab.device) return if tab.isOffline(): act, obj = "close", "dump file" else: act, obj = "disconnect", "device" if dialogs.runQuestion("Do you want to %s '%s' %s?" % (act, tab.device.name, obj)): log.debug("Disconnecting device of '%s' tab" % tab.device.name) tab.device.disconnectDevice()
def removeLocation(self): ''' Removes selected items from locations tree and refreshes the tests tree. ''' items = self._locsTree.selectedItems() if not (items and runQuestion("Are you sure you want to remove %s?\n\n %s" % ("these locations" if len(items) > 1 else "this location", "\n".join(item.text(0) for item in items)))): return for item in items: path = item.text(0) log.debug("Removing test path '%s'" % path) location.remove(path) self._locsTree.takeTopLevelItem( self._locsTree.indexOfTopLevelItem(item)) self._locItems.pop(path) self.refresh()
def _emitSignals(self, item, column): ''' Emits 'deviceChecked' or 'deviceUnchecked' signal based on the state of the given item. ''' if self._silent: return if item is not self._tree.currentItem(): return if item.checkState(0) == QtCore.Qt.Checked: self.deviceChecked.emit(self._dict[item.text(0)]) if item.checkState(0) == QtCore.Qt.Unchecked: if (not self.getChecked() and self._warning and not runQuestion("Excluding this device will stop execution of " "tests. Are you sure?")): self._silent = True item.setCheckState(0, QtCore.Qt.Checked) QtGui.qApp.processEvents() self._silent = False else: self.deviceUnchecked.emit(self._dict[item.text(0)])
def _emitSignals(self, item, column): ''' Emits 'deviceChecked' or 'deviceUnchecked' signal based on the state of the given item. ''' if self._silent: return if item is not self._tree.currentItem(): return if item.checkState(0) == QtCore.Qt.Checked: self.deviceChecked.emit(self._dict[item.text(0)]) if item.checkState(0) == QtCore.Qt.Unchecked: if (not self.getChecked() and self._warning and not runQuestion( "Excluding this device will stop execution of " "tests. Are you sure?")): self._silent = True item.setCheckState(0, QtCore.Qt.Checked) QtGui.qApp.processEvents() self._silent = False else: self.deviceUnchecked.emit(self._dict[item.text(0)])
def _addModifier(self, name, code): ''' Adds modifier to the list. ''' selected = self._modifiers.selectedItems() if name in self._MODIFIERS: dialogs.runWarning("Default modifier '%s' cannot be redefined" % name) return if selected: self._setItemData(selected[0], name, code) elif name in self._userModifiers: if dialogs.runQuestion("Modifier '%s' already exists. Do you " "want to update it?" % name): item = self._modifiers.findItems(name, QtCore.Qt.MatchExactly)[0] self._setItemData(item, name, code) else: return else: self._userModifiers.append(name) self._modifiers.scrollToItem(self._createItem(name, code)) config.set(self._CONFIG_NAME, self._CONFIG_SECTION, name, code)