本文整理汇总了C++中PlaylistItem::canSubscribe方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem::canSubscribe方法的具体用法?C++ PlaylistItem::canSubscribe怎么用?C++ PlaylistItem::canSubscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistItem
的用法示例。
在下文中一共展示了PlaylistItem::canSubscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r
//.........这里部分代码省略.........
{
gpi->removeFromList();
// Send a new mouse event to the view, since if the mouse is now over another item's delete area we want it to show up
QMouseEvent* ev = new QMouseEvent( QEvent::MouseMove, m_parent->viewport()->mapFromGlobal( QCursor::pos() ), Qt::NoButton, Qt::NoButton, Qt::NoModifier );
QApplication::postEvent( m_parent->viewport(), ev );
}
return true;
}
}
else if ( type == SourcesModel::Source )
{
SourceItem* colItem = qobject_cast< SourceItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
Q_ASSERT( colItem );
if ( hoveringTrack && colItem->source() && colItem->source()->currentTrack() )
{
if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
{
ViewManager::instance()->show( colItem->source()->currentTrack() );
return true;
}
else if ( event->type() == QEvent::MouseButtonPress && mEvent->button() == Qt::RightButton )
{
Tomahawk::ContextMenu* contextMenu = new Tomahawk::ContextMenu( m_parent );
contextMenu->setQuery( colItem->source()->currentTrack() );
contextMenu->exec( QCursor::pos() );
return true;
}
}
if ( !colItem->source().isNull() && !colItem->source()->currentTrack().isNull() && !colItem->source()->isLocal() )
{
if ( headphonesRectContainsClick || lockRectContainsClick )
{
if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
{
if ( headphonesRectContainsClick )
{
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
// unlatch
emit latchOff( colItem->source() );
else
emit latchOn( colItem->source() );
}
else // it's in the lock rect
emit toggleRealtimeLatch( colItem->source(), !index.data( SourcesModel::LatchedRealtimeRole ).toBool() );
}
return true;
}
}
}
else if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton && type == SourcesModel::StaticPlaylist )
{
PlaylistItem* plItem = qobject_cast< PlaylistItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
Q_ASSERT( plItem );
if ( plItem->canSubscribe() && !plItem->subscribedIcon().isNull() )
{
const int padding = m_margin / 16;
const int imgWidth = option.rect.height() - 2 * padding;
const QRect subRect( option.rect.right() - padding - imgWidth, option.rect.top() + padding, imgWidth, imgWidth );
if ( subRect.contains( mEvent->pos() ) )
{
// Toggle playlist subscription
plItem->setSubscribed( !plItem->subscribed() );
}
}
}
}
// We emit our own clicked() signal instead of relying on QTreeView's, because that is fired whether or not a delegate accepts
// a mouse press event. Since we want to swallow click events when they are on headphones other action items, here we make sure we only
// emit if we really want to
if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
{
if ( m_lastClicked == -1 )
{
m_lastClicked = QDateTime::currentMSecsSinceEpoch();
emit clicked( index );
}
else
{
qint64 elapsed = QDateTime::currentMSecsSinceEpoch() - m_lastClicked;
if ( elapsed < QApplication::doubleClickInterval() )
{
m_lastClicked = -1;
emit doubleClicked( index );
} else
{
m_lastClicked = QDateTime::currentMSecsSinceEpoch();
emit clicked( index );
}
}
}
return QStyledItemDelegate::editorEvent( event, model, option, index );
}
示例2: if
//.........这里部分代码省略.........
const int indentDelta = optIndentation.rect.x() - m_parent->viewport()->x();
optIndentation.rect.setX( optIndentation.rect.x() - indentDelta + indentMult * TomahawkUtils::DpiScaler::scaledY( m_parent, TREEVIEW_INDENT_ADD ) );
opt.rect.setX( 0 );
}
if ( type == SourcesModel::Source || type == SourcesModel::ScriptCollection )
{
paintSource( painter, optIndentation, index );
}
else if ( type == SourcesModel::Group )
{
paintGroup( painter, opt, index );
}
else if ( type == SourcesModel::Category )
{
paintCategory( painter, optIndentation, index );
}
else if ( type == SourcesModel::Divider )
{
const QRect middle = optIndentation.rect.adjusted( 0, m_margin / 16, 0, -m_margin / 16 );
const QColor bgcolor = opt.palette.color( QPalette::Base );
painter->setPen( bgcolor.darker( 120 ) );
painter->drawLine( middle.topLeft(), middle.topRight() );
painter->setPen( bgcolor.lighter( 120 ) );
painter->drawLine( middle.bottomLeft(), middle.bottomRight() );
}
else
{
optIndentation.state &= ~QStyle::State_MouseOver;
if ( !index.parent().parent().isValid() )
optIndentation.rect.adjust( m_margin / 4, 0, 0, 0 );
if ( type == SourcesModel::Inbox || type == SourcesModel::Queue || type == SourcesModel::Collection )
{
QString count;
if ( type == SourcesModel::Inbox )
{
InboxItem* ii = qobject_cast< InboxItem* >( item );
if ( ii && ii->unlistenedCount() )
count = QString::number( ii->unlistenedCount() );
}
else if ( type == SourcesModel::Queue )
{
QueueItem* qi = qobject_cast< QueueItem* >( item );
if ( qi && qi->unlistenedCount() )
count = QString::number( qi->unlistenedCount() );
}
else if ( type == SourcesModel::Collection )
{
CollectionItem* ci = qobject_cast< CollectionItem* >( item );
if ( ci )
count = QString::number( ci->trackCount() );
}
paintStandardItem( painter, optIndentation, index, count );
}
else if ( type == SourcesModel::TemporaryPage || type == SourcesModel::DeletablePage || type == SourcesModel::RemovablePage )
{
if ( opt.state & QStyle::State_MouseOver )
{
m_iconHeight = ( opt.rect.height() / 2 );
paintStandardItem( painter, optIndentation, index );
// draw close icon
const QRect r( opt.rect.right() - m_margin / 8 - m_iconHeight, opt.rect.y() + ( opt.rect.height() - m_iconHeight ) / 2, m_iconHeight, m_iconHeight );
painter->drawPixmap( r, TomahawkUtils::defaultPixmap( TomahawkUtils::ListRemove, TomahawkUtils::Original, r.size() ) );
}
else
paintStandardItem( painter, optIndentation, index );
}
else if ( type == SourcesModel::StaticPlaylist )
{
paintStandardItem( painter, optIndentation, index );
PlaylistItem* plItem = qobject_cast< PlaylistItem* >( item );
if ( plItem->canSubscribe() && !plItem->subscribedIcon().isNull() )
{
const int imgWidth = optIndentation.rect.height() / 2;
const QPixmap icon = plItem->subscribedIcon().scaled( imgWidth, imgWidth, Qt::KeepAspectRatio, Qt::SmoothTransformation );
const QRect subRect( optIndentation.rect.right() - m_margin / 2 - imgWidth, optIndentation.rect.top() + ( optIndentation.rect.height() - imgWidth ) / 2, imgWidth, imgWidth );
painter->drawPixmap( subRect, icon );
}
if ( plItem->collaborative() )
{
const int imgWidth = optIndentation.rect.height() / 2;
const QRect subRect( optIndentation.rect.left(), optIndentation.rect.top(), imgWidth, imgWidth );
painter->drawPixmap( subRect, TomahawkUtils::defaultPixmap( TomahawkUtils::GreenDot, TomahawkUtils::Original, subRect.size() ) );
}
}
else
paintStandardItem( painter, optIndentation, index );
}
paintDecorations( painter, opt, index );
painter->restore();
}