mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 11:30:49 +02:00
Still get no output, but at least the debug looks good now, and fixed segfault on exit
This commit is contained in:
@@ -409,8 +409,6 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
||||||
qRegisterMetaType< QMap< QString, QMap< unsigned int, unsigned int > > >("QMap< QString, QMap< unsigned int, unsigned int > >");
|
qRegisterMetaType< QMap< QString, QMap< unsigned int, unsigned int > > >("QMap< QString, QMap< unsigned int, unsigned int > >");
|
||||||
qRegisterMetaType< PairList >("PairList");
|
qRegisterMetaType< PairList >("PairList");
|
||||||
qRegisterMetaType< JobStatusItem* >("JobStatusItem*");
|
|
||||||
qRegisterMetaType< AclJobItem* >("AclJobItem*");
|
|
||||||
|
|
||||||
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
||||||
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#define ROW_HEIGHT 40
|
#define ROW_HEIGHT 40
|
||||||
#define ICON_PADDING 1
|
#define ICON_PADDING 1
|
||||||
#define PADDING 2
|
#define PADDING 2
|
||||||
|
|
||||||
|
|
||||||
AclJobDelegate::AclJobDelegate( QObject* parent )
|
AclJobDelegate::AclJobDelegate( QObject* parent )
|
||||||
: QStyledItemDelegate ( parent )
|
: QStyledItemDelegate ( parent )
|
||||||
, m_parentView( qobject_cast< QListView* >( parent ) )
|
, m_parentView( qobject_cast< QListView* >( parent ) )
|
||||||
@@ -42,6 +44,7 @@ AclJobDelegate::AclJobDelegate( QObject* parent )
|
|||||||
void
|
void
|
||||||
AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
initStyleOption( &opt, index );
|
initStyleOption( &opt, index );
|
||||||
QFontMetrics fm( opt.font );
|
QFontMetrics fm( opt.font );
|
||||||
@@ -49,26 +52,62 @@ AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
opt.state &= ~QStyle::State_MouseOver;
|
opt.state &= ~QStyle::State_MouseOver;
|
||||||
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
|
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
|
||||||
|
|
||||||
|
painter->setRenderHint( QPainter::Antialiasing );
|
||||||
|
|
||||||
|
QString mainText;
|
||||||
|
AclJobItem* item = dynamic_cast< AclJobItem* >( index.data( JobStatusModel::JobDataRole ).value< JobStatusItem* >() );
|
||||||
|
if ( !item )
|
||||||
|
mainText = tr( "Error displaying ACL info" );
|
||||||
|
else
|
||||||
|
mainText = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Displaying text:" << mainText;
|
||||||
|
|
||||||
|
const QString text = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
||||||
|
const int w = fm.width( text );
|
||||||
|
const QRect rRect( opt.rect.left() + PADDING, ROW_HEIGHT + PADDING, opt.rect.width() - 2*PADDING, opt.rect.height() - 2*PADDING );
|
||||||
|
painter->drawText( rRect, Qt::AlignCenter, text );
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
initStyleOption( &opt, index );
|
||||||
|
QFontMetrics fm( opt.font );
|
||||||
|
const bool allowMultiLine = index.data( JobStatusModel::AllowMultiLineRole ).toBool();
|
||||||
|
|
||||||
|
opt.state &= ~QStyle::State_MouseOver;
|
||||||
|
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
|
||||||
|
|
||||||
// painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
|
// painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
|
||||||
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing );
|
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 );
|
||||||
//QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
if ( allowMultiLine )
|
||||||
//p = p.scaledToHeight( iconRect.height(), Qt::SmoothTransformation );
|
iconRect.moveTop( opt.rect.top() + opt.rect.height() / 2 - iconRect.height() / 2);
|
||||||
//painter->drawPixmap( iconRect, p );
|
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
||||||
|
p = p.scaledToHeight( iconRect.height(), Qt::SmoothTransformation );
|
||||||
|
painter->drawPixmap( iconRect, p );
|
||||||
|
|
||||||
// draw right column if there is one
|
// draw right column if there is one
|
||||||
AclJobItem* item = index.data( JobStatusModel::JobDataRole ).value< AclJobItem* >();
|
const QString rCol = index.data( JobStatusModel::RightColumnRole ).toString();
|
||||||
const QString text = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
int rightEdge = opt.rect.right();
|
||||||
const int w = fm.width( text );
|
if ( !rCol.isEmpty() )
|
||||||
const QRect rRect( opt.rect.left() + PADDING, opt.rect.y() - PADDING, opt.rect.width() - 2*PADDING, opt.rect.height() - 2*PADDING );
|
{
|
||||||
painter->drawText( rRect, Qt::AlignCenter, text );
|
const int w = fm.width( rCol );
|
||||||
|
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();
|
rightEdge = rRect.left();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString mainText;
|
||||||
|
AclJobItem* item = dynamic_cast< AclJobItem* >( index.data( JobStatusModel::JobDataRole ).value< JobStatusItem* >() );
|
||||||
|
//QString mainText = index.data( Qt::DisplayRole ).toString();
|
||||||
|
if ( !item )
|
||||||
|
mainText = tr( "Error displaying ACL info" );
|
||||||
|
else
|
||||||
|
mainText = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Displaying text:" << mainText;
|
||||||
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 );
|
QTextOption to( Qt::AlignLeft | Qt::AlignVCenter );
|
||||||
if ( !allowMultiLine )
|
if ( !allowMultiLine )
|
||||||
mainText = fm.elidedText( mainText, Qt::ElideRight, mainW );
|
mainText = fm.elidedText( mainText, Qt::ElideRight, mainW );
|
||||||
@@ -81,7 +120,29 @@ AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
QSize
|
QSize
|
||||||
AclJobDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
AclJobDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT );
|
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT );
|
||||||
|
|
||||||
|
/*
|
||||||
|
const bool allowMultiLine = index.data( JobStatusModel::AllowMultiLineRole ).toBool();
|
||||||
|
|
||||||
|
if ( !allowMultiLine )
|
||||||
|
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT );
|
||||||
|
else if ( m_cachedMultiLineHeights.contains( index ) )
|
||||||
|
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), m_cachedMultiLineHeights[ index ] );
|
||||||
|
|
||||||
|
// Don't elide, but stretch across as many rows as required
|
||||||
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
initStyleOption( &opt, index );
|
||||||
|
|
||||||
|
const QString text = index.data( Qt::DisplayRole ).toString();
|
||||||
|
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 );
|
||||||
|
|
||||||
|
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), rect.height() + 4*PADDING );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,8 +157,6 @@ AclJobItem::AclJobItem( ACLRegistry::User user, const QString &username )
|
|||||||
|
|
||||||
AclJobItem::~AclJobItem()
|
AclJobItem::~AclJobItem()
|
||||||
{
|
{
|
||||||
if ( m_delegate )
|
|
||||||
delete m_delegate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -76,6 +76,4 @@ private:
|
|||||||
const QString m_username;
|
const QString m_username;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( AclJobItem* );
|
|
||||||
|
|
||||||
#endif // ACLJOBITEM_H
|
#endif // ACLJOBITEM_H
|
||||||
|
@@ -78,8 +78,11 @@ JobStatusModel::addJob( JobStatusItem* item )
|
|||||||
m_items.append( item );
|
m_items.append( item );
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
if ( item->hasCustomDelegate() )
|
if ( item->hasCustomDelegate() )
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "job has custom delegate";
|
||||||
emit customDelegateJobInserted( currentEndRow, item );
|
emit customDelegateJobInserted( currentEndRow, item );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Qt::ItemFlags
|
Qt::ItemFlags
|
||||||
|
@@ -87,18 +87,21 @@ JobStatusView::setModel( JobStatusModel* m )
|
|||||||
connect( m_view->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
connect( m_view->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
||||||
connect( m_view->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
connect( m_view->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
||||||
connect( m_view->model(), SIGNAL( modelReset() ), this, SLOT( checkCount() ) );
|
connect( m_view->model(), SIGNAL( modelReset() ), this, SLOT( checkCount() ) );
|
||||||
connect( m_view->model(), SIGNAL( customDelegateJobInserted( int, QStyledItemDelegate* ) ), this, SLOT( customDelegateJobInserted( int, QStyledItemDelegate* ) ) );
|
connect( m_view->model(), SIGNAL( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInserted( int, JobStatusItem* ) ) );
|
||||||
connect( m_view->model(), SIGNAL( customDelegateJobRemoved( int, QStyledItemDelegate* ) ), this, SLOT( customDelegateJobRemoved( int, QStyledItemDelegate* ) ) );
|
connect( m_view->model(), SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemoved( int ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
||||||
{
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
if ( !item )
|
if ( !item )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "telling item to create delegate";
|
||||||
item->createDelegate( m_view );
|
item->createDelegate( m_view );
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "item delegate is " << item->customDelegate();
|
||||||
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user