def paint(self, painter, option, index): painter.save() model = index.model() col = index.column() d = model.data[index.row()][col] if option.state & QtGui.QStyle.State_Selected: painter.fillRect(option.rect, option.palette.highlight()) elif index.row() % 2 == 1: painter.fillRect(option.rect, self.brush) painter.translate(option.rect.topLeft()) painter.setFont(self.font) d = shorten_str(d, 25) if col in [0, 3]: painter.drawText(QtCore.QPoint(10, 20), d) elif col == 1: painter.drawText(self.center_text(option.rect, d), d) elif col == 2: pos = self.center_text(option.rect, d[0]) painter.drawImage(QtCore.QPoint(pos.x()-25, 7), self.images[d[0]]) painter.drawText(pos, d[0]) painter.restore()
def paint(self, painter, option, index): painter.save() model = index.model() col = index.column() d = model.data[index.row()][col] if option.state & QtGui.QStyle.State_Selected: painter.fillRect(option.rect, option.palette.highlight()) elif index.row() % 2 == 1: painter.fillRect(option.rect, self.brush) painter.translate(option.rect.topLeft()) painter.setFont(self.font) d = shorten_str(d, 25) if col == 0: painter.drawText(QtCore.QPoint(10, 20), d) elif col == 3: if 'Error' in d: error = d.split('-')[1] pos = self.center_text(option.rect, error) painter.drawImage(QtCore.QPoint(pos.x()-25, 7), self.images['Error']) painter.drawText(pos, error) else: painter.drawText(self.center_text(option.rect, d), d) elif col == 4: if d == '': pos = self.center_text(option.rect, d) painter.drawImage(QtCore.QPoint(pos.x()-25, 7), self.images['Loading']) painter.drawText(pos, d) else: painter.drawText(self.center_text(option.rect, d), d) elif col == 1: painter.drawText(self.center_text(option.rect, d), d) elif col == 5: pos = self.center_text(option.rect, d) painter.drawText(QtCore.QPoint(pos.x()-10, pos.y()), d) else: pos = self.center_text(option.rect, d) painter.drawImage(QtCore.QPoint(pos.x()-25, 7), self.images[d]) painter.drawText(pos, d) painter.restore()
def onCopyClick(self): model = self.history_table.model() selection_model = self.history_table.selectionModel() clipboard = QtGui.QApplication.clipboard() clipboard.clear() links = [] selections = selection_model.selectedRows() add_name = True if len(selections) != 1 else False for s in selections: name = model.data[s.row()][0] link = model.data[s.row()][2][1] if add_name: links.append('{}: {}'.format(shorten_str(name, 25), link)) else: links.append(link) if links: self.statusBar().showMessage(self.history_table_sb_tmp.format(len(links)), 2000) clipboard.setText('\n'.join(links))
def paint(self, painter, option, index): painter.save() sharelink_rect = self.sharelink_img.rect().translated(self.sharelink_pos.x(), option.rect.top() + self.sharelink_pos.y()) model = index.model() d = model.data[index.row()] if option.state & QtGui.QStyle.State_MouseOver: painter.fillRect(option.rect, self.brush) painter.translate(option.rect.topLeft()) painter.setClipRect(option.rect.translated(-option.rect.topLeft())) painter.setFont(self.font) painter.drawImage(QtCore.QPoint(5, 4), d[0]) painter.drawText(QtCore.QPoint(40, 15), shorten_str(d[1], 35)) painter.setPen(self.date_color) painter.drawText(QtCore.QPoint(40, 30), d[3]) if option.state & QtGui.QStyle.State_MouseOver: painter.drawImage(self.sharelink_pos, self.sharelink_img) painter.restore()
def paint(self, painter, option, index): painter.save() sharelink_rect = self.sharelink_img.rect().translated( self.sharelink_pos.x(), option.rect.top() + self.sharelink_pos.y()) model = index.model() d = model.data[index.row()] if option.state & QtGui.QStyle.State_MouseOver: painter.fillRect(option.rect, self.brush) painter.translate(option.rect.topLeft()) painter.setClipRect(option.rect.translated(-option.rect.topLeft())) painter.setFont(self.font) painter.drawImage(QtCore.QPoint(5, 4), d[0]) painter.drawText(QtCore.QPoint(40, 15), shorten_str(d[1], 35)) painter.setPen(self.date_color) painter.drawText(QtCore.QPoint(40, 30), d[3]) if option.state & QtGui.QStyle.State_MouseOver: painter.drawImage(self.sharelink_pos, self.sharelink_img) painter.restore()