mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-24 09:49:42 +01:00
* Moved itemSize from model to delegate.
This commit is contained in:
parent
1860d7732a
commit
bd629e6178
src/libtomahawk/playlist
@ -64,8 +64,13 @@ GridItemDelegate::GridItemDelegate( QAbstractItemView* parent, PlayableProxyMode
|
||||
QSize
|
||||
GridItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint( option, index );
|
||||
return size;
|
||||
if ( m_itemSize.isNull() )
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint( option, index );
|
||||
return size;
|
||||
}
|
||||
else
|
||||
return m_itemSize;
|
||||
}
|
||||
|
||||
|
||||
@ -363,7 +368,7 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q
|
||||
|
||||
// reset mouse cursor. we switch to a pointing hand cursor when hovering an artist name
|
||||
m_view->setCursor( Qt::ArrowCursor );
|
||||
|
||||
|
||||
if ( hoveringArtist )
|
||||
{
|
||||
|
||||
|
@ -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 );
|
||||
@ -257,8 +257,8 @@ GridView::layoutItems()
|
||||
const int remSpace = rectWidth - ( itemsPerRow * itemWidth );
|
||||
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; }
|
||||
@ -111,7 +112,7 @@ private:
|
||||
bool m_inited;
|
||||
bool m_autoFitItems;
|
||||
bool m_autoResize;
|
||||
|
||||
|
||||
QRect m_paintRect;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user