def add_target(self, target): logging.debug('add_target: %s' % misc.text_type(target)) new_item = QTreeWidgetItem(self.__mainWindow.ui_dest_list) new_item.setData(0,Qt.UserRole,target) # FIXME: # the new_item lines should be auto triggered onChange to the # TreeWidget when new_item is appended. new_item.setText(0,target) new_item.setIcon(0,KIcon("drive-removable-media-usb-pendrive")) item = self.__mainWindow.ui_dest_list.currentItem() if not item: item = self.__mainWindow.ui_dest_list.topLevelItem(0) if item: self.__mainWindow.ui_dest_list.setCurrentItem(item,True) # populate from device data if self.__backend is not None: dev = self.__backend.targets[target] pretty_name = "%s %s (%s)" % (dev['vendor'], dev['model'], dev['device']) new_item.setText(0,pretty_name) new_item.setText(1,dev['label']) new_item.setText(2,misc.format_size(dev['capacity'])) free = dev['free'] if free >= 0: new_item.setText(3,misc.format_size(free)) else: new_item.setText(3,'')
def add_target(self, target): t = self.maindialog.targets t.clear() target = self.backend.targets[target] i = t.insert_item(target['device'], -1) t.set_item(i, 1, target['label']) t.set_item(i, 2, misc.format_size(target['capacity'])) t.set_item(i, 3, misc.format_size(target['free']))
def add_source(self, source): # FIXME evand 2009-07-21: Don't expose backend data structures like # this. source = self.backend.sources[source] i = self.maindialog.sources.insert_item(source['device'], -1) self.maindialog.sources.set_item(i, 1, source['label']) self.maindialog.sources.set_item(i, 2, misc.format_size(source['size']))
def column_data_func(layout, cell, model, iterator, column): if not self.backend: return udi = model[iterator][0] dev = self.backend.sources[udi] if column == 0: if udi in self.names: cell.set_property('text', self.names[udi]) else: cell.set_property('text', dev['device']) elif column == 1: cell.set_property('text', dev['label']) elif column == 2: cell.set_property('text', misc.format_size(dev['size']))
def column_data_func(layout, cell, model, iterator, column): if not self.backend: return udi = model[iterator][0] dev = self.backend.targets[udi] if column == 0: if udi in self.pretty_names: cell.set_property('text', self.pretty_names[udi]) else: cell.set_property('text', dev['device']) elif column == 1: if udi in self.names: cell.set_property('text', self.names[udi]) else: cell.set_property('text', dev['label']) elif column == 2: cell.set_property('text', misc.format_size(dev['capacity'])) elif column == 3: free = dev['free'] if free >= 0: cell.set_property('text', misc.format_size(free)) else: cell.set_property('text', '')
def column_data_func(layout, cell, model, iterator, column): if not self.backend: return udi = model[iterator][0] dev = self.backend.targets[udi] if column == 0: if udi in self.pretty_names: cell.set_property("text", self.pretty_names[udi]) else: cell.set_property("text", dev["device"]) elif column == 1: if udi in self.names: cell.set_property("text", self.names[udi]) else: cell.set_property("text", dev["label"]) elif column == 2: cell.set_property("text", misc.format_size(dev["capacity"]))
def add_source(self, source): logging.debug('add_source: %s' % misc.text_type(source)) new_item = QTreeWidgetItem(self.__mainWindow.ui_source_list) new_item.setData(0,Qt.UserRole,source) # FIXME: # the new_item lines should be auto triggered onChange to the TreeWidget # when new_item is appended. new_item.setText(0,source) new_item.setIcon(0,KIcon("media-optical")) item = self.__mainWindow.ui_source_list.currentItem() if not item: item = self.__mainWindow.ui_source_list.topLevelItem(0) if item: self.__mainWindow.ui_source_list.setCurrentItem(item,True) # how does this all get added? here or elsewhere... # populate from device data if self.__backend is not None: new_item.setText(0,self.__backend.sources[source]['device']) # Strip as some derivates like to have whitespaces/newlines (e.g. netrunner) new_item.setText(1,self.__backend.sources[source]['label'].strip()) new_item.setText(2,misc.format_size(self.__backend.sources[source]['size']))