当前位置: 首页>>代码示例>>C++>>正文


C++ TreeModelItem::album方法代码示例

本文整理汇总了C++中TreeModelItem::album方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeModelItem::album方法的具体用法?C++ TreeModelItem::album怎么用?C++ TreeModelItem::album使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeModelItem的用法示例。


在下文中一共展示了TreeModelItem::album方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: itemFromIndex

bool
TreeModel::hasChildren( const QModelIndex& parent ) const
{
    TreeModelItem* parentItem = itemFromIndex( parent );
    if ( !parentItem )
        return false;

    if ( parentItem == m_rootItem )
        return true;

    return ( !parentItem->artist().isNull() || !parentItem->album().isNull() );
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例2: if

void
TreeModel::fetchMore( const QModelIndex& parent )
{
    TreeModelItem* parentItem = itemFromIndex( parent );
    if ( !parentItem || parentItem->fetchingMore )
        return;

    parentItem->fetchingMore = true;
    if ( !parentItem->artist().isNull() )
    {
        qDebug() << Q_FUNC_INFO << "Loading Artist:" << parentItem->artist()->name();
        addAlbums( parentItem->artist(), parent );
    }
    else if ( !parentItem->album().isNull() )
    {
        qDebug() << Q_FUNC_INFO << "Loading Album:" << parentItem->album()->name();
        addTracks( parentItem->album(), parent );
    }
    else
        Q_ASSERT( false );
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例3: if

void
ArtistView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
    QTreeView::currentChanged( current, previous );

    if ( !m_updateContextView )
        return;

    TreeModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
    if ( item )
    {
        if ( !item->result().isNull() )
            ViewManager::instance()->context()->setQuery( item->result()->toQuery() );
        else if ( !item->artist().isNull() )
            ViewManager::instance()->context()->setArtist( item->artist() );
        else if ( !item->album().isNull() )
            ViewManager::instance()->context()->setAlbum( item->album() );
        else if ( !item->query().isNull() )
            ViewManager::instance()->context()->setQuery( item->query() );
    }
}
开发者ID:mguentner,项目名称:tomahawk,代码行数:21,代码来源:ArtistView.cpp

示例4: if

void
ArtistView::onCustomContextMenu( const QPoint& pos )
{
    m_contextMenu->clear();

    QModelIndex idx = indexAt( pos );
    idx = idx.sibling( idx.row(), 0 );
    m_contextMenuIndex = idx;

    if ( !idx.isValid() )
        return;

    QList<query_ptr> queries;
    QList<artist_ptr> artists;
    QList<album_ptr> albums;

    foreach ( const QModelIndex& index, selectedIndexes() )
    {
        if ( index.column() || selectedIndexes().contains( index.parent() ) )
            continue;

        TreeModelItem* item = m_proxyModel->itemFromIndex( m_proxyModel->mapToSource( index ) );

        if ( item && !item->result().isNull() )
            queries << item->result()->toQuery();
        else if ( item && !item->query().isNull() )
            queries << item->query();
        if ( item && !item->artist().isNull() )
            artists << item->artist();
        if ( item && !item->album().isNull() )
            albums << item->album();
    }

    m_contextMenu->setQueries( queries );
    m_contextMenu->setArtists( artists );
    m_contextMenu->setAlbums( albums );

    m_contextMenu->exec( mapToGlobal( pos ) );
}
开发者ID:excieve,项目名称:tomahawk,代码行数:39,代码来源:artistview.cpp

示例5: itemFromIndex

Qt::ItemFlags
TreeModel::flags( const QModelIndex& index ) const
{
    Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );

    if ( index.isValid() && index.column() == 0 )
    {
        TreeModelItem* item = itemFromIndex( index );
        if ( item && !item->result().isNull() )
            return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
        if ( item && ( !item->album().isNull() || !item->artist().isNull() ) )
            return Qt::ItemIsDragEnabled | defaultFlags;
    }

    return defaultFlags;
}
开发者ID:seezer,项目名称:tomahawk,代码行数:16,代码来源:TreeModel.cpp

示例6: if

bool
TreeModel::canFetchMore( const QModelIndex& parent ) const
{
    TreeModelItem* parentItem = itemFromIndex( parent );

    if ( parentItem->fetchingMore )
        return false;

    if ( !parentItem->artist().isNull() )
    {
        return true;
    }
    else if ( !parentItem->album().isNull() )
    {
        return true;
    }

    return false;
}
开发者ID:seezer,项目名称:tomahawk,代码行数:19,代码来源:TreeModel.cpp

示例7: resultStream

QMimeData*
TreeModel::mimeData( const QModelIndexList &indexes ) const
{
    qDebug() << Q_FUNC_INFO;

    QByteArray resultData;
    QDataStream resultStream( &resultData, QIODevice::WriteOnly );

    // lets try with artist only
    bool fail = false;
    foreach ( const QModelIndex& i, indexes)
    {
        if ( i.column() > 0 || indexes.contains( i.parent() ) )
            continue;

        TreeModelItem* item = itemFromIndex( i );
        if ( !item )
            continue;

        if ( !item->artist().isNull() )
        {
            const artist_ptr& artist = item->artist();
            resultStream << artist->name();
        }
        else
        {
            fail = true;
            break;
        }
    }
    if ( !fail )
    {
        QMimeData* mimeData = new QMimeData();
        mimeData->setData( "application/tomahawk.metadata.artist", resultData );
        return mimeData;
    }

    // lets try with album only
    fail = false;
    resultData.clear();
    foreach ( const QModelIndex& i, indexes )
    {
        if ( i.column() > 0 || indexes.contains( i.parent() ) )
            continue;

        TreeModelItem* item = itemFromIndex( i );
        if ( !item )
            continue;

        if ( !item->album().isNull() )
        {
            const album_ptr& album = item->album();
            resultStream << album->artist()->name();
            resultStream << album->name();
        }
        else
        {
            fail = true;
            break;
        }
    }
    if ( !fail )
    {
        QMimeData* mimeData = new QMimeData();
        mimeData->setData( "application/tomahawk.metadata.album", resultData );
        return mimeData;
    }

    // lets try with tracks only
    fail = false;
    resultData.clear();
    foreach ( const QModelIndex& i, indexes )
    {
        if ( i.column() > 0 || indexes.contains( i.parent() ) )
            continue;

        TreeModelItem* item = itemFromIndex( i );
        if ( !item )
            continue;

        if ( !item->result().isNull() )
        {
            const result_ptr& result = item->result();
            resultStream << qlonglong( &result );
        }
        else
        {
            fail = true;
            break;
        }
    }
    if ( !fail )
    {
        QMimeData* mimeData = new QMimeData();
        mimeData->setData( "application/tomahawk.result.list", resultData );
        return mimeData;
    }

    // Ok... we have to use mixed
    resultData.clear();
//.........这里部分代码省略.........
开发者ID:seezer,项目名称:tomahawk,代码行数:101,代码来源:TreeModel.cpp

示例8: QVariant

QVariant
TreeModel::data( const QModelIndex& index, int role ) const
{
    TreeModelItem* entry = itemFromIndex( index );
    if ( !entry )
        return QVariant();

    if ( role == Qt::SizeHintRole )
    {
        if ( !entry->result().isNull() || !entry->query().isNull() )
        {
            return QSize( 128, 20 );
        }
        else if ( !entry->album().isNull() )
        {
            return QSize( 128, 32 );
        }
        else if ( !entry->artist().isNull() )
        {
            return QSize( 128, 44 );
        }

        return QSize( 128, 0 );
    }

    if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
        return QVariant();

    if ( !entry->artist().isNull() && index.column() == Name )
    {
        return entry->artist()->name();
    }
    else if ( !entry->album().isNull() && index.column() == Name )
    {
        return entry->album()->name();
    }
    else if ( !entry->result().isNull() )
    {
        const result_ptr& result = entry->result();
        unsigned int discnumber = 0;
        if ( !entry->query().isNull() )
            discnumber = entry->query()->discnumber();
        if ( discnumber == 0 )
            discnumber = result->discnumber();

        unsigned int albumpos = 0;
        if ( !entry->query().isNull() )
            albumpos = entry->query()->albumpos();
        if ( albumpos == 0 )
            albumpos = result->albumpos();

        switch( index.column() )
        {
            case Name:
                return QString( "%1%2%3" ).arg( discnumber > 0 ? QString( "%1." ).arg( discnumber ) : QString() )
                                          .arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
                                          .arg( result->track() );

            case Duration:
                return TomahawkUtils::timeToString( result->duration() );

            case Bitrate:
                if ( result->bitrate() > 0 )
                    return result->bitrate();
                break;

            case Age:
                return TomahawkUtils::ageToString( QDateTime::fromTime_t( result->modificationTime() ) );

            case Year:
                if ( result->year() != 0 )
                    return result->year();
                break;

            case Filesize:
                return TomahawkUtils::filesizeToString( result->size() );

            case Origin:
                return result->friendlySource();

            case AlbumPosition:
                return result->albumpos();

            case Composer:
                if ( !result->composer().isNull() )
                    return result->composer()->name();
                break;

            default:
                return QVariant();
        }
    }
    else if ( !entry->query().isNull() )
    {
        const query_ptr& query = entry->query();
        switch( index.column() )
        {
            case Name:
                return QString( "%1%2%3" ).arg( query->discnumber() > 0 ? QString( "%1." ).arg( query->discnumber() ) : QString() )
                                          .arg( query->albumpos() > 0 ? QString( "%1. ").arg( query->albumpos() ) : QString() )
//.........这里部分代码省略.........
开发者ID:seezer,项目名称:tomahawk,代码行数:101,代码来源:TreeModel.cpp


注:本文中的TreeModelItem::album方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。