forked from qt-creator/qt-creator
ExtensionManager: Simplify ExtensionItemDelegate a bit
Lifetime of m_itemWidget is the same as the delegate's. Also the need to have it mutable now makes it clear that the widget is in fact mutated. Change-Id: Ia24d0787cbf43e7b02652f17e89baeb20c0fc079 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -375,30 +375,23 @@ class ExtensionItemDelegate : public QItemDelegate
|
|||||||
public:
|
public:
|
||||||
explicit ExtensionItemDelegate(QObject *parent)
|
explicit ExtensionItemDelegate(QObject *parent)
|
||||||
: QItemDelegate(parent)
|
: QItemDelegate(parent)
|
||||||
{
|
{}
|
||||||
m_itemWidget = new ExtensionItemWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
~ExtensionItemDelegate()
|
|
||||||
{
|
|
||||||
delete m_itemWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||||
const override
|
const override
|
||||||
{
|
{
|
||||||
m_itemWidget->paint(painter, option, index);
|
m_itemWidget.paint(painter, option, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize sizeHint([[maybe_unused]] const QStyleOptionViewItem &option,
|
QSize sizeHint([[maybe_unused]] const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const override
|
const QModelIndex &index) const override
|
||||||
{
|
{
|
||||||
m_itemWidget->setData(index);
|
m_itemWidget.setData(index);
|
||||||
return {cellWidth, m_itemWidget->minimumSizeHint().height() + gapSize};
|
return {cellWidth, m_itemWidget.minimumSizeHint().height() + gapSize};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExtensionItemWidget *m_itemWidget;
|
mutable ExtensionItemWidget m_itemWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SortFilterProxyModel : public QSortFilterProxyModel
|
class SortFilterProxyModel : public QSortFilterProxyModel
|
||||||
|
Reference in New Issue
Block a user