コード例 #1
0
void
PlaylistBrowserNS::BiasDialog::biasReplaced( Dynamic::BiasPtr oldBias, Dynamic::BiasPtr newBias )
{
    Q_UNUSED( oldBias );

    if( m_biasWidget )
    {
        m_biasLayout->removeWidget( m_biasWidget );
        m_biasWidget->deleteLater();
        m_biasWidget = 0;
    }

    m_bias = newBias;
    if( !newBias )
        return;

    connect( newBias.data(), SIGNAL(replaced(Dynamic::BiasPtr,Dynamic::BiasPtr)),
             this, SLOT(biasReplaced(Dynamic::BiasPtr,Dynamic::BiasPtr)) );

    m_biasWidget = newBias->widget( 0 );
    if( !m_biasWidget )
        m_biasWidget = new QLabel( i18n("This bias has no settings.") );
    m_biasLayout->addWidget( m_biasWidget );

    factoriesChanged(); // update the bias description and select the new combo entry
}
コード例 #2
0
ファイル: TestDynamicModel.cpp プロジェクト: ErrAza/amarok
void
TestDynamicModel::testPlaylistIndex()
{
    Dynamic::DynamicModel *model = Dynamic::DynamicModel::instance();

    // load from the empty directory
    model->loadPlaylists();

    // now we should have the four default playlists
    QCOMPARE( model->rowCount(), 4 );
    QCOMPARE( model->columnCount(), 1 );

    // -- random playlist with one bias
    QModelIndex playlistIndex = model->index( 0, 0 );
    QModelIndex biasIndex = model->index( 0, 0, playlistIndex );

    QCOMPARE( model->rowCount( playlistIndex ), 1 );
    QCOMPARE( model->rowCount( biasIndex ), 0 );
    QCOMPARE( playlistIndex.parent(), QModelIndex() );
    QCOMPARE( biasIndex.parent(), playlistIndex );

    // -- albumplay playlist with bias structure
    playlistIndex = model->index( 2, 0 );
    biasIndex = model->index( 0, 0, playlistIndex );
    QModelIndex subBiasIndex = model->index( 1, 0, biasIndex );

    QCOMPARE( model->rowCount( playlistIndex ), 1 );
    QCOMPARE( model->rowCount( biasIndex ), 2 );
    QCOMPARE( model->rowCount( subBiasIndex ), 0 );
    QCOMPARE( playlistIndex.parent(), QModelIndex() );
    QCOMPARE( biasIndex.parent(), playlistIndex );
    QCOMPARE( subBiasIndex.parent(), biasIndex );


    // and now the non-model index functions:
    model->setActivePlaylist( 2 );
    Dynamic::DynamicPlaylist* playlist = model->activePlaylist();
    playlistIndex = model->index( model->activePlaylistIndex(), 0 );
    QCOMPARE( model->index( playlist ), playlistIndex );

    Dynamic::BiasPtr bias = qobject_cast<Dynamic::BiasedPlaylist*>(playlist)->bias();
    biasIndex = model->index( 0, 0, playlistIndex );
    QCOMPARE( model->index( bias ), biasIndex );

    Dynamic::BiasPtr subBias = qobject_cast<Dynamic::AndBias*>(bias.data())->biases().at(0);
    subBiasIndex = model->index( 0, 0, biasIndex );
    QCOMPARE( model->index( subBias ), subBiasIndex );
}
コード例 #3
0
ファイル: Bias.cpp プロジェクト: phalgun/amarok-nepomuk
 foreach( Dynamic::BiasPtr bias, m_biases )
 {
     writer->writeStartElement( bias->name() );
     bias->toXml( writer );
     writer->writeEndElement();
 }