mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Moved itemSize from model to delegate.
This commit is contained in:
@@ -64,8 +64,13 @@ GridItemDelegate::GridItemDelegate( QAbstractItemView* parent, PlayableProxyMode
|
||||
QSize
|
||||
GridItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
if ( m_itemSize.isNull() )
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint( option, index );
|
||||
return size;
|
||||
}
|
||||
else
|
||||
return m_itemSize;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,6 +41,9 @@ Q_OBJECT
|
||||
public:
|
||||
GridItemDelegate( QAbstractItemView* parent = 0, PlayableProxyModel* proxy = 0 );
|
||||
|
||||
QSize itemSize() const { return m_itemSize; }
|
||||
void setItemSize( const QSize& size ) { m_itemSize = size; }
|
||||
|
||||
protected:
|
||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
@@ -70,6 +73,7 @@ private:
|
||||
|
||||
QAbstractItemView* m_view;
|
||||
PlayableProxyModel* m_model;
|
||||
QSize m_itemSize;
|
||||
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_artistNameRects;
|
||||
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_covers;
|
||||
|
@@ -229,7 +229,7 @@ GridView::verifySize()
|
||||
|
||||
const int overlapRows = m_model->rowCount( QModelIndex() ) % itemsPerRow;
|
||||
const int rows = floor( (double)m_model->rowCount( QModelIndex() ) / (double)itemsPerRow );
|
||||
const int newHeight = rows * m_model->itemSize().height();
|
||||
const int newHeight = rows * m_delegate->itemSize().height();
|
||||
|
||||
if ( newHeight > 0 )
|
||||
setFixedHeight( newHeight );
|
||||
@@ -258,7 +258,7 @@ GridView::layoutItems()
|
||||
const int extraSpace = remSpace / itemsPerRow;
|
||||
const int newItemWidth = itemWidth + extraSpace;
|
||||
|
||||
m_model->setItemSize( QSize( newItemWidth, newItemWidth ) );
|
||||
m_delegate->setItemSize( QSize( newItemWidth, newItemWidth ) );
|
||||
verifySize();
|
||||
|
||||
if ( !m_inited )
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
PlayableModel* model() const { return m_model; }
|
||||
PlayableProxyModel* proxyModel() const { return m_proxyModel; }
|
||||
GridItemDelegate* delegate() const { return m_delegate; }
|
||||
|
||||
bool autoFitItems() const { return m_autoFitItems; }
|
||||
void setAutoFitItems( bool b ) { m_autoFitItems = b; }
|
||||
|
Reference in New Issue
Block a user