mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 22:14:32 +00:00
Merge pull request #5070 from Chocobo1/icon_sizehint
Improve TransferListDelegate::sizeHint
This commit is contained in:
commit
feab999093
@ -215,17 +215,19 @@ QWidget* TransferListDelegate::createEditor(QWidget*, const QStyleOptionViewItem
|
|||||||
|
|
||||||
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
|
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||||
{
|
{
|
||||||
static int iconHeight = -1;
|
// Reimplementing sizeHint() because the 'name' column contains text+icon.
|
||||||
if (iconHeight == -1) {
|
// When that WHOLE column goes out of view(eg user scrolls horizontally)
|
||||||
QIcon icon(":/icons/skin/downloading.png");
|
// the rows shrink if the text's height is smaller than the icon's height.
|
||||||
QList<QSize> icSizes(icon.availableSizes());
|
// This happens because icon from the 'name' column is no longer drawn.
|
||||||
iconHeight = icSizes[0].height();
|
|
||||||
|
static int nameColHeight = -1;
|
||||||
|
if (nameColHeight == -1) {
|
||||||
|
QModelIndex nameColumn = index.sibling(index.row(), TorrentModel::TR_NAME);
|
||||||
|
nameColHeight = QItemDelegate::sizeHint(option, nameColumn).height();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize size = QItemDelegate::sizeHint(option, index);
|
QSize size = QItemDelegate::sizeHint(option, index);
|
||||||
if (size.height() < iconHeight)
|
size.setHeight(std::max(nameColHeight, size.height()));
|
||||||
size.setHeight(iconHeight);
|
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,6 @@ public:
|
|||||||
TransferListDelegate(QObject *parent);
|
TransferListDelegate(QObject *parent);
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const;
|
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const;
|
||||||
|
|
||||||
// Reimplementing sizeHint() because the 'name' column contains text+icon.
|
|
||||||
// When that WHOLE column goes out of view(eg user scrolls horizontally)
|
|
||||||
// the rows shrink if the text's height is smaller than the icon's height.
|
|
||||||
// This happens because icon from the 'name' column is no longer drawn.
|
|
||||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user