mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 15:47:38 +02:00
* Style cleanup.
This commit is contained in:
@@ -26,8 +26,10 @@
|
||||
#include <QListView>
|
||||
|
||||
#define ROW_HEIGHT 20
|
||||
#define ICON_PADDING 1
|
||||
#define ICON_PADDING 2
|
||||
#define PADDING 2
|
||||
|
||||
|
||||
JobStatusDelegate::JobStatusDelegate( QObject* parent )
|
||||
: QStyledItemDelegate ( parent )
|
||||
, m_parentView( qobject_cast< QListView* >( parent ) )
|
||||
@@ -35,6 +37,7 @@ JobStatusDelegate::JobStatusDelegate( QObject* parent )
|
||||
Q_ASSERT( m_parentView );
|
||||
}
|
||||
|
||||
|
||||
JobStatusDelegate::~JobStatusDelegate()
|
||||
{
|
||||
|
||||
@@ -55,7 +58,7 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
// painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
|
||||
|
||||
painter->setRenderHint( QPainter::Antialiasing );
|
||||
QRect iconRect( ICON_PADDING, ICON_PADDING + opt.rect.y(), ROW_HEIGHT - 2*ICON_PADDING, ROW_HEIGHT - 2*ICON_PADDING );
|
||||
QRect iconRect( ICON_PADDING, ICON_PADDING + opt.rect.y(), ROW_HEIGHT - 2 * ICON_PADDING, ROW_HEIGHT - 2 * ICON_PADDING );
|
||||
if ( allowMultiLine )
|
||||
iconRect.moveTop( opt.rect.top() + opt.rect.height() / 2 - iconRect.height() / 2);
|
||||
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
||||
@@ -71,22 +74,24 @@ JobStatusDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
if ( !rCol.isEmpty() )
|
||||
{
|
||||
const int w = fm.width( rCol );
|
||||
const QRect rRect( opt.rect.right() - PADDING - w, PADDING + opt.rect.y(), w, opt.rect.height() - 2*PADDING );
|
||||
const QRect rRect( opt.rect.right() - PADDING - w, PADDING + opt.rect.y(), w, opt.rect.height() - 2 * PADDING );
|
||||
painter->drawText( rRect, Qt::AlignCenter, rCol );
|
||||
|
||||
rightEdge = rRect.left();
|
||||
}
|
||||
|
||||
const int mainW = rightEdge - 3*PADDING - iconRect.right();
|
||||
const int mainW = rightEdge - 3 * PADDING - iconRect.right();
|
||||
QString mainText = index.data( Qt::DisplayRole ).toString();
|
||||
QTextOption to( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
if ( !allowMultiLine )
|
||||
mainText = fm.elidedText( mainText, Qt::ElideRight, mainW );
|
||||
else
|
||||
to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
|
||||
painter->drawText( QRect( iconRect.right() + 2*PADDING, PADDING + opt.rect.y(), mainW, opt.rect.height() - 2*PADDING ), mainText, to );
|
||||
|
||||
painter->drawText( QRect( iconRect.right() + 4 * PADDING, PADDING + opt.rect.y(), mainW, opt.rect.height() - 2 * PADDING ), mainText, to );
|
||||
}
|
||||
|
||||
|
||||
QSize
|
||||
JobStatusDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
@@ -102,11 +107,11 @@ JobStatusDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelInd
|
||||
initStyleOption( &opt, index );
|
||||
|
||||
const QString text = index.data( Qt::DisplayRole ).toString();
|
||||
const int leftEdge = ICON_PADDING + ROW_HEIGHT + 2*PADDING;
|
||||
const int leftEdge = ICON_PADDING + ROW_HEIGHT + 2 * PADDING;
|
||||
const QRect rect = opt.fontMetrics.boundingRect( leftEdge, opt.rect.top(), m_parentView->width() - leftEdge, 200, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, text );
|
||||
|
||||
m_cachedMultiLineHeights.insert( index, rect.height() + 4*PADDING );
|
||||
m_cachedMultiLineHeights.insert( index, rect.height() + 4 * PADDING );
|
||||
|
||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), rect.height() + 4*PADDING );
|
||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), rect.height() + 4 * PADDING );
|
||||
}
|
||||
|
||||
|
@@ -101,13 +101,12 @@ JobStatusView::setModel( JobStatusModel* m )
|
||||
void
|
||||
JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "item is " << item << ", row is " << row;
|
||||
tLog() << Q_FUNC_INFO << "item is" << item << ", row is" << row;
|
||||
if ( !item )
|
||||
return;
|
||||
|
||||
tLog() << Q_FUNC_INFO << "telling item to create delegate";
|
||||
item->createDelegate( m_view );
|
||||
tLog() << Q_FUNC_INFO << "item delegate is " << item->customDelegate();
|
||||
tLog() << Q_FUNC_INFO << "item delegate is" << item->customDelegate();
|
||||
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
||||
AclJobDelegate* delegate = qobject_cast< AclJobDelegate* >( item->customDelegate() );
|
||||
if ( delegate )
|
||||
@@ -127,7 +126,7 @@ JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
||||
void
|
||||
JobStatusView::customDelegateJobRemoved( int row )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "row is " << row;
|
||||
tLog() << Q_FUNC_INFO << "row is" << row;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,12 +137,12 @@ JobStatusView::refreshDelegates()
|
||||
int count = m_model->rowCount();
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "checking row " << i;
|
||||
tLog() << Q_FUNC_INFO << "checking row" << i;
|
||||
QModelIndex index = m_model->index( i );
|
||||
QVariant itemVar = index.data( JobStatusModel::JobDataRole );
|
||||
if ( !itemVar.canConvert< JobStatusItem* >() || !itemVar.value< JobStatusItem* >() )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "unable to fetch JobStatusItem* at row " << i;
|
||||
tLog() << Q_FUNC_INFO << "unable to fetch JobStatusItem* at row" << i;
|
||||
continue;
|
||||
}
|
||||
JobStatusItem* item = itemVar.value< JobStatusItem* >();
|
||||
|
@@ -102,6 +102,7 @@ PlaylistItem::IDValue() const
|
||||
return m_playlist->createdOn();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistItem::isBeingPlayed() const
|
||||
{
|
||||
|
Reference in New Issue
Block a user