class CartoDBDatasetsListItem(QWidget): def __init__(self, tableName=None, tableOwner=None, size=None, rows=None, multiuser=False, shared=False): QWidget.__init__(self) self.ui = Ui_ListItem() self.ui.setupUi(self) self.shared = shared self.multiuser = multiuser self.readonly = False self.tableOwner = tableOwner self.setTableName(tableName) self.setSize(size) self.setRows(rows) def setTableName(self, tableName): self.tableName = tableName text = tableName if tableName is not None: if self.shared: text = text + ' ({})'.format(self.tableOwner) self.ui.tableNameTX.setText(text) def setSize(self, size): self.size = size if size is not None: sizeText = float(size / 1024) if sizeText >= 1000: sizeText = sizeText / 1024 if sizeText >= 1000: sizeText = "{:.2f}".format(sizeText / 1024) + ' GB' else: sizeText = "{:.2f}".format(sizeText) + ' MB' else: sizeText = "{:.2f}".format(sizeText) + ' KB' self.ui.sizeTX.setText(sizeText) def setRows(self, rows): self.rows = rows if rows is not None: self.ui.rowsTX.setText("{:,} rows".format(rows)) def setTextColor(self, color): self.ui.tableNameTX.setStyleSheet('color: ' + color) self.ui.rowsTX.setStyleSheet('color: ' + color) self.ui.sizeTX.setStyleSheet('color: ' + color) def clone(self): return CartoDBDatasetsListItem(self.tableName, self.tableOwner, self.size, self.rows)
class CartoDBDatasetsListItem(QWidget): def __init__(self, tableName=None, tableOwner=None, size=None, rows=None, multiuser=False, shared=False): QWidget.__init__(self) self.ui = Ui_ListItem() self.ui.setupUi(self) self.shared = shared self.multiuser = multiuser self.readonly = False self.tableOwner = tableOwner self.setTableName(tableName) self.setSize(size) self.setRows(rows) def setTableName(self, tableName): self.tableName = tableName text = tableName if tableName is not None: if self.shared: text = text + ' ({})'.format(self.tableOwner) self.ui.tableNameTX.setText(text) def setSize(self, size): self.size = size if size is not None: sizeText = float(size/1024) if sizeText >= 1000: sizeText = sizeText/1024 if sizeText >= 1000: sizeText = "{:.2f}".format(sizeText/1024) + ' GB' else: sizeText = "{:.2f}".format(sizeText) + ' MB' else: sizeText = "{:.2f}".format(sizeText) + ' KB' self.ui.sizeTX.setText(sizeText) def setRows(self, rows): self.rows = rows if rows is not None: self.ui.rowsTX.setText("{:,} rows".format(rows)) def setTextColor(self, color): self.ui.tableNameTX.setStyleSheet('color: ' + color) self.ui.rowsTX.setStyleSheet('color: ' + color) self.ui.sizeTX.setStyleSheet('color: ' + color) def clone(self): return CartoDBDatasetsListItem(self.tableName, self.tableOwner, self.size, self.rows)
def __init__(self, tableName=None, tableOwner=None, size=None, rows=None, shared=False): QWidget.__init__(self) self.ui = Ui_ListItem() self.ui.setupUi(self) self.shared = shared self.readonly = False self.tableOwner = tableOwner self.setTableName(tableName) self.setSize(size) self.setRows(rows)