本文整理汇总了C++中PlaylistItem::setSubscribed方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem::setSubscribed方法的具体用法?C++ PlaylistItem::setSubscribed怎么用?C++ PlaylistItem::setSubscribed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistItem
的用法示例。
在下文中一共展示了PlaylistItem::setSubscribed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}